SlideShare a Scribd company logo
1 of 127
Download to read offline
Communication Networks
Sanjay K. Bose
Lecture Set V
Network Layer
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
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?
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
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.
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
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
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.
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
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
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
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
Using Dijkstra’s algorithm
Iteration N D2 D3 D4 D5 D6
Initial {1} 3 2 5  
1 {1,3} 3 2 4  3
2 {1,2,3} 3 2 4 7 3
3 {1,2,3,6} 3 2 4 5 3
4 {1,2,3,4,6} 3 2 4 5 3
5 {1,2,3,4,5,6} 3 2 4 5 3
1
2
4
5
6
1
1
2
3
2
3
5
2
4
3 1
2
4
5
6
1
1
2
3
2
3
5
2
4
331
2
4
5
6
1
1
2
3
2
3
5
2
4
3 1
2
4
5
6
1
1
2
3
2
3
5
2
4
331
2
4
5
6
1
1
2
3
2
3
5
2
4
33 1
2
4
5
6
1
1
2
3
2
3
5
2
4
331
2
4
5
6
1
1
2
3
2
3
5
2
4
33









Shortest Paths in Dijkstra’s Algorithm
1
2
4
5
6
1
1
2
3
2
3
5
2
4
3 31
2
4
5
6
1
1
2
3
2
3
5
2
4
3
1
2
4
5
6
1
1
2
3
2
3
5
2
4
33 1
2
4
5
6
1
1
2
3
2
3
5
2
4
33
1
2
4
5
6
1
1
2
3
2
3
5
2
4
33 1
2
4
5
6
1
1
2
3
2
3
5
2
4
33
Dijkstra’s Algorithm Example
Iteration [N] D2 D3 D4 D5 D6
0 [1] 3
(1-2)
2
(1-3)
5
(1-4)
∞ ∞
1 [1,3] 3
(1-2)
2
(1-3)
4
(1-3-4)
∞ 3
(1-3-6)
2 [1,2,3] 3
(1-2)
2
(1-3)
4
(1-3-4)
7
(1-2-5)
3
(1-3-6)
3 [1,2,3,6] 3
(1-2)
2
(1-3)
4
(1-3-4)
5
(1-3-6-5)
3
(1-3-6)
4 [1,2,3,4,
6]
3
(1-2)
2
(1-3)
4
(1-3-4)
5
(1-3-6-5)
3
(1-3-6)
5 [1,2,3,4,
5,6]
3
(1-2)
2
(1-3)
4
(1-3-4)
5
(1-3-6-5)
3
(1-3-6)
15
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
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.
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)
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:
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
Network Layer 4-21
Distance Vector Algorithm
(Example Network)
1
2
4
5
6
1
1
2
3
2
3
5
2
4
33
Network Layer 4-22
Distance Vector Algorithm
(Example Network)
Destination Node 6
1
2
4
5
6
1
1
2
3
2
3
5
2
4
33
D1 D2 D3 D4 D5
∞
(-1)
∞
(-1)
1
(6)
∞
(-1)
2
(6)
3
(1-3-6)
6
(2-5-6)
1
(6)
3
(4-3-6)
2
(6)
3
(1-3-6)
4
(2-4-3-6)
1
(6)
3
(4-3-6)
2
(6)
3
(1-3-6)
4
(2-4-3-6)
1
(6)
3
(4-3-6)
2
(6)
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
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
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.
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.
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
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
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
3b
1d
3a
1c
2a
AS3
AS1
AS2
1a
2c
2b
1b
Intra-AS
Routing
algorithm
Inter-AS
Routing
algorithm
Forwarding
table
3c
Interconnected AS’s
Forwarding Table
configured by both intra- and
inter-AS routing algorithm
 intra-AS sets entries for
internal destinations
 inter-AS & intra-As sets
entries for external
destinations
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!
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
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
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
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
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.
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
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
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
Hierarchical Implementation of OSPF
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
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
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
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
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
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
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
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
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
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
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
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.
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
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.
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).
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.
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.
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.
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
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)
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
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
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
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
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!
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.
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
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
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
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
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?
2
3
How Many Subnets?
0 0 0 0 0 0 0 0Original
network
198 45 78
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
1st subnet
2nd subnet
zero subnet
8th subnet Broadcast subnet
198.45.78.0
198.45.78.32
198.45.78.64
198.45.78.96
198.45.78.128
198.45.78.160
198.45.78.192
198.45.78.224
Subnet Mask 255.255.255.224
2
3
How Many Host In Each Subnet?
0 0 1 0 0 0 0 02nd Subnet 198 45 78
0 0 0 0 1
0 0 0 1 0
0 0 0 1 1
198.45.78.33
198.45.78.34
198.45.78.35
198.45.78.62
198.45.78.63
Subnet Mask 255.255.255.224
1 1 1 1 0
1 1 1 1 1Broadcast address
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
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
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
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.
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
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
1st octet 2nd octet 3rd octet 4th octet
200.23.16.0 1100 1000 00010111 0001 0000 0000 0000
200.23.17.0 1100 1000 00010111 0001 0001 0000 0000
200.23.18.0 1100 1000 00010111 0001 0010 0000 0000
200.23.19.0 1100 1000 00010111 0001 0011 0000 0000
200.23.20.0 1100 1000 00010111 0001 0100 0000 0000
200.23.21.0 1100 1000 00010111 0001 0101 0000 0000
200.23.22.0 1100 1000 00010111 0001 0110 0000 0000
200.23.23.0 1100 1000 00010111 0001 0111 0000 0000
Example – Route Summarization 200.23.16.0/21
Example – Route Summarization
200.23.16.0/24
200.23.20.0/24
200.23.23.0/24
200.23.16.0/21
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
140.24.7.0/26
140.24.7.64/26 140.24.7.128/26
R1
R2
R3
Announce
“140.24.7.192/26”
S2
Announce
“140.24.7.0/24” S1
140.24.7.192/26
140.24.7.200
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
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.
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
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.
DHCP server: 223.1.2.5 arriving
client
time
DHCP discover
src : 0.0.0.0, 68
dest.: 255.255.255.255,67
yiaddr: 0.0.0.0
transaction ID: 654
DHCP offer
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 654
Lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
DHCP Client-Server Example
See next slide
for details
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.
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
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
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
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
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
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.
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
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
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
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.
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)
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
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
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
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
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
 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
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
?
 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
 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
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
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
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
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
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
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
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”
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
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.
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!
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
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!
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)
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
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?
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
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.
 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

More Related Content

What's hot (20)

Network Layer
Network LayerNetwork Layer
Network Layer
 
Routing
RoutingRouting
Routing
 
Transport layer protocol
Transport layer protocolTransport layer protocol
Transport layer protocol
 
Open Shortest Path First
Open Shortest Path FirstOpen Shortest Path First
Open Shortest Path First
 
Basic of IPv6
Basic of IPv6Basic of IPv6
Basic of IPv6
 
Switching - data communication
Switching - data communicationSwitching - data communication
Switching - data communication
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithm
 
Routing ppt
Routing pptRouting ppt
Routing ppt
 
Distance Vector Routing Protocols
Distance Vector Routing ProtocolsDistance Vector Routing Protocols
Distance Vector Routing Protocols
 
Routing Techniques
Routing TechniquesRouting Techniques
Routing Techniques
 
switching techniques in data communication and networking
switching techniques in data communication and networkingswitching techniques in data communication and networking
switching techniques in data communication and networking
 
Routing protocols
Routing protocolsRouting protocols
Routing protocols
 
Rip presentation
Rip presentationRip presentation
Rip presentation
 
OFDM
OFDMOFDM
OFDM
 
IP Address
IP AddressIP Address
IP Address
 
Transport layer services
Transport layer servicesTransport layer services
Transport layer services
 
Routing Protocols
Routing ProtocolsRouting Protocols
Routing Protocols
 
IEEE 802.11 Architecture and Services
IEEE 802.11 Architecture and ServicesIEEE 802.11 Architecture and Services
IEEE 802.11 Architecture and Services
 
VIRTUAL CIRCUIT NETWORKS, atm , frame relay
VIRTUAL CIRCUIT NETWORKS, atm , frame relayVIRTUAL CIRCUIT NETWORKS, atm , frame relay
VIRTUAL CIRCUIT NETWORKS, atm , frame relay
 
Router configuration in packet tracer
Router configuration in packet  tracerRouter configuration in packet  tracer
Router configuration in packet tracer
 

Similar to Lecture set 5

Module 3- transport_layer .pptx
Module 3- transport_layer           .pptxModule 3- transport_layer           .pptx
Module 3- transport_layer .pptxhariprasad279825
 
IAP presentation-1.pptx
IAP presentation-1.pptxIAP presentation-1.pptx
IAP presentation-1.pptxHirazNor
 
routing algorithm
routing algorithmrouting algorithm
routing algorithmAnusuaBasu
 
Route1
Route1Route1
Route1Saeed
 
Introduction to Computer Networks
Introduction to Computer NetworksIntroduction to Computer Networks
Introduction to Computer NetworksVenkatesh Iyer
 
Intro 2 Computer Networks
Intro 2 Computer NetworksIntro 2 Computer Networks
Intro 2 Computer Networksrakeshgoswami
 
Comparative Analysis of Distance Vector Routing & Link State Protocols
Comparative Analysis of Distance Vector Routing & Link State ProtocolsComparative Analysis of Distance Vector Routing & Link State Protocols
Comparative Analysis of Distance Vector Routing & Link State ProtocolsEast West University
 
IRJET- Survey on Adaptive Routing Algorithms
IRJET- Survey on Adaptive Routing AlgorithmsIRJET- Survey on Adaptive Routing Algorithms
IRJET- Survey on Adaptive Routing AlgorithmsIRJET Journal
 
DCCN Network Layer congestion control TCP
DCCN Network Layer congestion control TCPDCCN Network Layer congestion control TCP
DCCN Network Layer congestion control TCPSreedhar Chowdam
 
4af46e43-4dc7-4b54-ba8b-3a2594bb5269 j.pdf
4af46e43-4dc7-4b54-ba8b-3a2594bb5269 j.pdf4af46e43-4dc7-4b54-ba8b-3a2594bb5269 j.pdf
4af46e43-4dc7-4b54-ba8b-3a2594bb5269 j.pdfmrcopyxerox
 
Computer networking presentation
Computer networking presentationComputer networking presentation
Computer networking presentationMd. Touhidur Rahman
 
Distance Vector & Link state Routing Algorithm
Distance Vector & Link state Routing AlgorithmDistance Vector & Link state Routing Algorithm
Distance Vector & Link state Routing AlgorithmMOHIT AGARWAL
 
IAP PPT-1.pptx
IAP PPT-1.pptxIAP PPT-1.pptx
IAP PPT-1.pptxHirazNor
 

Similar to Lecture set 5 (20)

Module 3- transport_layer .pptx
Module 3- transport_layer           .pptxModule 3- transport_layer           .pptx
Module 3- transport_layer .pptx
 
Week13 lec1
Week13 lec1Week13 lec1
Week13 lec1
 
Cnetwork
CnetworkCnetwork
Cnetwork
 
Week13 lec2
Week13 lec2Week13 lec2
Week13 lec2
 
Week11 lec2
Week11 lec2Week11 lec2
Week11 lec2
 
IAP presentation-1.pptx
IAP presentation-1.pptxIAP presentation-1.pptx
IAP presentation-1.pptx
 
routing algorithm
routing algorithmrouting algorithm
routing algorithm
 
Route1
Route1Route1
Route1
 
Introduction to Computer Networks
Introduction to Computer NetworksIntroduction to Computer Networks
Introduction to Computer Networks
 
Intro 2 Computer Networks
Intro 2 Computer NetworksIntro 2 Computer Networks
Intro 2 Computer Networks
 
Comparative Analysis of Distance Vector Routing & Link State Protocols
Comparative Analysis of Distance Vector Routing & Link State ProtocolsComparative Analysis of Distance Vector Routing & Link State Protocols
Comparative Analysis of Distance Vector Routing & Link State Protocols
 
IRJET- Survey on Adaptive Routing Algorithms
IRJET- Survey on Adaptive Routing AlgorithmsIRJET- Survey on Adaptive Routing Algorithms
IRJET- Survey on Adaptive Routing Algorithms
 
5.2_video_slides.pptx
5.2_video_slides.pptx5.2_video_slides.pptx
5.2_video_slides.pptx
 
DCCN Network Layer congestion control TCP
DCCN Network Layer congestion control TCPDCCN Network Layer congestion control TCP
DCCN Network Layer congestion control TCP
 
4af46e43-4dc7-4b54-ba8b-3a2594bb5269 j.pdf
4af46e43-4dc7-4b54-ba8b-3a2594bb5269 j.pdf4af46e43-4dc7-4b54-ba8b-3a2594bb5269 j.pdf
4af46e43-4dc7-4b54-ba8b-3a2594bb5269 j.pdf
 
Routing Algorithm
Routing AlgorithmRouting Algorithm
Routing Algorithm
 
Computer networking presentation
Computer networking presentationComputer networking presentation
Computer networking presentation
 
Distance Vector & Link state Routing Algorithm
Distance Vector & Link state Routing AlgorithmDistance Vector & Link state Routing Algorithm
Distance Vector & Link state Routing Algorithm
 
End sem
End semEnd sem
End sem
 
IAP PPT-1.pptx
IAP PPT-1.pptxIAP PPT-1.pptx
IAP PPT-1.pptx
 

More from Gopi Saiteja

More from Gopi Saiteja (20)

Trees gt(1)
Trees gt(1)Trees gt(1)
Trees gt(1)
 
Topic11 sortingandsearching
Topic11 sortingandsearchingTopic11 sortingandsearching
Topic11 sortingandsearching
 
Heapsort
HeapsortHeapsort
Heapsort
 
Hashing gt1
Hashing gt1Hashing gt1
Hashing gt1
 
Ee693 sept2014quizgt2
Ee693 sept2014quizgt2Ee693 sept2014quizgt2
Ee693 sept2014quizgt2
 
Ee693 sept2014quizgt1
Ee693 sept2014quizgt1Ee693 sept2014quizgt1
Ee693 sept2014quizgt1
 
Ee693 sept2014quiz1
Ee693 sept2014quiz1Ee693 sept2014quiz1
Ee693 sept2014quiz1
 
Ee693 sept2014midsem
Ee693 sept2014midsemEe693 sept2014midsem
Ee693 sept2014midsem
 
Ee693 questionshomework
Ee693 questionshomeworkEe693 questionshomework
Ee693 questionshomework
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Cs105 l15-bucket radix
Cs105 l15-bucket radixCs105 l15-bucket radix
Cs105 l15-bucket radix
 
Chapter11 sorting algorithmsefficiency
Chapter11 sorting algorithmsefficiencyChapter11 sorting algorithmsefficiency
Chapter11 sorting algorithmsefficiency
 
Answers withexplanations
Answers withexplanationsAnswers withexplanations
Answers withexplanations
 
Sorting
SortingSorting
Sorting
 
Solution(1)
Solution(1)Solution(1)
Solution(1)
 
Pthread
PthreadPthread
Pthread
 
Open mp
Open mpOpen mp
Open mp
 
Introduction
IntroductionIntroduction
Introduction
 
Cuda
CudaCuda
Cuda
 
Vector space interpretation_of_random_variables
Vector space interpretation_of_random_variablesVector space interpretation_of_random_variables
Vector space interpretation_of_random_variables
 

Lecture set 5

  • 1. Communication Networks Sanjay K. Bose Lecture Set V Network Layer
  • 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
  • 13. Using Dijkstra’s algorithm Iteration N D2 D3 D4 D5 D6 Initial {1} 3 2 5   1 {1,3} 3 2 4  3 2 {1,2,3} 3 2 4 7 3 3 {1,2,3,6} 3 2 4 5 3 4 {1,2,3,4,6} 3 2 4 5 3 5 {1,2,3,4,5,6} 3 2 4 5 3 1 2 4 5 6 1 1 2 3 2 3 5 2 4 3 1 2 4 5 6 1 1 2 3 2 3 5 2 4 331 2 4 5 6 1 1 2 3 2 3 5 2 4 3 1 2 4 5 6 1 1 2 3 2 3 5 2 4 331 2 4 5 6 1 1 2 3 2 3 5 2 4 33 1 2 4 5 6 1 1 2 3 2 3 5 2 4 331 2 4 5 6 1 1 2 3 2 3 5 2 4 33         
  • 14. Shortest Paths in Dijkstra’s Algorithm 1 2 4 5 6 1 1 2 3 2 3 5 2 4 3 31 2 4 5 6 1 1 2 3 2 3 5 2 4 3 1 2 4 5 6 1 1 2 3 2 3 5 2 4 33 1 2 4 5 6 1 1 2 3 2 3 5 2 4 33 1 2 4 5 6 1 1 2 3 2 3 5 2 4 33 1 2 4 5 6 1 1 2 3 2 3 5 2 4 33
  • 15. Dijkstra’s Algorithm Example Iteration [N] D2 D3 D4 D5 D6 0 [1] 3 (1-2) 2 (1-3) 5 (1-4) ∞ ∞ 1 [1,3] 3 (1-2) 2 (1-3) 4 (1-3-4) ∞ 3 (1-3-6) 2 [1,2,3] 3 (1-2) 2 (1-3) 4 (1-3-4) 7 (1-2-5) 3 (1-3-6) 3 [1,2,3,6] 3 (1-2) 2 (1-3) 4 (1-3-4) 5 (1-3-6-5) 3 (1-3-6) 4 [1,2,3,4, 6] 3 (1-2) 2 (1-3) 4 (1-3-4) 5 (1-3-6-5) 3 (1-3-6) 5 [1,2,3,4, 5,6] 3 (1-2) 2 (1-3) 4 (1-3-4) 5 (1-3-6-5) 3 (1-3-6) 15
  • 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
  • 21. Network Layer 4-21 Distance Vector Algorithm (Example Network) 1 2 4 5 6 1 1 2 3 2 3 5 2 4 33
  • 22. Network Layer 4-22 Distance Vector Algorithm (Example Network) Destination Node 6 1 2 4 5 6 1 1 2 3 2 3 5 2 4 33 D1 D2 D3 D4 D5 ∞ (-1) ∞ (-1) 1 (6) ∞ (-1) 2 (6) 3 (1-3-6) 6 (2-5-6) 1 (6) 3 (4-3-6) 2 (6) 3 (1-3-6) 4 (2-4-3-6) 1 (6) 3 (4-3-6) 2 (6) 3 (1-3-6) 4 (2-4-3-6) 1 (6) 3 (4-3-6) 2 (6)
  • 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
  • 30. 3b 1d 3a 1c 2a AS3 AS1 AS2 1a 2c 2b 1b Intra-AS Routing algorithm Inter-AS Routing algorithm Forwarding table 3c Interconnected AS’s Forwarding Table configured by both intra- and inter-AS routing algorithm  intra-AS sets entries for internal destinations  inter-AS & intra-As sets entries for external destinations
  • 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?
  • 72. 2 3 How Many Subnets? 0 0 0 0 0 0 0 0Original network 198 45 78 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 1st subnet 2nd subnet zero subnet 8th subnet Broadcast subnet 198.45.78.0 198.45.78.32 198.45.78.64 198.45.78.96 198.45.78.128 198.45.78.160 198.45.78.192 198.45.78.224 Subnet Mask 255.255.255.224
  • 73. 2 3 How Many Host In Each Subnet? 0 0 1 0 0 0 0 02nd Subnet 198 45 78 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 198.45.78.33 198.45.78.34 198.45.78.35 198.45.78.62 198.45.78.63 Subnet Mask 255.255.255.224 1 1 1 1 0 1 1 1 1 1Broadcast address
  • 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
  • 80. 1st octet 2nd octet 3rd octet 4th octet 200.23.16.0 1100 1000 00010111 0001 0000 0000 0000 200.23.17.0 1100 1000 00010111 0001 0001 0000 0000 200.23.18.0 1100 1000 00010111 0001 0010 0000 0000 200.23.19.0 1100 1000 00010111 0001 0011 0000 0000 200.23.20.0 1100 1000 00010111 0001 0100 0000 0000 200.23.21.0 1100 1000 00010111 0001 0101 0000 0000 200.23.22.0 1100 1000 00010111 0001 0110 0000 0000 200.23.23.0 1100 1000 00010111 0001 0111 0000 0000 Example – Route Summarization 200.23.16.0/21
  • 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.
  • 88. DHCP server: 223.1.2.5 arriving client time DHCP discover src : 0.0.0.0, 68 dest.: 255.255.255.255,67 yiaddr: 0.0.0.0 transaction ID: 654 DHCP offer src: 223.1.2.5, 67 dest: 255.255.255.255, 68 yiaddrr: 223.1.2.4 transaction ID: 654 Lifetime: 3600 secs DHCP request src: 0.0.0.0, 68 dest:: 255.255.255.255, 67 yiaddrr: 223.1.2.4 transaction ID: 655 Lifetime: 3600 secs DHCP ACK src: 223.1.2.5, 67 dest: 255.255.255.255, 68 yiaddrr: 223.1.2.4 transaction ID: 655 Lifetime: 3600 secs DHCP Client-Server Example See next slide for details
  • 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