UNIT 4-1
UNIT 4-1
Network Layer
1.Introduction,
3.Inside Router,
Key Components
1.Fixed Path – A dedicated route is set before data
transfer.
2.VC Numbers – Each link in the path gets a unique
number to identify the connection.
3.Forwarding Table – Routers store VC numbers to
forward packets properly.
How It Works?
4.Each packet carries a VC number in its header.
Routing and Forwarding
value in arriving
packet’s header
0111 1
3 2
Virtual Circuit Setup
application
6. receive data application
transport 5. data flow begins transport
network 4. call connected 3. accept call
network
data link 1. initiate call 2. incoming call
data link
physical physical
Virtual Circuit Setup
Found in ATM, Frame Relay, and X.25 networks.
1. VC setup
2. Data transfer
3. VC teardown
1. VC setup:
Connection Request: Sender asks the network to create a
path to the receiver.
Path Selection: The network decides the best route for all
packets.
VC Number Assignment: Each link in the path gets a unique
number to track packets.
Router Configuration: Routers update their tables to forward
packets correctly.
Connection Confirmation: The network informs the sender
that the VC is ready for data transfer.
2. Data Transfer
Once the VC is set up, packets follow the fixed path to reach
their destination.
3. VC Teardown (Closing the Connection)
The sender or receiver requests to close the connection.
The network informs the other side and removes VC
information from routers.
The network layer updates all routers to delete the VC,
meaning it no longer exists.
VC Forwarding Table
3.Datagram Network
• In connectionless service, each packet is sent
individually and can take a different route to
reach the destination.
✔ No setup is needed before sending packets.
✔ These packets are called datagrams, and the
network is a datagram subnet.
application application
transport transport
network 1. send datagrams 2. receive datagrams network
data link data link
physical physical
Datagram forwarding table
IP destination address in
arriving packet’s header
1
3 2
Network Layer
Datagram forwarding table
Destination Address Range Link Interface
otherwise 3
From above table,
examples:
which interface?
DA: 11001000 00010111 00010110 10100001
DA: 11001000 00010111 00011000 10101010which interface?
4. ROUTER
Components of a Router
1. Input Ports – Receive incoming data packets.
2. Switching Fabric – Moves packets inside the router.
Inside Router
Routers have four components:
1. Input ports
2. Switching fabric
3. Output ports
4. Routing processor
Input port functions
lookup,
link forwarding
line layer switch
termination protocol fabric
(receive)
queueing
physical layer:
bit-level reception
data link layer: decentralized switching:
e.g., Ethernet • given datagram dest., 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
Input Port
The input port in a router receives incoming data and prepares
it for forwarding.
Main Functions:
Functions:
1. Memory-Based Switching
•Uses router memory to store and send packets.
•The processor decides where to forward packets.
•Slowest because packets pass through memory.
2. Bus-Based Switching
•Uses one shared communication bus for all
packets.
•Only one packet moves at a time (limits speed).
•Faster than memory-based switching but still
slow.
3. Crossbar Switching
•Uses a grid of switches to connect ports directly.
Output Port
datagram
buffer line
switch link termination
fabric layer
queueing protocol
(send)
Output Port
The output port is responsible for sending packets from the
router to the next destination.
• Functions of an Output Port:
1.Buffering – Temporarily stores packets before sending.
2.Packet Transmission – Sends packets to the next device.
3.Congestion Handling – If the buffer is full, some packets may
be lost.
Bidirectional Links:
• Data can flow in both directions using input and output
ports together.
Routing Processor
The Routing Processor is like the brain of a
router. It decides where to send data packets.
Functions:
link layer
physical layer
Internet Network Layer
The Network Layer is responsible for moving data
between devices across different networks.
Key Components:
…
must be broken into in: one large datagram
smaller parts. out: 3 smaller datagrams
How does it work?
1.A large IP packet is split
into smaller packets
(fragments). reassembly
2.These fragments travel
separately through the
network.
3.At the final destination, …
the fragments are
reassembled into the
original packet.
4.Special header bits help to
identify and order the
fragments correctly.
IP fragmentation Example
✔ What happens?
172 16 254 1
• ✔ IP Address Structure
Divided into 2 parts:
1. Network ID (NID) → Identifies the network.
2.Host ID (HID) → Identifies the device in that network.
IP Address = Network ID + Host ID
IP Addressing - Example
• IP address: It is 32-bit 223.1.1.1
identifier for host, router
interface 223.1.1.2
223.1.2.1
223.1.1.4 223.1.2.9
• Interface: It is a connection
between host/router and 223.1.3.27
physical link. 223.1.1.3
223.1.2.2
223 1 1 1
Interface Example
223.1.1.1
Q: how are interfaces actually
connected? 223.1.2.1
223.1.1.2
223.1.1.4 223.1.2.9
223.1.3.27
223.1.1.3
223.1.2.2
7 Bit 24 Bit
Fix Network ID Host ID
Class: B
1 0
Fix
Class: E Multicast address
1 1 1 1
223.1.3.0/24
subnet
223.1.3.1 223.1.3.2
223.1.3.0/24
Type of addresses in IPv4 Network
• Network address - The address by which we refer to the network.
• E.g.: 10.0.0.0
subnet host
part part
11001000 00010111 00010000 00000000
200.23.16.0/23
Classless Inter-Domain Routing(CIDR)
• CIDR is a slash notation of subnet mask. CIDR tells us number of
on bits in a network address.
subnet host
part part
11001000 00010111 00010000 00000000
200.23.16.0/23
• A single IP address can be used to designate many unique IP
addresses with CIDR.
• CIDR addresses reduce the size of routing tables and make more IP
addresses available within organizations.
Subnetting
• Subnetting take places when we extend the default subnet mask.
• Now find the host bits borrowed to create subnets and convert them
in decimal.
• In second step find the block size and count from zero in block until
subnet mask value.
• We have 32 - 26
1. [Total bits in IP address - Bits consumed by network address] = 6
2. Total hosts per subnet would be 26 = 64
Network Prefixes
• For Class C, Default subnet mask of class C is 255.255.255.0
DHCP
223.1.1.0/24
server
223.1.1.1 223.1.2.1
223.1.2.0/24
223.1.3.1 223.1.3.2
223.1.3.0/24
• With dynamic addressing, a device can have a different IP address
every time it connects to the network.
DHCP offer
src: 223.1.2.5, 67
Broadcast: I’m a DHCP
dest: 255.255.255.255, 68
server!
yiaddrr:Here’s
223.1.2.4an IP
transaction
address youID:can
654 use
lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
Broadcast: OK. I’ll
yiaddrr: 223.1.2.4
take that IPID:address!
transaction 655
lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255,
Broadcast: 68
OK. You’ve
yiaddrr: 223.1.2.4
gottransaction
that IPID:address!
655
lifetime: 3600 secs
DHCP: More than IP addresses
DHCP can return more than just allocated IP address on subnet:
address of first-hop router for client
encapsulated in UDP,
DHCP DHCP 168.1.1.1 encapsulated in IP,
DHCP UDP encapsulated in 802.1
DHCP IP Ethernet frame
DHCP Eth router with DHCP
Phy server built into broadcast (dest:
router FFFFFFFFFFFF) on LAN,
received at router
running DHCP
Ethernet demuxedserver to
IP demuxed, UDP
demuxed to DHCP
DHCP DHCP • DCP server formulates DHCP
DHCP UDP ACK containing client’s IP
DHCP IP address, IP address of first-
DHCP Eth hop router for client, name
Phy & IP address of DNS server
encapsulation of
DHCP DHCP DHCP server, frame
DHCP UDP forwarded to client,
DHCP IP demuxing up to
Eth router with DHCP
DHCP
DHCP at client
DHCP
Phy server built into client now knows its
router IP address, name
and IP address of
DSN server, IP
address of its first-
hop router
Network Address Translation
• NAT is a method that is used to translate Private IP addresses to
Public IP addresses.
rest of local network
Internet (e.g., home network)
10.0.0/24 10.0.0.1
10.0.0.4
10.0.0.2
138.76.29.7
10.0.0.3
• Inside Global Address: The name of the inside host after translation. This
would be the Public IP.
• Outside Local Address: The name of the destination host before translation.
• Outside Global Address: The name of the destination host after translation.
• Where:
• Global Addresses → Public
• Local Addresses → Private
• Inside Hosts → Within Local Network
• Outside Hosts → Outside Local Network
Implementation : NAT router must:
• incoming datagrams: replace (NAT IP address, new port #) in dest fields of every
incoming datagram with corresponding (source IP address, port #) stored in NAT
table
NAT translation table 1: host 10.0.0.1
2: NAT router WAN side addr LAN side addr
changes datagram sends datagram to
source addr from 138.76.29.7, 5001 10.0.0.1, 3345 128.119.40.186, 80
10.0.0.1, 3345 to …… ……
138.76.29.7, 5001,
updates table S: 10.0.0.1, 3345
D: 128.119.40.186, 80
10.0.0.1
1
S: 138.76.29.7, 5001
2 D: 128.119.40.186, 80 10.0.0.4
10.0.0.2
138.76.29.7 S: 128.119.40.186, 80
D: 10.0.0.1, 3345
4
S: 128.119.40.186, 80
D: 138.76.29.7, 5001 3 10.0.0.3
4: NAT router
3: reply arrives changes datagram
dest. address: dest addr from
138.76.29.7, 5001 138.76.29.7, 5001 to 10.0.0.1, 3345
Internet Control Message Protocol - ICMP
• When something unexpected occurs, the event is reported by the
ICMP, which is also used to test the Internet.
• Some of the ICMP messages are defined and are listed below.
Each ICMP message type is encapsulated in an IP packet.
• additional motivation:
• header format helps speed processing/forwarding
• header changes to facilitate QoS
• Traffic Class:
• The size of Traffic Class field is 8 bits. Traffic Class field is similar to the IPv4 Type
of Service (ToS) field.
• The Traffic Class field indicates the IPv6 packet’s class or priority.
• Flow Label:
• The size of Flow Label field is 20 bits.
• The Flow Label field provide additional support for real-time datagram delivery and
quality of service features.
• The purpose of Flow Label field is to indicate that this packet belongs to a specific
sequence of packets between a source and destination and can be used to prioritized
delivery of packets for services like voice.
• Payload Length: The size of the Payload Length field is 16 bits. The Payload
Length field shows the length of the IPv6 payload, including the extension
headers and the upper layer protocol data
• Next Header: The size of the Next Header field is 8 bits. The Next Header
field shows either the type of the first extension (if any extension header is
available) or the protocol in the upper layer such as TCP, UDP, or ICMPv6.
• Hop Limit: The size of the Hop Limit field is 8 bits The Hop Limit field shows
the maximum number of routers the IPv6 packet can travel. This Hop Limit
field is similar to IPv4 Time to Live (TTL) field.
• Source Address: The size of the Source Address field is 128 bits. The Source
Address field shows the IPv6 address of the source of the packet.
Difference between IPv4 & IPv6
IPv4 IPv6
32 bit length 128 bit length
Fragmentation is done by sender Fragmentation is done only by sender
and forwarding routers
No packet flow identification Packet flow identification is available within
the IPv6 header using the Flow Label field
Checksum field in header No checksum field in header
Options fields are available in No option fields, but Extension headers are
header available
Address Resolution Protocol (ARP)is Address Resolution Protocol (ARP) is
available to map IPv4 addresses replaced with Neighbor Discovery Protocol
to MAC addresses
2. decentralized:
• router knows physically-connected neighbors, link costs to
neighbors
• iterative process of computation, exchange of info with neighbors
• “distance vector” algorithms
Second way
1. Static:
routes change slowly over time
2. Dynamic:
routes change more quickly
periodic update
in response to link cost changes
Third way
1. Load-sensitive algorithm
• In link costs vary dynamically to reflect the current level of
congestion in the underlying link.
• If a high cost is associated with a link that is currently congested,
a routing algorithm will tend to choose routes around such a
congested link.
•
2. Load-insensitive :
• Today’s Internet routing algorithms (such as RIP, OSPF, and BGP)
are load-insensitive, as a link’s cost does not explicitly reflect its
current (or recent past) level of congestion.
Link State Routing Algorithm
• Also known as Dijkstra’s Algorithm.
• It computes the least-cost path from one node (source node) to all
other nodes in the network.
• Its iterative and after the kth least-cost paths are known to k
destination nodes.
• Notation:
• c(x,y): link cost from node x to y; = ∞ if not direct neighbours
• D(v): current value of cost of path from source to destination v
• p(v): predecessor node along path from source to v
• N': set of nodes whose least cost path definitively known
Basics of Dijkstra's Algorithm
• Dijkstra's Algorithm basically starts at the node that you choose (the source
node) and it analyses the graph to find the shortest path between that node
and all the other nodes in the graph.
• The algorithm keeps track of the currently known shortest distance from each
node to the source node and it updates these values if it finds a shorter path.
• Once the algorithm has found the shortest path between the source node and
another node, that node is marked as "visited" and added to the path.
• The process continues until all the nodes in the graph have been added to the
path. This way, we have a path that connects the source node to all other
nodes following the shortest path possible to reach each node.
Dijkstra’s Algorithm
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'
Dijkstra’s Algorithm – Example:1
D(v) D(w) D(x) D(y) D(z)
Step N' p(v) p(w) p(x) p(y) p(z)
0 u 7,u 3,u 5,u ∞ ∞
1 uw 6,w 5,u 11,w ∞
2 uwx 6,w 11,w 14,x
3 uwxv 10,v 14,x
x
4 uwxvy 12,y 9
5 uwxvyz
5 7
4
notes: 8
construct shortest path 3
tree by tracing u w y z
2
predecessor nodes
ties can exist (can be 3
broken arbitrarily) 7 4
v
Dijkstra’s Algorithm – Example:2
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
Distance Vector Algorithm
• Distance-vector (DV) algorithm is iterative, asynchronous, and
distributed.
dx(y) = min
v
{c(x,v) + d v(y) }
from
from
y ∞∞ ∞ y 2 0 1
z ∞∞ ∞ z 7 1 0
Dx(z) = min{c(x,y) +
node y cost to
table x y z Dy(z), c(x,z) + Dz(z)}
x ∞ ∞ ∞ = min{2+1 , 7+0} = 3
y 2 0 1
from
z ∞∞ ∞
y
2 1
node z cost to
table x y z x z
7
x ∞∞ ∞
from
y ∞∞ ∞
z 7 1 0
time
Distance Vector Algorithm - Example
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 y 2 0 1
from
y
z ∞∞ ∞ z 7 1 0 z 3 1 0 2 1
node y cost to
x z
cost to cost to 7
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
x ∞∞ ∞ x 0 2 7 x 0 2 3
from
from
y 2 0 1 y 2 0 1
from
y ∞∞ ∞
z 7 1 0 z 3 1 0 z 3 1 0
time
Difference: LS and DV Routing Algorithm
Distance Vector Protocol Link State Protocol
Entire routing table is sent as an update Updates are incremental & entire routing table is
not sent as update
Distance vector protocol send periodic Updates are triggered not periodic
update at every 30 or 90 second
Update are broadcasted Updates are multicasted
Updates are sent to directly connected Update are sent to entire network & to just
neighbour only directly connected neighbour
Routers don't have end to end visibility Routers have visibility of entire network of that
of entire network. area only.
It is prone to routing loops No routing loops
Hierarchical Routing
• As networks grow in size, the router routing tables grow
proportionally.
• Each router knowing all the details about how to route packets to
destinations within its own region.
• One router was indistinguishable from another in the sense that all
routers executed the same routing algorithm to compute routing
paths through the entire network.
• At a certain point the network may grow to the point where it is no longer
feasible for every router to have an entry for every other router, so the
routing will have to be done hierarchically, as it is in the telephone
network.
2. Administrative autonomy.
• Although researchers tend to ignore issues such as a company’s
desire to run its routers as it pleases (for example, to run whatever
routing algorithm it chooses) or to hide aspects of its network’s
internal organization from the outside, these are important
considerations.
• Ideally, an organization should be able to run and administer its
network as it wishes, while still being able to connect its network
to other outside networks.
• When hierarchical routing is used, the routers are divided into what
called regions, with each router knowing all the details about how
to route packets to destinations within its own region, but knowing
nothing about the internal structure of other regions.
• Both of these problems can be solved by organizing routers into
autonomous systems (ASs), with each AS consisting of a group of
routers that are typically under the same administrative control
(e.g., operated by the same ISP or belonging to the same company
network).
• Routers within the same AS all run the same routing algorithm (for
example, an LS or DV algorithm)
• To connect ASs to each other, and thus one or more of the routers in
an AS will have the added task of being responsible for forwarding
packets to destinations outside the AS; these routers are called
gateway routers.
• When hierarchical routing is used, the routers are divided into what called
regions, with each router knowing all the details about how to route packets
to destinations within its own region, but knowing nothing about the
internal structure of other regions.
• Figure below provides a simple example with three ASs: AS1, AS2, and AS3.
• In figure, the heavy lines represent direct link connections between pairs of
routers.
• The thinner lines hanging from the routers represent subnets that are
directly connected to the routers.
Interconnected ASes
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d forwarding table
configured by both intra-
and inter-AS routing
Intra-AS
Routing
Inter-AS
Routing
algorithm
algorithm algorithm intra-AS sets entries for internal
dests
Forwarding inter-AS & intra-AS sets entries
table
for external dests
Inter-AS tasks
suppose router in AS1 AS1 must:
receives datagram destined 1. learn which dests are
outside of AS1: reachable through AS2,
router should forward packet to
gateway router, but which one?
which through AS3
2. propagate this
reachability info to all
routers in AS1
job of inter-AS routing!
3c
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Hierarchical Routing - Example
THANK YOU