Network Layer
Lecture#19-26
Dr. Sanjeev Patel
Asst Professor, CSE Dept.
NIT Rourkela
3/27/2023 Network Layer 1
Outline
• IPv4 Addressing, CIDR
• Sub-netting and Super-netting
• IPv6
• IP Datagram (IPv4) / IP Protocol
• NAT
• Routing protocol: DV routing and LS routing
• Hierarchical Routing
• Internet Routing: RIP, OSPF and BGP
• Broadcast Routing and Multicast routing
• ARP, RARP, and DHCP
3/27/2023 Network Layer 2
IPv4 Addresses
• An IP address is a 32-bit address
• The IP addresses are unique
• The address space of IPv4 is 232 which is equal to
4,294,967,296
• Classful addressing
– Class A : 231 or 2,147,483,648
– Class B : 230 or 1,073,741,824
– Class C : 229 or 536,870,912
– Class D: 228 or 268,435,456
– Class E : 228 or 268,435,456
3/27/2023 Network Layer 3
Figure 4-2
Occupation of the address space
3/27/2023 Network Layer 4
Finding the class in binary notation [5]
3/27/2023 Network Layer 5
Finding the address class [5]
3/27/2023 Network Layer 6
Finding the class in decimal notation[5]
3/27/2023 Network Layer 7
Netid and hostid [5]
3/27/2023 Network Layer 8
Blocks in class A[5]
3/27/2023 Network Layer 9
Blocks in class B[5]
3/27/2023 Network Layer 10
Figure 4-9
Blocks in class C[5]
3/27/2023 Network Layer 11
IP Addresses
• Millions of class A addresses are wasted
• Many class B addresses are wasted.
• The number of addresses in a class C block is smaller than the needs of most
organizations
• Class D addresses are used for multicasting; there is only one block in this
class.
• Class E addresses are reserved for special purposes; most of the block is
wasted.
• Network address
– In classfull addressing, the network address (the first address in the block) is the
one that is assigned to the organization.
– The network address defines the network to the rest of the Internet.
– using network address, we can find the class of the address, the block, and the
range of the addresses in the block.
3/27/2023 Network Layer 12
Example 1 [5]
Given the network address [Link], find the
class, the block, and the range of the
addresses.
Solution
The class is A because the first byte is between
0 and 127. The block has a netid of 17.
The addresses range from [Link] to
[Link].
3/27/2023 Network Layer 13
Example 2[5]
Given the network address [Link], find
the class, the block, and the range of the
addresses.
Solution
The class is B because the first byte is between
128 and 191. The block has a netid of 132.21.
The addresses range from
[Link] to [Link].
3/27/2023 Network Layer 14
Example 3[5]
Given the network address [Link], find
the class, the block, and the range of the
addresses.
Solution
The class is C because the first byte is between
192 and 223. The block has a netid of 220.34.76.
The addresses range from [Link]
to [Link].
3/27/2023 Network Layer 15
Mask
A mask is a 32-bit binary number that gives the
first address in the block (the network address)
when bitwise ANDed with an address in the
block.
3/27/2023 Network Layer 16
Masking concept [5]
3/27/2023 Network Layer 17
AND operation [5]
3/27/2023 Network Layer 18
Mask
• The network address is the beginning address
of each block.
• It can be found by applying the default mask
to any of the addresses in the block (including
itself).
• It retains the netid of the block and sets the
hostid to zero.
• We must not apply the default mask of one class to
an address belonging to another class.
3/27/2023 Network Layer 19
Example 4[5]
Given the address [Link] and the default
class A mask, find the beginning address
(network address).
Solution
The default mask is [Link], which means
that only the first byte is preserved
and the other 3 bytes are set to 0s.
The network address is [Link].
3/27/2023 Network Layer 20
Example 5[5]
Given the address [Link] and the
default class B mask, find the beginning
address (network address).
Solution
The default mask is [Link], which means
that the first 2 bytes are preserved
and the other 2 bytes are set to 0s.
The network address is [Link].
3/27/2023 Network Layer 21
Example 6[5]
Given the address [Link] and the class
C default mask, find the beginning
address (network address).
Solution
The default mask is [Link],
which means that the first 3 bytes are
preserved and the last byte is set to 0.
The network address is [Link].
3/27/2023 Network Layer 22
Private Addresses
A number of blocks in each class are assigned for
private use. They are not recognized globally.
These blocks are depicted as follows:
Class A: 10.0.0(Net id) and no of Blocks is 1
Class B: 172.16-172.31 and 16
Class C: 192.168.0-192.168.255 and 256 blocks
3/27/2023 Network Layer 23
Unicast, Multicast, and
Broadcast Addresses
Unicast communication is one-to-one.
Multicast communication is one-to-many.
Broadcast communication is one-to-all.
3/27/2023 Network Layer 24
IP addresses are designed with
two levels of hierarchy.
3/27/2023 Network Layer 25
A network with two levels of
hierarchy (not subnetted) [5]
3/27/2023 Network Layer 26
A network with three levels of
hierarchy (sub netted) [5]
3/27/2023 Network Layer 27
Addresses in a network with
and without sub netting [5]
3/27/2023 Network Layer 28
Hierarchy concept in a telephone number
3/27/2023 Network Layer 29
Default mask and subnet mask [5]
3/27/2023 Network Layer 30
Finding the Subnet Address
Given an IP address, we can find the subnet
address the same way we found the
network address in the previous slide. We
apply the mask to the address.
3/27/2023 Network Layer 31
Short-Cut Method [5]
** If the byte in the mask is 255, copy
the byte in the address.
** If the byte in the mask is 0, replace
the byte in the address with 0.
** If the byte in the mask is neither 255
nor 0, we write the mask and the address
in binary and apply the AND operation.
3/27/2023 Network Layer 32
Example 8[5]
What is the subnetwork address if the
destination address is [Link] and the
mask is [Link]?
Solution
See Figure 1
3/27/2023 Network Layer 33
Figure 1
Example 8 [5]
3/27/2023 Network Layer 34
Comparison of a default mask and
a subnet mask [5]
3/27/2023 Network Layer 35
The number of subnets must be
a power of 2.
3/27/2023 Network Layer 36
Example 9[5]
A company is granted the site address
[Link] (class C). The company needs
six subnets. Design the subnets.
Solution
The number of 1s in the default
mask is 24 (class C).
3/27/2023 Network Layer 37
Solution (Continued)
The company needs six subnets. This number
6 is not a power of 2. The next number that is
a power of 2 is 8 (23). We need 3 more 1s in
the subnet mask. The total number of 1s in
the subnet mask is 27 (24 + 3).
The total number of 0s is 5 (32 - 27). The
mask is
3/27/2023 Network Layer 38
Solution (Continued)
11111111 11111111 11111111 11100000
or
[Link]
The number of subnets is 8.
The number of addresses in each subnet
is 25 (5 is the number of 0s) or 32.
See Figure 5.8
3/27/2023 Network Layer 39
Example 9[5]
3/27/2023 Network Layer 40
Example 10[5]
A company is granted the site address
[Link] (class B). The company needs
1000 subnets. Design the subnets.
Solution
The number of 1s in the default mask is 16
(class B).
3/27/2023 Network Layer 41
Solution (Continued)
The company needs 1000 subnets. This
number is not a power of 2. The next number
that is a power of 2 is 1024 (210). We need 10
more 1s in the subnet mask.
The total number of 1s in the subnet mask is
26 (16 + 10).
The total number of 0s is 6 (32 - 26).
3/27/2023 Network Layer 42
Solution (Continued)
The mask is
11111111 11111111 11111111 11000000
or
[Link].
The number of subnets is 1024.
The number of addresses in each subnet is 26
(6 is the number of 0s) or 64.
See Figure 2
3/27/2023 Network Layer 43
Figure 2
Example 10[5]
3/27/2023 Network Layer 44
Variable-length sub netting [5]
3/27/2023 Network Layer 45
A super network [5]
3/27/2023 Network Layer 46
Rules:
** The number of blocks must be a power of 2 (1,
2, 4, 8, 16, . . .).
** The blocks must be contiguous in the address
space (no gaps between the blocks).
** The third byte of the first address in the
superblock must be evenly divisible by the number
of blocks. In other words, if the number of blocks is
N, the third byte must be divisible by N.
3/27/2023 Network Layer 47
Example 11[5]
A company needs 600 addresses. Which of the
following set of class C blocks can be used to form a
super net for this company?
1. [Link] [Link] [Link]
2. [Link] [Link] [Link] [Link]
3. [Link] [Link] [Link] [Link]
4. [Link] [Link] [Link] [Link]
3/27/2023 Network Layer 48
Solution
1: No, there are only three blocks.
2: No, the blocks are not contiguous.
3: No, 31 in the first block is not divisible by 4.
4: Yes, all three requirements are fulfilled.
3/27/2023 Network Layer 49
In subnetting,
we need the first address of the
subnet and the subnet mask to
define the range of addresses.
3/27/2023 Network Layer 50
In supernetting,
we need the first address of
the supernet
and the supernet mask to
define the range of addresses.
3/27/2023 Network Layer 51
Comparison of subnet, default, and supernet
masks [5]
3/27/2023 Network Layer 52
Example 12[5]
We need to make a supernetwork out of 16
class C blocks. What is the supernet mask?
Solution
We need 16 blocks. For 16 blocks we need to change four
1s to 0s in the default mask. So the mask is
11111111 11111111 11110000 00000000
or
[Link]
3/27/2023 Network Layer 53
Example 13[5]
A supernet has a first address of [Link] and a
supernet mask of [Link]. A router receives three
packets with the following destination addresses:
[Link]
[Link]
[Link]
Which packet belongs to the supernet?
3/27/2023 Network Layer 54
Solution
We apply the supernet mask to see if we can find
the beginning address.
[Link] AND [Link] ➔ [Link]
[Link] AND [Link] ➔ [Link]
[Link] AND [Link] ➔ [Link]
Only the first address belongs to this supernet.
3/27/2023 Network Layer 55
Example 14[5]
A supernet has a first address of [Link] and a
supernet mask of [Link]. How many blocks are in
this supernet and what is the range of addresses?
Solution
The supernet has 21 1s. The default mask has 24 1s. Since
the difference is 3, there are 23 or 8 blocks in this supernet.
The blocks are [Link] to [Link]. The first
address is [Link]. The last address is [Link].
3/27/2023 Network Layer 56
Classless Addressing
• It is also known by CIDR (Classless Inter
Domain Routing) notation.
• Slash notation is also called CIDR
• It is denoted as A.B.C.D/n
3/27/2023 Network Layer 57
Example 15[5]
A small organization is given a block with the beginning
address and the prefix length [Link]/29 (in slash
notation). What is the range of the block?
Solution
The beginning address is [Link]. To find the last address we
keep the first 29 bits and change the last 3 bits to 1s.
Beginning:11001111 00010000 00100101 00011000
Ending : 11001111 00010000 00100101 00011111
There are only 8 addresses in this block.
3/27/2023 Network Layer 58
Solution (contd.)
We can find the range of addresses in Example 15 by
another method. We can argue that the length of the suffix
is 32 - 29 or 3. So there are 23 = 8 addresses in this block.
If the first address is [Link], the last address is
[Link] (24 + 7 = 31).
3/27/2023 Network Layer 59
A block in classes A, B, and C
can easily be represented in slash
notation as
A.B.C.D/ n
where n is
either 8 (class A), 16 (class B), or
24 (class C).
3/27/2023 Network Layer 60
Example 16[5]
What is the network address if one of the addresses is
[Link]/27?
Solution
The prefix length is 27, which means that we must keep
the first 27 bits as is and change the remaining bits (5) to
0s. The 5 bits affect only the last byte. The last byte is
01010010. Changing the last 5 bits to 0s, we get 01000000
or 64. The network address is [Link]/27.
3/27/2023 Network Layer 61
Example 17[5]
An organization is granted the block [Link]/26.
The organization needs to have four subnets. What are the
subnet addresses and the range of addresses for each
subnet?
Solution
The suffix length is 6. This means the total number
of addresses in the block is 64 (26). If we create
four subnets, each subnet will have 16 addresses.
3/27/2023 Network Layer 62
Solution (Continued)
Let us first find the subnet prefix (subnet mask). We need
four subnets, which means we need to add two more 1s to
the site prefix. The subnet prefix is then /28.
Subnet 1: [Link]/28 to [Link]/28.
Subnet 2 : [Link]/28 to [Link]/28.
Subnet 3: [Link]/28 to [Link]/28.
Subnet 4: [Link]/28 to [Link]/28.
See Figure 3 on next slide
3/27/2023 Network Layer 63
Figure-3 Example 14
3/27/2023 Network Layer 64
Example 18[5]
An ISP is granted a block of addresses starting with
[Link]/16. The ISP needs to distribute these addresses
to three groups of customers as follows:
1. The first group has 64 customers; each needs 256 addresses.
2. The second group has 128 customers; each needs 128 addresses.
3. The third group has 128 customers; each needs 64 addresses.
Design the subblocks and give the slash notation for each subblock.
Find out how many addresses are still available after these
allocations.
3/27/2023 Network Layer 65
Solution
Group 1
For this group, each customer needs 256 addresses. This
means the suffix length is 8 (28 = 256). The prefix length is
then 32 - 8 = 24.
01: [Link]/24 ➔[Link]/24
02: [Link]/24 ➔[Link]/24
…………………………………..
64: [Link]/24➔[Link]/24
Total = 64 256 = 16,384
3/27/2023 Network Layer 66
Solution (Continued)
Group 2
For this group, each customer needs 128 addresses. This
means the suffix length is 7 (27 = 128). The prefix length is
then 32 - 7 = 25. The addresses are:
001: [Link]/25 ➔[Link]/25
002: [Link]/25 ➔[Link]/25
……………………………………………
128: [Link]/25 ➔[Link]/25
Total = 128 128 = 16,384
3/27/2023 Network Layer 67
Solution (Continued)
Group 3
For this group, each customer needs 64 addresses. This
means the suffix length is 6 (26 = 64). The prefix length is
then 32 - 6 = 26. The addresses are:
001: [Link]/26 ➔[Link]/26
002: [Link]/26 ➔[Link]/26
……………………………………………
128: [Link]/26 ➔[Link]/26
Total = 128 64 = 8,192
3/27/2023 Network Layer 68
IP Protocol [2]
• Internet Protocol (IP) is the glue
– It facilitates packets to be transported across different types of networks,
from source host to destination host
3/27/2023 Network Layer 69
IP packet format [2]
version of the IP IP header length in used for DiffServ length of header +
protocol 32 bit words payload
Specified in terms
Unique packet id “do not fragment” “more fragments” of “no of 8 bytes”
3/27/2023 Network Layer 70
IP Packet Format [2]
Helps to limit the no. of Protocol used to generate the 16 bit checksum,
hops or time spent in the payload (TCP, UDP etc.) covers header only
network
Source IP address Optional information, Destination IP address
such as source route
3/27/2023 Network Layer 71
NAT – Network Address Translation [2]
Placement and operation of a NAT box.
3/27/2023 Network Layer 72
IP Fragmentation
• The Identification field, and Fragment offset field along
with Don't Fragment and More Fragment flags in the IP
protocol header are used for fragmentation and
reassembly of IP datagram's.
• In a case where a router receives a protocol data
unit (PDU) larger than the next hop's MTU(Maximum
Transfer Unit).
• It has two options if the transport is IPv4. Drop the PDU
and send an Internet Control Message Protocol(ICMP)
message which indicates the condition Packet too Big.
• Or to fragment the IP packet and send it over the link
with a smaller MTU.
3/27/2023 Network Layer 73
IPv6 [6]
• Initial motivation: 32-bit address space soon
to be completely allocated.
• Additional motivation:
– header format helps speed processing/forwarding
– header changes to facilitate QoS
IPv6 datagram format:
– fixed-length 40 byte header
– no fragmentation allowed
3/27/2023 Network Layer 4-74
IPv6 Header (Cont) [6]
Priority: identify priority among datagrams in flow
Flow Label: identify datagrams in same “flow.”
(concept of“flow” not well defined).
Next header: identify upper layer protocol for data
3/27/2023 Network Layer 4-75
Other Changes from IPv4
• Checksum: removed entirely to reduce
processing time at each hop
• Options: allowed, but outside of header,
• ICMPv6: new version of ICMP
– additional message types, e.g. “Packet Too Big”
– multicast group management functions
3/27/2023 Network Layer 4-76
Transition From IPv4 To IPv6
• Not all routers can be upgraded simultaneous
– no “flag days”
– How will the network operate with mixed IPv4 and
IPv6 routers?
• Dual Stack: each node will have IPv4/IPv6
datagram ( for detail refer Kurose book )
• Tunneling: IPv6 carried as payload in IPv4
datagram among IPv4 routers
3/27/2023 Network Layer 4-77
Tunneling
A B E F
Logical view: tunnel
IPv6 IPv6 IPv6 IPv6
A B E F
Physical view:
IPv6 IPv6 IPv4 IPv4 IPv6 IPv6
3/27/2023 Network Layer 4-78
Tunneling [6]
A B E F
Logical view: tunnel
IPv6 IPv6 IPv6 IPv6
A B C D E F
Physical view:
IPv6 IPv6 IPv4 IPv4 IPv6 IPv6
Flow: X Src:B Src:B Flow: X
Src: A Dest: E Dest: E Src: A
Dest: F Dest: F
Flow: X Flow: X
Src: A Src: A
data Dest: F Dest: F data
data data
A-to-B: E-to-F:
B-to-C: B-to-C:
IPv6 IPv6
IPv6 inside IPv6 inside
IPv4 IPv4
3/27/2023 Network Layer 4-79
Routing: the problem
• Largely concerned with routing datagram's through a subnet
• Between a pair of source-destination devices, packets may have to
traverse several “subnets”
• Routing tables are updated every T seconds
H1 H4
H5
H2 LAN Router1 Router2 LAN H6
H3 Router1
3/27/2023 Network Layer 80
Routing
• Performance metric :
– Number of hops
– Measured delay
– Mean queue length
– Avg traffic
– Bandwidth
– Transmission delay
3/27/2023 Network Layer 81
Routing protocols: classification
• Static routes
– Computed off-line
– based on certain topology, traffic, Routing
performance metric algorithms
– Not change, unless there is a
major network overhaul
• Adaptive routing
static adaptive others
– Routes adapt to changes in
topology, traffic
– On-line based on current
measurements Centralized (based Decentralized (on
– Based on complete or partial on all info) incomplete info)
knowledge
– Distributed computation vs.
centralized computation
• Other algorithms
– Flooding
– Broadcasting
3/27/2023 Network Layer 82
Routing module and routing table [5]
3/27/2023 Network Layer 83
Shortest Path Routing Algorithm [6]
Dijkstra’s algorithm Notation:
• net topology, link costs known to • c(x,y): link cost from node x to
all nodes y; = ∞ if not direct neighbors
– accomplished via “link state
• D(v): current value of cost of
broadcast”
path from source to dest. v
– all nodes have same info
• computes least cost paths from
• p(v): predecessor node along
path from source to v
one node (‘source”) to all other
nodes • N': set of nodes whose least cost
– gives forwarding table for path definitively known
that node
• iterative: after k iterations, know
least cost path to k dest.’s
3/27/2023 Network Layer 4-84
Dijsktra’s Algorithm [6]
1 Initialization:
2 N' = {u}
3 for all nodes v
4 if v adjacent to u
5 then D(v) = c(u,v)
6 else D(v) = ∞
7
8 Loop
9 find w not in N' such that D(w) is a minimum
10 add w to N'
11 update D(v) for all v adjacent to w and not in N' :
12 D(v) = min( D(v), D(w) + c(w,v) )
13 /* new cost to v is either old cost to v or known
14 shortest path cost to w plus cost from w to v */
15 until all nodes in N'
3/27/2023 Network Layer 4-85
Shortest Path Routing (Dijkstra’s Algorithm) [6]
Step N' D(v),p(v) D(w),p(w) D(x),p(x) D(y),p(y) D(z),p(z)
0 u 2,u 5,u 1,u ∞ ∞
1 ux 2,u 4,x 2,x ∞
2 uxy 2,u 3,y 4,y
3 uxyv 3,y 4,y
4 uxyvw 4,y
5 uxyvwz
v 3 w
2 5
u 2 1 z
3
1 2
x y
1
3/27/2023 Network Layer 4-86
Dijkstra’s Algorithm(2)
Resulting shortest-path tree from u:
v w
u z
x y
Resulting forwarding table in u:
destination link
v (u,v)
x (u,x)
y (u,x)
w (u,x)
z (u,x)
3/27/2023 Network Layer 4-87
Adaptive routing
• Distance-vector routing
• Link-state routing
• Others
– Hierarchical routing
• Standards
– OSPF
– BGP
3/27/2023 Network Layer 88
Distance Vector Algorithm (1) [6]
Bellman-Ford Equation (dynamic programming)
Define
dx(y) := cost of least-cost path from x to y
Then
dx(y) = min {c(x,v) + dv(y) }
where min is taken over all neighbors of x and v
belongs to neighbors of x
3/27/2023 Network Layer 4-89
DVR:Bellman-Ford Example (2) [6]
5
Clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
v 3 w
2 5
u z B-F equation says:
2 1
3
1 du(z) = min { c(u,v) + dv(z),
x y 2
1 c(u,x) + dx(z),
c(u,w) + dw(z) }
= min {2 + 5,
1 + 3,
5 + 3} = 4
Node that achieves minimum is next
hop in shortest path ➜ forwarding table
3/27/2023 Network Layer 4-90
Distance Vector Algorithm (3)
• Dx(y) = estimate of least cost from x to y
• Distance vector: Dx = [Dx(y): y є N ]
• Node x knows cost to each neighbor v: c(x,v)
• Node x maintains Dx = [Dx(y): y є N ]
• Node x also maintains its neighbors’ distance
vectors
– For each neighbor v, x maintains
Dv = [Dv(y): y є N ]
3/27/2023 Network Layer 4-91
Distance Vector Algorithm (4)
Basic idea:
• Each node periodically sends its own distance vector estimate
to neighbors v
• When a node x receives new DV estimate from neighbor, it
updates its own DV using Bellman-Ford equation:
D x(y) ← min v{c( x, v) + D v(y)} for each node y ∊ N, v ∊ neighbor
Under minor, natural conditions, the estimate D x(y)
converge the actual least cost d x(y)
3/27/2023 Network Layer 4-92
Distance Vector Routing (1) [2]
• Also known as Bellman-Ford routing
– Used in ARPANET, till 1979
• Each router maintains a routing table, with estimated “distance” to each
destination (and updates it periodically)
• Each router periodically exchanges this table with its neighbors
At node J
3/27/2023 Network Layer 93
Distance Vector Routing (2) [2]
• Each router measures “distance” on each outgoing link
– Using e.g. queue length, round-trip delay
• It re-computes the routes as follows:
At node J
3/27/2023 Network Layer 94
DVR: Count-to-infinity Problem [2]
• Several problems with Distance Vector routing:
– Poor estimate of delays along each link
– Count-to-infinity problem:
• Good news spreads fast
• Bad news travels slow, very slow
3/27/2023 Network Layer 95
Complexity of LS vs DV Algorithms [6]
Message complexity
– LS: with n nodes, E links, O(nE) msgs sent
– DV: exchange between neighbors only
Speed of Convergence
– LS: O(n2) algorithm requires O(nE) msgs
– DV: convergence time varies
• may be routing loops
• count-to-infinity problem
3/27/2023 Network Layer 4-96
DVR vs Link State Routing
• Distance Vector Routing:
– Tell neighbors about distance of all the destination
– Node’s computation depends on neighbors
– Each router maintains distance vector, (dist , cost) tuple per destination
– Periodically send copy of distance vector to all neighbors
– DV node can advertise incorrect path cost
– each node’s table used by others that leads to error propagate through network
• Link State Routing :
– node can advertise incorrect link cost
– each node computes only its own table
– Tell about distance to each neighbor to all routers
– Each router computes its best paths
3/27/2023 Network Layer 97
Hierarchical Routing [2]
• Essentially solves “scalability” problem for large networks
• Considers a network to consist of a connected network of regional networks
• Routing is either within the local region, or across regions
• Multiple levels of hierarchy ( 2 or more)
3/27/2023 Network Layer 98
Hierarchical Routing(2) [2]
• Significant saving in size of routing tables
– In example below, entries in table at 1A:
• for local destination: 3 (size of local network)
• For other regions: 4 (one for every other region)
– For a network with say 720 routers organized as 8 regional networks, each
consisting of 9 sub-nets, each of which contains 10 routers:
• 10 entries, one for each router in its sub-net
• 8 entries, one for every other sub-net
• 7 entries, one for every other regional network
3/27/2023 Network Layer 99
Internet Routing [6]
Example: Choosing among multiple ASes
• Now suppose AS1 learns from the inter-AS protocol that subnet x
is reachable from AS3 and from AS2.
• To configure forwarding table, router 1d must determine towards
which gateway it should forward packets for destination x.
• This is also the job on inter-AS routing protocol!
3c
3a 2c
3b 2a
AS3 2b
1c
AS2
1a 1b
1d AS1
Network Layer 4-100
Internet Routing [6]
Example: Choosing among multiple ASes
• Now suppose AS1 learns from the inter-AS protocol that subnet
x is reachable from AS3 and from AS2.
• To configure forwarding table, router 1d must determine
towards which gateway it should forward packets for
destination x.
• This is also the job on inter-AS routing protocol!
• Hot potato routing: send packet towards closest of two routers.
Use routing info Determine from
Learn from inter-AS Hot potato routing: forwarding table the
from intra-AS
protocol that subnet Choose the gateway interface I that leads
protocol to determine
x is reachable via that has the to least-cost gateway.
costs of least-cost
multiple gateways smallest least cost Enter (x,I) in
paths to each
of the gateways forwarding table
3/27/2023 Network Layer 4-101
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
proprietary)
3/27/2023 Network Layer 4-102
RIP ( Routing Information Protocol) [6]
• Distance vector algorithm is used by RIP.
• Included in BSD-UNIX Distribution in 1982
• Distance metric: # of hops (max = 15 hops)
u destination hops
v
u 1
A B w v 2
w 2
x 3
x y 3
C D z 2
z
y
A’s Table
3/27/2023 Network Layer 4-103
RIP advertisements
• Distance vectors: exchanged among neighbors
every 30 sec via Response Message (also
called advertisement)
• Each advertisement: list of up to 25
destination nets within AS
3/27/2023 Network Layer 4-104
RIP: Example [6]
w x y
A D B
Destination Network Next Router Num. of hops to dest.
w A 2
y B 2
z B 7
x -- 1
…. …. ....
Routing table in D
3/27/2023 Network Layer 4-105
RIP: Example [6]
Dest Next hops
Advertisement
w - -
x - - from A to D
z C 4
…. … ...
z
w x y
A D B
C
Destination Network Next Router Num. of hops to dest.
w A 2
y B 2
z BA 75
x -- 1
…. …. ....
Routing table in D
3/27/2023 4-106
Network Layer
RIP: Link Failure and Recovery
If no advertisement heard after 180 sec --> neighbor/link declared
dead
– routes via neighbor invalidated
– new advertisements sent to neighbors
– neighbors in turn send out new advertisements (if
tables changed)
– link failure info quickly propagates to entire net
– Message in reverse direction (poison reverse) is used
to prevent ping-pong loops (infinite distance = 16
hops)
3/27/2023 Network Layer 4-107
RIP Table processing [6]
• RIP routing tables managed by application-level process
called routed
• Advertisements sent in UDP packets, periodically repeated
routed routed
Transprt Transprt
(UDP) (UDP)
network forwarding forwarding network
(IP) table table (IP)
link link
physical physical
3/27/2023 Network Layer 4-108
OSPF (Open Shortest Path First)
• “Open”: publicly available
• Uses Link State algorithm
– LS packet dissemination
– Topology map at each node
– Route computation using Dijkstra’s algorithm
• OSPF advertisement carries one entry per neighbor
router
• Advertisements disseminated to entire AS (via flooding)
– Carried in OSPF messages directly over IP (rather
than TCP or UDP
3/27/2023 Network Layer 4-109
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; high
for real time)
• Integrated unicast and multicast support:
– Multicast OSPF (MOSPF) uses same topology data
base as OSPF
• Hierarchical OSPF in large domains.
3/27/2023 Network Layer 4-110
Hierarchical OSPF [6]
3/27/2023 Network Layer 4-111
Hierarchical OSPF
• Two-level hierarchy: local area, backbone.
– Link-state advertisements only in area
– each nodes has detailed area topology; only know
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.
3/27/2023 Network Layer 4-112
Internet inter-AS routing: BGP
• BGP (Border Gateway Protocol): the de facto
standard
• BGP provides each AS a means to:
1. Obtain subnet reachability information from
neighboring ASs.
2. Propagate the reachability information to all routers
internal to the AS.
3. Determine “good” routes to subnets based on
reachability information and policy.
• Allows a subnet to advertise its existence to rest
of the Internet: “I am here”
3/27/2023 Network Layer 4-113
BGP Basics [6]
• Pairs of routers (BGP peers) exchange routing info over semi-
permanent TCP connections: BGP sessions
• Note that BGP sessions do not correspond to physical links.
• When AS2 advertises a prefix to AS1, AS2 is promising it will
forward any datagram's destined to that prefix towards the prefix.
– AS2 can aggregate prefixes in its advertisement
3c
3a 2c
3b 2a
AS3 2b
1c
AS2
1a 1b
AS1 1d
eBGP session
iBGP session
3/27/2023 Network Layer 4-114
Distributing Reachability Info[6]
• With eBGP session between 3a and 1c, AS3 sends prefix
reachability info to AS1.
• 1c can then use iBGP to distribute this new prefix reach info to all
routers in AS1
• 1b can then re-advertise the new reach info to AS2 over the 1b-
to-2a eBGP session
• When router learns about a new prefix, it creates an entry for the
prefix in its forwarding table.
3c
3a 2c
3b 2a
AS3 2b
1c
AS2
1a 1b
AS1 1d
eBGP session
iBGP session
3/27/2023 Network Layer 4-115
Path attributes & BGP routes
• When advertising a prefix, advert includes BGP attributes.
– prefix + attributes = “route”
• Two important attributes:
– AS-PATH: contains the ASs through which the advert for the prefix
passed: AS 67 AS 17
– NEXT-HOP: Indicates the specific internal-AS router to next-hop AS.
(There may be multiple links from current AS to next-hop-AS.)
• When gateway router receives route advert, uses import
policy to accept/decline.
3/27/2023 Network Layer 4-116
BGP Route Selection [6]
• Router may learn about more than 1 route to
some prefix. Router must select route.
• Elimination rules:
1. Local preference value attribute: policy decision
2. Shortest AS-PATH
3. Closest NEXT-HOP router: hot potato routing
4. Additional criteria
3/27/2023 Network Layer 4-117
BGP Messages [6]
• BGP messages exchanged using TCP.
• BGP messages:
– OPEN: opens TCP connection to peer and
authenticates sender
– UPDATE: advertises new path (or withdraws old)
– KEEPALIVE keeps connection alive in absence of
UPDATES; also ACKs OPEN request
– NOTIFICATION: reports errors in previous msg;
also used to close connection
3/27/2023 Network Layer 4-118
Broadcast Routing
• Deliver packets from source to all other nodes
• Source duplication is inefficient:
duplicate
duplicate R1 creation/transmission R1
duplicate
R2 R2
R3 R4 R3 R4
source in-network
duplication duplication
Source duplication: how does source determine
recipient addresses?
3/27/2023 Network Layer 4-119
In-network duplication
• Flooding: when node receives broadcast packet,
sends copy to all neighbors
– Problems: cycles & broadcast storm
• Controlled flooding: node only broadcast packet
if it hasn’t broadcast same packet before
– Node keeps track of packet ids already broadcasted
– Or reverse path forwarding (RPF): only forward packet
if it arrived on shortest path between node and
source
• Spanning tree
– No redundant packets received by any node
3/27/2023 Network Layer 4-120
Reverse Path Forwarding: example
S: source
LEGEND
R1
R4 router with attached
group member
R2
router with no attached
R5 group member
R3 datagram will be
R6 R7 forwarded
datagram will not be
forwarded
• result is a source-specific reverse SPT
– may be a bad choice with asymmetric links
Spanning Tree
• First construct a spanning tree
• Nodes forward copies only along spanning
tree
A A
B B
c c
D D
F E F E
G G
(a) Broadcast initiated at A (b) Broadcast initiated at D
3/27/2023 Network Layer 4-122
Multicast Routing: Problem Statement
• Goal: find a tree (or trees) connecting routers
having local mcast group members
– tree: not all paths between routers used
– source-based: different tree from each sender to rcvrs
– shared-tree: same tree used by all group members
Shared tree Source-based trees
3/27/2023 Network Layer 123
Approaches For Building Mcast Trees
Approaches:
• source-based tree: one tree per source
– shortest path trees
– reverse path forwarding
• group-shared tree: group uses one tree
– minimal spanning ( Work out this only)
– center-based trees
3/27/2023 Network Layer 124
Internet Control Protocols [2]
• Several protocols:
– ARP, RARP (these are discussed later)
– ICMP
• Several messages, including “echo” and “echo-reply” used to “ping” hosts
• These are encapsulated inside an IP packet
3/27/2023 Network Layer 125
ARP Protocol [2]
• ARP protocol: “address resolution protocol”
– IP address ➔ Data-link (or physical) address
– This is distinct from ”domain-name” ➔ IP address problem
3/27/2023 Network Layer 126
ARP Protocol(2) [2]
• ARP protocol:
– ARP-REQ ARP-REPLY packets
• ARP-REQ is broadcast over local subnet only
– Destination IP address ➔ Ethernet address is cached by source, once a
reply is received
– The destination also caches similar info about the source
3/27/2023 Network Layer 127
ARP Protocol(3) [2]
• Consider H1 to H4 communication
– H1 issues an ARP-REQ, to which CS router responds with its E3 address
– CS router issues an ARP-REQ on FDDI ring, to which EE router responds
with its F3 address
– EE router issues an ARP-REQ on the Ethernet, to which H4 responds with
its E6 address
3/27/2023 Network Layer 128
RARP Protocol
• ARP gives IP-addr ➔ Physical-addr
• RARP solves the problem of “what is my IP address”?
– A problem that occurs in disk-less workstations, that have no
disk resident OS
• RARP-REQ issued by client, while RARP-REPLY is sent by RARP
server
• Need a RARP server for each network separated by a router
• BOOTP - It also provides a diskless workstation with additional
information
– including the IP address of the file server holding the memory image and the
IP address of the default router
• Both problems solved using DHCP protocol
3/27/2023 Network Layer 129
Dynamic Host Configuration Protocol [2]
Operation of DHCP.
3/27/2023 Network Layer 130
References
1. William Stallings, “Data and Computer Communications”, Seventh
Edition, PHI 2004.
2. Andrew S. Tanenbaum, ”Computer Networks” 4th Edition PHI
3. B. A. Fourozan, “TCP/IP Protocol Suite”, 3rd Edition, Singapore,
McGrawHill, 2004.
4. L. L. Peterson and B. S. Davie, Computer Networks-A System
Approach, Elsevier.
5. B. A. Fourozan, “Data Communications and Networking”, 4th Edition,
Singapore, McGrawHill, 2004.
6. James F. Kurose, Keith W. Ross, “Computer Networking: A Top-
Down Approach Featuring the Internet”, 3rd Edition , Pearson
Education 2009.
7. [Link]
8. PPT available for the respective books
3/27/2023 Network Layer 131
Thank You
3/27/2023 Network Layer 132