The network layer is responsible for transporting data segments from source to destination hosts. It encapsulates segments into datagrams and delivers them to the transport layer. Network layer protocols run on every host and router. Routers examine header fields to forward datagrams appropriately based on destination addresses. The network layer handles addressing, routing, and intermediate forwarding of datagrams between source and destination hosts.
2. Network Layer
transport segment from sending
to receiving host
on sending side encapsulates
segments into datagrams
on receiving side, delivers
segments to transport layer
network layer protocols in every
host, router
router examines header fields in
all IP datagrams passing through
it
application
transport
network
data link
physical
application
transport
network
data link
physical
network
data link
physical network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physicalnetwork
data link
physical
Connection-Less approach (e.g. IP)
considered here.
Intermediate routers forward
datagrams appropriately based on
their respective destination addresses
3. Network Layer
o Highly complex layer as it requires the coordinated action
of a number of geographically distributed network
elements (i.e. routers) along with the end-systems
o The approach followed must be scalable as it may have to
deal with very large systems (millions of end systems and
routers as in today’s Internet)
o Must tackle two issues –
• Addressing – where is the destination of the information
that has to be sent?
• Routing – what path should be followed to reach the
destination?
4. Physical
layer
Data link
layer
Physical
layer
Data link
layer
End-system
A
Network
layer
Network
layer
Physical
layer
Data link
layer
Network
layer
Physical
layer
Data link
layer
Network
layer
Transport
layer
Transport
layer
Messages Messages
Segments
Network
service
Network
service
Service Provided by Network Layer
Network layer can offer a variety of services to transport layer
Connection-oriented service or connectionless service
Best-effort or delay/loss guarantees
End-system
B
5. Functions of the Network-Layer
Forwarding: move packets from router’s input to appropriate
router output
(Which output interface of a particular router should be used to
forward a particular packet?)
Routing: determine the route to be taken by packets from
source to destination.
(Which sequence of routers should a packet go through as the best
possible path from source to destination?)
Priority considerations and Quality of Service (QoS) guarantees
may also be an issue for the Network Layer.
However, common network layer protocol (IP: Internet Protocol) in
use today does not adequately address these issues.
6. Functional View of the IP Network Layer
forwarding
table
Routing protocols
•path selection
•RIP, OSPF, BGP
IP protocol
•addressing conventions
•datagram format
•packet handling conventions
ICMP protocol
•error reporting
•router “signaling”
Transport layer: TCP, UDP
Link layer
physical layer
Network
layer
7. Routing in the Internet
How to get IP datagram from the source to the destination?
Decentralized nature of Internet makes routing a major
challenge
Interior gateway protocols (IGPs) are used to determine
routes within a domain
Exterior gateway protocols (EGPs) are used to determine
routes across domains
Routes must be consistent & produce stable flows
However, routes should change as nodes and links go down or
new ones appear
Scalability required to accommodate growth
Hierarchical structure of IP addresses essential to keeping
size of routing tables manageable
8. Routing in the Internet
How to get IP datagram from the source to the destination?
Routers build and keep updated Forwarding Tables for routing
For every datagram received, router looks up the forwarding table
based on the destination IP address of the datagram to decide which of
its (multiple) interfaces should be used to forward the datagram.
(Router must have multiple interfaces.)
Forwarding Table has specific routes for some IP addresses for which
routes have been established. (To keep the size of the forwarding table
manageable, groups of IP addresses along the same route which have
common leading bits, may share the same entry in the forwarding table.
Routes are also timed out if unused for sufficient time.)
For other addresses, datagram is forwarded to a default interface
A “route” in a network (e.g. Internet) is established by ensuring that proper
entries are made in the Forwarding Table of each intermediate router in the
path between the source and the destination.
9. Datagram Routing Options
Hop-by-Hop Routing: Each intermediate node makes its own decision
Proper forwarding tables needed
Source Routing: Source computes the path and adds this information to
the datagram for intermediate nodes to follow
Forwarding tables not really needed
1
2
3
4
5
6
A
B
Source Host
Destination Host
1,3,6,B
3,6,B 6,B
B
IP supports both but Hop-by-Hop Routing is what is typically used
10. Routing in the Internet
Routing Algorithms
Link State Algorithm
e.g. Dijkstra’s Algorithm
Distance Vector
Algorithm
e.g. Bellman-Ford Algorithm
Hierarchical Routing
Hierarchical Network
11. Some Graph Theory Notation
u
yx
wv
z
2
2
1
3
1
1
2
5
3
5Graph G(N, E) is a set of N nodes with
E edges, where each edge is a pair of
nodes from N
N = {u, v, w, x, y, z}
E = {(u,x),(u,v),(v,w),(x,w),(x,y), (y,w),
(w,z), (y,z), (u,w)}
Cxy = cost of the edge (x,y)
Cxy= ∞ if no edge (x,y) in E
Neighbour: Node x is a neighbour of
node y if (x,y) is in E, i.e x and y are
directly connected by an edge
Path: Path
between nodes x1 and xp is a sequence
of nodes such that each successive
node pairs are connected by edges in E
•Nodes are routers or end systems
•Edges are the links in the network
• Cost of an edge is the cost of
using that link on a path
)......,,,......,,( 21 pji xxxxx
Cost of Path is additive sum of the
cost of its individual edges
Least Cost Path (or Shortest Path) is the path with the lowest cost
12. Dijkstra’s Algorithm
N : set of nodes for which shortest path already found (interpret
costs as distances)
Initialization: (Start with source node s)
N = {s}, Ds = 0, “s is distance zero from itself”
Dj=Csj for all j s, distances of directly-connected neighbors
Step A: (Find next closest node i)
Find i N such that
Di = min Dj for j N
Add i to N
If N contains all the nodes, stop
Step B: (update minimum costs)
For each node j N
Dj = min (Dj, Di+Cij)
Go to Step A
Minimum distance from s to j
through node i in N
Loop until shortest path
found from (to ) s to (from)
all other nodes in N
16. Shortest Paths and Forwarding Tables
(Dijkstra’s Algorithm)
• Similar approach needed for each node to find the shortest (least cost)
path from that node to every other node in the network
• Information on the available links and their costs must be globally
available at every node for decentralized routing algorithm to be
implemented (i.e. each node computes the shortest path from itself to
every other node based on this information. The algorithm can also be run
centrally and the results distributed to each node.
Based on the shortest paths computed,
each node must then build a Forwarding
Table to handle the datagrams that it
needs to forward. For each destination
address, the forwarding table specifies
the link (i.e. router interface) on which
a datagram for that destination must be
forwarded.
Forwarding Table at Node 1
Destination Next Link
2 (1,2)
3 (1,3)
4 (1,3)
5 (1,3)
6 (1,3)
Forwarding will be done properly if all nodes keep proper forwarding tables
17. Distance Vector Algorithm
Bellman-Ford Equation
Define dx(y) := cost of least-cost path from x to y
Then dx(y) = min {Cxv+ dv(y) } where min is taken over all
neighbors v of xv
u
yx
wv
z
2
2
1
3
1
1
2
5
3
5
dv(z) = 5, dx(z) = 3, dw(z) = 3
From the B-F equation, we get -
du(z) = min { c(u,v) + dv(z), c(u,x) + dx(z),
c(u,w) + dw(z) }
= min {2 + 5, 1 + 3, 5 + 3}
= 4
Node that achieves minimum will be the next
hop in shortest path to the destination. This
will be entered in the Forwarding Table for
that destination.
18. Distance Vector Algorithm
Dx(y) = estimate of least cost from x to y
Node x knows cost to each neighbour v: Cxv
Node x maintains distance vector Dx = [Dx(y): y є N ]
Node x also maintains its neighbours’ distance vectors
For each neighbor v, x maintains Dv = [Dv(y): y є N ]
Basic idea:
From time-to-time, each node sends its own distance vector
estimate to neighbours, may be done asynchronously
When a node x receives new DV estimate from neighbour, it
updates its own DV using B-F equation:
Dx(y) ← minv{Cxv+ Dv(y)} for each node y ∊ N
Typically, Dx(y) will eventually converge to the actual least cost dx(y)
19. Distance Vector Algorithm
Iterative, asynchronous: each
local iteration caused by:
local link cost change
DV update message from
neighbor
Distributed:
each node notifies
neighbors only when its DV
changes
neighbors then notify
their neighbors if
necessary
wait for (change in local link
cost or msg from neighbor)
recompute estimates
if DV to any dest has changed,
notify neighbors
Actions taken at each node:
20. Network Layer 4-20
Distance Vector Algorithm
1. Initialization
(Destination d is distance 0 from itself)
Di =∞ for all i≠d
Dd = 0
2. Updating
For each i≠d,
3. Repeat Step 2 until no more changes
jij
j
i DCD min
23. x y z
x
y
z
0 2 7
∞ ∞ ∞
∞ ∞ ∞
from
cost to
fromfrom
x y z
x
y
z
0
from
cost to
x y z
x
y
z
∞ ∞
∞ ∞ ∞
cost to
x y z
x
y
z
∞ ∞ ∞
7 1 0
cost to
∞
2 0 1
∞ ∞ ∞
2 0 1
7 1 0
time
x z
12
7
y
node x table
node y table
node z table
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2
Dx(z) = min{c(x,y) +
Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
32
24. x y z
x
y
z
0 2 7
∞ ∞ ∞
∞ ∞ ∞
from
cost to
fromfrom
x y z
x
y
z
0 2 3
from
cost to
x y z
x
y
z
0 2 3
from
cost to
x y z
x
y
z
∞ ∞
∞ ∞ ∞
cost to
x y z
x
y
z
0 2 7
from
cost to
x y z
x
y
z
0 2 3
from
cost to
x y z
x
y
z
0 2 3
from
cost to
x y z
x
y
z
0 2 7
from
cost to
x y z
x
y
z
∞ ∞ ∞
7 1 0
cost to
∞
2 0 1
∞ ∞ ∞
2 0 1
7 1 0
2 0 1
7 1 0
2 0 1
3 1 0
2 0 1
3 1 0
2 0 1
3 1 0
2 0 1
3 1 0
time
x z
12
7
y
node x table
node y table
node z table
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2
Dx(z) = min{c(x,y) +
Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
25. Distance Vector: link cost changes
Link cost changes:
node detects local link cost change
updates routing info, recalculates
distance vector
if DV changes, notify neighbors
“good
news
travels
fast”
x z
14
50
y
1
At time t0, y detects the link-cost change, updates its DV,
and informs its neighbors.
At time t1, z receives the update from y and updates its table.
It computes a new least cost to x and sends its neighbors its DV.
At time t2, y receives z’s update and updates its distance table.
y’s least costs do not change and hence y does not send any
message to z.
26. Link cost changes:
good news travels fast
bad news travels slowly - “count to infinity” problem!
large number of iterations before algorithm
stabilizes
x z
14
50
y
60
Distance Vector: link cost changes
The “Count to Infinity” problem may be tackled by –
Split Horizon: If X thinks that its best route to Y is via Z then X does
not send the cost it has to Y when it updates Z, i.e. no update for Z sent
to Y
Split Horizon with Poisoned Reverse: If X thinks that its best route to
Y is via Z, then X advertises its cost to Z as ∞ when it sends its minimum
cost update to Y. (X here does send updates to all its neighbours.)
This effectively sets the minimum cost to a destination as ∞ if the
neighbour happens to be the next node along the shortest path to that
destination.
27. Reaction to Failure (DV Algorithm)
If a link fails,
Router sets link distance to infinity & floods the network
with an update packet
All routers immediately update their link database &
recalculate their shortest paths
Recovery is generally quick
However, old update messages must be ignored
Add time stamp or sequence # to each update message
Check whether each received update message is new
If new, add it to database and broadcast
If older, send update message on arriving link
28. Comparison of LS and DV algorithms
Message complexity
LS: with n nodes, E links,
O(nE) msgs sent
DV: exchange between
neighbors only
convergence time varies
Speed of Convergence
LS: O(n2) algorithm requires
O(nE) msgs
may have oscillations
DV: convergence time varies
may be routing loops
count-to-infinity problem
Robustness: what happens
if router malfunctions?
LS:
node can advertise
incorrect link cost
each node computes only
its own table
DV:
DV node can advertise
incorrect path cost
each node’s table used by
others
• error propagate thru
network
29. Hierarchical Routing
Aggregate routers into regions, “autonomous systems” (AS)
Routers in same AS run same routing protocol
“intra-AS” routing protocol
routers in different AS can run different intra-AS
routing protocol
Gateway
Router
Provides direct
link to router in
another AS
3b
1d
3a
1c
2a
AS3
AS1
AS2
1a
2c
2b
1b
3c
Interior Gateway Protocol (IGP): routing within AS (RIP, OSPF)
Exterior Gateway Protocol (EGP): routing between AS’s (BGP)
Border Gateways perform both IGP & EGP routing
31. 3b
1d
3a
1c
2a
AS3
AS1
AS2
1a
2c
2b
1b
3c
Inter-AS tasks
Suppose router in AS1 receives
a datagram destined outside of
AS1:
Router should forward
packet to gateway router,
but which one?
AS1 must do the following:
1. Learn which destinations are
reachable through AS2, and
which through AS3
2. Propagate this reachability
information to all routers in
AS1
Job of inter-AS routing!
32. Example: Setting Forwarding Table in Router 1d
Suppose AS1 learns (via inter-AS protocol) that subnet x
reachable via AS3 (gateway 1c) but not via AS2.
Inter-AS protocol propagates reachability information to all
internal routers.
Router 1d determines from intra-AS routing info that its interface
I is on the least cost path to 1c.
Router 1d then installs forwarding table entry (x,I)
3b
1d
3a
1c
2a
AS3
AS1
AS2
1a
2c
2b
1b
3c
x
33. Example: Choosing between Multiple ASes
Suppose AS1 learns from inter-AS protocol that subnet x is
reachable both from AS3 and from AS2.
To configure its Forwarding Table, Router 1d must determine
towards which gateway it should forward packets for
destination x.
This is also job of inter-AS routing protocol!
3b
1d
3a
1c
2a
AS3
AS1
AS2
1a
2c
2b
1b
3c
x
34. Learn from inter-AS
protocol that subnet
x is reachable via
multiple gateways
Use routing info
from intra-AS
protocol to determine
costs of least-cost
paths to each
of the gateways
Hot potato routing:
Choose the gateway
that has the
smallest least cost
Determine from
forwarding table the
interface I that leads
to least-cost gateway.
Enter (x,I) in
forwarding table
Example: Choosing between Multiple ASes
Hot Potato Routing:
Send packet towards closest of two routers.
This approach is useful because while Inter-AS protocol may distribute
reachability information to all nodes, it typically would not give the cost of
traversing the path inside an AS other than one’s own
35. RIP ( Routing Information Protocol)
Distance Vector algorithm using distance metric as “no. of hops”
(Limited to maximum of 15 hops)
Old protocol (in use since 1982) mostly superseded by OSPF
DC
BA
u v
w
x
y
z
Destination Hops
u 1
v 2
w 2
x 3
y 3
z 2
From Router A to subnets:
RIP advertisements
distance vectors: exchanged among neighbors every 30 sec via
Response Message (also called advertisement)
each advertisement may list of up to 25 destination subnets within AS
36. RIP (Example)
Destination Network Next Router Num. of hops to Dest.
w A 2
y B 2
z B 7
x -- 1
…. …. ....
w x y
z
A
C
D B
Routing/Forwarding Table in D
Note that D can reach network z through Router B in 7 hops. See next slide for what
would happen if some other router advertised a shorter route to network z.
37. RIP (Example)
w x y
z
A
C
D B
Dest Next hops
w - 1
x - 1
z C 4
…. … ...
Advertisement
from A to D
Destination Network Next Router Num. of hops to Dest.
w A 2
y B 2
z B A 7 5
x -- 1
…. …. ....
Routing/Forwarding Table in D
38. Link Failure and Recovery in RIP
If no advertisement heard for 180 sec, then neighbor/link is
declared dead. In that case, the following are done –
Routes via neighbor invalidated
New advertisements sent to neighbors
Neighbors in turn send out new advertisements (if tables changed)
Link failure information propagates to entire net
Poison Reverse used to prevent ping-pong loops (infinite distance is
set to be 16 hops)
RIP routing tables managed by application-level process called
route-d (daemon). Advertisements are sent in UDP packets, which
are periodically repeated
39. OSPF (Open Shortest Path First)
Uses Link State (Dijkstra’s) algorithm
Link State packets disseminated to create a topology map
OSPF advertisement carries one entry per neighbor router
Advertisements disseminated to entire AS (via flooding) directly over
IP (rather than over UDP or TCP)
Security: all OSPF messages authenticated (prevent hacking of router)
Multiple same-cost paths allowed (only one path in RIP)
For each link, different cost metrics for different services (e.g.,
satellite link cost set “low” for best effort; high for real time)
Different routes to a given destination possible for different types of
service
Integrated unicast and multicast support:
Hierarchical OSPF implementation for large domains.
“Flooding”: Router forwards copies of an incoming packet to all
ports (interfaces) except the one from where the packet came in
41. Hierarchical Implementation of OSPF
Two-level hierarchy: local area, backbone.
Link-state advertisements only in area
each node has detailed area topology of its own area; only
knows direction (shortest path) to nets in other areas.
Area border routers: “summarize” distances to nets in own
area, advertise to other Area Border routers.
Backbone routers: run OSPF routing limited to backbone.
Boundary routers: connect to other AS’s.
Autonomous System Boundary router: has links to another
autonomous system
42. Border Gateway Protocol (BGP)
Standard for inter-AS routing in Internet
BGP provides each AS a means to:
1. Obtain subnet reachability information from neighboring ASs.
2. Propagate reachability information to all AS-internal routers.
3. Determine “good” routes to subnets based on reachability
information and policy.
Allows subnet to advertise its presence to rest of Internet
Pairs of routers (BGP peers) exchange routing information
over semi-permanent TCP connections to establish BGP
sessions.
(BGP sessions need not correspond to physical links.)
When AS2 advertises a prefix to AS1:
1. AS2 promises it will forward datagrams towards that prefix.
2. AS2 can aggregate prefixes in its advertisement
Usage of CIDR Prefixes to “summarize” networks covered later
43. Distributing Reachability Information (BGP)
Using eBGP session between 3a and 1c, AS3 sends prefix
reachability info to AS1.
1c can then use iBGP to distribute new prefix info to all routers
in AS1
1b can then re-advertise new reachability info to AS2 over 1b-
to-2a eBGP session
When router learns of new prefix, it creates entry for that
prefix in its forwarding table.
3b
1d
3a
1c
2a
AS3
AS1
AS2
1a
2c
2b
1b
3c
eBGP session
iBGP session
44. Path attributes & BGP routes
Advertised prefix includes BGP attributes; prefix + attributes = “route”
Two important attributes:
AS-PATH: contains ASs through which prefix advertisement has
passed: e.g, AS 67, AS 17
NEXT-HOP: indicates specific internal-AS router to next-hop AS.
(may be multiple links from current AS to next-hop-AS)
When gateway router receives route advertisement, it uses its import
policy to accept/decline.
Router may learn about more than one route to some prefix. In that case,
the router must select one of the routes using elimination rules –
Local preference value attribute (based on some policy decision)
Shortest AS-PATH
Closest NEXT-HOP router (i.e. Hot Potato Routing)
Additional criteria
45. BGP Messages
BGP messages exchanged using TCP (establishment of TCP
connection would be needed)
BGP messages:
OPEN: opens TCP connection to peer and authenticates
sender
UPDATE: advertises new path (or withdraws old)
KEEPALIVE keeps connection alive in the absence of
UPDATES; also ACKs OPEN request
NOTIFICATION: reports errors in previous message; also
used to close connection
46. Example: BGP Routing Policy
A,B,C are provider networks
X,W,Y are customers (of provider networks)
X is dual-homed: attached to two networks
X does not want to route from B via X to C
.. so X will not advertise to B a route to C
A
B
C
W
X
Y
legend:
customer
network:
provider
network
47. Example: BGP Routing Policy
A advertises path AW to B
B advertises path BAW to X
Should B advertise path BAW to C?
No way! B gets no “revenue” for routing CBAW since neither W nor
C are B’s customers
B wants to force C to route to w via A
B wants to route only to/from its customers!
A
B
C
W
X
Y
legend:
customer
network:
provider
network
48. Why use different Intra- and Inter-AS
routing ?
Policy:
Inter-AS: admin wants control over how its traffic routed, who
routes through its net.
Intra-AS: single admin, so no policy decisions needed
Scale:
hierarchical routing saves table size, reduced update traffic
Performance:
Intra-AS: can focus on performance
Inter-AS: policy may dominate over performance
49. HTTP SMTP RTP
TCP UDP
IP
Network
Interface 1
Network
Interface 3
Network
Interface 2
DNS
TCP/IP Protocol Suite
Best-effort
connectionless
packet transfer
Diverse network technologies
Reliable
stream
service
User
datagram
service
Distributed
applications
50. Internet Protocol (IP)
Internet’s Network Layer Protocol
Router
Internet
Layer
Network
Interface
Transport
Layer
Internet
Layer
Network
Interface
Transport
Layer
Internet
Layer
Network
Interface
Host A Host B
Net 5Net 1
Net 5Net 2 Net 5Net 3
Router
Internet
Layer
Network
Interface
Router
Internet
Layer
Network
Interface
Net 5Net 4
51. Internet Names & Addresses
Internet Names: Each host has a unique name typically in the
form host@domain (e.g. eecomp@ntu.edu.sg)
IP Address: Each host has globally unique logical 32 bit IP
address with two parts, netid & hostid
IP address associated with the network interface. For multi-homed
hosts (e.g. routers), each interface will have its own IP address
Routing decisions are made based on the netid part of the IP address
Dotted Decimal Notation: int1.int2.int3.int4 (intj = jth octet)
For example, 128.100.10.13
DNS resolves IP
name to IP address DNS: Domain Name Server/Service
52. Physical Addresses
LANs (and other networks) assign physical addresses to the
physical attachment to the network
The network uses its own address to transfer packets or
frames to the appropriate destination
IP address needs to be resolved to physical address at each
IP network interface
Example: Ethernet uses 48-bit addresses
Each Ethernet network interface card (NIC) has globally
unique Medium Access Control (MAC) or physical address
First 24 bits identify NIC manufacturer; second 24 bits
are serial number
00:90:27:96:68:07 12 hex numbers
Intel
RP and RARP (discussed later) to associate IP Addresses and MAC
(Ethernet) Addresses with each other. Note that network needs to
work with the IP Address but the network interface can only receive
frames based on their MAC Address.
53. IP Packet Header
Version IHL Type of Service Total Length
Identification Flags Fragment Offset
Time to Live Protocol Header Checksum
Source IP Address
Destination IP Address
Options Padding
0 4 8 16 19 24 31
Minimum 20 bytes
Up to 40 bytes in options fields
54. IP Packet Header
Version IHL Type of Service Total Length
Identification Flags Fragment Offset
Time to Live Protocol Header Checksum
Source IP Address
Destination IP Address
Options Padding
0 4 8 16 19 24 31
Version: current IP version is 4.
Internet header length (IHL): length of the header in 32-bit words.
Type of service (TOS): traditionally priority of packet at each router.
Differentiated Services redefines TOS field to include other services besides
best effort.
55. IP Packet Header
Version IHL Type of Service Total Length
Identification Flags Fragment Offset
Time to Live Protocol Header Checksum
Source IP Address
Destination IP Address
Options Padding
0 4 8 16 19 24 31
Total length: number of bytes of the IP packet including header and data,
maximum length is 65535 bytes.
Identification, Flags, and Fragment Offset: used for fragmentation and
reassembly (discussed later).
56. IP Packet Header
Version IHL Type of Service Total Length
Identification Flags Fragment Offset
Time to Live Protocol Header Checksum
Source IP Address
Destination IP Address
Options Padding
0 4 8 16 19 24 31
Time to live (TTL): number of hops packet is allowed to traverse in the
network..
• Each router along the path to the destination decrements this value by one.
• If the value reaches zero before the packet reaches the destination, the
router discards the packet and sends an error message back to the source.
57. IP Packet Header
Version IHL Type of Service Total Length
Identification Flags Fragment Offset
Time to Live Protocol Header Checksum
Source IP Address
Destination IP Address
Options Padding
0 4 8 16 19 24 31
Protocol: specifies upper-layer protocol that is to receive IP data at the
destination. Examples include TCP (protocol = 6), UDP (protocol = 17), and ICMP
(protocol = 1).
Header checksum: verifies the integrity of the IP header.
Source IP address and Destination IP address: contain the addresses of the
source and destination hosts.
58. IP Packet Header
Version IHL Type of Service Total Length
Identification Flags Fragment Offset
Time to Live Protocol Header Checksum
Source IP Address
Destination IP Address
Options Padding
0 4 8 16 19 24 31
Options: Variable length field, allows packet to request special features such
as security level, route to be taken by the packet, and timestamp at each
router. Detailed descriptions of these options can be found in [RFC 791].
Padding: This field is used to make the header a multiple of 32-bit words.
59. IP Header (Header Checksum Field)
The Internet Header checksum bL is calculated as follows:
Treating each 16-bit word as an integer, find
x = b0 + b1 + b2+ ...+ bL-1 modulo 216-1
The checksum is then given by:
bL = - x modulo 216-1
Thus, the headers must satisfy the following pattern:
0 = b0 + b1 + b2+ ...+ bL-1 + bL modulo 216-1
60. IP Header Processing (at each router)
1. Compute header checksum for correctness and
check that fields in header (e.g. version and total
length) contain valid values. Only correct IP
datagrams with valid values are forwarded to the
next hop
2. Consult routing table (forwarding table) to
determine next hop; forward to default interface if
no entry in table
3. Change fields that require updating (TTL, header
checksum)
61. Fragmentation & Reassembly of IP
Datagrams
Network links have MTU
(max.transfer size) - largest
possible link-level frame.
different link types may
have different MTUs
large IP datagram divided
(“fragmented”) by router
before forwarding to conform
to MTU of outgoing link
one datagram becomes
several datagrams
“reassembly” only at final
destination
IP header bits used to
identify, order related
fragments for reassembly
at the destination
fragmentation:
in: one large datagram
out: 3 smaller datagrams
reassembly
62. Fragmentation & Reassembly of IP
Datagrams
ID
=x
offset
=0
fragflag
=0
length
=4000
ID
=x
offset
=0
fragflag
=1
length
=1500
ID
=x
offset
=185
fragflag
=1
length
=1500
ID
=x
offset
=370
fragflag
=0
length
=1040
One large datagram becomes
several smaller datagrams
Example
4000 byte datagram
MTU = 1500 bytes
1480 bytes in
data field
offset =
1480/8 =185
To detect lost fragments, the destination IP sets a timer once the 1st
fragments arrives. If a timer expires before all fragments have been
received, received fragments will be discarded.
Offset in multiples of 8 bytes
63. IP Addressing
IP Address: 32-bit identifier
for host, router interface
(netid: hostid)
Interface: connection
between host/router and
physical link
Router will have multiple
interfaces
Host typically has only
one interface
IP addresses associated
with each interface
223.1.1.1
223.1.1.2
223.1.1.3
223.1.1.4 223.1.2.9
223.1.2.2
223.1.2.1
223.1.3.2223.1.3.1
223.1.3.27
223.1.1.1 = 11011111 00000001 00000001 00000001
223 1 11
• netid identifies the network
where the host is located
• hostid identifies the interface
in the “netid” network
64. Classful IP Addresses
0
1 0
netid
netid
hostid
hostid
7 bits 24 bits
14 bits 16 bits
Class A
Class B
126 networks with up
to 16 million hosts
16,382 networks with
up to 64,000 hosts
1.0.0.0 to
127.255.255.255
128.0.0.0 to
191.255.255.255
1 1 netid hostid
22 bits 8 bitsClass C
0
2 million networks with up to 254
hosts
192.0.0.0 to
223.255.255.255
Class D (111….) addresses used as multicast addresses
65. Classful IP Addresses
• (netid: hostid) hostid=“all 1’s” => broadcast to all hosts on network netid
• (netid: hostid) hostid=“all 0’s” => network itself
• 127.x.x.x => Loopback address (this host)
•(netid: hostid) “all 1’s” => broadcast to all hosts on local network
• IP addresses must be assigned by proper authority; cannot be arbitrarily
chosen
• However, some Private IP Addresses are available which can be used by
anyone provided the network ensures that these addresses never appear on
the actual Internet
Range 1, Class A 10.0.0.0 to 10.255.255.255
Range 2, Class B 172.16.0.0 to 172.31.255.255
Range 3, Class C 192.168.0.0 to 192.168.255.255
PrivateIP
Addresses
Network designer can use private IP addresses within his/her own network
(e.g. home or campus LAN) and then use a NAT (described later) to connect
this network to the Internet. (NAT will have a legal IP address)
Useful trick as IPv4 addresses are running short!
66. Classful IP Addresses
Inefficient use of address space
•Typically, one does not have enough hosts to use the whole range of
address space available in a given Class A, B or C address
•The unused address space is wasted as it cannot be made available to
others who need their own IP address
•Historically, early network adopters managed to get Class B or Class C
address.
•Later networks were not so lucky! They typically got a few Class C
addresses and are forced to use a NAT to interface their networks
and hosts to the Internet
More efficient use of a given classful netid can be done by using Subnetting,
described next
An even better way is to discard the concept of classes altogether and use
Classless Inter Domain Routing (CIDR)
Remember that the netid portion is actually useful because this is what is
used to forward an IP datagram from the source to the right network. The
hostid is useful only when it has reached the right destination network.
67. Subnets
IP address:
Subnet part (high
order bits)
Host part (low order
bits)
What’s a subnet ?
Device interfaces with
same subnet part of IP
address
Can physically reach
each other without
intervening router
223.1.1.1
223.1.1.2
223.1.1.3
223.1.1.4 223.1.2.9
223.1.2.2
223.1.2.1
223.1.3.2223.1.3.1
223.1.3.27
Network consisting of 3 subnets
subnet
68. Subnets
223.1.1.0/24
223.1.2.0/24
223.1.3.0/24
To determine the subnets,
detach each interface
from its host or router,
creating islands of isolated
networks. Each isolated
network is called a subnet.
Subnet mask: /24
Subnet mask indicates the network
portion (inclusive of subnet ID) of the
IP address, eg. 255.255.255.0
(11111111.11111111.11111111.000000000)
In short form, this may also be written
as x.x.x.x/24 indicating that in this
case the higher order 24 bits have
been used as the network address
69. Subnets
This has six subnets
(x.x.x.x/24).
Note that the router to
router link is a subnet by
itself
223.1.1.1
223.1.1.3
223.1.1.4
223.1.2.2223.1.2.1
223.1.2.6
223.1.3.2223.1.3.1
223.1.3.27
223.1.1.2
223.1.7.0
223.1.7.1
223.1.8.0223.1.8.1
223.1.9.1
223.1.9.2
70. Example : Subnet Addressing
R1
H1 H2
H3 H4
R2 H5
To the rest of
the Internet
150.100.0.0
150.100.12.0
150.100.13.0
150.100.15.0
71. Subnet Addressing Example
Consider a class C network address 198.45.78.0
There are 8 bits for host id
If we use 3 bits for subnets, the subnet mask will be
255.255.255.224 (the last 8 bits are 1110 0000)
How many subnets can we have?
• Note that all 0’s and all 1’s are not allowed.
• Hostid=“all 0’s” is the address of the network
• Hostid=“all 1’s” is for broadcast in that network
How many hosts can we have in each subnet?
What is the subnet address for the first subnet in the
network?
What is the address range for the first subnet? And
other subnets?
74. Subnet Scheme for Class C Addresses
Number of Bits
for Subnets
Subnet Mask
Number
Number of
Subnets
Number of
Hosts
2 255.255.255.192 2 62
3 255.255.225.224 6 30
4 255.255.255.240 14 14
5 255.255.255.248 30 6
6 255.255.255.252 62 2
75. Subnet Scheme for
Class B Addresses
Number of Bits for
Subnets
Subnet Mask
Number
Number of subnets Number of Hosts
2 255.255.192.0 2 16382
3 255.255.224.0 6 8190
4 255.255.240.0 14 4094
5 255.255.248.0 30 2046
6 255.255.252.0 62 1022
7 255.255.254.0 126 510
8 255.255.255.0 254 254
9 255.255.255.128 510 126
10 255.255.255.192 1022 62
11 255.255.255.224 2046 30
12 255.255.255.240 4094 14
13 255.255.255.248 8190 6
14 255.255.255.252 16382 2
2n-2, n=bits borrowed
2m-2, m=bits for hosts
76. IP addressing: CIDR
CIDR: Classless InterDomain Routing
Subnet portion of address of arbitrary length
Address format: a.b.c.d/x, where x is # bits in subnet
portion of address
Note that the IP Classes A, B and C are no longer
meaningful when this approach is followed
11001000 00010111 00010000 00000000
subnet
part
host
part
200.23.16.0/23
77. Classless Interdomain Routing (CIDR)
With CIDR, packets are routed according to the prefix
of the IP address without distinguishing different
address classes.
The CIDR routing table contain a 32-bit IP address and
a 32-bit mask.
CIDR enables a technique called “route summarization”
or “supernetting” to allow a single routing entry to
cover a block of classful addresses.
78. Example - Supernetting
A company is given 4 contiguous Class C addresses
205.100.0.0, 205.100.1.0, 205.100.2.0, 205.100.3.0
The company can use a prefix 205.100.0.0/22 to
supernet these 4 contiguous networks
1st octet 2nd octet 3rd octet 4th octet
205.100.0.0 1100 1101 0110 0100 0000 0000 0000 0000
205.100.1.0 1100 1101 0110 0100 0000 0001 0000 0000
205.100.2.0 1100 1101 0110 0100 0000 0010 0000 0000
205.100.3.0 1100 1101 0110 0100 0000 0011 0000 0000
To the outside world, this company will appear to have a single
network 205.100.0.0/22 (mask 255.255.252.0) which includes all IP
addresses from 205.100.0.0 to 205.100.3.255
79. Example – Route Summarization
An ISP connecting eight organization may aggregate the
organization’s IP addresses and advertise to the outside
world as a single network 200.23.16.0/21.
Organization 0: 200.23.16.0/24;
Organization 1: 200.23.17.0/24
Organization 2: 200.23.18.0/24;
Organization 3: 200.23.19.0/24
Organization 4: 200.23.20.0/24;
Organization 5: 200.23.21.0/24
Organization 6: 200.23.22.0/24;
Organization 7: 200.23.23.0/24
81. Example – Route Summarization
200.23.16.0/24
200.23.20.0/24
200.23.23.0/24
200.23.16.0/21
82. Longest Prefix Match
This principle states that routing tables should be sorted
from the longest mask to the shortest mask.
The destination IP address of a packet will then be matched
sequentially to the entries of a routing table starting from
the longest prefix.
For example, consider the IPv4 routing table with entries for
both 192.168.20.16/28 and 192.168.0.0/16.
When the address 192.168.20.19 needs to be looked up, both
entries in the routing table "match".
In this case, the longest prefix of the candidate routes is
192.168.20.16/28, since its subnet mask (/28) is higher than the
other entry's mask (/16), making the route more specific. The
next hop will therefore be chosen based on the routing table entry
for 192.168.20.16/28
84. Longest Prefix Match
Destination
Network
Next-Hop
Address
140.24.7.0/26 x.x.x.x
140.24.7.64/26 x.x.x.x
140.24.7.128/26 x.x.x.x
Destination
Network
Next-Hop
Address
140.24.7.192/26 S2
140.24.7.0/24 S1
Destination
Network
Next-Hop
Address
140.24.7.192/26 x.x.x.x
R1 Routing Table R2 Routing Table
R3 Routing Table
Suppose a packet with address
140.24.7.200 arrives at R2, the 1st
mask at R2 is applied; which gives
the networks as 140.24.7.192.
The packet is directed to S2 and
hence routed correctly to R3
85. How does a host get its IP Address?
Two common choices are –
hard-coded by system admin in a file
Windows: control-panel->network->configuration->tcp/ip-
>properties
UNIX: /etc/rc.config
DHCP (Dynamic Host Configuration Protocol) dynamically get
address from a DHCP server
“plug-and-play”
Hard coding IP address is cumbersome, especially when the PC is
something like a laptop which keeps moving from one network to another.
DHCP is more convenient and is the approach used commonly today. Here
the host gets its own IP address from the DHCP server of whichever
network it connects to.
86. DHCP: Dynamic Host Configuration Protocol
Goal: To allow host to dynamically obtain its IP address from
network server when it joins network
Can renew its lease on address in use
Allows reuse of addresses (only hold address while connected and
“on”)
Support for mobile users who want to join network
DHCP Overview:
Host broadcasts “DHCP Discover” message
DHCP server responds with “DHCP Offer” message
Host requests IP address: “DHCP Request” message
DHCP server sends address: “DHCP Ack” message
87. DHCP Client-Server Example
223.1.1.1
223.1.1.2
223.1.1.3
223.1.1.4 223.1.2.9
223.1.2.2
223.1.2.1
223.1.3.2223.1.3.1
223.1.3.27
A
B
E
DHCP
Server
Arriving DHCP
client needs
address in this
network
223.1.2.5
Since only a fraction of the hosts are ON at any given time in the
network, DHCP is also an efficient way of distributing as on demand, a
limited set of IP address to a much larger set of potential hosts.
89. DHCP Client-Server Example
DHCP Discover: Broadcast by new client as a UDP packet
targeted to port 67 of the DHCP server(s). Router set up to do
DHCP relay will forward this to all the subnets served by the
DHCP server(s)
There may be more than one DHCP server available in the
network
DHCP Offer: Broadcast by all receiving DHCP servers specifying
the IP address being offered to the new client and its lease time
DHCP Request: Broadcast by the new client accepting the DHCP
offer echoing offer details.
Choose one if there are multiple DHCP offers received
DHCP ACK: DHCP Server acks the DHCP request confirming it
Plug and Play (PnP) operation possible if client (e.g. a laptop) keeps
moving from one network to another. It will then automatically get
a new IP address for the new network which it joins.
90. Getting an IP Address
How does network get subnet part of IP addr?
The host gets allocated portion of its provider ISP’s address
space. See example given below
ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20
Organization 0 11001000 00010111 00010000 00000000 200.23.16.0/23
Organization 1 11001000 00010111 00010010 00000000 200.23.18.0/23
Organization 2 11001000 00010111 00010100 00000000 200.23.20.0/23
... ….. …. ….
Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23
91. Direct IP Routing - Intranetwork
Both machines (source and destination) are on the same network
sender encapsulates the datagram in a network frame
map the IP address into physical address using Address
Resolution Protocol (ARP)
network hardware then make delivery using the physical
address
Example: the machine with IP address 144.234.12.4 is to send a
datagram to the machine 144.234.12.8
144.234.12.4 144.234.12.8
Link
hdr
IP
hdr
dest IP = 144.234.12.8
dest ethernet address of 144.234.12.8
Ethernet: 144.234.12
92. Indirect IP Routing -- Internetwork
Destination is not on the same network as the source
encapsulates datagram in a network frame and sends it to a
gateway (router) which is on the same physical network as
the source
gateway will then forward the datagram to the next gateway
along the path to the destination
Routing Table is used by gateway to determine where to send
each datagram
typical routing table contains pairs (N,G)
• N is the IP address of the destination network
• G is the IP address of the next gateway along the path
to N
Default Gateway: if no route is specified for a destination
network, the routing routine sends the datagram to a default
gateway
Note: routing table in gateway only specifies one step along the path,
and it does not know the complete path to a destination
93. A Sample Routing Table
Destination
Network
Next Hop IP
Address
Flags Interface Info
127.0.0.1 127.0.0.1 H lo0
150.100.15.0 150.100.15.11 E01
150.100.60.0 150.100.12.4 S02
default 150.100.14.54 G Fa01
150.100.60.0
150.100.12.4R1
150.100.15.0
150.100.15.11
94. Indirect IP Routing -- Internetwork
Consider a site that has a Class B IP address of 150.100.0.0
(with 9 bits for subnet and 7 bits for host ID).
How does router R1 handle an arriving packet with
destination IP address of 150.100.15.11 from the outside
network?
R1
H1 H2
H3 H4
R2 H5
To the rest of
the Internet
150.100.12.176150.100.12.154
150.100.12.24 150.100.12.55
150.100.15.11
150.100.15.11
150.100.0.1 150.100.12.128
150.100.12.129
150.100.12.4
150.100.12.0
150.100.12.1
150.100.15.54
150.100.15.0
95. Extracting Subnet Address
First, R1 applies the subnet mask (255.255.255.128) to extract
the subnet address from the IP address – binary “AND”
operation.
The result is 150.100.15.0
10010110 01100100 00001111 00001011
11111111 11111111 11111111 10000000
Packet IP
Address
Subnet Mask
10010110 01100100 00001111 00000000Subnet Number
150.100.15.11
255.255.255.128
150.100.15.0
R1 then looks up this subnet number in its routing table
and forward the packet to R2, which is 150.100.12.1.
R2 performs the same process and forward the packet
finally to H5.
96. Indirect IP Routing (H5 sending to H2)
R1
H1 H2
H3 H4
R2 H5
To the rest of
the Internet
150.100.0.1
150.100.12.128
150.100.12.0
150.100.12.176150.100.12.154
150.100.12.24 150.100.12.55
150.100.12.1
150.100.15.54
150.100.15.0
150.100.15.11
150.100.12.129
150.100.12.4
Destination Next-Hop Flags Net I/F
127.0.0.1 127.0.0.1 H lo0
default 150.100.15.54 G emd0
150.100.15.0 150.100.15.11 emd0
Routing Table at H5
150.100.12.176
97. Indirect IP Routing (H5 sending to H2)
R1
H1 H2
H3 H4
R2 H5
To the rest of
the Internet
150.100.0.1
150.100.12.128
150.100.12.0
150.100.12.176150.100.12.154
150.100.12.24 150.100.12.55
150.100.12.1
150.100.15.54
150.100.15.0
150.100.15.11
150.100.12.129
150.100.12.4
Destination Next-Hop Flags Net I/F
127.0.0.1 127.0.0.1 H lo0
default 150.100.12.4 G emd0
150.100.15.0 150.100.15.54 emd1
150.100.12.0 150.100.12.1 emd0
Routing Table at R2
150.100.12.176
98. Indirect IP Routing (H5 sending to H2)
R1
H1 H2
H3 H4
R2 H5
To the rest of
the Internet
150.100.0.1
150.100.12.128
150.100.12.0
150.100.12.176150.100.12.154
150.100.12.24 150.100.12.55
150.100.12.1
150.100.15.54
150.100.15.0
150.100.15.11
150.100.12.129
150.100.12.4
Destination Next-Hop Flags Net I/F
127.0.0.1 127.0.0.1 H lo0
150.100.12.176 150.100.12.176 emd0
150.100.12.0 150.100.12.4 emd1
150.100.15.0 150.100.12.1 G emd1
Routing Table at R1
150.100.12.176
99. Route Aggregation
(Hierarchical Addressing in an IP Nework)
“Send me anything
with addresses
beginning
200.23.16.0/20”
200.23.16.0/23
200.23.18.0/23
200.23.30.0/23
Fly-By-Night-ISP
Organization 0
Organization 7
Internet
Organization 1
ISPs-R-Us
“Send me anything
with addresses
beginning
199.31.0.0/16”
200.23.20.0/23
Organization 2
.
.
.
.
.
.
Hierarchical addressing allows efficient advertisement of routing
Information. This is important as it helps in reducing the size of
forwarding tables( i.e. routing tables) in the routers.
100. Longest Prefix Match First
ISPs-R-Us has a more specific route to Organization 1
“Send me anything
with addresses
beginning
200.23.16.0/20”
200.23.16.0/23
200.23.18.0/23
200.23.30.0/23
Fly-By-Night-ISP
Organization 0
Organization 7
Internet
Organization 1
ISPs-R-Us
“Send me anything
with addresses
beginning 199.31.0.0/16
or 200.23.18.0/23”
200.23.20.0/23
Organization 2
.
.
.
.
.
.
Route Aggregation
(Hierarchical Addressing in an IP Nework)
101. International IP Address Allocation
Authority
How does an ISP get blocks of addresses (to distribute to its
customers)?
It gets these from ICANN (Internet Corporation for Assigned
Names and Numbers)
ICANN handles the following –
Allocates addresses
Manages DNS
Assigns domain names
Resolves disputes
102. NAT: Network Address Translation
10.0.0.1
10.0.0.2
10.0.0.3
10.0.0.4
138.76.29.7
local network
(e.g., home network)
10.0.0/24
rest of
Internet
Datagrams with source or
destination in this network have
10.0.0/24 address for source,
destination (as usual)
All datagrams leaving local
network have same single
source NAT IP address:
138.76.29.7, different source
port numbers
103. Motivation for using NAT:
Local network uses just one IP address as far as outside world is concerned:
Range of addresses not needed from ISP. Just one IP address for all
devices would be sufficient
Can change addresses of devices in local network without notifying
outside world
Can change ISP without changing addresses of devices in local network
Devices inside local net not explicitly addressable from outside or
visible by outside world. (Good for network security – i.e. what the
hacker cannot see cannot be attacked!)
NAT: Network Address Translation
104. The NAT Router must do the following for NAT to work -
In outgoing datagrams it replaces (source IP address, port #)
of every outgoing datagram to (NAT IP address, new port #)
Note that remote clients/servers will respond using (NAT IP
address, new port #) as destination addr.
It must remember in its NAT translation table every (source IP
address, port #) to (NAT IP address, new port #) translation
pair
In incoming datagrams, it must replace (NAT IP address, new
port #) in dest fields of every incoming datagram with
corresponding (source IP address, port #) stored in NAT table
NAT: Network Address Translation
105. NAT (Network Address Translation)
Example
10.0.0.1
10.0.0.2
10.0.0.3
S: 10.0.0.1, 3345
D: 128.119.40.186, 80
1
10.0.0.4
138.76.29.7
1: host 10.0.0.1
sends datagram to
128.119.40.186, 80
NAT translation table
WAN side addr LAN side addr
138.76.29.7, 5001 10.0.0.1, 3345
…… ……
S: 128.119.40.186, 80
D: 10.0.0.1, 3345 4
S: 138.76.29.7, 5001
D: 128.119.40.186, 802
2: NAT router
changes datagram
source addr from
10.0.0.1, 3345 to
138.76.29.7, 5001,
updates table
S: 128.119.40.186, 80
D: 138.76.29.7, 5001 3
3: Reply arrives
dest. address:
138.76.29.7, 5001
4: NAT router
changes datagram
dest addr from
138.76.29.7, 5001 to 10.0.0.1, 3345
106. 16-bit port-number field:
60,000 simultaneous connections can be handled with
just one LAN-side address!
NAT is also somewhat controversial because of the following
It breaks the rule that routers should only process up to
layer 3
It violates end-to-end argument
• NAT possibility must be taken into account by app
designers, eg, P2P applications
NAT is a somewhat “bandaid” like solution. A better
solution to the address shortage would be to use IPv6
NAT: Network Address Translation
107. NAT Traversal Problem
Client wants to connect to server
with address 10.0.0.1
server address 10.0.0.1 local to
LAN (client can’t use it as
destination address)
only one externally visible
NATted address: 138.76.29.7
Solution 1: Statically configure
NAT to forward incoming
connection requests at given port
to server
e.g., (123.76.29.7, port 2500)
always forwarded to 10.0.0.1 port
25000
10.0.0.1
10.0.0.4
NAT
router
138.76.29.7
Client
?
108. Solution 2: Universal Plug and Play (UPnP)
Internet Gateway Device (IGD) Protocol.
Allows NATted host to:
learn public IP address (138.76.29.7)
add/remove port mappings (with lease
times)
i.e., automate static NAT port map
configuration
10.0.0.1
10.0.0.4
NAT
router
138.76.29.7
IGD
NAT Traversal Problem
109. Solution 3: relaying (used in Skype)
NATed client establishes connection to relay
External client connects to relay
relay bridges packets between to connections
138.76.29.7
Client
10.0.0.1
NAT
router
1. connection to
relay initiated
by NATted host
2. connection to
relay initiated
by client
3. relaying
established
NAT Traversal Problem
110. IPv6
Initial motivation: 32-bit address space of IPv4 close to exhaustion!
Additional motivation:
Header format helps speed processing/forwarding
Header changes to facilitate QoS
IPv6 datagram format:
Fixed-length 40 byte header
No fragmentation allowed
Priority: Identify priority among
datagrams in flow
Flow Label: Identify datagrams in
same “flow.”
Next Header: Identify upper layer
protocol for data
Checksum: Removed for faster
header processing
Options: Allowed but in Next Header
ICMPv6: New ICMP version
111. Transition from IPv4 to IPv6
(Using Tunnelling)
A B E F
IPv6 IPv6 IPv6 IPv6
tunnelLogical view:
Physical view:
A B E F
IPv6 IPv6 IPv6 IPv6
C D
IPv4 IPv4
Flow: X
Src: A
Dest: F
data
Flow: X
Src: A
Dest: F
data
Flow: X
Src: A
Dest: F
data
Src:B
Dest: E
Flow: X
Src: A
Dest: F
data
Src:B
Dest: E
A-to-B:
IPv6
E-to-F:
IPv6
B-to-C:
IPv6 inside
IPv4
B-to-C:
IPv6 inside
IPv4
112. Mobile IP
no mobility high mobility
mobile wireless user,
using same access
point
mobile user, passing
through multiple
access point while
maintaining ongoing
connections (like cell
phone)
mobile user,
connecting/
disconnecting
from network
using DHCP.
Typical Mobility Variations
113. Mobile IP (Terminology)
home network: permanent
“home” of mobile
(e.g., 128.119.40/24)
Permanent address:
address in home
network, can always be
used to reach mobile
e.g., 128.119.40.186
home agent: entity that will
perform mobility functions on
behalf of mobile, when mobile
is remote
wide area
network
correspondent
114. Mobile IP (Terminology)
Care-of-address: address
in visited network.
(e.g., 79.29.13.2)
wide area
network
visited network: network
in which mobile currently
resides (e.g., 79.129.13/24)
Permanent address: remains
constant (e.g., 128.119.40.186)
foreign agent: entity
in visited network
that performs
mobility functions on
behalf of mobile.
correspondent: wants
to communicate with
mobile
115. Mobile IP (Possible Approaches)
Let routing handle it: Routers advertise permanent
address of mobile-nodes-in-residence via usual
routing table exchange.
Routing tables indicate where each mobile located
No changes needed to end-systems
Let end-systems handle it:
Indirect Routing: Communication from
correspondent to mobile goes through home
agent, then forwarded to remote
Direct Routing: correspondent gets foreign
address of mobile, sends directly to mobile
Notpractically
feasiblewithmillions
ofmobilesastables
wouldbeimpossible
tomaintain
Feasiblein
practicalmobile
systems
116. Registering a Mobile outside its Home
Network
End result:
Foreign agent knows about mobile
Home agent knows location of mobile
wide area
network
home network
visited network
1
Mobile contacts
foreign agent on
entering visited
network
2
Foreign agent contacts home
agent home: “this mobile is
resident in my network”
117. Mobile IP (Indirect Routing)
wide area
network
home
network
visited
network
3
2
4
1
Correspondent
addresses packets
using home address
of mobile
Home agent intercepts
packets, forwards to
foreign agent
Foreign agent
receives packets,
forwards to mobile
Mobile replies
directly to
correspondent
118. Mobile IP (Indirect Routing)
Mobile uses two addresses:
Permanent Address: used by correspondent (hence
mobile location is transparent to correspondent)
Care-of-address: used by home agent to forward
datagrams to mobile
Foreign agent functions may be done by mobile itself
Triangle Routing: Between correspondent-home-network-
mobile. This is actually inefficient if correspondent and
mobile happen to be in the same network.
119. Mobile IP (Indirect Routing)
Handling what happens when mobile user moves to another
network -
Registers with new foreign agent
New foreign agent registers with home agent
Home agent updates care-of-address for mobile
Packets continue to be forwarded to mobile (but with
new care-of-address)
Note that even though mobility may force the mobile to change
from one foreign network to another, the on-going connections can
be maintained as the IP addresses do not change! This is important
as disconnecting a flow (e.g. a TCP connection) and setting it up
once again can be very inefficient!
120. Mobile IP (Direct Routing)
wide area
network
home
network
visited
network
4
2
41Correspondent
requests, receives
foreign address of
mobile
Correspondent forwards
to foreign agent
Foreign agent
receives packets,
forwards to mobile
Mobile replies
directly to
correspondent
3
121. Mobile IP (Direct Routing)
This overcomes the triangle routing problem
However, this approach is non-transparent to the
correspondent node. The correspondent node must
get care-of-address from home agent. This will have
to be repated if mobile changes the visited network
possibly requiring the flow to be disconnected and
established once again!
122. wide area
network
1
foreign net visited
at session start
anchor
foreign
agent
2
4
new foreign
agent
3
5
correspondent
agent
correspondent
new
foreign
network
Mobile IP (Direct Routing)
Handling Mobility of the Mobile Node, moving from one
network to another
Anchor foreign agent: FA in first visited network
Data always routed first to anchor FA
When mobile moves, the new FA arranges to have data forwarded
from old FA (chaining)
123. Address Resolution Protocol (ARP)
• Addresses how to actually deliver IP datagrams to the destination host
when the source and destination are on the same network
• Note that packet has an IP address but the network interface of the
destination receives packets based on the MAC (Ethernet) address. (The
IP datagram is encapsulated in a Ethernet frame for transmission.)
However, the source does not know at the beginning what is the MAC
address of the destination!
• The ARP protocol allows this correspondence to be established between
the IP address of the destination and its MAC address
1A-2F-BB-76-09-AD
58-23-D7-FA-20-B0
0C-C4-11-6F-E3-98
71-65-F7-2B-08-53
LAN
137.196.7.23
137.196.7.78
137.196.7.14
137.196.7.88
124. Address Resolution Protocol (ARP)
• Each node (host or router) keeps the IP address to MAC address
mappings of the nodes that it knows about in the network in an ARP Table
as <IP Address, MAC Address, TTL>
• Entry only kept for TTL (Time to Live) seconds (following the last time it
saw an IP datagram from that MAC address) after which the entry is
erased. This is done to account for nodes which may move from one
network to another – note that if that happens, the node’s IP address
changes but its MAC address remains the same.
•Typical value of TTL = 20 minutes
1A-2F-BB-76-09-AD
58-23-D7-FA-20-B0
0C-C4-11-6F-E3-98
71-65-F7-2B-08-53
LAN
137.196.7.23
137.196.7.78
137.196.7.14
137.196.7.88
How is the ARP Table
built up?
125. ARP protocol for A sending to B where A
and B are in the same physical network
A wants to send datagram to B, and B’s MAC address not in
A’s ARP Table.
A broadcasts ARP query packet, containing B's IP address
Dest MAC address set to FF-FF-FF-FF-FF-FF (i.e.
broadcast)
All nodes on LAN receive ARP query
B receives ARP packet, replies to A with its (B's) MAC
address
Frame sent to A’s MAC address (unicast). A caches (saves)
IP-to-MAC address pair in its ARP Table until information
becomes old (times out because of TTL)
ARP is “plug-and-play” as nodes create their ARP tables
without intervention from net administrator
126. Sending Packets from A to B when A and B
are on Different Networks
(through a Router)
R
1A-23-F9-CD-06-9B
222.222.222.220
111.111.111.110
E6-E9-00-17-BB-4B
CC-49-DE-D0-AB-7D
111.111.111.112
111.111.111.111
A
74-29-9C-E8-FF-55
222.222.222.221
88-B2-2F-54-1A-0F
B
222.222.222.222
49-BD-D2-C7-56-2A
Assume A knows B’s IP address. A sends packet first to R and then R
sends it to B. Two ARP Tables are used, one at A and another at R, i.e.
one for each network.
127. A creates IP datagram with source A, destination B
A uses ARP to get R’s MAC address for 111.111.111.110
A creates link-layer frame with R's MAC address as destination. Frame
contains A-to-B IP datagram
A’s NIC sends frame
R’s NIC receives frame
R removes IP datagram from Ethernet frame, sees it is destined to B
R uses ARP to get B’s MAC address
R creates frame containing A-to-B IP datagram and sends to B
R
1A-23-F9-CD-06-9B
222.222.222.220
111.111.111.110
E6-E9-00-17-BB-4B
CC-49-DE-D0-AB-7D
111.111.111.112
111.111.111.111
A
74-29-9C-E8-FF-55
222.222.222.221
88-B2-2F-54-1A-0F
B
222.222.222.222
49-BD-D2-C7-56-2A
Example: A and B on Different Networks