Network Layer
Network Layer
value in arriving
packet’s header
0111 1
3 2
Network Service Model
• Services provided by network layer for individual datagrams.
• Guaranteed delivery
• This service guarantees that the packet will eventually arrive at its destination.
• Guaranteed delivery with bounded delay
• This service not only guarantees delivery of the packet, but delivery within a specified
host-to-host delay bound.
Network Service Model – Cont…
• Services provided by network layer for a flow of datagrams.
• In-order packet delivery
• This service guarantees that packets arrive at the destination in the order that they were
sent.
• Guaranteed minimum bandwidth
• This network-layer service emulates the behaviour of a transmission link of a specified bit
rate (for example, 1 Mbps) between sending and receiving hosts.
• As long as the sending host transmits bits at a rate below the specified bit rate, then no
packet is lost.
Network Service Model – Cont…
• Guaranteed maximum jitter
• This service guarantees that the amount of time between the transmission of two
successive packets at the sender is equal to the amount of time between their receipt at
the receiver.
• Security services
• Using a secret session key known only by a source and destination host, the network layer
in the source host could encrypt the payloads of all datagrams being sent to the
destination host.
• The network layer in the destination host would then be responsible for decrypting the
payloads.
Virtual Circuit Switching
• A VC consists of
1. A path between the source and destination hosts
2. VC numbers, one number for each link along the path
3. Entries in the forwarding table in each router along the path
• A packet belonging to a virtual circuit will carry a VC number in its header.
• VC number can be changed on each link
• New VC number comes from forwarding table
VC Forwarding Table
12 22 32
1 3
2
VC number
interface
number
Forwarding table in router:
Incoming interface Incoming VC # Outgoing interface Outgoing VC #
1 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87
… … … …
application application
5. data flow begins 6. receive data
transport transport
network 4. call connected 3. accept call
1. initiate call network
data link 2. incoming call
data link
physical physical
Datagram Network
• In connectionless service, packets are injected into the subnet individually and
routed independently of each other.
• No advance setup is needed. The packets are frequently called datagrams and the
subnet is called a datagram subnet.
• Only directly-connected lines can be used.
application application
transport transport
network 1. send datagrams 2. receive datagrams network
data link data link
physical physical
Datagram Network vs. Virtual Circuit Network
State Information None other than router table containing Route established at setup, all packets follow
destination network same route.
Effect of Router Failure Only on packets lost during crash All virtual circuits passing through failed router
terminated.
Congestion Control Difficult since all packets routed Simple by pre-allocating enough buffers to each
independently router resource requirements virtual circuit at setup, since maximum number of
can vary. circuits fixed.
Router Architecture
Router Architecture
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
memory
input output
port memory port
(e.g., (e.g.,
Ethernet) Ethernet)
system bus
• Like traditional computers, with switching between input and output ports being
done under direct control of the CPU (routing processor).
• Packet signalled a routing processor via an interrupt then copied from the input
port into processor memory.
Switching via Memory – Cont…
• Routing processor extracted the destination address from the header, from
forwarding table, and copied the packet to the output port buffers.
• If the memory bandwidth is such that B packets per second can be written into, or
read from, then the overall forwarding throughput must be less than B/2.
• Two packets cannot be forwarded at the same time, even if they have different
destination ports.
• Only one memory read/write over the shared system bus can be done at a time.
Switching via bus
• An input port transfers a packet to the output port over a shared bus, without
intervention by the routing processor.
• 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, and only used within the switch to
cross the bus.
• Switching speed of the router is limited to the bus speed. bus
Switching via an interconnection network
Crossbar switch consists 2N buses.
N input ports to N output ports.
Its overcome the bandwidth limitation of shared bus; used
to interconnect processors in a multiprocessor computer
architecture.
Cross-point connection can be opened or closed at any
time by the switch fabric controller.
Crossbar networks are capable of forwarding multiple
packets in parallel.
Output Port
datagram
switch buffer link
fabric layer line
protocol termination
queueing (send)
• It buffers packets received from the switching fabric and transmits these packets
on the outgoing link.
• Packets can be lost due to congestions lacks of buffers.
• When a link is bidirectional, an output port will typically be paired with the input
port for that link on the same line card.
Routing Processor
• The routing processor executes the routing protocols, maintains routing tables
and attached link state information and computes the forwarding table for the
router.
• It also performs the network management functions.
Internet Network Layer
link layer
physical layer
IPv4 Datagram format
IP protocol version 32 bits
number total datagram
header length head. type of length (bytes)
ver length
(bytes) len service for
“type” of data fragment fragmentation/
16-bit identifier flags
offset reassembly
max number time to upper header
remaining hops live layer checksum
(decremented at
32 bit source IP address
each router)
32 bit destination IP address
upper layer protocol
to deliver payload to options (if any) e.g. timestamp,
record route
Total IP Datagram Size data taken, specify
?? (variable length, list of routers
Minimum IP Header Size typically a TCP to visit.
?? or UDP segment)
Maximum IP Header Size ??
IP Address
IP addresses are useful in identifying a specific host in a network.
IP addresses are 32 bit numbers which are divided into 4 octets. Each octet
represents 8 bit binary number.
Below is an example of an IP address:
172 16 254 1
1 1 0
Fix 21 Bit Network 8 Bit Host ID
ID
16,777,216 2,147,483,648
Class A 0 8 24 128 (27) 0.0.0.0 127.255.255.255 255.0.0.0 /8
(224) (231)
1,073,741,824
Class B 10 16 16 16,384 (214) 65,536 (216) 128.0.0.0 191.255.255.255 255.255.0.0 /16
(230)
2,097,152
Class C 110 24 8 256 (28) 536,870,912 (229) 192.0.0.0 223.255.255.255 255.255.255.0 /24
(221)
223.1.2.1
• Interface: It is a connection between 223.1.1.2
interfaces
• IP addresses associated with each 223.1.3.1 223.1.3.2
interface.
223 1 1 1
Subnet
• Subnet: high order bits defines subnet 223.1.1.0/24
223.1.2.0/24
• Host: low order bits defines host 223.1.1.1
223.1.3.1 223.1.3.2
223.1.3.0/24
Network consisting of 3 subnets
Type of addresses in IPv4 Network
• Network address - The address by which we refer to the network.
• E.g.: 10.0.0.0
• Broadcast address - A special address used to send data to all hosts in the
network.
• The broadcast address uses the highest address in the network range.
• E.g.: 10.0.0.255
• Host addresses - The addresses assigned to the end devices in the network.
• E.g.: 10.0.0.1
Type of addresses – Cont…
Classless Inter-Domain Routing(CIDR)
• CIDR is a slash notation of subnet mask. CIDR tells us number of on bits in a
network address.
host
subnet part
part
11001000 00010111 00010000 00000000
200.23.16.0/23
223.1.2.0/24
223.1.3.1 223.1.3.2
223.1.3.0/24
DHCP – Cont…
• With dynamic addressing, a device can have a different IP address every time it
connects to the network.
• In some systems, the device's IP address can even change while it is still
connected.
• It allows reuse of addresses (only hold address while connected “on”).
• It also support mobile users who want to join network.
DHCP Client Server Interaction
DHCP server: 223.1.2.5 DHCP discover arriving
client
src : 0.0.0.0, 68
Broadcast:
dest.: is there a DHCP server
255.255.255.255,67
out there?
yiaddr: 0.0.0.0
transaction ID: 654
DHCP offer
src: 223.1.2.5, 67
Broadcast: I’m a DHCP68server!
dest: 255.255.255.255,
Here’s anyiaddrr:
IP address you can use
223.1.2.4
transaction ID: 654
lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
Broadcast: OK. I’ll take that
yiaddrr: 223.1.2.4
IP
address!
transaction ID: 655
lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
Broadcast:255.255.255.255,
dest: OK. You’ve got 68 that IP
yiaddrr: 223.1.2.4
address!
transaction ID: 655
lifetime: 3600 secs
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
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
8
3 w z
u y
2
3
7 4
v
Dijkstra’s Algorithm – Example:2
v 3 w
2 5
u 2 1 z
3
1 2
x 1
y
Dijkstra’s Algorithm – Example:2
v w
u z
x y
4-62
Distance Vector Algorithm – Cont…
each node:
recompute estimates
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
from
y 2 0 1
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
from
2 0 1 y
z ∞ ∞ ∞ z 7 1 0 z 2 1
3 1 0
x z
node y cost to 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 from y 2 0 1
from
y 2 0 1
z ∞ ∞ ∞ z 7 1 0 z 3 1 0
from
y y 2 0 1
from
y ∞ ∞ ∞ 2 0 1
z z 3 1 0 z 3 1 0
7 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 update at every Updates are triggered not periodic
30 or 90 second
Update are broadcasted Updates are multicasted
Updates are sent to directly connected neighbour only Update are sent to entire network & to just directly connected
neighbour
Routers don't have end to end visibility of entire Routers have visibility of entire network of that area only.
network.
It is prone to routing loops No routing loops
Hierarchical Routing
• As networks grow in size, the router routing tables grow proportionally.
• Router memory, CPU time and more bandwidth consumed to send status reports
about them.
• When hierarchical routing is used, the routers are divided into what called regions.
• 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.
Hierarchical Routing - Example
Broadcast Routing
• Host need to send messages to many or all other hosts.
• For example
• A service distributing weather reports
• Stock market updates
• Live radio programs
• In Short, Sending a packet to all destinations simultaneously is called
broadcasting.
• First broadcasting method that simply send a distinct packet to each destination.
• So, it waste of bandwidth, but it also requires the source to have a complete list of
all destinations.
• In practice this may be the only possibility, but it is the least desirable of the
methods.
Broadcast Routing – Cont…
• Flooding is Second method. Although flooding is for ordinary point-to-point
communication, for broadcasting it might rate serious consideration, especially if
none of the methods are applicable.
• The problem with flooding as a broadcast technique is the same problem it has as
a point-to-point routing algorithm.
• It generates too many packets and consumes too much bandwidth.
• A third algorithm is Multi Destination Routing.
• If this method is used, each packet contains either a list of destinations or a bit
map indicating the desired destinations.
Broadcast Routing – Cont…
• When a packet arrives at a router, the router checks all the destinations to
determine the set of output lines that will be needed.
• The router generates a new copy of the packet for each output line to be used and
includes in each packet only those destinations that are to use the line.
• A fourth broadcast algorithm makes explicit use of the sink tree for the router
initiating the broadcast-or any other convenient spanning tree for that matter.
• A spanning tree is a subset of the subnet that includes all the routers but contains
no loops.
• If each router knows which of its lines belong to the spanning tree, it can copy an
incoming broadcast packet onto all the spanning tree lines except the one it
arrived on.
Multicast Routing
• Sending a message to a group is called multicasting, and its routing algorithm is called multicast
routing.
• Multicasting requires group management. Need to create and destroy groups, and to allow processes to
join and leave groups.
• To do multicast routing, each router computes a spanning tree covering all other routers.
• For example, in Figure (a) we have two groups, 1 and 2.
• Some routers are attached to hosts that belong to one or both of these groups, as indicated in the figure.
Multicast Routing – Cont…
• A spanning tree for the leftmost router is shown in Figure (b).
• When a process sends a multicast packet to a group, the first router examines its spanning tree and
prunes it, removing all lines that do not lead to hosts that are members of the group.
• In our example, Figure (c) shows the pruned spanning tree for group 1.
• Figure(d) shows the pruned spanning tree for group 2. Multicast packets are forwarded only along the
appropriate spanning tree.
Comparison between RIP, OSPF and BGP
RIP OSPF BGP
RIP is intra domain routing protocol OSPF is also intra domain routing It is inter domain routing protocol
used with in the autonomous system protocol used with in the autonomous used between the autonomous
system system
RIP is used for Small networks with OSPF is used in large autonomous The BGP protocol is used for very
maximum number of hops 16 system with no limitation large-scale networks
RIP uses Distance Vector OSPF uses Link State BGP uses Path Vector
RIP send entire routing update to all OSPF send multicast Hello packet to BGP send Open packet to the
directly connected interface the neighbours, to create session neighbours to create session
RIP use Bellman ford Algorithm OSPF use Dijikstra Algorithm BGP use Path-Vector Routing