Cs8591 Computer Networks: Unit - Iii
Cs8591 Computer Networks: Unit - Iii
UNIT – III
3
NETWORK LAYER SERVICES
In this section, we briefly discuss services provided by the network layer. Our discussion
is mostly based on the connectionless service, the dominant service in today’s Internet.
Logical Addressing
Services Provided at the Source Computer
Services Provides at the Each Router
Services Provided at the Destination Computer
At the conceptual level, we can think of the global Internet as a black box network that connects
millions (if not billions) of computers in the world together. At this level, we are only concerned that a
message from the application layer in one computer reaches the application layer in another
computer.
4
Logical Addressing: An imaginary part of the Internet
5
Services provided at the source computer
6
Processing at each router
7
Processing at the destination computer
8
ROUTING
Routing algorithm:: that part of the Network Layer responsible for
deciding on which output line to transmit an incoming packet.
Remember: For virtual circuit subnets the routing decision is made
ONLY at set up.
Algorithm properties:: correctness, simplicity, robustness,
stability, fairness, optimality, and scalability.
In packet switching, the message is first divided into manageable packets at the
source before being transmitted. The packets are assembled at the destination.
The NL is designed as a packet-switched network. This means that the packet at the source is divided into manageable
packets called datagrams. Individual datagrams are then transferred from S to D. The received datagrams are assembled at
the destination before recreating the original message. The packet-switched network layer of the Internet was originally
designed as a connectionless service, but recently there is a tendency to change this to a connection-oriented service.
10
Types of Services
Note Connectionless Service
Connection-Oriented Service
In a connectionless packet-switched network, the forwarding decision is
based on the destination address of the packet.
Network
A connectionless
packet-swtiched network
R1 R2
4 3 2 1 2 Delay in a connectionless network
Sender 1
Network
4 Destination
2
3 Souce
R4 1
3 3
4 1 3 4 2 1
R3 R5 Out of order Receiver
Total delay
2
Source D
Setup
4 3 2 1
2
4
Total delay
3 3 Transmission
time
2 4
1
5
4 3 2 1 4 3 2 1
Teardown
6
12
Forwarding of IP Packets
The network layer supervises the handling of the packets by the underlying physical networks. We
define this handling as the delivery of a packet. The delivery of a packet to its final destination is
accomplished using two different methods of delivery: direct and indirect. Direct Delivery
Direct delivery Indirect Delivery
Direct delivery
Direct delivery
Indirect delivery
A B
Indirect delivery
Indirect delivery 13
FORWARDING
Forwarding means to place the packet in its route to its destination. Since the Internet
today is made of a combination of links (networks), forwarding means to deliver the
packet to the next hop (which can be the final destination or the intermediate connecting
device). Although the IP protocol was originally designed as a connectionless protocol,
today the tendency is to use IP as a connection-oriented protocol.
4 types
Next – hop
Network Specific method
Host specific method
Default method
14
Figure 6.3 Next-hop method
15
Figure 6.4 Network-specific method
Network-specific
routing table for host S
Destination Next Hop
Host-specific
routing table for host S N2 R1
16
Figure 6.5 Host-specific routing
N1
R1 R3
Host B
N2 R2 N3
17
Figure 6.6 Default routing
Default
R2
router
18
ADDRESSING
The address in the network layer of the TCP/IP model is called Internet Address or
IP address, an IP address is a 32-bit address
The IP addresses are unique (each connection has a different address) and
universal (must be accepted by any host wants to connect to the internet).
Consists of 4 octets (bytes)
Network IP addresses are managed by a nonprofit organization called ICANN
(International Corporation for Assigned Names and Numbers) to avoid conflicts.
Assigns addresses to regional Authorities which assign numbers to ISPs
32
The address space of IPv4 is 2 or 4,294,967,296.
Example 1
Change the IP addresses from binary notation to dotted-decimal notation.
a. 10000001 00001011 00001011 11101111
b. 11111001 10011011 11111011 00001111
Solution
We replace each group of 8 bits with its equivalent decimal number and add dots for separation:
a. 129.11.11.239
b. 249.155.251.15
20
ADDRESSING
PROBLEM
Example 2 Change the IP addresses from dotted-decimal notation to binary notation.
a. 111.56.45.78
b. 75.45.34.78
Solution We replace each decimal number with its binary equivalent:
Note
22
Find the class of each address:
Example 3
a. 00000001 00001011 00001011 11101111
b. 11110011 10011011 11111011 00001111
See the procedure in Figure 19.11.
Solution a. The first bit is 0; this is a class A address.
b. The first 4 bits are 1s; this is a class E address.
Class B
Start with binary 10
Range 128.x.x.x to 191.x.x.x
230 class B complete IP addresses
214=16384 blocks (network addresses)
Number of addresses in each block is 216=65536 – (all zeros host, and all ones)
All allocated
24
Classful Addressing
Class C
229 Class C complete IP addresses
221=2097152 blocks (network addresses)
Start with binary 110
Number of addresses in each block is 256 – (all zeros host, and all ones) class
25
Figure 19.14 Blocks in class A
Note
Note:
Note
The number of addresses in class C block is
28
smaller than the needs of most organizations.
Figure 19.17 Network address
29
Example 6 Given the address 132.6.17.85, find the network address.
The class is B. The first 2 bytes defines the netid. We can find the network address by
Solution replacing the hostid bytes (17.85) with 0s. Therefore, the network address is 132.6.0.0.
Sample internet
Class C
Note
In Dotted-
Class In Binary Using Slash
Decimal
31
Figure A network with two levels of hierarchy
Note
A class B “Flat Network”, more than
16
The network address can be found by 2 =65536 hosts
applying the default mask to any address How to manage?
in the block (including itself).It retains the
Performance? Too many hosts on the
netid of the block and sets the hostid to 0s. same LAN (single broadcast domain) will
slowdown the LAN performance
Solution: Subnetting
32
Figure 19.23 Subnet mask
Class B
Reduces
the routing
table
entries and
size 33
Subnetting
Dividing the network into several smaller groups (subnets) with each
group having its own subnet IP address
Site looks to rest of internet like single network and routers outside
the organization route the packet based on the main Network address
Local routers route within subnetted network using subnet address
Host portion of address partitioned into subnet number (most
significant part) and host number (least significant part)
In this case, IP address will have 3 levels (Main network, subnet, host)
Subnet mask is a 32-bit consists of zeros and ones that indicates
which bits of the IP address are subnet number and which are host
number
Subnet mask when ANDed with the IP address it gives the
subnetwork address
34
Figure 19.20 A network with three levels of hierarchy
(subnetted)
Example 9 A router inside the organization receives the same packet with D address
190.240.33.91 /19. Show how it finds the subnetwork address to route the packet.
Solution
The router follows three steps:
The router must know the mask. Is 255.255.224.0 or /19
The router applies the mask to the address, 190.240.33.91. The subnet address is 190.240.32.0.
The router looks in its routing table to find how to route the packet to this destination. Later, we will
see what happens if this destination does not exist.
36
Obtaining Host IP Address
Once a network administrator in an organization obtained a block of
addresses from its ISP, it can then assign individual IP addresses to
the host and router interfaces
It can be done in two ways:
Manual configuration: IP address is stored manually by the
another?
Solution is using a protocol called Dynamic Host Configuration
Protocol (DHCP)
DHCP is a client-server program
37
Dynamic Host Configuration Protocol
Dynamic Host Configuration Protocol (DHCP)
A protocol that provide IP address, subnet mask, IP address of a
temporary Addresses.)
Static IP addresses database maps physical addresses (MAC) to
database first.
If no address match is found, DHCP will select the dynamic IP
39
Four cases using ARP
40
ARP operation
Note
An ARP request is
broadcast; an ARP
reply is unicast.
41
Figure 20.5 IPv4 datagram format
+ Padding
42
IPv4 datagram fields
Minimum Header length is 20 bytes without options.
With options the maximum can go to 60 bytes
Largest data that can be carried in the datagram is 65535 – 20 = 65515
Version field: will carry the version number which is 4 = (0100)2
Header length: the length of the header in bytes after dividing it by 4. Min is 20/4 = 5 =
(0101)2 and the max is 60/4 = 15 = (1111 )2
Total length: total length of the packet: header + data. Max = 65535 bytes
Identification, flags, and offset used for fragmentation and reassembly at the D
Packet can be fragmented at any node between the source and the destination but
reassembly is done ONLY at the destination node.
Time to Live is used to prevent lost packets from circulating between routers forever. This
field is set to certain value depending on the device operating system. Each router will
decrement this field by one and check the value. If the value is zero the packet will be
dropped.
Protocol: contains a code for what is being carried in the data field.
Header checksum used for checking if there is error in the header only. The checksum is
recomputed at each router between the source and the destination.
43
Protocol field and encapsulated data
44
Internet Control Message Protocol
used by hosts & routers to
communicate network-level Type Code description
0 0 echo reply (ping)
information
3 0 dest. network unreachable
error reporting: 3 1 dest host unreachable
unreachable host, network, 3 2 dest protocol unreachable
port, protocol 3 3 dest port unreachable
echo request/reply (used by
3 6 dest network unknown
3 7 dest host unknown
ping)
4 0 source quench (congestion
network-layer “above” IP: control - not used)
ICMP msgs carried in IP 8 0 echo request (ping)
datagrams 9 0 route advertisement
10 0 router discovery
ICMP message: type, code 11 0 TTL expired
plus first 8 bytes of IP 12 0 bad IP header
datagram causing error
45
Traceroute and ICMP
source sends series of UDP segments to dest
first set has TTL =1
second set has TTL=2, etc.
unlikely port number
when nth set of datagrams arrives to nth router:
router discards datagrams
and sends source ICMP messages (type 11, code 0)
stopping criteria:
UDP segment eventually arrives at destination host
destination returns ICMP “port unreachable” message (type 3, code 3)
source stops
3 probes 3 probes
3 probes 46
IPv6: Motivation
initial motivation: 32-bit address space soon to be completely
allocated.
additional motivation:
header format helps speed processing/forwarding
how will network operate with mixed IPv4 and IPv6 routers?
tunneling: IPv6 datagram carried as payload in IPv4 datagram among IPv4 routers
IPv4 header fields IPv6 header fields
IPv4 payload
IPv4 source, dest addr IPv6 source dest addr
UDP/TCP payload
IPv6 datagram
IPv4 datagram
Tunneling
IPv4 tunnel
A B connecting IPv6 routers
E F
logical view: IPv6 IPv6 IPv6 IPv6
A B C D E F
physical view:
IPv6 IPv6 IPv4 IPv4 IPv6 IPv6
flow: X flow: X
src: A src:B src:B src: A
dest: F dest: F
dest: E dest: E
Flow: X Flow: X
data Src: A data
Src: A
Dest: F Dest: F
data data
A-to-B: E-to-F:
IPv6 B-to-C: B-to-C: IPv6
IPv6 inside IPv6 inside
IPv4 IPv4
49
Interplay between routing, forwarding
routing algorithm routing algorithm determines
end-end-path through network
local forwarding table
IP destination address in
arriving packet’s header
1
3 2
50
Unicast Routing basics
graph: G = (N,E) 5
v 3 w
N = set of routers = { u, v, w, x, y, z } 5
2
u z
2 1
E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), 3
1 x y 2
(x,y), (w,y), (w,z), (y,z) }
1
aside: graph abstraction is useful in other network contexts, e.g., P2P, where
N is set of peers and E is set of TCP connections
Graph abstraction: costs
c(x,x’) = cost of link (x,x’) e.g., c(w,z) = 5
cost could always be 1, or inversely related to bandwidth, or inversely
related to congestion
cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp)
key question: what is the least-cost path between u and z ?
routing algorithm: algorithm that finds that least cost path
51
Routing algorithm classification
Q: global or decentralized information?
global: all routers have complete topology, link cost info “link state”
algorithms
decentralized:
router knows physically-connected neighbors, link costs to neighbors
iterative process of computation, exchange of info with neighbors
“distance vector” algorithms
Q: static or dynamic?
static: routes change slowly over time
dynamic: routes change more quickly
periodic update
53
Dijsktra’s Algorithm D(v) D(w) D(x) D(y) D(z)
p(v) p(w) p(x) p(y) p(z)
Step N'
1 Initialization:
2 N' = {u} 0 u 7,u 3,u 5,u ∞ ∞
3 for all nodes v 1 uw 6,w 5,u 11,w ∞
4 if v adjacent to u
5 then D(v) = c(u,v) 2 uwx 6,w 11,w 14,x
7 4 uwxvy 12,y
8 Loop 5 uwxvyz
9 find w not in N' such that D(w) is a minimum
10 add w to N' x
11 update D(v) for all v adjacent to w and not in N' : 9
12 D(v) = min( D(v), D(w) + c(w,v) )
13 /* new cost to v is either old cost to v or known 5 7
14 shortest path cost to w plus cost from w to v */ 4
15 until all nodes in N'
8
notes:
u 3 w y z
node x:
maintains Dv = [Dv(y): y є N ]
key idea:
from time-to-time, each node sends its own distance vector estimate
to neighbors
when x receives new DV estimate from neighbor, it updates its own
57
Distance vector algorithm
iterative, asynchronous: each each node:
local iteration caused by:
local link cost change
DV update message from wait for (change in local link cost or
neighbor msg from neighbor)
distributed:
each node notifies neighbors only recompute estimates
when its DV changes
neighbors then notify their
neighbors if necessary
if DV to any dest has changed, notify
neighbors
58
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} Dx(z) = min{c(x,y) +
= min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
node x cost to cost to
cost to
table x y z x y z x y z
x 0 2 7 x 0 2 3 x 0 2 3
from
from
y ∞∞ ∞ y 2 0 1
from
y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
node y cost to cost to
cost to
y
table x y z x y z x y z 2 1
x ∞ ∞ ∞ x 0 2 7 x 0 2 3 x z
from
from
y y 2 7
from
2 0 1 0 1 y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
cost to cost to
node z cost to
table x y z x y z x y z
x ∞∞ ∞ x 0 2 7 x 0 2 3
from
from
from
y y 2 0 1 y 2 0 1
∞∞ ∞
z z 3 1 0 z 3 1 0
71 0
time 59
Comparison of LS and DV algorithms
message complexity robustness: what happens if router
LS: with n nodes, E links, O(nE)
malfunctions?
msgs sent LS:
DV: exchange between neighbors node can advertise incorrect
only link cost
convergence time varies
each node computes only its
network
60
Hierarchical routing
scale: with 600 million destinations:
3c
can’t store all dest’s in routing tables! 3a 2c
3b 2a
AS3 2b
routing table exchange would swamp links! 1c
1a 1b AS1 AS2
gateway router: 1d
each network admin may want to control routing in its own network
61
Inter-AS tasks
suppose router in AS1 receives datagram destined outside of AS1:
router should forward packet to gateway router, but which one?
AS1 must: 1.learn which dests are reachable through AS2, which through AS3
2.propagate this reachability info to all routers in AS1
job of inter-AS routing!
suppose AS1 learns (via inter-AS protocol) that subnet x reachable via AS3
router 1d determines from intra-AS routing info that its interface I is on the least
cost path to 1c
installs forwarding table entry (x,I)
x
3c
3a
3b
AS3 2c other
1c networks
2a
other
1a 2b
networks 1b
AS1 1d AS2 62
Intra-AS Routing
also known as interior gateway protocols (IGP)
most common intra-AS routing protocols:
RIP: Routing Information Protocol
OSPF: Open Shortest Path First
IGRP: Interior Gateway Routing Protocol(Cisco prop.)
RIP: example z
w x y
A D B
transport transprt
(UDP) (UDP)
network forwarding forwarding network
(IP) table table (IP)
link link
65
physical physical
OSPF (Open Shortest Path First)
OSPF advertisement carries one entry per neighbor
advertisements flooded to entire AS
carried in OSPF messages directly over IP (rather than TCP / UDP
66
OSPF “advanced” features (not in RIP)
security: all OSPF messages authenticated (to prevent malicious intrusion)
multiple same-cost paths allowed (only one path in RIP)
for each link, multiple cost metrics for different TOS (e.g., satellite link cost
set “low” for best effort ToS; high for real time ToS)
integrated uni- and multicast support:
Hierarchical OSPF
two-level hierarchy: local area, backbone.
each nodes has detailed area topology; only know direction (shortest
AS3 2c other
prefix + attributes = “route” 1c 2a networks
other
1a 2b
networks 1b
two important attributes: AS1 1d AS2
e.g., AS 67, AS 17
NEXT-HOP: indicates specific internal-AS router to next-hop AS. (may
policy-based routing 69
BGP route selection
router may learn about more than 1 route to destination AS, selects
route based on:
local preference value attribute: policy decision
shortest AS-PATH
closest NEXT-HOP router: hot potato routing
additional criteria
BGP messages : msg exchanged between peers over TCP connection
BGP messages:
close connection
70
Multicast Basics
goal: find a tree connecting routers having local mcast group members
tree: not all paths between routers used, 2 types
legend
group
member
not group
member
router
with a
group
member
router
shared tree source-based trees without
group
member
71
Approaches for building mcast trees
Approaches
source-based tree: one tree per sources: source
R1 2
shortest path trees R4
1
reverse path forwarding
R2 5
group-shared tree: group uses one tree 3 4 R5
minimal spanning (Steiner) R3 6
R6 R7
center-based trees
LEGEND
router with attached
Shortest path tree group member
mcast forwarding tree: tree of shortest router with no attached
group member
path routes from source to all receivers i link used for forwarding,
Dijkstra’s algorithm
i indicates order link
added by algorithm
72
Reverse path forwarding
rely on router’s knowledge of unicast shortest path from it to sender
each router has simple forwarding behavior:
s: source LEGEND
R1 router with attached
R4 group member
R2 router with no attached
group member
R5
datagram will be
R3 forwarded
R6 R7 datagram will not be 73
forwarded
Reverse path forwarding: pruning
forwarding tree contains subtrees with no mcast group
members
no need to forward datagrams down subtree
s: source
R1
R4
LEGEND
R2 P P
prune message
R5
links with multicast
R3 P forwarding
R6
R7
74
Shared-tree: steiner tree
steiner tree: minimum cost tree connecting all
routers with attached group members
problem is NP-complete
excellent heuristics exists
not used in practice:
computational complexity
join/leave
75
Center-based trees
single delivery tree shared by all
one router identified as “center” of tree
to join:
edge router sends unicast join-msg addressed to center router
join-msg either hits existing tree branch for this center, or arrives at
center
path taken by join-msg becomes new branch of tree for this router
R1
3 R4
LEGEND
R2 2 1 path order in which join
R5 messages generated
R3
1 R6 76
R7
Internet Multicasting Routing: DVMRP
DVMRP: distance vector multicast routing protocol, RFC1075
flood and prune: reverse path forwarding, source-based tree
RPF tree based on DVMRP’s own routing tables constructed by
78
PIM: Protocol Independent Multicast
not dependent on any specific underlying unicast routing algorithm
(works with all)
two different multicast distribution scenarios :
dense: sparse:
group members densely packed, in networks with group members small wrt
“close” proximity. interconnected networks
bandwidth more plentiful group members “widely dispersed”
bandwidth not plentiful
Consequences of sparse-dense
dense sparse:
group membership by routers no membership until routers
assumed until routers explicitly prune explicitly join
data-driven construction on mcast receiver- driven construction of
tree (e.g., RPF) mcast tree (e.g., center-based)
bandwidth and non-group-router bandwidth and non-group-router
processing profligate processing conservative
79
PIM- dense mode
80
PIM - sparse mode
center-based approach
router sends join msg to rendezvous point (RP)
intermediate routers update state and forward join
sender(s):
unicast data to RP, which distributes down RP-rooted tree
RP can extend mcast tree upstream to source
RP can send stop msg if no attached receivers
“no one is listening!”
81
Questions?
82