You are on page 1of 48

Introduction to Network layer

Prepared by
Anand Gachhadar
Assistant Professor
Department of Electrical and Electronics Engineering
Kathmandu University, Dhulikhel

9/3/2017 Anand Gachhadar, DoEEE 1


Network layer Services
Packetizing
Routing and Forwarding
Other services
Error Control
Flow Control
Congestion Control
Security
Packetizing
The first duty of the network layer is
packetizing.
Encapsulating the payload in a network
layer packet at the source and
decapsulating the payload from the
network layer packet at the destination.
Routing
Network layer is responsible for routing
packet from source to destination
A network is a combination of several
LANs, WANs and routers.
The network layer is responsible for
finding the best one among these possible
routes.
2 C 3
E
A
4
1
1
3 D

B 2

Djkistras
Bellmanford Algorithm
Forwarding
Routing is applying strategies and running
some routing protocol to create the
decision making tables for each router.
Forwarding is defined as the action
applied by each router when a packet
arrives at the interface.
Flow Control
Network layer in the internet does not
provide flow control due to following
reasons.
Since there is no error control in this layer, the
job of network layer at the receiver is so simple
that it is rarely overwhelmed.
The upper layer services implement buffers to
receive data from network layer so they do not
consume the data as fast as it is received.
Flow control is provided for most of the upper
layer protocols so another level of flow control in
network layer makes the network layer more
complicated and inefficient.
Congestion Control
Congestion occurs if number of
datagrams sent by source is beyond the
capacity of the networks or routers.
Some routers may drop some of the data
grams.
If the congestion continues, sometimes a
situation may reach where the system
collapse and no datagrams are received.
Network layer performance
Delay
Transmission delay
Propagation delay
Processing Delay
Queuing Delay
Throughput
Packet loss
Delay
Transmission Delay
If the first bit of the packet is put on line at time t1 and the last bit is put on time t2,
transmission delay of the packet is (t2-t1).
Delay = (packet length)/(Transmission Rate)
Propagation Delay
Propagation delay is the time it takes to travel from point A to point B in transmission
media.
Delay = (Distance)/(propagation speed)
Processing Delay
Processing delay is the time required for a router host to receive a packet from its
input port, remove the header, perform error detection procedure, and deliver the
packet to the output port or deliver packet to the upper layer protocols.
Queuing Delay
A router has an input queue connected to each of its input ports to store packets
waiting to be processed.The router also has a output queue connected to each of its
output port to store packets waiting to be transmitted.

Total delay = (n+1)(delay(tr) + delay(pg) + delay(pr)) + n(delay(qu))


Classless Addressing
Variable length blocks were used that
belong to no classes.
Whole address space is divided into
variable blocks.
The prefix defines the block or network
and the suffix defines the addresses

Address space
Prefix length: slash notation
The notation is referred to as slash
notation and formally referred to as CIDR
(classless Inter domain routing).

byte . byte . byte . byte /

Extracting Information from an Address


1. The number of addresses in the block is found as N = 2^32
n
2. To find the first address, we keep the n leftmost bits and set
the (32-n) rightmost bits all to 0s.
3. To find the last address, we keep the n leftmost bits and set
the (32-n) rightmost bits all to 1s.
4. Address mask is a 32 bit identifier in which the n leftmost
bits are set to 1s and rest set to all 0s.
Network address
The first address network address is important
because it is used in packet routing.
Let us assume an internet is made up of m
networks and with m interfaces

m2

m1 m3

Routing Process Network Add. Interface

Find network D A1.B1.C1.D1 1


A2.B2.C2.D2 2
address A3.B3.C3.D3 3
Destination Address
Designing Subnets
The sub network should be carefully designed to
enable routing information of packets.
Assume total number of address granted to an
organization is N, prefix length is n.
The assigned number of addresses to each sub
network is Nsub, and prefix length for each sub
network is nsub.
The number of addresses in each sub network should
be power of 2.
The prefix length for each sub network should be
found using
nsub = 32 log2Nsub
Address Aggregation
Advantages of CIDR is address
aggregation.
Routing can be done based on the prefix
of the larger block.
When block of addresses are combined
to create a larger block, routing can be
done based on the prefix of larger block.
Four small blocks of addresses are assigned to four organizations by an ISP.
The ISP combines these four blocks into one single block and advertises the larger
block to the rest of the world.Any packet destined for this larger block should be s
to this ISP
N = 256

n = 24

14.24.74.255/24 (last address)


14.24.74.0/24 (first address)

n = 25 n = 26 28 Unused

N = 128 N = 64 N = 16
Example of Address Aggregation

160.70.14.0/26
All packet with
To
destination
160.70.14.63/26
addresses
160.70.14.0/24
To 160.70.14.255/24
are sent to ISP
160.70.14.64/26
To
160.70.14.127/26
Internet

160.70.14.128/26
To
160.70.14.191/26

160.70.14.192/26
To
160.70.14.255/26
Special addresses
This-host address
The only address in the block 0.0.0.0/32 is called this-
host address.
Limited Broadcast address
The only address in the block 255.255.255.255/32 is
called limited broadcast address.
Loopback address
The block 127.0.0.0/8 is called loop back address.
Private address
Four blocks are assigned as private addresses: 10.0.0.0/8,
172.16.0.0/12, 192.168.0.0/16, and 169.254.0.0/16.
Multicast address
The block 224.0.0.0/4 is reserved for multicast address.
Dynamic Host Configuration
Protocol (DHCP)
Dynamic address assignment.
Widespread use in Internet and is often
called plug and play protocol.
Four piece of information are normally
needed for communication
Computer address
Prefix
Address of a router
IP address of a name server
DHCP Message format
DHCP is a client-server protocol in which
a client sends a request message and the
server returns a response message.
Opcode Htype HLen HCount Fields:
Opcode: Operation Code, request(1) or reply (2)
Transaction ID
Htype: Hardware type (Ethernet.)
Time Elapsed Flags Hlen: Length of Hardware address
Client IP Address Hcount: maximum number of hops packet can travel
Transaction ID: An integer set by the client and
Your IP Address repeated by server.
Time Elapsed: the number of seconds since the
Server IP Address
client started to boot
Gateway IP Address Flags: first bit defines unicast(0) or multicast(1)
Client IP Address: Set to 0 if the client does not know
Client hardware address Your IP Address: The client IP address sent by the serv
Server IP Address: A broadcast IP address if client
does not know it
Server name Gateway IP address: default router address.
Server name: A 64-byte domain name server
Boot file name Boot file name: A 128-byte file name holding extra
information.
Options: A 64 byte field with dual purpose.
Options
Client Server
IP Address: ? IP Address: 181.14.16.170

DHCPDISCOVER Application

Transaction ID: 1001 UDP


Lease Time:
Client Address IP
Your Address DHCPOFFER
Server Address
Source Port: 68 Destination Port: 67 Transaction ID: 1001
Source Address: 0.0.0.0 Lease Time:
Destination Address: 255.255.255.255 Client Address
Your Address: 181. 14. 16. 182
Server Address: 181.14.16.170
Source Port: 67 Destination Port: 68
Source Address: 181.14.16.170
DHCPREQUEST
Destination Address: 255.255.255.255
Transaction ID: 1001
Lease Time: 3600
Client Address: 181. 14. 16. 182
Your Address:
Server Address: 181.14.16.170
DHCPACK
Source Port: 68 Destination Port: 67
Source Address: 181. 14. 16. 182
Destination Address: 255.255.255.255 Transaction ID: 1001
Lease Time: 3600
Client Address:
Your Address: 181. 14. 16. 182
Server Address: 181.14.16.170
Source Port: 67 Destination Port: 68
Source Address: 181. 14. 16. 170
Destination Address: 255.255.255.255
DHCP video
Transition States
Join

INIT

DHCPOFFER
DHCP DISCOVER

SELECTING

Select offer/DHCP REQUEST


DHCP NACK lease time expired
REQUESTING

DHCP ACK
Lease time 50% expired DHCP RELEASE
DHCP REQUEST
BOUND

DHCP ACK DHCP ACK


RENEWING REBINDING

Lease time 75% expired/


DHCP REQUEST
When DHCP client starts, it is in INIT state.
Client broadcasts discover message DHCP DISCOVER.
When client receives it goes to SELECTING state.
It may receive offer or many offers. It sends a request
message a goes to REQUESTING state.
If an ACK arrives it goes to BOUND state and uses the IP
address.
When the lease time expires 50% the client tries to renew it
by moving to RENEWING state.
When the lease time expires 75% the client tries to renew it
by moving to REBINDING state.
The client can use IP address only when it is in BOUND,
RENEWING and REBINDING state.
Network Address Translation (NAT)
A technology that provide the mapping
between the private and universal
addresses is called NAT.
The technology allows a site to use a set
of private addresses for internal
communication and a set of global
Internet addresses.
The site must have only one connection
to the global Internet through NAT
capable router.
NAT video part I
NAT

172.18.3.1

200.24.5.8

172.18.3.2

172.18.3.30

172.18.3.20
Address Translation
Source: 172.18.3.1 Source: 200.24.5.8

172.18.3.1

200.24.5.8

172.18.3.2

172.18.3.30

172.18.3.20 Destination: 172.18.3.1 Destination: 200.24.5.8


Translation Table
Private Network

S: 172.18.3.1 2 S: 200.24.5.8
D: 25.8.2.10 D: 25.8.2.10

Data Data

1
Private Universal
172.18.3.1 25.8.2.10

Private Network 4 3

S: : 25.8.2.10 S: 25.8.2.10
D: 172.18.3.1 D: 200.24.5.8

Data Data
Using One IP address
A translation table has two columns: the
private address and external address.
When a router translates the source
address it also makes note of destination
address.
NAT is mostly use by ISPs that assign
single address to a customer.
Use of only one global address allows
only one private network host to access a
given external host.
Using a pool of IP address
NAT router can use a pool of global
addresses.
NAT router can use four addresses
(200.24.5.8, 200.24.5.9, 200.24.5.10 and
200.24.5.11).
Four private host can communicate with
the same external host at the same time
because each pair of address defines a
separate connection.
Forwarding of IP Packets
Forwarding means to deliver packets to the
next hop.
IP protocol was originally designed as a
connectionless protocol, tendency is
changed it to a connection-oriented
protocol.
In connectionless protocol, forwarding is
based on the destination address of the IP
datagram.
In connection oriented protocol, forwarding
is based on label attached to an IP datagram.
Forwarding based on destination
address
Forwarding based on destination address is a
traditional approach.
In this case, forwarding required a host or router
to have a forwarding table.
When a host has packet to be forwarded, it looks
at this table to find the next hop.
In classless addressing, the whole address space is
one entity. There are no classes.
The table needs to be searched based on the
network address (first address of the block)
Unfortunately, the destination address in the
packet gives no clue about the network address.
To solve this problem, we need to include
the mask (/n) in the table.
Classless forwarding needs four piece of
information.
The mask
Network address
Interface number
IP address of the next router
Simplified forwarding module in
classless address
Router Forwarding Table

Network Address Next hop IP Interface


/mask
address
Extract x0y0z0t0/n0 -------- mo
Search
destination
table x1y1z1t1/n1 -------- m1
address
x2y2z2t2/n2 -------- m2
Job of forwarding is to search the table
row by row.
In each row the n leftmost bits of the
destination address are kept and the rest
of the bits are set to 0s.
If the resulting address matches with the
network address in the first column, the
next information from the column are
extracted.
Example. Make a forwarding table for router R1 using the configuration in
the fig.

180.70.65.128/25

180.70.65.135/25
m0

201.4.16.0/22 m1 m3
201.4.22.0/24
m2 R1

201.4.16.2/22
201.4.22.3/24

1180.70.65.194/26

180.70.65.192/26

180.70.65.200/26
Forwarding table for router R1

Network Next hop Interface


address/mask
180.70.65.192/26 ----- m2
180.70.65.128/25 ----- m0
201.4.22.0/24 ----- m3
201.4.16.0/22 ----- m1
Default 180.70.65.200 m2
Address aggregation
140.24.7.0/26 Network Next hop
Add/Mask
140.24.7.0/24 ---- m0

0.0.0.0/0 Default router m1

140.24.7.64/26 m0
m1
m0 m1
R1 R2
m4
m2
m3
Net address/mask Next-hop address Interface
140.24.7.128/26
140.24.7.0/26 ----- m0

140.24.7.64/26 ----- m1

140.24.7.128/26 ----- m2
140.24.7.192/26
140.24.7.192/26 ----- m3

0.0.0.0/0 Address of R2 m4
Longest Mask Matching
This principle states that the forwarding
table is stored from the longest mask to
the shortest mask
E.g if there are three mask, /27, /26, /24
the mask must be /27 at first and /24 at
last entry.

Suppose a packet arrives at router R2 for organization 4 with


destination address 140.24.7.200. the first mask at router R2 is
applied, which gives the network address 140.24.7.192. the packet is
routed correctly from interface m1 and reaches organization 4
Net address/mask Next-hop address Interface

140.24.7.0/26 ----- m0

140.24.7.64/26 ----- m1

140.24.7.128/64 ----- m2

0.0.0.0/0 Default router m3

m1 m0

m3 m0 m2

m2
m0

Network Next hop


Add/Mask
140.24.7.192/26 ---- m1
140.24.7.0/24 Address of R1 m0
0.0.0.0/0 Default router m2
Hierarchical routing

Small
ISP
Local
ISP
Small
ISP

Local Region
ISP al ISP

Local
ISP
Forwarding based on label
In connectionless network router
forwards a packet based on destination
address in the header of the packet.
In a connection oriented network a
switch forwards a packet based on label
attached to a packet.
Routing in done on searching the table of
content, switching is done based on
accessing a table using an index.
Forwarding based on destination address

Mask/n Network Next-hop Interface


Address address
32 NF

32 NF

31 NF

31 NF

31 NF

31 NF

30 F y 2

Destination Address
0
1
x y
2
x
Forwarding based on label
Switching label
Label used as index
Interface Next label

0000

0001

0002

0003 2 0012
0004

0005

label 0006

0
0003 switch 1
0012
2
MPLS
MPLS behaves both as a router and as a
switch.
It can forward packets behaving like a
router and as a switch.
The IPV4 packet is encapsulated in a
MPLS packet and MPLS header is added.

MPLS
IP Header IP payload
header
MPLS header
0 20 24 31
label exp S TTL

Label: 20 bit field used to index the forwarding table.


Exp: 3 bit field used for experimental purpose.
S: one bit stack field.
TTL: 8 bit field. Time to live.
THE
END

ANY QUERIES?...

9/3/2017 Anand Gachhadar, DoEEE 48

You might also like