0% found this document useful (0 votes)
51 views

Chapter5 NetworkLayer Withnotes

The document discusses routing algorithms and concepts at the network layer. It describes the goals of routing as finding the least-cost path between nodes in a graph. It outlines different routing algorithms like Dijkstra's algorithm, distance vector routing, and link state routing.

Uploaded by

c lamp
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Chapter5 NetworkLayer Withnotes

The document discusses routing algorithms and concepts at the network layer. It describes the goals of routing as finding the least-cost path between nodes in a graph. It outlines different routing algorithms like Dijkstra's algorithm, distance vector routing, and link state routing.

Uploaded by

c lamp
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 110

Network Layer

Chapter 5

Slides courtesy: Sweta & Chebrolu


Revised: August 2011
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Outline

• Network Layer Overview


• Inside a Router
• Routing Algorithms
• Congestion Control
• Network Layer of the Internet

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Network Layer Overview

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Problem

• What we have learned so far:


• Build reasonably sized networks via LANs
• Drawbacks:
• Not scalable
• Can’t handle heterogeneity (Layer 2 switches
usually work for one network type)
• Goal: Make millions of hosts using different technology
communicate
• Solution: Network layer switching

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
The Network Layer

• Responsible for delivering packets


between endpoints over multiple links
Application
• The lowest layer that deals with end- Transport
to-end transmission Network
Link
• The network layer protocol supported
Physical
by TCP/IP protocol suit is:
• Internet Protocol (IP)
• Internet: Interconnected Networks

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Store-and-Forward Packet Switching

Hosts send packets into the network; packets are


forwarded by routers
ISP’s equipment

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Network Layer Functions
To move packets from a sending host to a receiving host,
two important network layer functions are needed:
• Forwarding:
− Directing a data packet to an outgoing link
− Router-local action
− Individual router using a forwarding table
− Take place at very short timescales (typically nanoseconds)

• Routing:
− Determining the route or path taken by the packets as they
flow from a sender to a receiver
− Network-wise process
− Routers talking amongst themselves
− Individual router creating a forwarding table
− Take place on longer timescales (typically seconds)
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Network Service Models
• Connectionless service
• No advance setup is needed
• Packets are routed independently
• Packets are called datagrams
• Networks are called datagram networks
• Connection-oriented service
• Source-destination connection must be established
first
• This connection is called a virtual circuit (VC)
• Networks are called virtual-circuit networks
• All packets follow the same route

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Connectionless Service – Datagrams
Packet is forwarded using destination address inside it
• Different packets may take different paths
ISP’s equipment

A’s table (initially) A’s table (later) C’s Table E’s Table

Dest. Line

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Connection-Oriented – Virtual Circuits
Packet is forwarded along a virtual circuit using tag inside it
• Virtual circuit (VC) is set up ahead of time

ISP’s equipment

A’s table C’s Table E’s Table

In: Line Tag Line Tag: Out

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Service Model for IP
• Connectionless Service – Datagram
• Best Effort Service
• Will make best effort to deliver the packets
− Packets can get lost, corrupted, reordered, misdelivered,
duplicated, delayed
• IP protocol’s greatest strength
− Runs over anything Email, Web, VoIP,
RSTP, etc.

TCP, UDP, SCTP

TCP/IP Protocol IP
stack Ethernet, PPP,
WiFi, FDDI
Twisted Pair, Fiber optics,
wireless, Coaxial cable
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Inside a Router

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Router Architecture
Functions: Components:
• Forwarding • Input ports
• Routing • Output ports
• Switching fabric
• Routing processor

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Terminate Inside a Router
Perform data-
physical link
link functions Can perform
look-up and
forwarding

Store incoming
Connect input ports packets (queues)
to output ports and transmit on
outgoing link;

Executes routing
protocols, main
forwarding tables
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Router Functions

• Data-path functions: operations performed on every


datagram
• Forwarding, checksum calculation, FIFO scheduling,
etc.
• Often implemented in specialized hardware for high
speed
• Control functions: operations performed infrequently
(packet exchange for routing protocols, system/network
management)
• Implemented in software

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Router Physical Layout

Juniper T series

Switch

Linecards

Cisco 12000
Review - 1
• Network layer: deliver packets from a sending host to a
receiving host
• Service that can be provided by the network layer
• Connectionless service
• Connection-oriented service
• Network layer protocol used in Internet: IP
• IP protocol helps interconnect heterogeneous
networks in a scalable fashion
• Best-effort datagram delivery service
• Router: a core device at network layer
• Key components and two functions
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Routing Algorithms

• Optimality principle »
• Dijkstra’s Shortest path algorithm »
• Distance vector routing »
• Link state routing »

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Problem
• Routers have forwarding tables
• Map IP prefix to outgoing link(s)
• Entries can be statically configured
• E.g., “map 12.34.158.0/24 to Serial0/0.1”
• But this doesn’t adapt
• To failures
• To new equipment
• To the need to balance load
• How to build the forwarding table?
• Via routing protocols

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Theory
• Based on graph theory
• Nodes: hosts, routers, networks
• Edges: physical links
• Each edge is associated with a cost
• No edge -> infinite cost
• Neighbor: directly connected nodes

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Goal of Routing

• Single-source “shortest” path problem


• Find the least-cost path from a source to all other
nodes in the graph

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
The Optimality Principle

Each portion of a best path is also a best path; the


union of them to a router is a tree called the sink tree
• Sink tree need not be unique
B

Network Sink tree of best paths to router B

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Cost Metric

• Hop count , physical distance


• Doesn’t distinguish between links based on
bandwidth, delay, current load, losses, etc.
• Static: 1/link_bandwidth
• Dynamic: queue length, delay
• Not stable (ping-pong effect)
• Reality: links assigned “static” cost by administrators

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Dijkstra’s Shortest-Path Algorithm (1)
Given: network topology with link distances (costs)
• Infinity if two nodes are not direct neighbors
Compute: shortest paths between a source and all
destinations in the network
Example: consider the start node A, and find the
shortest paths to B,C,D,E.
Node Shortest distance Previous
6 from A node
A C
3 A 0
3 2 B 1 A
1 E
C 4 B
B D 3 D 3 B
2
E 6 D
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Dijkstra’s Shortest-Path Algorithm (2)
Initially,
• distances to all other nodes from the start node A are
unknown, therefore, set the distances to infinity (∞).
• Distance to A from A is 0

6 Node Shortest distance Previous


A C from A node
3
3 A 0
1 2
E B ∞

B D 3 C ∞
2 D ∞
E ∞
Visited = [] Unvisited = [A,B,C,D,E]
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Dijkstra’s Shortest-Path Algorithm (3)
• Visit the unvisited node with the smallest known distance from the
start node A.
• For the current node, examine its unvisited neighbors, and calculate
the distance of each neighbor from the start node A.
• If the calculated distance is less than the known distance, update the
shortest distance from start node A and the previous node.
• Add the current node to the list of visited node

6 Node Shortest distance Previous


A C from A node
3
3 A 0
1 2
E B ∞ → 1 A

B D C ∞ →6 A
3
2 D ∞
Visited = [] Unvisited = [A,B,C,D,E] E ∞

Visited = [A] Unvisited = [B,C,D,E]


CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Dijkstra’s Shortest-Path Algorithm (4)
• Visit the unvisited node with the smallest known distance from the
start node A.
• For the current node, examine its unvisited neighbors, and calculate
the distance of each neighbor from the start node A.
• If the calculated distance is less than the known distance, update the
shortest distance from start node A and the previous node.
• Add the current node to the list of visited node

6 Node Shortest distance Previous


A C from A node
3
3 A 0
1 2
E B 1 A

B D C 6 →4 B
3
2 D ∞ →3 B
Visited = [A] Unvisited = [B,C,D,E] E ∞

Visited = [A,B] Unvisited = [C,D,E]


CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Dijkstra’s Shortest-Path Algorithm (5)
• Visit the unvisited node with the smallest known distance from the
start node A.
• For the current node, examine its unvisited neighbors, and calculate
the distance of each neighbor from the start node A.
• If the calculated distance is less than the known distance, update the
shortest distance from start node A and the previous node.
• Add the current node to the list of visited node

6 Node Shortest distance Previous


A C from A node
3
3 A 0
1 2
E B 1 A

B D C 4 B
3
2 D 3 B
Visited = [A,B] Unvisited = [C,D,E] E ∞ →6 D

Visited = [A,B,D] Unvisited = [C,E]


CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Dijkstra’s Shortest-Path Algorithm (6)
• Visit the unvisited node with the smallest known distance from the
start node A.
• For the current node, examine its unvisited neighbors, and calculate
the distance of each neighbor from the start node A.
• If the calculated distance is less than the known distance, update the
shortest distance from start node A and the previous node.
• Add the current node to the list of visited node

6 Node Shortest distance Previous


A C from A node
3
3 A 0
1 2
E B 1 A

B D C 4 B
3
2 D 3 B
Visited = [A,B,D] Unvisited = [C,E] E 6 D

Visited = [A,B,D,C] Unvisited = [E]


CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Dijkstra’s Shortest-Path Algorithm (7)
• Visit the unvisited node with the smallest known distance from the
start node A.
• For the current node, examine its unvisited neighbors, and calculate
the distance of each neighbor from the start node A.
• If the calculated distance is less than the known distance, update the
shortest distance from start node A and the previous node.
• Add the current node to the list of visited node

6 Node Shortest distance Previous


A C from A node
3
3 A 0
1 2
E B 1 A

B D C 4 B
3
2 D 3 B
Visited = [A,B,D,C] Unvisited = [E] E 6 D

Visited = [A,B,D,C,E] Unvisited = []


CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Dijkstra’s Shortest-Path Algorithm (8)
• Let distance of start node from start node be 0
• Let distance of all other nodes from start node be
infinity (∞)
• WHILE nodes remain unvisited
• Visit the unvisited node with the smallest known
distance from the start node.
• FOR each unvisited neighbor of the current node
− Calculate the distance from the start node.
− IF the calculated distance is less than the known distance
» update the shortest distance from start node A and the
previous node
− END IF
• Add the current node to the list of visited node
• END WHILE
Problem
What we have learned:
• Given a network topology, find the shortest path from
one node to all other nodes in the network
Question?
• Network topology may not be known
• Network topology can change
• Cost between two nodes can change
Solution: Learn the topology dynamically
• Distance Vector Routing (DVR)
• Link State Routing (LSR)
Distance Vector Routing - Background
• Distance vector is a distributed routing algorithm
− Shortest path computation is split across nodes

• Also goes by the name Bellman-Ford algorithm

• Used in ARPANET until 1979, RIP (Routing information


protocol)
• Not used much now

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Distance Vector Routing – Key Idea
• DVR works by having each router maintain a table (i.e.,
vector) giving the best known distance (cost) to each
destination and which link to use to get there
− Initial state: distance to neighbors
− Final state: distance to all nodes, and the next hop
− Tables are updated by exchanging information with the
neighbors
Destination Distance Next Hop
Initial
B 1 B
6 routing
A C C 6 C table at A
3
3 2 Destination Distance Next Hop
1 E
B 1 B
Final
B D 3 C 4 B routing
2 table at A
D 3 B
E 6
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011 B
Distance Vector Routing – Questions

• Questions?
• What information to exchange?
• How to act on a message?
• When to send a message?

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Distance Vector Routing – What information
to Exchange

Each node exchanges with all its neighbors the “routing


table” information
• Destinations and the best known distance to
destinations
• Next hop information is not shared

Destination Distance
B 1
C 6

Message shared by A
with its neighbors initially

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Distance Vector Routing – How to Act on a
Message
• Bellman-Ford equation
• Dx(y) ← minv{c(x,v) + Dv(y)}
• Dx(y) = estimate of the least cost from x to y
• c(x,v) = cost for direct link from x to v
• v is the neighbor of node x
• On receiving a message from a neighbor v,
• Update cost to destinations based on the Bellman-
ford equation; change next hop accordingly
• For each destination in the received routing table
− Dx(y) ← min{current estimate, c(x,v) + Dv(y)}
• Estimated costs finally converge to the optimal cost
after series of message exchanges
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Distance Vector Routing – Example (1)
How to update the routing table at
node A? 6
A C
Initially 3
3 2
Destination Distance Next Hop 1 E
B 1 B
B D 3
C 6 C 2

Message from B

Destination Distance
Dx(y)
A 1
Dv(y) Destination Distance Next Hop
C 3
D 2 B 1 B
C 4 B
c(x,v) Cost from A to B = 1 D 3 B
Distance Vector Routing – Example (2)
After the first iteration 6
Destination Distance Next Hop A C
3
B 1 B 3
1 2
C 4 B E
D 3 B B D 3
2

Message from C
Destination Distance Dx(y)
A 6
Destination Distance Next Hop
B 3
Dv(y) B 1 B
D 2
C 4 B
E 3
D 3 B
E 9 C
c(x,v) Cost from A to C = 6
Distance Vector Routing – How long to
Converge
• The settling of routes to the best paths across the
network is called convergence.
• If no topology changes, convergence will happen in a
few rounds.
• For a network whose longest path is of length N
hops, the convergence happens within N message
exchanges.
− After one message exchange, each node knows about
nodes two hops away
− After two message exchange, each node knows about nodes
three hops away,
− And so on….

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Distance Vector Routing – When to Send a
Message
• Triggered update: sent whenever the routing table
changes
• Link/node failure or cost changes
• Periodic update: sent even when no change in routing
table
• To tell others that “I am still alive”
• To update others’ routing table in case some route
becomes invalid
• Timescale: few seconds or few minutes

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Distance Vector Routing - Count-to-Infinity
Problem
Failures can cause DV to “count to infinity” while
seeking a path to an unreachable node

Good news of a path


to A spreads quickly

Bad news of no path to A


is learned slowly

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Review - 2
• Dijkstra’s shortest path algorithm
• Given the topology, it finds the shortest paths from
one start node to all other nodes in the network.
• Static algorithm that works with global knowledge
• Distance Vector algorithm
• Nodes learn topology and finds the shortest paths
to other nodes by exchanging information with
neighbors
• Distributed algorithm that works with local
knowledge
• Suffer from the count-to-infinity problem

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Link State Routing - Overview

Link state is an alternative to distance vector


• More computation but simpler dynamics
• Widely used in the Internet (OSPF, ISIS)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Link State Routing – Key Idea

Two Phases:
• Phase 1: Nodes flood topology in the form of link
state packets
• Initial state: each node only knowns the cost to its
neighbors
• Final state: each node learns the full topology
• Phase 2: Each node computes its own forwarding
table
• By running Dijkstra’s algorithm to find the optimal
routes to all nodes

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Link State Routing - Flooding
• Each node floods link state packet (LSP) that includes
neighborhood information to all nodes in the topology

Network LSP for each node

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Link State Routing – Problems & Solutions
(1)
• Problem 1: How to avoid loops and minimize message
exchanges?
A 6 A 6
A 6
C C
C
1 1
1
3 3
3
B B
B

• What we need? – detect duplicates


• Solution to Problem 1:
• Each packet needs a unique id
• For a given id, maintain state to determine on which
interface to send
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Link State Routing – Problems & Solutions
(2)
• Problem 2: What if link cost changes?

A 6 A 6
C C

1 3
3 3
B B

Old new

• Solution to Problem 2:
• Use sequence number (seq.) to uniquely identify a
packet
• At a node, increment sequence number for each
new message flooded.
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Link State Routing – Problems & Solutions
(3)
• Problem 3: What if the sequence number wrap around?

• Solution to Problem 3:
• Use a very large sequence space (e.g., 32 bits).

• Problem 4: What if the sequence number get


corrupted?
• Solution to Problem 4:
• Use checksums.
• Each entry stored at node is “aged” (decremented
per second), discard packet when “age” becomes
zero
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Link State Routing – Problems & Solutions
(4)
• Problem 5: What if a router crashed and came back
up? What sequence number should it use?

• Solution to Problem 5:
• Start with sequence number 0. If heard “your own”
packet, increment sequence number (within) and
use
• Packets are associated with an “age”, discard
packets when age becomes zero.

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Link State Routing – Questions

• Questions?
• What information to send?
• How to act on a message?
• When to send a message?

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Link State Routing – What Message to
Send

Each node floods the link state packet (LSP), which


includes the following information:
• The id of node sending the packet
• The sequence number
• Age
• Link-state of the node: Neighborhood information (list
of neighbors and cost to each neighbor)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Link State Routing – How to Act on a
Message
Suppose node A receives an LSP generated by node B
(B may not be A’s neighbor)
Based on whether A has heard from B before
• If no, store the link-state information. Start an aging
timer.
• If yes, compare the sequence number of this packet
(seq_new) with the stored information (seq_old).
• If Seq_new > Seq_old, overwrite old link-state
information, refresh aging timer, forward to
”required” neighbors
• Otherwise, discard the packet
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Link State Routing – When to Send
Message
Triggered updates
• A node floods the network whenever its link-state
information changes
Periodic updates
• Need not be sent often, use long timers (order of
hours) to avoid large flooding traffic

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
DVR vs LSR
Message complexity Robustness: what happens
if router malfunctions?
LSR: with n nodes, E links, O(nE)
messages sent LSR:
DVR: exchange between • Node can advertise incorrect
neighbors only link cost
• Each node computes only its
Speed of Convergence own table
LSR: relatively fast DVR:
DVR: convergence time varies • DV node can advertise
• May be routing loops incorrect path cost
• Count-to-infinity problem • Each node’s table used by
others (error propagates)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Review - 3
• Link State routing:
• Distributed algorithm
• Two phases: flooding, then calculate routes
• Provides fast convergence
• Used in Internet (IS-IS, OSPF)
• Comparison between LSR and DVR

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Congestion Control

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
The Problem of Congestion
What is congestion?
• Load is higher than capacity
What do IP routers do?
• Drop the excess packets
Why is this bad?
• Wasted bandwidth for retransmissions

“congestion
Goodput
collapse” Increase in load that
(useful results in a decrease in
packets)
useful work done.
Load 59
Congestion Control
Handling congestion is the responsibility of the Network
and Transport layers working together
− We look at the Network portion here

Network must do its best with the offered load


• Different approaches at different timescales
• Nodes should also reduce offered load (Transport)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Traffic-Aware Routing
Choose routes depending on traffic, not just topology
• E.g., use EI for West-to-East traffic if CF is loaded
• But take care to avoid oscillations

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Admission Control
Admission control allows a new traffic load only if the
network has sufficient capacity, e.g., with virtual circuits
• Can combine with looking for an uncongested route

Network with some Uncongested portion and


congested nodes route AB around congestion

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Traffic Throttling

Congested routers signal hosts to slow down traffic


• ECN (Explicit Congestion Notification) marks
packets and receiver returns signal to sender

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Load Shedding (1)

When all else fails, network


1 4
will drop packets (shed load)
Can be done end-to-end or
link-by-link 2 5

Link-by-link (right) produces


rapid relief
3

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Load Shedding (2)

1
End-to-end (right) takes
5
longer to have an effect,
but can better target the 2
cause of congestion
6

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Load Shedding - Random Early Detection
(RED)
Basic idea of RED
• Router notices that the queue is getting backlogged
• … and randomly drops packets to signal congestion
When to start dropping?
• Router maintains a running average of its queue lengths.
• When the queue length on some link exceeds a threshold,
the link is considered to be congested.

Randomization makes it more


Probability
likely that faster senders will see
a packet drop, and then slow
down traffic.
Average Queue Length 66
Review - 4
Congestion control happens when load exceeds the
capacity.
• Managed by both network and transport layers.
Different congestion control techniques with different
timescales
• Traffic-aware routing
• Admission control
• Traffic throttling
• Load shedding
• Link-by-link, end-to-end, RED
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Network Layer in the Internet

• IP Packet Format »
• IP Addresses »
• Internet Control Protocols »

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
IP Packet Format (1)
• Version (4 bits) 32 bits
• Indicates the version
of the IP protocol
• Necessary to know
what other fields to
expect
• Typically “4” (for
IPv4), and sometimes
“6” (for IPv6)

• Header Length (4 bits)


• Specify the header in
32-bit words
• Typically “5” (for a 20-
byte IPv4 header)
• Can be more
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
IP Packet Format (2)
• Type-of-Service (8 bits) 32 bits
• Allow packets to be
treated differently
based on needs
• E.g., low delay for
audio, high bandwidth
for bulk transfer

• Total Length (16 bits)


• Number of bytes in the
packet (including
header)
• Maximum size is
65,535 bytes (216 − 1)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
IP Packet Format (3)
32 bits
• Identification/Flags/Fragmen
t offset (32 bits)
• Supports dividing a large
IP packet into fragments
• Underlying links may not
support large packets

• Time-To-Live (8 bits)
• Limit packet lifetimes
• Routers decrement the
field by one before
forwarding; if zero
discard
• Default value = 64
• Used to identify packets
stuck in forwarding looks
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
IP Packet Format (4)
32 bits
• Protocol (8 bits):
• Tells which transport
process to give the
packet to.
• TCP: 6, UDP: 17

• Header Checksum (16 bits)


• Detects errors in
header

• Source/Destination IP
Address (32 + 32 bits)
• Global address space,
independent of physical
network address (MAC)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
IP Packet Format (5)
32 bits
• Options: rarely used
• E.g., Security, record
route, etc.

• Payload
• Higher layer data (TCP
or UDP segment)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
IP Packet Format – Fragmentation (1)
• Problem: each technology has different Maximum
Transmission Unit (MTU) size
• MTU: largest IP datagram that can be carried in a
frame
• E.g., Ethernet: 1500 bytes, WiFi: 7981 bytes.
• When fragmentation and reassembling happen?
• At host: select MTU of link it is connected to
• At intermediate router: if forward datagram on a
network with smaller MTU, fragment the datagram
• At destination: reassemble the fragments.
3-bit
16-bit Identification Flags 13-bit Fragment Offset

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
IP Packet Format – Fragmentation (2)
• Identification (16 bits): helps identify a datagram
• All fragments carry same identification
3-bit
16-bit Identification
13-bit Fragment Offset
• Flags (3 bits): Flags

• First bit: reserved, set to zero


• Second bit: Don’t Fragment (DF); useful for path
MTU discovery
• Third bit: More Fragment (MF); set to one to indicate
more fragments to follow
• Fragmentation offset (13 bits):
• Measures payload in units of 8-bytes blocks
• Specifies start of data relative to the beginning of the
original unfragmented datagram
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
IP Packet Format – Fragmentation (3)
Original datagram
• Original datagram:
Length = 1500 ID = x Flag = 0 Offset = 0
1500B
• Payload = 1480B
Fragmented Datagrams
• MTU: 296B Length = 292 ID = x Flag = 1 Offset = 0

• Max. payload within


Length = 292 ID = x Flag = 1 Offset = 34
each fragment = 276B
Length = 292 ID = x Flag = 1 Offset = 68
• Offset has to be
multiple of 8, making
Length = 292 ID = x Flag = 1 Offset = 102
payload within each
fragment = 272B Length = 292 ID = x Flag = 1 Offset = 136

Length = 140 ID = x Flag = 0 Offset = 170


IP Addresses

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Problem
• Flat addressing: N hosts needs N entries in the
forwarding table (MAC addresses)
• Millions of hosts make address lookup in forwarding
becomes a bottleneck
• Need a method of reducing entries in the forwarding
table for scalability purposes
• Solution: hierarchical addressing

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Hierarchical Addressing
• Address structure: address captures location in the
network topology
• IP addresses (32 bits) consists of two parts: network
and host
• Network part identifies the network to which the
host is connected to
• Host part uniquely identifies each host in the
network
• How does this help?
• An entire network (e.g., a LAN) can be represented
by a single entry at a router.

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Classful Addressing

Before 1993, IP addresses were divided into five


categories:

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Special IP Addresses

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Points to Note
• Every datagram contains the IP address of the
destination host, where the network part uniquely
identifies a single physical network
• All nodes that share the same network part are
connected to the same physical network
• An IP address refers to a network interface, rather
than a host
• If a host is on two networks, it must have two IP
addresses
• In practice, most hosts are on one network, thus
one IP address
• Routers have multiple interfaces and thus multiple
IP addresses.
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Forwarding at Host

• If (NetNum of Dest = my NetNum) then


• Deliver packet to destination directly
• use ARP to get MAC address corresponding to the
destination IP address
• Else
• Deliver packet to the default router
• Use ARP to get MAC address corresponding to the
router IP address

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Forwarding at Router

• If (NetNum of Dest = NetNum of one of my interfaces)


then
• Deliver packet to destination over that interface
• Else if (NetNum of Dest is in my forwarding table) then
• Deliver packet to NextHop router
• Else
• Deliver packet to default router

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Example

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Review - 4
• Look at IP packet format
• Fragmentation and reassembly
• IP addresses (classful addressing):
• Hierarchical addressing to address scalability
• IP address has a network and a host part
• Significantly reduces entries in the forwarding table
• Looked at how forwarding is done at host and router
• Next: How IP addresses are assigned now?

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Issues of Classful Addressing

• Motivating example:
• Network with just 2 hosts needs a Class C address;
efficiency is 2/2^8 = 0.7%
• Network with 260 hosts needs a Class B address;
efficiency is 260/2^16 = 0.4%
• Class B addresses in high demand
• Class B networks: ~ 16000 (2^14)
• Out of class B addresses
• Out of addresses to hand out (2^32 ~ 4 billion in
total)
• Problem: how to address the “address assignment
inefficiency” issue?
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Scenario 1

• An organization has 30 different physical networks,


each network has about 2000 hosts.
• Classful addressing: allocate 30 class B addresses
• Efficiency = 2000/2^16 = 3%
• Can we just use one class B address to support all 30
networks?
• 2^16 = 65536 > 30*2000
• Solution: subnetting

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Subnetting (1)
• Introduce another level of hierarchy
• Divide host part into subnet id and host id
Network Number Host Number

Network Number Subnet ID Host ID

• Previous example: divide 16 host bits into 5 subnet


bits (32 physical networks) and 11 host bits (2048
hosts)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Subnetting (2)
• Address format of subnet number (prefix): a.b.c.d/x,
where x is number of bits in the network portion of the
address

• The bit-wise AND of the IP address and the subnet


mask give the subnet number of the host
• All hosts on a given physical network have the same
prefix and subnet mask
• Example: IP address 190.23.12.17 with subnet mask
255.255.248.0 has a prefix of 190.23.8.0/21
Subnetting (3)
• Class B address: 190.23.0.0/16;
10111110.00010111.*.*

Subnet ID Prefix Hosts


00000 190.23.0.0 190.23.0.1 – 190.23.7.254
32
00001 192.23.8.0 190.23.8.1 – 190.23.15.254
subnets
... … …
11111 190.23.248.0 190.23.248.1 – 190.23.255.254

• All routers outside organization have one entry


(190.23.0.0/16)
• Routers within organization have more detailed entries
corresponding to different subnets.
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Subnetting (4) – Forwarding at Router
• D = Destination IP address
• For each forwarding table entry
• T = D & SubnetMask
• If T == prefix
− If Nexthop is an interface
» Deliver the datagram directly to the destination
− Else
» Deliver datagram to the Nexthop (router)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Subnetting (5) - Example

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Longest Matching Prefix
• Routers do a prefix match
• There may be many matching prefixes
• Packets are forwarded to the entry with the longest
matching prefix or smallest address block
− Complicates forwarding but adds flexibility

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Scenario 2
• An organization has a physical network with 4000 hosts.
• Classful addressing: give a class B address
• Efficiency = 4000/2^16 = 6%
• Can we assign multiple class C addresses?
• Lead to 16 entries for the same organization in the
forwarding table
• Solution: supernetting

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Supernetting

• Multiple class addresses shared among one physical


network
• Previous example: assign multiple contiguous class C
addresses & aggregate
• 222.7.16.* through 222.7.31.*, top 20 bits in this range
are the same (0001 bits, 20-bit prefix)
• Advertise 222.7.16/20 as the organization’s prefix

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Classless Interdomain Routing (CIDR)

• Address block represented as A/X, where A is the


address prefix and X is the prefix length
• X can range from 2 till 32
• X is represented as a network mask as well
NAT (1)
• NAT (Network Address Translation) is another solution
to IPv4 address exhaustion
• Example: an organization with 4000 hosts. Assign
multiple class C addresses (4000 IP addresses)
• How about managing with just a single IP address?

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
NAT (2)
• Key idea:
• Assign each organization with a single IP address.
• Within the organization, each host gets a unique IP
address from the private address space.
• Connect to Internet via a NAT router, which
translates the unique internal IP address to the
shared external IP address.
• Private address space:
• Class A: 10.0.0.0 ~ 10.255.255.255/8
• Class B: 172.16.0.0 ~ 172.31.255.255/12
• Class C: 192.168.0.0 ~ 192.168.255.255/16
• Anyone can use the private address space, but
address is not routable in the global Internet
NAT (3)
• Uses TCP/UDP port to tell connections apart
• Violates layering; very common in homes, etc.

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Review - 5
• Classful addressing was found not efficient or scalable
enough
• Subnetting: share a single class address among
multiple networks
• Supernetting: share multiple class addresses on a
single network
• Lead to CIDR (classless addressing) and longest prefix
match
• Widely used now
• NAT: assign one IP address for an organization
• another solution to IPv4 address exhaustion
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Internet Control Protocols

IP works with the help of several control protocols:


• ARP finds Ethernet address of a local IP address
− Glue that is needed to send any IP packets
− Host queries an address and the owner replies
• DHCP assigns a local IP address to a host
− Gets host started by automatically configuring it
− Host sends request to server, which grants a lease

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
ARP (1)
• ARP: Address Resolution Protocol
• Operates at the link layer
• Based on broadcast: what is the MAC address
corresponding to the given IP address?
• Host with matching IP address replies
• Each host maintains a cache with IP to MAC translations
• Entries in cache times out periodically (15 min)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
ARP (2)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
DHCP
• DHCP: Dynamic Host Configuration Protocol
• Based on broadcast

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Review - 6
• Studied two useful protocols: ARP and DHCP
• ARP is needed for forwarding
• Performs IP to MAC address translation
• DHCP allows automatic assignment of IP address

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Summary
Three different kinds of addresses
• Host names (e.g., www.cnn.com)
• IP addresses (e.g., 64.236.16.20)
• MAC addresses (e.g., 00:15:C5:49:04:A9)
Protocols for translating between addresses
• Domain Name System (DNS)
• Dynamic Host Configuration Protocol (DHCP)
• Address Resolution Protocol (ARP)
Three Kinds of Identifiers
Host name (e.g., www.cnn.com)
• Mnemonic name appreciated by humans
• Provides little (if any) information about location
• Hierarchical, variable # of alpha-numeric characters
IP address (e.g., 64.236.16.20)
• Numerical address appreciated by routers
• Related to host’s current location in the topology
• Hierarchical name space of 32 bits
MAC address (e.g., 00:15:C5:49:04:A9)
• Numerical address appreciated within local area
network
• Unique, hard-coded in the adapter when it is built
• Flat name space of 48 bits
Names vs IP Address vs MAC Address
• Separating names (www.cnn.com) and IP address
(64.236.16.20)
• Names are easier for us to remember
• IP address can change underneath
• Name can map to multiple IP addresses
• Separating IP and MAC addresses
• Different LANs may have different addressing
schemes
• A host may move to a new location, so cannot simply
assign a static IP address

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Mapping Between Identifiers
Domain Name System (DNS)
• Given a host name, provide the IP address
• Given an IP address, provide the host name
Dynamic Host Configuration Protocol (DHCP)
• Given a MAC address, assign a unique IP address
• To automate the boot-strapping process
Address Resolution Protocol (ARP)
• Given an IP address, provide the MAC address
• To enable communication within the Local Area
Network

You might also like