Usually prevent hosts from communicating on certain ports, or hosting services.
HTTP and firewalls means that webclients are unlikely to be webservers as well. That communication must be initiated by clients rather than webservices.
IETF seems unaware of their existence but at least HTTP gets through.
Scenario
Get http://slashdot.org
Context
I am at home on a Friday evening. It is 10pm and I haven't been outside all day.
I need to read slashdot because I'm bored
I have a cable modem internet connection from Shaw.
I've connected to the cable modem with CAT5 cables and ethernet.
$ python3
python 3.7.2 (default, jan 3 2019, 02:55:40)
[gcc 8.2.0] on linux
type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.get("http://slashdot.org")
<response [200]>
>>>
Python
requests
tells the OS to connect to
slashdot.org
via TCP on TCP port 80.
The OS looks up
slashdot.org
and needs to contact a nameserver
OS Sends a UDP packet on port 53 to the nameserver configured (my Shaw router, 192.168.0.1)
The UDP packet is over IP
The IP packet is over ethernet
Cable modem accepts this packet, contacts Shaw's DNS server behalf of my computer, over UDP over IP over the cable modem link.
Shaw's DNS server receives my query and doesn't know
slashdot.org
so it asks a more authoritative server.
Sends DNS request over UDP over IP over ethernet to the switch in its datacenter, to an edge router, over the internet, to the root DNS server, asking about
org.
Gets a DNS response indicating the address of the
org
server.
Sends a DNS request to the
org
server asking for the
SOA
(Start of Authority) of
slashdot.org
Gets a DNS response indicating the DNS server that knows about
slashdot.org
Sends a DNS request to the authoritative server for
slashdot.org
Gets a response back on the UDP port, response contains an A record listing an IP of
slashdot.org
Shaw's DNS server makes a DNS response packet and sends it back to me over UDP, over IP, over ethernet, over their private network, back to my cable modem, back on to ethernet, IP, and UDP back to my home computer.
My OS receives the DNS response, records the IP address and then initiates a TCP connection to port 80 of the slashdot.org IP.
A TCP SYN packet is sent to the slashdot.org IP at port 80, over IP, over ethernet to the cable modem, through shaw and through the internet to slashdot's datacenter where a copy of the packet appears on some ethernet cable, decoded as an IP, TCP connect SYN packet.
Slashdot.org sends a TCP SYN+ACK packet back across IP, across ethernet, over their network and internet back to shaw, over shaw's network, to my cable modem, over ethernet, over IP, back to my computer
My computer sends a TCP ACK packet back across all the way to slashdot.org through all the prior layers
A connection is established!
Now that my home computer is connected with slashdot.org over TCP I can send data packets across that TCP connection.
Python eventually runs
send(ourSlashdotConnection, “GET / HTTP/1.0\r\nHost: slashdot.org\r\n\r\n”);
This causes a TCP data packet on the slashdot connection to be made, shuffled off to IP and ethernet, across to cable modem and back all the way to slashdot.org
Slashdot's webserver is waiting on the connection and it is reading bytes from the connection. After my packet is delivered to the webserver (over TCP, over IP, over ethernet, over the datacenter network, over the internet, ...)
“GET / HTTP/1.0\r\nHost: slashdot.org\r\n\r\n”
Slashdot.org's webserver's TCP layers send a TCP ACK packet back to my IP address acknowledging the receipt of the packet that contained the GET request I sent.
Slashdot.org's webserver sends an HTTP response which is over 40kb in size broken up across 29 packets. All these packets needs to be acknowledged by my home computer.
1 UDP DNS Request for slashdot.org
1 UDP DNS Response from my nameserver for slashdot.org of 1.2.3.4
1 TCP SYN for 1.2.3.4 on port 80
1 TCP SYN+ACK from 1.2.3.4 port 80
1 TCP ACK to 1.2.3.4 on port 80
1 TCP data packet with the GET request to 1.2.3.4
1 TCP ACK from 1.2.3.4
1 TCP data packet from 1.2.3.4
1 TCP ACK to 1.2.3.4
... 26 data & ACKs later
1 TCP data packet from 1.2.3.4
1 TCP ACK to 1.2.3.4
1 TCP FIN close from 1.2.3.4
1 TCP FIN+ACK to 1.2.3.4
1 TCP ACK from 1.2.3.4
~2 UDP packets (except all the ones I didn't see because they were done on my behalf by Shaw's DNS server)
~60 TCP packets
~62 Ethernet packets
The TCP packets are probably copied at least 10 times across 10 or more links.
So my 1 request of 50KiB in size could cost the entire network more than 500KiB in traffic.
How did we get routed to slashdot?
hindle1@piggy:~$ sudo traceroute slashdot.org
traceroute to slashdot.org (216.34.181.45), 30 hops max, 60 byte packets
1 192.168.0.1 (192.168.0.1) 0.171 ms
2 * * *
3 xxxxxxxxxxxx.ed.shawcable.net (64.59.184.245) 33.812 ms
4 rc3sc-tge0-0-0-10.wp.shawcable.net (66.163.74.226) 44.058 ms
5 rc2so-tge0-4-0-1.cg.shawcable.net (66.163.77.98) 77.525 ms
6 ix-3-3-2-0.tcore1.ct8-chicago.as6453.net (66.110.14.13) 74.733 ms
7 64.86.78.10 (64.86.78.10) 70.375 ms
8 hr1-te-9-0-0.elkgrovech3.savvis.net (204.70.196.14) 74.230 ms
9 das5-v3032.ch3.savvis.net (64.37.207.158) 71.660 ms
10 64.27.160.194 (64.27.160.194) 83.311 ms
11 slashdot.org (216.34.181.45) 73.920 ms
Takeaways
The bandwidth used to send large or small messages.
If latency matters which transport should you use?
Packets get routed!
Ethernet often imposes requirements on communication
Can you think of any other takeaways?
Special IPs and Ports
127.0.0.1 localhost (packets loop back to your computer)
192.168.*.* and 10.*.*.* are common private subnets for local IP communication. E.g. 192.168.0.2 is my computer and 192.168.0.1 is my Shaw cable modem.
Other images used under fair use and copyright their copyright holders.
License
Copyright (C) 2019-2023 Hazel Victoria Campbell
Copyright (C) 2014-2023 Abram Hindle and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN.
01234567890123456789012345678901234567890123456789012345678901234567890123456789