Distance-Vector
Periodically send
Poisoned reverse: if
RIP
-
Metric: number of hops (number of subsets traversed())
-
Max path cost: 15
-
DVs sent to neighbors every 30 seconds via UDP
- Each advertisement contains at max 25 entries
-
Table stores destination network, next hop and number of hops
-
After 3 minutes of no advertisements, node declared dead
Link-State (Dijkstra)
Each router reliably floods information about its neighbors and independently calculates the least-cost path to every other router.
Add nearest node not in tree to the tree, calculate distance to each neighbor through the node.
OSPF
- Authenticated advertisements over IP (not UDP/TCP)
- Multiple same-cost paths allowed
- Link cost can be set by administrators
- Uni/multi/broadcast support
- Used mostly in upper-tier ISPs
Hierarchy
- Can be configured into areas. Each area runs OSPF:
- Broadcasts only within the same area
- Each node has detailed topology about its own area
- Inter-area routing through area-border routers
- ‘Summarizes’ distance to networks in its own area
- One backbone area which connects all areas
- Boundary routers connect to other ASes
IPv6
- Version (4): 6
- Traffic class (8): QoS
- Flow label (20): identifier for a group of packets
- Payload length (16): size of data in bytes
- Next header (8): payload type (e.g. UDP, TCP)
- Hop limit (8): TTL
- Source/Destination: 128 bytes each
When forwarding packet through IPv4 router:
- Dual stack: transform to IPv4, lose metadata
- Tunnelling: stuff IPv6 packet into IPV4
BGP
Pairs of routers, either in the same (iBGP) or different AS (eBGP), exchange information over TCP. If a node advertises a prefix, it promises that it can forward datagrams to the prefix. Some attributes:
AS_PATH: not updated in iBGP connections. Contains a list of ASes through which the advertisement has passed - reject if already in the pathNEXT_HOP: not updated in iBGP connections. Advertisements flow from the destination outwards, so it contains the address of the boundary router for the next-hop AS
Import policy used to accept/reject advertisements.
Route selection uses local preference (policy decision), shortest AS_PATH, closest NEXT_HOP router etc.
Reliable Data Transfer
Internet checksum:
def ones_complement_addition(shorts):
result = 0
for short in shorts:
result += short
if result > 0xFFFF:
result -= 0xFFFF
return result
def checksum(shorts):
return 0xFFFF - ones_complement_addition(shorts)
def check_checksum(shorts, checksum):
return 0xFFFF == (ones_complement_addition(shorts) + checksum)
CRC
ddata bits andrchecksum appended to the end.- Agreed-upon
r+1bit pattern, with MSB being1 - To find
r: Initially setrto0, do long division (XOR) and get remainder - Can detect consecutive bit errors up to
rbits long.
RDT
1.0: no bit errors, buffer overflows, out-of-order packets, packet loss
2.0: bit errors; checksum. Stop and wait for ACK/NACK after each packet
2.1: 1-bit sequence numbers in case ACK/NACK corrupted
2.2: No NACK. Sends ACK with sequence number - last packet that was received successfully
3.0: bit errors and lost packets. Assumes packets are not reordered in the channel (although this can be solved by having a time to live and sufficiently large sequence space)
Go-Back-N
No more than N unacknowledged packets. Receiver sends cumulative ACK. On timeout, all packets reset.
Selective Repeat
An ACK for each packet.
On timeout, resend oldest packet without ACK. If duplicate packet received, send ACK for that packet again.
Worst case scenario:
- All but the first packet in the window arrives. ACKs arrive
- First packet resent, ACK lost
- Receiver window moves forward by
sender does not move - Sender window is
- Receiver window is
- Sender window is
- Sender sends first packet again
To prevent this from being interpreted as a new packet, the sender base number must not be in the receiver window. Hence, the window size must be larger than
UDP and TCP
UDP
| 16 bits | 16 bits |
| Source port | Destination port |
| Length | Checksum |
| Data |
Identified by destination port and IP.
TCP
| 16 bits | 16 bits |
| Source port | Destination port |
| Sequence Number |
| Acknowledgement Number |
| Flags | Receive window |
| Checksum | Urg. data pointer |
| Options (variable) |
| Application Data |
- Sequence number: byte number for first byte in segment
- Acknowledgement: next expected byte number
- Flags starts with 4-bit header length - bytes in header divided by 4
LastByteSent - LastByteACKed <= min(CongestionWindow, RecvWindow)
Handshake and Termination
Segments with SYN or FIN treated as if they have a 1 byte payload.
Three-way handshake:
- Client sends TCP SYN segment
- Server replies with SYNACK:
ack = client_isn + 1 - Client replies with ACK:
ack = server_isn + 1, sequence_number = client_isn + 1
Termination:
- Client sends
FIN - Server responds with
ACK - Once connection closed, server sends
FIN - Client responds with
ACK, waiting twice the max segment lifespan to ensure the ACK arrived
Acknowledgements
ACK: largest byte received (cumulative ACK).
Sender events:
- One retransmission timer timer
- If timer expires, resend oldest unacknowledged packet
- Double timeout and restart timer
- When ACK received, restart timer (if received ACK is not for base packet)
- Fast retransmit: if three ACKs with the same segment number received, retransmit it immediately
Receiver events:
- If in-order segment arrives, wait 500 ms. If another in-order segment arrives in this window, send the ACK immediately
- If out-of-order packet arrives, buffer and send duplicate ACK
Timeout value requires finding round trip time: use exponential weighted moving average:
Flow control
- Send receive window - amount of free space in buffer
- If receive window 0, need to periodically send TCP segment
Congestion Control
Overflowing router buffers:
Slow start:
- Congestion window = 1 MSS (1 segment per RTT)
- Double window every RTT (increment by one after every ACK)
AIMD (after first loss):
- Increase by 1 after every RTT (window += 1/window)
- Half after every loss
After 3 duplicate ACKs, half window and move to AIMD.
After timeout, slow start until it reaches half of window size before timeout. Then move to AIMD.
LastByteSent - LastByteAcked <= min(CongestionWindow, ReceiveWindow)
Lab 4
- First ping to station on the same network slow as ARP request required
- Minimal forwarding table:
0.0.0.0/0pointing to default gateway
Ping failure modes:
- Network unreachable: no entry in forwarding table
- Destination host unreachable: directly-attached network, ARP fails
- Destination port not reachable: TCP/UDP packet, port not bound
- No response: if routing table of receiver empty
ASes:
- Stub: leaf node connected to single AS
- Multihomed: connected to multiple ASes
- Transit: multihomed but traffic can path through