QUIC & IP address
1. Lecture 11: QUIC
1.1. Big picture
This lecture introduces QUIC, a modern protocol designed to improve on the traditional TCP + TLS + HTTP stack.
The central question is:
Why was QUIC introduced, and how is it different from TCP?
QUIC was originally developed and deployed by Google around 2012. Later, it was standardized by the IETF. The final core specification, RFC 9000, was published in 2021 after many drafts.
Although QUIC originally stood for “Quick UDP Internet Connections”, the current specification treats QUIC as a name, not an acronym.
The lecturer emphasizes that QUIC does not fit perfectly into the traditional layered model. It uses UDP below, integrates TLS security, provides transport-like reliability and congestion control, and also includes stream multiplexing features that previously belonged more to HTTP/2. Therefore, whether QUIC is “just a transport protocol” is partly a philosophical question.
1.2. Recap: TCP and UDP
1.2.1. TCP
TCP provides a reliable, in-order, full-duplex byte stream between one sender and one receiver.
Important properties:
- point-to-point communication;
- connection-oriented communication via a handshake;
- reliable delivery;
- in-order byte stream;
- no explicit message boundaries;
- cumulative ACKs;
- pipelining;
- congestion control;
- flow control;
- full-duplex data transfer.
The key limitation for later discussion is:
TCP exposes only one ordered byte stream to the application.
If several logical application streams are multiplexed over one TCP connection, TCP itself does not know that they are independent.
1.2.2. UDP
UDP is much simpler.
It is:
- connectionless;
- best-effort;
- message/datagram-oriented;
- not reliable;
- not ordered;
- without congestion control;
- without flow control;
- without a handshake.
UDP is useful because it is simple and already widely supported by hosts, routers, firewalls, NATs, and other network devices.
1.3. Motivation for QUIC
QUIC tries to keep useful TCP-like features while avoiding several deployment and performance problems.
The main goals are:
- reduce connection establishment latency;
- integrate security by default;
- avoid TCP head-of-line blocking when multiple logical streams are used;
- be deployable without changing routers, middleboxes, or operating system kernels;
- allow future extensions such as multipath and forward error correction;
- support IP mobility through connection IDs.
A simplified view:
Traditional web stack: HTTP/1.1 or HTTP/2 TLS TCP IP QUIC-based web stack: HTTP/3 QUIC UDP IP
QUIC uses UDP, but it is not “just UDP”. UDP is mainly used as a compatibility layer so that existing networks will carry QUIC traffic.
1.4. Security by design
1.4.1. Security goals
QUIC integrates security into the protocol itself.
The goals are:
- confidentiality: data should be encrypted;
- authentication: usually the server is authenticated, the client optionally;
- integrity: data should not be tampered with undetectably.
QUIC uses TLS 1.3. Older TLS versions are not allowed in the standard QUIC design. QUIC also restricts the available cryptographic choices to modern AEAD algorithms.
1.4.2. Why integrate TLS into the transport protocol?
In the traditional stack, TCP first establishes a connection. Then TLS establishes a secure channel on top of that connection.
This creates sequential handshake delay:
TCP handshake first then TLS handshake then application data
So even before useful encrypted application data can be sent, multiple RTTs may be consumed.
QUIC combines the transport handshake and the TLS handshake.
The client sends an Initial packet containing transport parameters and TLS ClientHello. The server responds with transport information and TLS handshake messages such as ServerHello and certificate-related messages. Once the handshake progresses far enough, encrypted data can be sent.
In the normal case, encrypted data can be sent after 1 RTT.
With previously stored information from an earlier connection to the same server, QUIC can also support 0-RTT data. This means the client may send some application data immediately in the first flight, using key material derived from an earlier connection. However, this requires previous state and has security trade-offs.
1.4.3. Authenticated transport parameters
Because QUIC combines the transport and cryptographic handshake, transport parameters can be authenticated.
This matters because parameters such as flow-control limits, connection IDs, and other negotiated values should not be silently modified by an attacker or middlebox.
1.5. Why QUIC uses UDP
A natural question is:
Why not define a completely new layer-4 protocol directly on top of IP?
The answer is deployment.
The Internet contains many middleboxes:
- firewalls;
- NATs;
- traffic optimizers;
- load balancers;
- enterprise boxes;
- vendor-specific devices with strange assumptions.
Many middleboxes only understand TCP and UDP. Unknown transport protocols may be blocked or mishandled.
Using UDP makes QUIC deployable on the existing Internet. The UDP header provides ports and a familiar protocol number, so firewalls and NATs are more likely to allow the traffic.
QUIC then encrypts most protocol information above UDP. This reduces the ability of middleboxes to inspect, modify, or ossify the protocol.
1.5.1. Middlebox ossification
The lecturer gives the example of TLS 1.3 deployment problems. Some middleboxes expected TLS version fields to contain specific older values and broke when new versions appeared. As a workaround, TLS 1.3 had to preserve some old-looking fields and move the real version information elsewhere.
This illustrates protocol ossification:
If middleboxes depend on accidental details of a protocol, future protocol evolution becomes difficult.
QUIC tries to avoid this by encrypting most transport-level information.
1.6. Connection IDs instead of the 5-tuple
TCP connections are usually identified by the 5-tuple:
source IP source port destination IP destination port transport protocol
This creates a problem when a client’s IP address or port changes.
Examples:
- a phone moves from Wi-Fi to mobile data;
- a mobile device changes cell towers or networks;
- a NAT mapping expires and the external port changes;
- a DSL connection is re-established.
With TCP, such a change usually breaks the connection.
QUIC introduces connection IDs. A connection ID identifies the QUIC connection independently of the lower-layer IP address and UDP port.
Thus, if a valid packet arrives with the same connection ID and proper cryptographic authentication, the endpoint can treat it as belonging to the same QUIC connection even if the IP address or port changed.
This enables IP mobility.
1.7. QUIC packet and frame structure
QUIC is designed to be more flexible and extensible than TCP.
1.7.1. UDP datagram and QUIC packet
QUIC packets are carried inside UDP datagrams.
A QUIC packet is a complete processable QUIC unit. It must fit into a UDP datagram. Multiple QUIC packets can be placed into a single UDP datagram, but one QUIC packet is not split across multiple UDP datagrams.
Simplified structure:
UDP datagram
UDP header
QUIC packet
QUIC header
protected payload
frames
The connection ID is visible enough for the endpoint or load balancer to associate the packet with the right connection. Much of the remaining information is encrypted.
1.7.2. Packet numbers
QUIC packet numbers are integers from 0 to \(2^{62}-1\).
They are used for packet protection, including cryptographic nonce construction.
QUIC packet numbers are not just counters. They are also used as part of the cryptographic machinery: each packet number helps derive a unique nonce for encrypting/protecting that packet.
Important differences from TCP sequence numbers:
- QUIC packet numbers count packets, not bytes.
- Packet numbers start at 0.
- Packet numbers are not reused.
- Even retransmitted data is sent in a new packet with a new packet number.
- Different packet number spaces exist, for example for Initial, Handshake, and Application Data packets.
This is different from TCP, where sequence numbers identify byte positions in a single byte stream.
1.7.3. Long and short headers
QUIC has different header formats.
Long headers are used during connection setup, for example:
- Initial packets;
- Handshake packets;
- Retry packets;
- 0-RTT packets.
Short headers are used after the connection is established. They are designed to reduce overhead.
1.7.4. Frames
Inside QUIC packets, information is carried in frames.
Examples:
- PADDING frames;
- PING frames;
- ACK frames;
- STREAM frames;
- CRYPTO frames;
- DATAGRAM frames, if the extension is used.
This design gives QUIC flexibility. New frame types can be added later. Different frames can be combined into one packet. Data from multiple streams can even be carried in the same QUIC packet.
1.8. Acknowledgements in QUIC
In TCP, ACK information is part of the TCP header and acknowledges bytes, typically using cumulative ACKs.
In QUIC, acknowledgements are ACK frames. They acknowledge packet numbers, not byte offsets.
An endpoint acknowledges a packet after it has:
- received the packet;
- decrypted it;
- checked integrity;
- processed the frames.
1.8.1. ACK ranges
QUIC ACK frames contain ranges of received packet numbers.
Example idea:
ACK ranges: 120-120 122-122 124-126 129-130
This tells the sender that some packets were received, while holes indicate missing packets.
For example, if 121 is missing but 122 arrived, the sender can infer that 121 may have been lost.
This is similar in spirit to selective acknowledgements, but QUIC makes ACK ranges part of the normal ACK mechanism.
1.8.2. Retransmission behavior
QUIC does not retransmit the same packet with the same packet number.
If data from a lost packet must be retransmitted, the sender creates a new packet with a new packet number.
The sender may retransmit the same frames, or it may reorganize the data:
- different frame order;
- different frame grouping;
- different packet composition.
This is possible because ACKs track packets, while stream data has its own stream IDs and offsets.
1.8.3. ACK frequency trade-off
ACKs are useful for:
- loss detection;
- congestion control;
- keeping the connection state fresh.
But sending ACKs too often creates overhead.
Therefore, QUIC has mechanisms and extensions related to ACK delay and acknowledgement frequency. An endpoint may indicate that it does not need an ACK for every small number of packets, or that it wants feedback at least within a certain time bound.
1.9. Streams and head-of-line blocking
1.9.1. The problem in TCP
TCP provides one in-order byte stream.
Suppose HTTP/2 multiplexes multiple objects over one TCP connection. TCP does not know that these are independent HTTP streams.
If one TCP segment is lost, TCP cannot deliver later bytes to the application until the missing segment has been retransmitted and placed in order.
This causes transport-layer head-of-line blocking.
Example:
One TCP connection carries: video stream 1 video stream 2 A packet containing part of video stream 1 is lost. Even if later packets for video stream 2 arrive, TCP cannot deliver them to HTTP/2 yet, because TCP must preserve one global byte order.
Thus, loss in one logical stream can delay unrelated data.
1.9.2. QUIC’s solution
QUIC is aware of multiple streams.
Each stream is a lightweight ordered byte stream within one QUIC connection.
If data is lost in one stream, only that stream is blocked. Other streams can continue to deliver data to the application.
This solves the main head-of-line blocking problem caused by putting multiplexed HTTP/2 streams over TCP.
1.9.3. Stream properties
QUIC streams:
- are ordered byte-stream abstractions;
- can be bidirectional or unidirectional;
- have unique stream IDs;
- can be opened, used, and closed via STREAM frames;
- can be multiplexed over the same QUIC connection;
- can be prioritized by the implementation or application.
A QUIC packet can contain STREAM frames from several different streams.
1.10. Congestion control in QUIC
QUIC still needs congestion control.
The goal is the same as in TCP:
- use a fair share of the network;
- avoid overloading the network;
- react to loss and congestion signals.
Congestion control is usually done at the connection level, not separately for each stream. From the network’s perspective, packets consume capacity regardless of which stream they belong to.
Many QUIC implementations reimplement existing TCP congestion-control algorithms, commonly CUBIC or Reno-like algorithms. Some also experiment with BBR.
The lecturer emphasizes that implementing congestion control correctly is difficult. QUIC’s flexibility does not automatically make congestion control easier. Different QUIC libraries may implement the same conceptual algorithm in subtly different and imperfect ways.
QUIC may enable future improvements because ACK frames and extensions can carry richer information, for example ranges and timing information.
1.11. Flow control in QUIC
Flow control prevents the receiver from being overwhelmed.
TCP has a receiver window. The receiver tells the sender how many bytes it is willing to receive. As ACKs advance, the window slides.
QUIC has a more fine-grained model:
- connection-level flow control;
- per-stream flow control.
Important QUIC limits:
max_data: maximum data allowed on the whole connection;max_stream_data: maximum data allowed on a particular stream.
Unlike TCP’s sliding receive window, QUIC uses limits that must be increased explicitly. The receiver must regularly send frames increasing these limits if it wants to allow more data.
This gives more control but also more complexity.
1.12. QUIC datagrams
The original core QUIC model is reliable and stream-based.
But some applications also want unreliable delivery. Therefore, QUIC has an unreliable datagram extension.
QUIC datagrams are:
- unreliable;
- not retransmitted;
- not ordered;
- still protected by QUIC security;
- still part of congestion control;
- not subject to normal stream flow control.
This may sound strange because QUIC already runs over UDP, and now it reintroduces UDP-like unreliable datagrams inside QUIC. But it makes sense because datagrams can share:
- one QUIC handshake;
- one security context;
- one congestion-control loop;
- the same connection infrastructure.
Use cases include:
- video or real-time media;
- proxies;
- tunnels;
- MASQUE-style protocols;
- cases where reliable control data and unreliable media data should share one connection.
1.13. Faster development cycles
TCP is typically implemented in the kernel.
Changing TCP behavior requires:
- kernel changes;
- OS updates;
- careful compatibility testing;
- slow deployment.
QUIC is implemented in user space on top of UDP.
This means application vendors can deploy new protocol versions by updating their applications rather than waiting for kernel updates.
This enabled Google, for example, to experiment with multiple versions of QUIC quickly.
The downside is performance overhead:
- user-space networking is often less optimized than kernel TCP;
- more system calls may be needed;
- UDP offload support is less mature than TCP offload support;
- encryption happens per QUIC packet;
- each packet has to be individually protected and processed.
For large bulk transfers, highly optimized TCP/TLS stacks may still outperform QUIC.
1.14. QUIC in practice
Main use cases:
- HTTP/3;
- MASQUE proxying and tunneling;
- iCloud Private Relay-like systems;
- DNS over QUIC;
- experimental SSH over QUIC or other protocols.
HTTP/3 is not simply “HTTP/2 but newer”. It is HTTP over QUIC. HTTP/2 runs over TCP/TLS, while HTTP/3 uses QUIC streams directly.
There are many QUIC implementations, for example:
quicheby Cloudflare;mvfstby Meta/Facebook;quic-goin Go;LSQUICby LiteSpeed;- Google implementations;
- libraries in Rust, C, C++, Go, Python, and other languages.
The lecture also mentions qlog/qvis: since QUIC encrypts most packet internals, passive packet captures reveal much less than with TCP. qlog is an endpoint-side logging format, and qvis is a visualization tool for inspecting QUIC and HTTP/3 behavior.
1.15. QUIC vs TCP vs UDP
| Feature | QUIC | TCP | UDP |
|---|---|---|---|
| Reliable | Yes, except datagrams | Yes | No |
| Connection-oriented | Yes | Yes | No |
| Flow control | Yes, for reliable streams | Yes | No |
| Congestion control | Yes | Yes | No |
| Multiple streams | Yes | No | No |
| Built-in security | Yes, TLS 1.3 | No | No |
1.16. Takeaways
QUIC combines several ideas:
- TCP-like reliability;
- TCP-like congestion control;
- flow control;
- TLS 1.3 security;
- multiple logical streams;
- UDP-based deployability;
- user-space implementation;
- connection IDs for mobility.
Its main benefits are:
- lower handshake latency;
- integrated security;
- less head-of-line blocking for multiplexed applications;
- easier deployment and experimentation;
- better support for mobile clients.
Its main costs are:
- higher implementation complexity;
- higher CPU and packet-processing overhead;
- less mature optimization compared with TCP;
- many different implementations with different behavior.
2. Lecture 12: Network Layer and Link Layer
2.1. Big picture
Lecture 12 moves downward in the protocol stack.
Previous lectures focused on application and transport layers. This lecture introduces:
- the network layer;
- IP addressing;
- IPv4 and IPv6;
- IP datagram structure;
- subnetting and CIDR;
- forwarding and longest prefix matching;
- the link layer;
- MAC addresses;
- ARP and IPv6 neighbor discovery;
- how IP and MAC addresses interact when sending across subnets.
2.2. Network layer
2.2.1. Role of the network layer
The transport layer provides end-to-end communication between applications.
The network layer is responsible for moving packets across the network from source host to destination host, potentially through many routers.
At the sender:
transport segment -> encapsulated into IP datagram -> passed to link layer
At the receiver:
IP datagram -> network layer checks destination and protocol -> payload delivered to TCP/UDP/QUIC-over-UDP etc.
Every Internet host and router has a network layer.
Routers inspect IP datagram headers and decide where to forward packets next.
2.2.2. Forwarding vs routing
The lecture distinguishes two key functions.
Forwarding is local.
It means:
Move a packet from a router’s input interface to the appropriate output interface.
Analogy: at one road intersection, decide which exit to take.
Routing is global.
It means:
Determine the path that packets should take from source to destination.
Analogy: plan the whole trip before traveling.
Routing protocols and routing algorithms build or maintain the forwarding tables. Forwarding uses those tables to make per-packet local decisions.
2.3. IP addresses and interfaces
An IP address identifies an interface, not a whole host or router.
This is important.
A router normally has multiple interfaces, and each interface has its own IP address. A host may also have multiple interfaces, for example Ethernet and Wi-Fi.
IPv4 addresses are 32 bits.
IPv6 addresses are 128 bits.
2.4. IPv4 addressing
IPv4 addresses are written as four 8-bit decimal octets.
Example:
203.0.113.1
In binary:
203 0 113 1 11001011 00000000 01110001 00000001
IPv4 was designed in the 1970s. A 32-bit address space gives about \(2^{32}\), roughly 4 billion, possible addresses. Not all are usable globally, and the Internet has long outgrown this space.
2.5. IPv6 addressing
IPv6 addresses are 128 bits.
They are written as eight 16-bit groups in hexadecimal, separated by colons.
Example long form:
2001:0DB8:0000:0001:0000:0000:0000:0001
IPv6 notation can be shortened:
- Leading zeros in each 16-bit group can be omitted.
- One consecutive run of all-zero groups can be replaced by
::.
Example:
2001:0DB8:0000:0001:0000:0000:0000:0001 => 2001:DB8:0:1::1
The :: abbreviation can only be used once in an address, otherwise the address would be ambiguous.
IPv6 has been discussed since the 1990s and standardized early, but deployment has been slow. IPv4 and IPv6 are not directly compatible, so IPv4 will remain in use for a long time.
A major difference in practice:
- IPv4 interfaces often have one address.
- IPv6 interfaces commonly have multiple addresses, including link-local addresses.
IPv6 link-local addresses often start with fe80::. They are only valid on the local link and are not globally routed.
2.6. What is an IP network?
From the IP-address perspective, a network/subnet is a group of interfaces that:
- can physically reach each other without an intervening router;
- share the same high-order address bits.
A practical way to find networks in a topology is:
Remove the routers. The remaining connected “islands” are separate networks.
Important: links between routers are also networks. A point-to-point link between two routers still forms an IP network.
2.7. IP protocol and ICMP
The Internet network layer contains:
- IP;
- ICMP;
- routing/forwarding mechanisms.
IP defines:
- datagram format;
- addressing;
- packet-handling conventions.
ICMP is used for error reporting and signaling.
Examples:
pinguses ICMP echo request and echo reply;tracerouterelies on TTL/hop-limit expiration and ICMP time exceeded messages;- routers may report destination unreachable or packet-too-big errors.
For IPv6, the corresponding protocol is ICMPv6, which is also used for neighbor discovery.
2.8. IPv4 datagram format
Important IPv4 header fields:
- version;
- header length;
- type of service / DSCP / ECN bits;
- total datagram length;
- 16-bit identifier;
- flags;
- fragment offset;
- time to live;
- upper-layer protocol;
- header checksum;
- source IP address;
- destination IP address;
- options, if any.
2.8.1. Header length
IPv4 headers may include options, so the header length is variable.
The header length is measured in multiples of 4 bytes.
Minimum IPv4 header size:
5 * 4 bytes = 20 bytes
2.8.2. Total length
The total length field gives the length of the entire IP datagram in bytes, including header and payload.
The maximum is about 64 KiB because the length field is 16 bits.
In practice, packets are usually much smaller, often around 1500 bytes or less because of common link-layer MTUs.
2.8.3. TTL
TTL originally meant “time to live” in seconds, but in practice it is used as a hop count.
Each router decrements TTL by 1. If TTL reaches 0, the packet is discarded, often with an ICMP time exceeded message.
This prevents packets from looping forever.
Typical initial TTL values include 64, 128, or 255.
2.8.4. Upper-layer protocol
This field tells IP what payload protocol is inside the datagram.
Examples:
- TCP;
- UDP;
- ICMP.
QUIC does not have its own IP protocol number here because QUIC runs over UDP. The IP datagram says UDP; the UDP payload contains QUIC.
2.8.5. Fragmentation
IPv4 allows routers to fragment packets if a packet is too large for the next link’s MTU.
Fragmentation uses:
- identifier;
- flags;
- fragment offset.
However, fragmentation is problematic.
Reason:
The first fragment contains the IP header and usually the transport header, such as TCP or UDP. Later fragments may contain only IP header plus payload bytes, without the TCP/UDP header. Middleboxes and firewalls that expect to inspect the transport header may drop those fragments.
Therefore, network-layer fragmentation is often avoided.
IPv6 changes this design: routers do not fragment packets. If a packet is too large, the router should send an ICMPv6 “Packet Too Big” message to the sender. The sender then sends smaller packets.
This is cleaner, but it relies on ICMPv6 messages not being blocked or lost.
2.9. Subnetting and CIDR
Subnetting divides an address into:
- network part / prefix;
- host part.
CIDR notation:
IPv4: a.b.c.d/m Example: 192.0.2.0/24 IPv6: x:y:z::/m Example: 2001:DB8:0:3::/64
The number after / is the prefix length, i.e. the number of network bits.
Example:
192.0.2.0/24
means:
- first 24 bits are the network prefix;
- remaining 8 bits are host bits.
So there are \(2^8 = 256\) addresses in the block.
For normal IPv4 LANs, the first address is the network address and the last is the broadcast address, leaving 254 usable host addresses.
Example:
192.0.2.0/24 network address: 192.0.2.0 usable addresses: 192.0.2.1 - 192.0.2.254 broadcast address: 192.0.2.255
2.10. Classful addressing and why it is deprecated
Originally, IPv4 used classful addressing.
Main classes:
| Class | Leading bits | Approximate range | Prefix size | Purpose |
|---|---|---|---|---|
| A | 0 | 0.0.0.0 - 127.255.255.255 | /8 | unicast |
| B | 10 | 128.0.0.0 - 191.255.255.255 | /16 | unicast |
| C | 110 | 192.0.0.0 - 223.255.255.255 | /24 | unicast |
| D | 1110 | 224.0.0.0 - 239.255.255.255 | multicast | multicast |
Problem:
- class A was too large for most organizations;
- class C was too small for many organizations;
- many organizations wanted class B networks;
- this wasted address space and accelerated IPv4 exhaustion.
CIDR replaced classful routing.
CIDR allows arbitrary prefix lengths, such as:
/23 /24 /27 /30 /31
This allows address blocks to be allocated much more flexibly.
Example:
A /23 contains \(2^9 = 512\) addresses, roughly two /24 networks.
A /30 contains 4 addresses, usually 2 usable host addresses, useful for point-to-point links.
A /31 can also be used for point-to-point links because there is no need for separate network and broadcast addresses in that special case.
2.11. Multicast addresses
Multicast addresses identify a group of receivers.
They are useful for:
- streaming;
- conferencing;
- signaling;
- IPv6 local network mechanisms.
IPv4 multicast uses a reserved range beginning at 224.0.0.0.
IPv6 multicast uses FF00::/8.
IPv6 relies more heavily on multicast for local signaling, such as neighbor discovery.
2.12. How hosts get IP addresses
There are two different questions:
- How does a host get an address inside its network?
- How does a network get an address block?
2.12.1. Host address assignment
A host address can be configured manually.
More commonly, IPv4 hosts use DHCP.
DHCP stands for Dynamic Host Configuration Protocol.
Its goal is to let a host dynamically obtain an IP address when it joins a network.
DHCP supports:
- plug-and-play joining;
- lease renewal;
- address reuse;
- mobile users joining and leaving.
The basic DHCP process:
1. DHCP Discover Client broadcasts: Is there a DHCP server? 2. DHCP Offer Server replies: Here is an address you can use. 3. DHCP Request Client says: I would like to use this address. 4. DHCP ACK Server confirms: You may use this address for this lease time.
Before it has an address, the client uses:
source IP: 0.0.0.0 destination IP: 255.255.255.255
The broadcast address 255.255.255.255 stays within the local network and is not forwarded by routers.
DHCP also uses UDP ports, typically client port 68 and server port 67.
2.12.2. Network address allocation
Address blocks are allocated hierarchically.
Simplified hierarchy:
ICANN / IANA
-> Regional Internet Registries (RIRs)
-> Local Internet Registries (LIRs) / ISPs
-> organizations / customers
RIRs include:
- RIPE NCC for Europe;
- ARIN for North America;
- APNIC for Asia-Pacific;
- LACNIC for Latin America and Caribbean;
- AFRINIC for Africa.
IPv4 address space is exhausted in the free allocation sense. New IPv4 addresses are scarce, often recovered, transferred, or bought.
IPv6 allocations are much larger. A local Internet registry may receive something like a /29 or /32, and customer sites may receive something like a /48 or /56.
2.13. Longest prefix matching
Routers use forwarding tables.
A forwarding table entry has the form:
network/prefix-length -> next hop or output interface
When a packet arrives, the router examines the destination IP address and chooses the entry with the longest matching prefix.
Why longest?
Because a longer prefix is more specific.
Example:
134.96.0.0/16 -> C 134.96.240.0/20 -> B 134.96.252.0/24 -> A 134.96.252.192/28 -> B 134.96.252.196/30 -> A
For a destination such as:
134.96.252.200
several prefixes may match, but the router chooses the longest matching one.
Conceptually:
- Convert address and prefixes to binary.
- Compare only the prefix bits.
- Among all matches, choose the one with the largest prefix length.
This is the core of CIDR forwarding.
2.14. Link layer
2.14.1. Role of the link layer
The link layer is one layer below the network layer.
At the link layer, hosts and routers are called nodes.
A link is a communication channel between adjacent nodes.
Examples:
- wired Ethernet link;
- Wi-Fi link;
- point-to-point link;
- LAN;
- other link technologies.
The layer-2 transfer unit is a frame.
The link layer transfers frames from one node to a physically adjacent node over a link.
The network layer sees the Internet as a collection of IP-connected networks. The link layer deals with the actual next-hop communication on each individual link.
2.14.2. Different links, different protocols
A packet traveling from source to destination may cross many different link types.
Example analogy:
MPII -> Saarbrücken Hbf: bus Saarbrücken -> Frankfurt Airport: train Frankfurt -> Sydney: plane Sydney -> University of Sydney: taxi
The whole trip has one end-to-end destination, but each segment uses a different transportation mode.
Similarly, an IP packet may be carried over:
- Ethernet;
- Wi-Fi;
- fiber technologies;
- data center links;
- ISP-specific link technologies.
IP does not care much about the details below. The link layer handles them locally.
2.15. MAC addresses
An IP address is a network-layer address.
A MAC address is a link-layer address.
MAC addresses are used locally to move a frame from one interface to another physically connected interface on the same subnet.
Typical MAC addresses are 48 bits, written in hexadecimal.
Example:
1A-2F-BB-76-09-AD
or:
1A:2F:BB:76:09:AD
Each hexadecimal digit represents 4 bits.
MAC addresses are usually burned into the network interface card, although they can often be changed in software.
2.15.1. MAC vs IP
MAC addresses are flat.
They do not express network topology.
IP addresses are hierarchical.
They contain a network prefix and are used for routing and forwarding.
Analogy from the lecture:
- MAC address: like a social security number;
- IP address: like a postal address.
If a network card moves to another LAN, it can keep its MAC address. But its IP address usually changes because it now belongs to a different IP subnet.
2.16. ARP: Address Resolution Protocol
Problem:
A host knows the destination IP address on the same LAN, but to send an Ethernet frame, it needs the destination MAC address.
ARP solves this for IPv4.
Each IP node on a LAN has an ARP table containing mappings like:
IP address -> MAC address -> TTL
The TTL means the entry is soft state. It expires unless refreshed.
2.16.1. ARP process
Suppose A wants to send to B on the same LAN.
If A does not know B’s MAC address:
- A broadcasts an ARP query.
The destination MAC address is the broadcast MAC address:
FF-FF-FF-FF-FF-FF
- All nodes on the LAN receive the ARP query.
- B recognizes its own IP address in the query.
- B sends an ARP reply directly to A, containing B’s MAC address.
- A stores the IP-to-MAC mapping in its ARP table.
- A can now send frames directly to B’s MAC address.
ARP is only for the same LAN / same IP subnet. Routers do not forward ARP broadcasts across subnets.
2.17. IPv6 neighbor discovery
IPv6 does not use ARP.
Instead, IPv6 uses Neighbor Discovery, based on ICMPv6.
Each node has a neighbor table, conceptually similar to an ARP table:
IPv6 address -> interface identifier -> TTL
The interface identifier generalizes the idea of a MAC address, so it can work with different link technologies.
2.17.1. Neighbor solicitation and advertisement
Suppose A wants to send to B and does not know B’s link-layer identifier.
- A sends an ICMPv6 Neighbor Solicitation.
- Source: A’s link-local IPv6 address.
- Destination: B’s solicited-node multicast address.
The solicited-node multicast address is based on the last 24 bits of B’s IPv6 address:
ff02::1:ff + last 24 bits of B's IPv6 address
Only nodes on the LAN with matching relevant address bits need to receive/process it.
Then:
- B replies with a Neighbor Advertisement.
- A caches the IPv6-to-interface-identifier mapping.
- The entry expires unless refreshed.
This is more structured than IPv4 ARP and uses IPv6 multicast instead of a full broadcast in the same way.
2.18. Sending to another subnet: IP vs MAC addresses
A key point:
IP source and destination usually stay end-to-end, but MAC source and destination change at every link.
Example:
A wants to send an IP datagram to B, but B is on another subnet. The packet must go through router R.
Assumptions:
- A knows B’s IP address.
- A knows the IP address of its first-hop router R, usually from DHCP or configuration.
- A knows R’s MAC address, usually via ARP or neighbor discovery.
2.18.1. Step 1: A creates the IP datagram
The IP datagram has:
IP source: A's IP address IP destination: B's IP address
These are end-to-end addresses.
2.18.2. Step 2: A sends a frame to R
A cannot send directly to B’s MAC address because B is not on the same link.
So A sends the frame to the router’s MAC address:
MAC source: A's MAC address MAC destination: R's MAC address
Inside that frame is the IP datagram whose destination is still B’s IP address.
2.18.3. Step 3: R receives and forwards
Router R receives the frame.
It removes the link-layer frame and passes the IP datagram to the network layer.
R checks the destination IP address, consults its forwarding table, and chooses the outgoing interface.
2.18.4. Step 4: R creates a new frame toward B
R sends the same IP datagram onward, but in a new link-layer frame.
Now the MAC addresses are:
MAC source: R's outgoing-interface MAC address MAC destination: B's MAC address
The IP addresses remain:
IP source: A's IP address IP destination: B's IP address
2.18.5. Step 5: B receives
B receives the frame, extracts the IP datagram, sees that the IP destination is B, and passes the payload up the protocol stack.
2.19. Important contrast: network layer vs link layer
| Aspect | Network layer | Link layer |
|---|---|---|
| Unit | IP datagram / packet | Frame |
| Address | IP address | MAC / link-layer address |
| Scope | End-to-end across networks | One link / one LAN / one hop |
| Devices | Hosts and routers | Adjacent nodes |
| Main job | Forward toward destination network | Deliver frame to next physically adjacent node |
| Address structure | Hierarchical | Flat |
| Changes per hop? | IP src/dst usually stay the same | MAC src/dst change on every hop |
2.20. Takeaways
Network layer:
- IP addresses identify interfaces, not whole hosts.
- IPv4 uses 32-bit addresses; IPv6 uses 128-bit addresses.
- IPv6 addresses can be shortened, but
::can only appear once. - A network/subnet is a group of interfaces sharing high-order address bits and reachable without an intervening router.
- IP provides datagram format, addressing, and packet-handling conventions.
- ICMP provides error reporting and signaling.
- IPv4 fragmentation exists but is problematic; IPv6 routers do not fragment.
- CIDR replaces classful addressing and allows flexible prefix lengths.
- Forwarding uses longest prefix matching.
Link layer:
- The link layer transfers frames between physically adjacent nodes.
- MAC addresses are flat, local link-layer identifiers.
- ARP maps IPv4 addresses to MAC addresses on the same LAN.
- IPv6 uses ICMPv6 Neighbor Discovery instead of ARP.
- When sending across subnets, the IP destination remains the final host, but the MAC destination is only the next hop.