Lecture 1
The Layered Architecture
A computer network lets programs on different machines exchange data.
Host (end system). A host is a machine that runs applications at the edge of the network, such as a laptop or a server.
Protocol. A protocol is a set of rules and exchanged messages.
The network is a stack of protocol layers.Each layer offers a service to the layer above and uses the service of the layer below.
A message goes down the sender's stack, across the medium, and up the receiver's stack.
The layers make the network flexible and modular:a laptop can move from WiFi to Ethernet with no change to its browser.
The internet stacks five layers.
The Application Layer and DNS
All network applications and end-to-end security reside in the application layer.
People use names, but machines on the internet are identified by numeric IP addresses.
Domain Name System (DNS). DNS is a client-server application that translates names into IP addresses.DNS clients query servers to resolve a name into an address.DNS servers hold the name-to-address mappings and respond.
The internet needed such a system in the 1990s.For example, ssc.epfl.ch maps to 128.178.222.83, and smtp.sunrise.ch maps to 212.35.39.69.
A name has a structure: labels separated by dots.
Top-level domain. The top-level domain of a name is its last label.
| Name | Top-level domain | Kind |
|---|---|---|
ssc.epfl.ch | ch | country code (two letters) |
www.nzherald.co.nz | nz | country code |
goo.gl | gl | country code |
www.newzealand.com | com | commerce |
love.computers | computers | private domain of a bogus company |
Example 1. Opening a web page.
A user types http://www.google.com into a browser on host 128.178.56.9.
- The client asks its DNS server, at
128.178.15.8:what is the IP address ofwww.google.com? - The DNS server answers, to
128.178.56.9:www.google.commaps to216.58.212.196. - The client sends
HTTP GET /index.htmlto216.58.212.196. - The web server answers, to
128.178.56.9:200 OK, then the HTML page.
The Transport Layer and Ports
With the layers below, the transport layer gives the application a virtual channel to send and receive data.
Socket. A socket is the software interface between an application and the transport layer.The application reads and writes its data through the socket.
The transport layer has two main protocols:the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP).
| TCP | UDP | |
|---|---|---|
| Reliability | reliable: retransmits lost data | unreliable: can lose a message |
| Order | delivered in the order sent | can arrive out of order |
| Service | byte stream: no message boundaries, TCP sends blocks of bytes at will | message-oriented: boundaries preserved, each block sent as written to the socket |
A third option, QUIC, runs over UDP and provides TCP-like reliability and TLS security in one protocol.
A host runs many network processes at the same time, so reaching the right host is not enough.
Port number. A port number uniquely identifies a process within a host.Every TCP or UDP header carries a source port and a destination port.
Some port numbers are reserved for servers:80 for HTTP, 443 for HTTPS and 53 for DNS.
Example 2. Ports in a DNS exchange.
Process pa on host A, with port 1267, sends a request to the DNS process pb on host B, with port 53.
| Header | Field | Value |
|---|---|---|
| IP | source address, destination address | A, B |
| IP | protocol | UDP |
| UDP | source port, destination port | 1267, 53 |
Host B also uses port 1267, for a TCP process unrelated to pa.A port number names a process only within its own host.
Packet Switching and IP
Direct cables between every pair of devices do not scale: devices need cables.Instead, nodes relay the data at the network layer, as a postal service relays mail.
Message relaying. In message relaying, a node forwards a message only after it has received the entire message.The first networks, such as Bitnet and SNA, relayed messages between mainframe computers over point-to-point cables.
Packet. A packet is a small unit of data that the network forwards.On the internet, a packet holds at most 1500 bytes.
Header. A packet's header holds the information needed to deliver it, such as the destination address.
Payload. A packet's payload is the data it carries.
Packet switching. In packet switching, the data is cut into packets, and the nodes forward each packet separately toward its destination.The internet uses packet switching.
Read a packet as a postcard:
it carries its own delivery address and travels on its own.
Router. A router is a network-layer system (or program) that forwards packets by rules based on their destination IP addresses.
Internet Protocol (IP). IP is the network-layer protocol of the internet.It delivers packets through a series of routers, by packet switching.
Best effort. A best-effort protocol makes no delivery guarantee.IP is best effort.Routers briefly store packets in buffers before forwarding them, and the packets of one message can follow different paths.So IP packets can be dropped, delayed or reordered.
IP Addresses and Subnets
Local area network (LAN). A LAN is a set of nearby devices that reach each other directly through one data link layer, such as one Ethernet or one WiFi network.
IP sees the internet as a collection of LANs joined by routers.
Interface. An interface is a device's attachment to one LAN, such as an Ethernet port or a WiFi card.A host typically has one interface, and a router has several.
IP address. An IP address is an interface's network-layer address.So a router has one IP address on each LAN it joins.Every IP header carries a source and a destination IP address.
- IPv4. An IPv4 address has 32 bits, written in dotted decimal:four numbers from 0 to 255, each standing for 8 bits (e.g. EPFL's public address
128.178.156.23). - IPv6. An IPv6 address has 128 bits, written in hexadecimal:eight groups of four hex digits (0 to 9, a to f), each digit standing for 4 bits (e.g. EPFL's public address
2001:0620:0618:01a6:0a00:20ff:fe78:30f9).
IPv4 and IPv6 are incompatible.IPv6 is another protocol, not IPv4 with a larger address space.A device that runs only IPv6 cannot parse IPv4 packets, and vice versa.
Prefix. A prefix is a run of leading bits of an IP address.
Subnet. A subnet is a LAN whose devices all share one prefix.The remaining address bits form the host part.The host part tells the devices of the subnet apart.
Subnet mask. A subnet mask is a bit sequence, as long as the address, with a 1 at each position of the prefix and a 0 elsewhere.Its 1s are contiguous (not a mask: 255.0.255.0, whose 1s are not contiguous).
For an EPFL IPv4 LAN, the mask is 24 ones followed by 8 zeros.It has two notations.
- Dotted decimal. The mask is
255.255.255.0, since11111111is 255 and00000000is 0. - Slash notation. The address is followed by the number of 1s, as in
128.178.71.34/24.
The prefix length depends on the network.The IPv4 LANs of ETH Zurich (ETHZ) use 26-bit prefixes.EPFL's IPv6 LANs use 64-bit prefixes, the first four groups, as in 2001:620:618:1a6:0a00:20ff:fe78:30f9/64.IPv6 notation may drop a group's leading zeros, as this address does.
Example 3. The EPFL and ETHZ network.
Each LAN below has one prefix, shared by all its addresses.A label such as .221 gives the last number of an address.On 128.178.15.0/24, it stands for 128.178.15.221.
One router joins INF119 and IC, with 128.178.71.1 on INF119 and 128.178.182.5 on IC.
SWITCH (130.59.x.x) is the Swiss academic network that joins EPFL to ETHZ.It is a network, not a data-link switch.
Example 4. Which address can A take?
Is 10.10.3.33 or 10.10.2.44 a valid address for host A?
Each mask has 24 ones, so each prefix is the first three numbers.A shares a LAN with router 1, whose interface there is 10.10.3.1.So A's address must start with 10.10.3, and 10.10.3.33 is valid.The address 10.10.2.44 is not, because 10.10.2 is B's prefix.
The Data Link Layer and MAC Addresses
The data link layer is also called the Medium Access Control (MAC) layer.It moves data from a node to a LAN neighbor, over a shared medium, wired or wireless.It also manages access to the physical link and multiplexes the link among the nodes.
Depending on the physical layer, the data link layer also offers error detection and correction, reliable delivery, collision avoidance and flow control.
MAC address. A MAC address is an interface's data-link-layer address.It has 48 bits, written as six hexadecimal bytes (e.g. 00:00:c0:3f:6c:a4).
A MAC address is comparable to a device's serial number.The manufacturer sets it, and its first 3 bytes name the manufacturer.It is unique, in principle.
Frame. A frame is the data link layer's unit of data:a MAC header followed by a payload.The sender writes the destination MAC address in the frame's header.That address travels in cleartext, even when the payload is encrypted.
On a shared medium, every node reads every frame.If a frame's destination MAC address matches a node's own, the node keeps the frame; otherwise it drops the frame.
When the physical links are too long or too many, switches relay frames, as routers relay packets.
Switch. A switch is a data-link-layer system (or program) that forwards frames by rules based on their destination MAC addresses.
Routers interconnect different LANs at the network layer.Switches interconnect devices of the same LAN at the data link layer.
Gateway (default gateway). The gateway of a LAN is its first-hop router.A host sends every packet destined outside its subnet to the gateway.A packet within the subnet crosses no router, only switches or the WiFi base station.
The Physical Layer and Capacity
The physical layer transforms bits into signals.
Signals are electromagnetic, or acoustic under water.The physical layer is technology-specific.Each Ethernet and each WiFi (IEEE 802.11) physical layer has its own maximum bit rate.
Bit rate. The bit rate is the number of bits transmitted per second.It is measured in b/s, with decimal prefixes: Mb/s b/s and Gb/s b/s.
Bandwidth. The bandwidth of a channel is the width, in hertz, of the frequency range it can use for transmission.
Capacity. The capacity of a channel is its maximum achievable bit rate.The bandwidth limits the capacity.
Signal-to-noise ratio (SNR). The SNR is the power of the emitted signal over the power of the noise.
For a bandwidth in hertz and Gaussian noise, the Shannon-Hartley law gives the capacity:
An ADSL line has MHz and an SNR of 45 dB.A value in decibels is of the power ratio, so the SNR is .The capacity is then Mb/s.
In networking practice, "bandwidth" often loosely means the bit rate.
Encapsulation and the Path of a Packet
Encapsulation. In encapsulation, TCP, IP and the data link layer each put a header in front of the unit from the layer above.The result is the payload of the layer below.
TCP segment. A TCP segment is the transport layer's unit of data:a TCP header followed by application data.
IP packet. An IP packet is the network layer's unit of data:an IP header followed by a TCP segment.
So a frame is a MAC header followed by an IP packet.
The word "packet" also names all three units, loosely.
A capture tool shows the headers of one frame from an EPFL host.The tool numbers this frame packet 4.The frame has 60 bytes and arrived at 19:03:32.40.
| Header | Field | Value |
|---|---|---|
| Ethernet | destination | 0:0:c:2:78:36, Cisco |
| Ethernet | source | 0:0:c0:b8:c2:8d, Western Digital |
| Ethernet | Ethertype | 0800 (IP) |
| IPv4 | version | 4 |
| IPv4 | header length | 20 bytes |
| IPv4 | type of service | 0x00: precedence 0,normal delay, throughput and reliability |
| IPv4 | total length | 44 bytes |
| IPv4 | identification | 2948 |
| IPv4 | flags | 0x0: may fragment, last fragment |
| IPv4 | fragment offset | 0 bytes |
| IPv4 | time to live | 64 seconds/hops |
| IPv4 | protocol | 6 (TCP) |
| IPv4 | checksum | cec2 |
| IPv4 | source | 128.178.156.7, lrcpc3.epfl.ch |
| IPv4 | destination | 129.132.2.72, ezinfo.ethz.ch |
| IPv4 | options | none |
| TCP | source port | 1268 |
| TCP | destination port | 23 (TELNET) |
| TCP | sequence number | 2591304273 |
| TCP | ack number | 0 |
| TCP | data offset | 24 bytes |
| TCP | flags | 0x02 |
The IP packet's 44 bytes are a 20-byte IP header and a 24-byte TCP header.So the TCP segment carries no application data.
The IP header holds numeric addresses, not the names lrcpc3.epfl.ch and ezinfo.ethz.ch.Names travel only inside payloads, such as DNS queries.The capture tool added the names only for its display.
A web server on Ethernet LAN B sends a file to Eliane's phone on WiFi LAN A.The gateway has an interface on both LANs.
The server calls send(s2, dataBlock) on its socket s2.TCP divides the data block into segments.Each segment travels in its own IP packet, and each packet in its own frame.Eliane's phone calls read(s1, dataBlock) on its socket s1.
Each device opens a frame only up to the highest layer it runs.The switch and the base station run only the MAC and physical layers.
Example 5. Which addresses does a frame carry?
The web server sends a packet to Eliane's phone.Which addresses does the frame carry at point 1, and at point 2?
The MAC layer is local, and the network layer is global.A frame's MAC addresses name the two ends of the current hop, so the gateway removes the incoming MAC header and writes a new one.At point 1, the MAC destination is the gateway's Ethernet interface; at point 2, the MAC source is its WiFi interface.On this path, the IP addresses stay the web server's and Eliane's.
IP addresses say where the packet is going; MAC addresses say who handles it next.
In the capture above, the destination IP address is at ETHZ, but the destination MAC address is the gateway's, a Cisco device.
Network Delays
Network delay and throughput are general quantities that span more than one layer.
Network delay. The network delay of a packet is the time it takes to get from its source to its destination.
A packet of bits crosses a link of bit rate and length .At each hop, it accumulates four delays.
- Processing delay. The processing delay is the time to examine the packet's headers and decide where to forward it.
- Queueing delay. The queueing delay is the time the packet waits in a queue until it is transmitted onto the outgoing link.
- Transmission delay. The transmission delay is the time to push all the packet's bits onto the outgoing link, .
- Propagation delay. The propagation delay is the time the head of the signal, or its tail, takes to cross the link.
Transmission depends on size and bit rate, never on distance; propagation depends on distance and medium, never on bit rate.
For a non-acoustic channel, the signal travels at the speed of light in the medium.So the propagation delay is
The speed of light is m/s in copper and m/s in glass optical fiber.For fiber, this gives a rule of thumb:
To the far side of the globe, about 20 000 km away, propagation takes about 100 ms one way and 200 ms for the round trip.
Store and forward. Under store and forward, a node forwards a packet only after its last bit has arrived and all bits of the previous packets have left.Routers store and forward packets, and switches frames.
A time-space diagram draws one vertical time axis per node.Time runs down.
Example 6. One store-and-forward router.
Host A sends a packet of bits to host B through a router R.The link from A to R has bit rate and propagation delay .The link from R to B has bit rate and propagation delay .Ignore processing and queueing.What is the end-to-end delay?
R starts sending only once the last bit has arrived, at .Then the packet needs more:
Example 7. Why packet switching beats message relaying.
A message of equal packets of bits crosses links from A to B, through router R.Both links have bit rate and propagation delay .Each packet takes ms to transmit, and each link adds ms.Ignore processing and queueing.
Message relaying sends the whole message over each hop in turn:
With packet switching, R forwards packet 1 while packets 2 to 4 still arrive.The last packet leaves A after .It then needs one more transmission per further hop, plus one propagation per link:
| Quantity | Effect | Reason |
|---|---|---|
| end-to-end delay | shorter | the links transmit in parallel |
| router buffers | smaller | a router stores packets, not whole messages |
| bit error rate | same | the links are unchanged |
| corruption risk per unit | smaller | a packet is shorter than a message |
| link capacity | same | only the physical layer sets it |
Example 8. Sending one 1 kB packet over one link.
A 1 kB packet holds about 8000 bits.It crosses one link, with no processing and no queueing.The data center, fiber and LoRa links use the 5 µs/km rule of thumb, and the satellite link uses m/s.The dominant delay is in bold.
| Data center | Fiber to the home | IoT sensor (LoRa) | LEO satellite (Starlink) | |
|---|---|---|---|---|
| Distance | 100 m | 50 km | 2 km | 1400 km |
| Bit rate | 100 Gb/s | 1 Gb/s | 5 kb/s | 100 Mb/s |
| Propagation delay | 0.5 µs | 250 µs | 10 µs | 4.7 ms |
| Transmission delay | 0.08 µs | 8 µs | 1.6 s | 80 µs |
| Total | 0.58 µs | 258 µs | ≈ 1.6 s | 4.78 ms |
For the fiber-to-the-home link:
For the LoRa sensor, s dwarfs µs.For the low-Earth-orbit satellite, ms.Propagation dominates three links, and transmission dominates LoRa.So speeding up a link starts with finding its bottleneck.
Throughput and Stop & Go
Throughput. Throughput is the number of useful data bits delivered at the destination per unit of time:
Throughput has the units of a bit rate: b/s, kb/s, Mb/s.
Example 9. A pigeon against an ADSL line.
In South Africa, a bandwidth shortage makes internet access slow, and access is also expensive.
In 2009, an 11-month-old pigeon named Winston carried a data card 80 km (50 miles), from Pietermaritzburg to Durban.The flight took 1 h 8 min, and the transfer, including the download, took 2 h 6 min 57 s.In that time, a Telkom ADSL line transferred only 4% of the data.The pigeon has a huge delay, but its throughput beats the line's.
Even over a single link, throughput stays below the bit rate, because of protocol overhead and waiting times.
Protocol overhead. Protocol overhead is the extra bytes, such as headers, that protocols use to exchange metadata.
Waiting time. A waiting time is an interval in which a host must wait for a response from the other end before it transmits.
Acknowledgement (ACK). An ACK is a short packet that the receiver returns to confirm that a packet arrived.
Stop & Go. Stop & Go is a simple protocol that repairs packet losses by keeping at most one packet unacknowledged.
Sender A sends a packet to receiver B, and B immediately returns an ACK.A waits for the ACK before it sends a new packet.If no ACK arrives within a time , A times out and retransmits the packet.
Assume no loss and one packet per cycle.The packet has bits, and the ACK has bits.The link has bit rate and propagation delay .
A cycle lasts , with and .It delivers useful bits, so
The term is the overhead of the ACK.
Bandwidth-delay product. The bandwidth-delay product is :the bits a sender transmits in one round-trip propagation time .If the sender transmits without pause, these bits are transmitted but not yet acknowledged.Its name says "bandwidth", but it means the bit rate .Divided by the packet size , it counts packets.
Efficiency. Efficiency is throughput as a fraction of the bit rate:
When the bandwidth-delay product dwarfs the packet, a Stop & Go sender spends almost the whole cycle waiting.
Example 10. Stop & Go on the four links.
Run Stop & Go on the links of Example 8, with 1 kB packets ( bits) and negligible ACKs ().
| Data center | Fiber to the home | IoT sensor (LoRa) | LEO satellite (Starlink) | |
|---|---|---|---|---|
| 100 kb | 500 kb | 0.1 b | 940 kb | |
| 12.5 | 62.5 | ≈ 0 | 117.5 | |
| Throughput | 7.4 Gb/s | 15.7 Mb/s | 4.8 kb/s | 844 kb/s |
| Efficiency | 7.4% | 1.6% | 96% | 0.84% |
For the fiber-to-the-home link, b/s kb, so
Only LoRa is efficient, because its of 0.1 b is negligible next to its 8000-bit packet.So its sender almost never waits.
With exactly, the formula gives LoRa 5 kb/s, or 100%.So the table's 4.8 kb/s and 96% do not follow from alone.
TCP beats Stop & Go with a mechanism called the sliding window.