18CS52 Module 3
18CS52 Module 3
18CS52 Module 3
Chapter 4
Network Layer
• Introduction
• Virtual Circuit and Datagram Networks
• What’s inside a Router?
• Internet Protocol (IP): Datagram Format, IPv4 Addressing,
ICMP, IPv6
• Routing Algorithms: Link state, Distance vector, Hierarchical
routing
• Routing in the Internet: RIP, OSPF, BGP
• Broadcast and Multicast routing
Network Layer Services
Host-to-Host transmission of messages (Transport
segments) from sending to receiving host
Sending side - encapsulates segments into datagrams and
send to DLL
Receiving side - decapsulate datagrams and deliver segments
to transport layer
Network Layer Protocols in Routers
Router examines header fields in all IP datagrams
passing through it
Routing: Determine route to be taken by packets
from source to destination
Forwarding: Move packets from router’s input to
appropriate router output
Network Layer Service Models
Two fundamental classes of Computer Networks
Datagram Network: Provides connectionless service
Internet
Virtual-Circuit Network: Provides connection service
ATM, Frame Relay
IP destination address in
arriving packet’s header
1
3 2
Datagram Network - Forwarding
Destination Address Range Link Interface
11001000 00010111 00010000 00000000
through 0
11001000 00010111 00010111 11111111
otherwise 3
Destination Address Range Link interface
11001000 00010111 00010*** ********* 0
11001000 00010111 00011000 ********* 1
11001000 00010111 00011*** ********* 2
otherwise 3
Network Layer Service Models
Virtual-Circuit Network
Guaranteed delivery
Guaranteed delivery with bounded delay
In-order packet delivery
Guaranteed minimal bandwidth
Guaranteed maximum jitter
Security services
E.g. ATM, Frame Relay
Virtual-Circuit Networks
A VC consists of
1. Path from source to destination
2. VC numbers, one number for each link along path
3. Entries in forwarding tables in routers along path
Packet carry VC number (rather than destination address)
VC number is changed on each link - new VC number
comes from Forwarding Table
Phases: VC Setup, Data Transfer, VC Teardown
VC Signaling Protocols
• Used to Setup, Maintain, Teardown VC
• Used in ATM, Frame-Relay, X.25
• Not used in today’s Internet
Virtual-Circuit Networks
• Routers along the path between the two end systems are
involved in VC setup
• Each router is fully aware of all the VCs passing through it
• VC routers maintain connection state information!
12 22 32
1 3
2
VC number
interface
number
Forwarding Table
Incoming interface Incoming VC # Outgoing interface Outgoing VC #
1 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87
… … … …
Router
Forwarding
Data plane (Hardware)
High-seed
Switching
Fabric
1.Input Ports
• Performs the physical layer function of terminating an incoming
physical link - leftmost box
• Performs link-layer functions needed to interoperate with the link
layer at the other side of the incoming link - middle box
• Lookup function is also performed - rightmost box
• Control packets (packets carrying routing protocol information) are
forwarded to the routing processor
Router
2. Switching Fabric
• Connects the router’s input ports to its output ports
• Completely contained within the router— a Network inside of a
network router!
3. Output Ports
• Store packets received from the switching fabric and transmits them
on the outgoing link by performing the necessary Link-layer and
Physical-layer functions
• Performs Link-layer functions needed to interoperate with the link layer at
the other side of the incoming link - middle box
• Performs the Physical layer function of terminating an incoming physical
link - rightmost box
Router
4. Routing Processor
• Executes the routing protocols
• Maintains routing tables and attached link state information,
• Computes the forwarding table for the router
• Performs the network management functions
Lookup,
Link Forwarding
Line Layer Switch
Termination Protocol Fabric
(Receive)
Queueing
Physical Layer:
Bit-level reception
Decentralized Switching:
Data Link Layer
• Given datagram destination, lookup output
port using Forwarding Table in input port
memory (“match plus action”)
• Goal: Complete input port processing at ‘line
speed’
• Queuing: If datagrams arrive faster than
forwarding rate into switch fabric
Router – Switching via Memory
• Switching can be accomplished in 3 ways:
Via Memory/ Via Bus/ Via an Interconnection Network
1. Switching via Memory
• First generation routers - Computers with switching
under control of CPU
• Packet is copied to system’s memory. Routing
processor extracts the destination address from the
header, looks up the appropriate output port in the
Forwarding Table - copies the packet to the output
port’s buffers
• Speed limited by memory bandwidth (2 bus crossings
per datagram)
memory
Router – Switching via Bus
2. Switching via Bus
• Input port pre-pends a Label (Header) to the packet
indicating the output port to which this packet is being
transferred and transmits onto the bus
• The packet is received by all output ports, but only the
port that matches the label will keep the packet
• The Label is then removed at the output port
• Every packet must cross the single bus - switching
speed is limited to the bus speed
Router – Switching via network
2. Switching via interconnection network
• A Crossbar Switch that connects N input ports to N
output ports is used
• Forwarding is done by closing the appropriate cross-
point switch
• Multiple packets can be forwarded in parallel (except
when the destinations are same)
Router – Output Processing
Queueing
(Buffer) Data Link
Switch Management) Layer Line
Fabric Protocol Termination
(Encapsulation)
Routing Protocols IP
• Path Selection • Addressing Conventions
• RIP, OSPF, BGP • Datagram Format
• Packet Handling Conventions
Network
Layer Forwarding
ICMP
Table
• Error Reporting
• Router “Signaling”
Link Layer
Physical Layer
IPv4 Datagram Format
3 Bits
32 bits
Version Traffic
4 Class 8 Flow Label 20
16 Bytes
Data
IPv6
1. Version: 4-bits - Identifies the IP version number – 0110
2. Traffic Class: 8-bits - Similar to the TOS in IPv4
3. Flow Label: 20-bits is used to identify a flow of datagrams
4. Payload Length: 16-bits - Treated as an unsigned integer
giving the number of bytes of data after the header
5. Next Header: 8-bits - Identifies the protocol to which the
contents (data field) of this datagram will be delivered
(TCP / UDP) - Same as the Protocol field in IPv4
6. Hop Limit: 8-bits – Value decremented by one by each
router that forwards the datagram. If it reaches zero, the
datagram is discarded – Same as TTL of IPv4
7 & 8. Source and Destination Addresses: 128-bits – 8
groups of 16 bits - denoted as Hexadecimal Number –
separated by colons
Transition from IPv4 to IPv6
• Abrupt transition (declaring a Flag Day) is not
feasible. Hence two solutions:
1. Dual-Stack Approach
• Nodes will have both IPv4 and IPv6 protocols and
addresses
• To determine if another node is IPv6 enables – DNS must
give the information while returning address
• Problem: IPv6 to IPv4 can be correctly done and the
reverse will not be correct as some fields of IPv6 are not
present in IPv4
Transition from IPv4 to IPv6
2. Tunneling
• If two IPv6 nodes are interconnected by an IPv4 node, the
sender encapsulates IPv6 datagram in an IPv4 datagram
and sends it to the intermediate node. This is then
forwarded to the next IPv6 node
3
v w
2 5
u 2 1 z
3
1
2
x y
1
•v, x, and w are the neighbours to u
•dv(z) = 5, dx(z) = 3, dw(z) = 3
•B-F equation:
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
Distance Vector Routing Algorithm
1 Initialization:
2 for all destinations y in N:
3 Dx(y) = c(x,y) /* if y is not a neighbor then c(x,y) = ∞ */
4 for each neighbor w
5 Dw(y) = ? for all destinations y in N
6 for each neighbor w
7 send distance vector Dx = [Dx(y): y in N] to w
8
9 loop
10 wait (until there is a link cost change to some neighbor w or
11 until a distance vector from some neighbor w is received)
12
13 for each y in N:
14 Dx(y) = minv{c(x,v) + Dv(y)}
15
16 if Dx(y) changed for any destination y
17 send distance vector Dx = [Dx(y): y in N] to all neighbors
18
19 forever
Distance Vector Routing Algorithm
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
Each Node: = min{2+0 , 7+1} = 2
from
y ∞∞ ∞ y 2 0 1
from
recompute estimates
z ∞∞ ∞ z 7 1 0
if DV to any dest has
node y cost to
changed, notify table x y z Dx(z) = min{c(x,y) +
neighbors
x ∞ ∞ ∞ Dy(z), c(x,z) + Dz(z)}
from
y 2 0 1 = min{2+1 , 7+0} = 3
z ∞∞ ∞
node z cost to
table x y z
x ∞∞ ∞
from
y ∞∞ ∞
z 7 1 0
Distance Vector Routing Algorithm
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)}
node x cost to cost to = min{2+1 , 7+0} = 3
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
y ∞∞ ∞ y 2 0 1
from
y 2 0 1
from
z ∞∞ ∞ z 7 1 0 z 3 1 0
node y cost to cost to cost to
table x y z x y z x y z
x ∞ ∞ ∞ x 0 2 7 x 0 2 3
from
y 2 0 1 y 2 0 1
from
y 2 0 1
from
z ∞∞ ∞ z 7 1 0 z 3 1 0
from
y 2 0 1 y 2 0 1
from
y ∞∞ ∞
z 7 1 0 z 3 1 0 z 3 1 0
time
Distance Vector Routing Algorithm
Link-Cost Changes and Link Failure
•Good news about the decreased cost between nodes
propagates quickly through the network
•when a link cost (x,y) increases: