Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
23 views80 pages

Chapter 4 - Network Layer

Uploaded by

Snehal Karki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views80 pages

Chapter 4 - Network Layer

Uploaded by

Snehal Karki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 80

Chapter 4: Network layer

Prepared By: Smriti Nakarmi


Assoc. Professor
Kathmandu Engineering College
Specific
Application layer Processes
addresses

Port
Transport layer SCTP TCP UDP
addresses

Logical
Network layer IP and other protocols
addresses

Data Link layer

Underlying physical network Physical


addressees
Physical layer
Internetwork
• The process of interconnecting a set of independent networks
is called internetworking.
• A scheme that provides universal service among
heterogeneous networks
• Hardware
– Used to interconnect a set of physical networks
• Software
– Provide universal services
• Internet
– System of connected physical networks
Internetwork
Internetworking Devices
• Devices that connect networks are called Internetworking devices.
• Internetworking devices are divided into categories based on the
OSI layer at which they operate.
• Interworking devices are considered as active components.
• Some of the internetworking devices are:
– Switch
– Router
– Bridge
– Gateway
• Physical layer interconnection devices are :
– Repeater
– Hub
Internetworking Devices
Application Layer Application Layer
Gateway
Presentation Presentation
Layer Layer
Session Layer Session Layer

Transport Layer Transport Layer

Network Layer Network Layer


Router
Data link Layer Router Data link Layer
Switch/ Bridge
Physical Layer Hub/Repeater Physical Layer

Fig. Connecting Devices and OSI model


Repeater
• A repeater is inserted into the network to
increase the coverage .
• Repeaters act only upon the electrical
components of the signal and are active only
at the physical layer.
• It regenerates signal arriving on either side
and puts on the other cable.
Hub
• Hub is a physical layer device that acts on
individual bits rather than frames.
• Hub re-creates the bit, boost its energy
strength and transmits the bit onto all other
interfaces. Discard
Sent A B C Discard

Hub

Discard F E D Discard
Accept
Switch
• Switch is used to connect several terminals
• Switch directs information to specific
workstations.
• Switch allows each workstation to transmit
information based on physical address.
• Normally, switch is a layer 2 device.
• A link- layer switch has filtering capability which
check the destination address of a frame and can
from which outgoing port the frame should be
sent.
Switch
switch
1 4
2 3

71:2B:13:45:61:41 A B C D 71:2B:13:45:61:12
71:2B:13:45:61:42 71:2B:13:45:61:43

Address Port
71:2B:13:45:61:41 1
71:2B:13:45:61:42 2
71:2B:13:45:61:43 3
71:2B:13:45:61:12 4
Bridge
• Bridge functions at the data link layer of the
OSI model.
• The function of bridge is very similar to switch.
• A bridge can divide an overloaded network
into smaller, more efficient network.
• Bridge filter traffic based on the destination
address of the frame.

LAN 1 Bridge LAN 2


Router
• A router is considered as a layer 3 relay that
operates in the network layer.
• It can be used to link two dissimilar LANs (LAN
segments).
• A router receives packet and selects the
optimum path to forward the packet across
the network.
• Router build a routing table of all the device
address across the network.
Internetwork
Internet

Token
Router
Ring

10 BaseT LAN

Bridge

10 BaseT LAN
Gateway
• Gateway is a multipurpose connection device.
• Gateway operates at the session layer and the
above.
• They are able to convert the format (data
translation) example; between ASCII and
EBCDIC, compression and decompression and
so on.
• Gateways are the most complex devices with
respect to the functionality.
Network Layer
• It is concerned with getting packets from
source to destination.
• The network layer studies the topology of the
subnet and chooses appropriate path.
Network layer: Design Issues
1. Store and forward packet switching.
A host with a packet to be sent transmits it to the nearest router where it is
stored until the packet is completely arrived so that the checksum can be
verified. Then it is forwarded to the next router along the path to the
destination.
2. Services provided to the transport layer
– The services should be independent of the subnet topology.
– The transport layer should be shielded from the number, type and
topology of the subnet present.
– The network address available to the transport layer should a uniform
numbering plan.
3. Implementation of connection less and connection oriented services.
The network service can be connectionless or connection oriented. In
connection oriented service , a connection is called a virtual circuit. In
connectionless service, independent packets are called datagram.
Internet Protocol (IP)
• The network protocol in the internet is called
internet protocol.
• This is host to host network delivery protocol
designed for internet.
• IP is a connectionless datagram protocol with
no guarantee of reliability.
• IP can only detects the error and discards it if
it is corrupted.
IP(IPv4) data format
Field Description
• Version: Indicates the version of this IP datagram.
• IP Header Length (IHL): Indicates the datagram header length in 32-bit words.
• Type-of-Service: Defines the class of the datagram for quality of service purposes. It specifies the
priority of the packet based on delay, throughput, reliability and cost requirement.
• Total Length: Specifies the length of the entire IP packet, including data and header, in bytes.
• Identification: this field identifies the datagram originating from the source host. When a datagram
is fragmented, the value in the identification field is copied into all fragments. The identification
number helps the destination in reassembling the fragments of the datagram. of an integer
identifying this datagram. This field is used to help piece together datagram fragments.
• Flags: defines DF= Don’t fragment and MF= More fragment
• Fragmentation offset: tell where in the current datagram this fragment belongs.
• Time-to-Live: Maintains a counter that gradually decrements down to zero, at which point the
datagram is discarded. This keeps packets from looping endlessly.
• Protocol: Indicates which upper-layer protocol receives incoming packets after IP processing is
complete.
• Header Checksum: Helps ensure IP header integrity.
• Source Address: Specifies the sending node.
• Destination Address: Specifies the receiving node.
• Options: Allows IP to support various options, such as security.
• Data: Contains upper-layer information.
IP Addressing
• An identifier used in the IP layer of the TCP/IP protocol
suite to identify the connection of each device to
Internet.
• Made of four bytes (32 bits).
Class Type Net ID Host ID

• Notation :
Binary 10000000.00001011.00000011.00011111
Decimal 128 .11 .3 .31
• IP address is generally written in dotted decimal
notation.
IP address
Calculation of IP range
Class A
00000000.00000000.00000000.00000000
01111111.11111111.11111111.11111111
0.0.0.0 – 127.255.255.255
Similarly,
Class B 128.0.0.0 – 191.255.255.255
Class C 192.0.0.0 – 223.255.255.255
Class D 224.0.0.0 – 239.255.255.255
Class E 240.0.0.0 – 255.255.255.255
Address Distribution concept
Class A net.host.host.host
network bits=7
host bits = 24
Total no. of network=27 =128
Total no. of hosts= 224 − 2 = 16777214

Class B net.net.host.host
network bits=14
host bits = 16
Total no. of network=214=16384
Total no. of hosts= 216 − 2= 65534
Address Distribution concept
Class C net.net.net.host
network bits=21
host bits = 8
Total no. of network=221=2097152
Total no. of hosts= 28 − 2 = 254

Class D
-used as multicast IP
-it is a unique network that directs packets with that destination
address to predefined groups for IP address.

Class E
-reserved for future use
Types of IP address
• Public IP
– Numbers used in Internet
– Unique world wide
– Given by ISP
• Private IP
– Any organization can use an address out of this set without
permission from the Internet authorities
– These addresses are free to use.
– Address for private networks:
• Class A  10.X.Y.Z
• Class B  172.16.X.Y – 172.31.255.254
• Class C 192.168.X.Y
Classful Address
• Default mask for classful address

• In IPv4 addressing, a block of addresses can be defined as


x.y.z.t /n in which x.y.z.t defines one of the addresses and the
/n defines the mask.
DHCP( Dynamic Host Configuration
Protocol)
• DHCP is a client-server protocol in which the
client sends a request message and the server
returns a response message.
• DHCP is used extremely in LANs and in
residential internet access
Client Server
DHCP Discover

DHCP Offer

DHCP Request
DHCP ACK

Time Time
Subnetting
• Subnetting is the process of dividing network
into several smaller subnetworks with each
subnetwork having its own subnetwork
address.
• Benefits:
– It reduces the network traffic
– It simplifies the management
– It breaks down the broadcast domain.
Subnet Mask
• It extracts the network address from an IP
address when subnetting is not used.
• It extracts the subnetwork address from an IP
address when subnetting is used.
• In a subnet mask, we change some of the
leftmost 0s in the default mask to make a
subnet mask,
Subnet address
• Given IP: 130.45.34.56
Mask: 255.255.0.0
What is the subnet address?
Sol:
IP : 10000010.00101101.00100010.00111000
Mask : 11111111.11111111.00000000.00000000
Anding
10000010.00101101.00000000.00000000
130.45.0.0 is the subnet address.
Network Address Translation (NAT)
• NAT enables a user to have a large set of
addresses internally and one address, or a
small set of addresses, externally.
Address Translation
• All the outgoing packets go through the NAT router,
which replaces the source address in the packet with
the global NAT address.
• All incoming packets also pass through the NAT
router, which replaces the destination address in the
packet with the appropriate private address.
Routing
• It is the process that a router used to forward
packets toward the destination network. The router
makes the decision based upon the destination IP
address of a packet.
• When a host has a packet to send or when a router
has received a packet to be forwarded, it looks at its
routing table to find the route to final destination.
Routing
Routing can be done by central computer or by
each router.
• Centralized
– A central computer calculates all possible paths
and dictates router in the network
• Distributed routing
– Each router calculates paths with available
information
Criteria for a good routing algorithm
• Correctness: correct route and accurate delivery of packets
• Robustness: adaptive to changes of network topology and varying
traffic load
• Cleverness: ability to detour congestion links and determine the
connectivity of the network
• Stability: avoiding the loops through the network when congestion.
• Optimality and fairness: some performance criteria may give
higher priority to the exchange of packets between nearby stations
compared to an exchange between distant stations. This may
maximize average throughput but will appear unfair to the station
that primarily needs to communicate with distant stations.
• Efficiency: rapid finding of the router and minimization of control
messages.
Routing Techniques
Routing can be divided two groups as:
• Non-adaptive routing (Static Routing)
– The routing decision is not based on the
measurement or estimation of current-traffic and
topology
– The choice of route is done in advance
– Good for small and fixed network topology
– This is called static routing
Routing Techniques
• Adaptive routing(dynamic routing)
– The routing decision is changed if there are any
changes in topology or traffic
– Each router learns the network topology by
exchanging information with its neighbors
– Different factors can be involved in dynamic
routing are bandwidth, delay, load, hop count.
– This is called dynamic routing
Optimality Principle
• It states that if the router J is on the optimal path from router
I to router K, then the optimal path from J to K also falls along
the same route. This can be elaborated as, call the part of the
route from I to J as r1 and rest of route as r2. If a router better
than r2 existed from J to K, it could be concatenated with r1 to
improve the route from I to K.
J
M r2
r1
K

M
Routing Algorithm
• A Routing Algorithm is that part of network
layer software responsible for deciding which
output line and incoming packet should be
transmitted on.
• The best path is one with minimum cost or
shortest path
Shortest path algorithm
• Given a network topology and a set of weights
describing the cost to send data across each
link in the network
• Find the shortest path from a specified source
to all other destinations in the network.
• Shortest path algorithm first developed by E.
W. Dijkstra
Shortest Path Routing
Flooding
• In this algorithm, every incoming packet is sent
out on every outgoing line except the line of
which it has arrived.
Flooding

• It generates a large number of duplicate


packets.
• To prevent endless copies of packets
circulating indefinitely through the network a
hop count may be used.
Distance Vector Routing (DVR)
It operated by having each router maintaining a table giving the
best-known distance to each destination.
Some of the keys to understand this algorithm are:
1. Knowledge about the whole network
Each router shares its knowledge about the entire AS with
neighbours. It sends whatever it has.
2. Routing only to neighbours
Sharing only with immediate neighbours. Each router sends
whatever knowledge it has through all its interface.
3. Sharing information at regular intervals
Sharing at regular intervals. sends at fixed intervals, e.g. every
30 sec.

44
Initialization of tables in DVR

45
A’ old routing table

14 1 –
78 1 –
23 1 - Combining

Routing table
received from B After Adjustment
A’s new table
14 1 – 14 2 B
+ 1 Hop =
55 1 - 55 2 B
08 2 E
14 1 – 08 2 E
Routing table 14 2 B 14 1 –
received from E 23 1 - 23 1 -
23 2 E 55 2 B
08 1 – 08 2 E 55 2 B 78 1 –
+ 1 Hop = 78 1 –
23 1 - 23 2 E 92 2 F
78 2 F
92 2 F
Routing table
received from F

78 1 – 78 2 F
+ 1 Hop =
92 1 - 92 2 F
Example of Final routing tables

47
Drawbacks of DVR
• Its slow convergence: tedious comparing/
updating process
• The algorithm does not take the line
bandwidth into consideration when choosing
route.
• May suffer from routing loop called count-to-
infinity problem.
• huge list to be maintained.
Count to Infinity
Count to Infinity
Link State Routing
• The link state routing algorithm maintains full
knowledge of distant routers and how they
interconnect.
• Every router maintains its link state packet(LSP) which
records the state information of links to all its
neighbors.
• A router floods its LSP to entire network, i.e., all
routers,
• When a router receives LSPs from other routers, it can
construct a map of entire network and from the map,
computer shortest paths between any pair of host.
Link State Routing
3 keys to understand how this algorithm works:
1. Sharing knowledge about the neighbourhood.
• Instead of sending its entire routing table, a router sends
information about its neighbourhood only.
2. Sharing with every other routers.
• Through process of flooding. each router sends the state of
its neighbourhood through all its output ports and each
neighbour sends to every other neighbours and so on until all
routers received same full information eventually
3. Sharing when there is a change.
• Each router share its state of its neighbour only when there
is a change; contrasting DVR results in lower traffic.
• From the received LSPs and knowledge of entire topology, a router
can then calculate the shortest path between itself and each network.
LSR
• Link-State advertisement (LSAs)
– A link-state advertisement : it is a small packet of
routing information that is sent between routers,
– Topological database: A topological database is a
collection of information gathered from LSAs.
– Routing tables: A list of the known paths and
interfaces.
Link State Routing
Five Steps
1.Discover your neighbors and learn their
addresses.
2. Measure the cost (delay) to each neighbor.
3. Construct a packet containing all this
information
4.Send this packet to all other routers.
5. Compute the shortest path to every other
router.
Collect the link state information from the neighboring nodes
and make the link state packets
Link State Database
Hierarchical Routing
• Addresses the growth of routing tables
• Routers are divided into regions
• Routers know the routes for their own
regions only
• Works like telephone routing
• Possible hierarchy
– city, state, country, continent
Two Level Hierarchical Routing Example

Full table for 1A Hierarchical table for 1A

Region2 Dest. Line Hops Dest. Line Hops


2A 2B 1A - - 1A - -
Region1
1B 1B 1B 1 1B 1B 1
1C 1C 1 1C 1C 1
2A 1B 2 2 1B 2
1A 1C
2C 2D 2B 1B 3 3 1C 2
2C 1B 3 4 1C 3
2D 1B 4 5 1C 4
3A 1C 3
3B 1C 2
4A 1C 3
5B
4B 1C 4
3A 3B Region4 5A 5C
4C 1C 4
4A
5A 1C 4 Region1
Region5
Region3 5B 1C 5
4C
5C 1B 5
4B 5E 5D 5D 1C 6
5E 1C 5
Routing Protocol
• A Routing Protocol is a combination of rules
and procedures that lets routers in an internet
inform each other of changes. It allows routers
to share whatever they know about the internet
or their neighbourhood.
• RIP
• OSPF
• BGP
Routing Protocols: Interior vs Exterior

• Routing inside an AS is referred to as interior routing whereas routing


between ASs is referred to as exterior routing.
• Each AS can choose one or more interior routing protocols inside an
AS.
• Only one exterior routing protocol is usually chosen to handle routing
between ASs. 60
Routing Protocols
Routing Information Protocol (RIP)
• RIP is based on distance vector routing algorithm which uses for
calculating the routing table.
• In RIP, the entire routing table is broadcast to its neighbours
every 30 seconds.
• RIP treats all network equals; the cost of passing through a
network is the same: one hop count per network.
• Each router/node maintains a vector (table) of minimum distances
to every node.
• The hop-count is the number of networks that a packet encounters
to reach its destination. Path costs are based on number of hops.
• RIP has a maximum hop count of 15. As a result RIP does not
work in large internetworks .
• The entry consists of Destination Network Address/id, Hop-
Count and Next-Router.
62
Example of Initial routing tables (RIP)
in a small autonomous system

63
Example of Final routing tables

64
Open Shortest Path First (OSPF)
• OSPF uses link state routing to update the routing table in an area;
OSPF divides an AS into different areas (depending on their type).
• Unlike RIP, OSPF treats the entire network within differently with
different philosophy; depending on the types, cost (metric) and
condition of each link: to define the ‘state’ of a link.
• OSPF allows the administrator to (only) assign a cost for passing
through a network based on the type of service required. e.g.
minimum delay, maximum throughput. (but not stating exact path)
• Each router should have the exact topology of the AS network(a
picture of entire AS network) at every moment. The topology is a
graph consisting of nodes and edges.
• Each router needs to advertise to the neighbourhood of every
other routers involved in an Area. (flood)

65
Areas in an Autonomous System

(AS>Areas)

OSPF divides an AS into areas. An area is a collection of network, hosts and routers
all contained within an AS. Routers inside an area flood the area with routing info. At
the border of an Area, special routers called Area Border routers summarize the info.
about the area and send it to other area. Among the areas inside an AS is a special area
called the Backbone connecting all areas through Backbone routers and serves as a
primary area to the outside (other ASs) via the AS Boundary router. 66
BGP
• Border Gateway Protocol (BGP) is an inter-domain or inter-
autonomous system routing protocol: routing between different ASs.
• BGP uses path vector routing to update the routing table in an area.
• PVR defines the exact paths as an ordered list of ASs that a packet
should travel through to reach the destination in its routing table.
• Security and Political issues involved: more desired to avoid ‘unsaved’
paths/routes/ASs than to take a shorter route.
• The AS boundary router that participate in PVR advertise the routes of
the networks in their own AS to neighbour AS boundary routers.

67
Types of BGP messages

• Open: To create a relationship, a router running BGP opens a


connection with a neighbouring AS and sends an open message.
• If the neighbour accepted, it responds with a Keep-alive message to
establish relationship between the two routers.
• Update: The heart of BGP protocol used by router to withdraw
destination that have been advertised previously, announce a route to a
new destination or do both. (Withdraw several but advertise only one).
• Notification: sent by a router whenever an error condition is detected
or router wants to close the connection (down).
Unicast Routing
• Unicast one source and one destination. (1-to-1 relationship)
• In Unicast routing, when a router receives a packet, it forwards the
packet through only one of its ports as defined in the routing table.
The router may discard the packet if it cannot find the destination
address.
Multicast Routing
• A mechanism that would send messages to well-defined groups that
are numerically large in size but small compared to the network as a
whole.
Sending a message to a such a group is called multicasting.
Corresponding routing algorithm is called multicast routing.

69
Multicast Routing (cont)
• Each Router Computes Spanning Tree Covering all other routers.
• Example of a network with nodes belonging to two groups (1 & 2).

2 1
2 1
1, 1,
1, 1, 2 2 2
2 2 2
2 2
2 1
1 1
1 Spanning Tree for the leftmost Router
Network

1 2

1 1 2 2
2

2
1
1
A Multicast Tree for group 1 A Multicast Tree for group 2

70
Broadcast Routing
• In certain application, the host has to send packets to all
other hosts. Sending a packet to all destination
simultaneously is called as broadcast routing.
• Various methods of broadcasting are:
• Simple broadcasting
• Flooding
• Multi-destination Routing
B C
B C
A D
A D F
F
E
E I G
I G
J
J H
H L
L N
N O
O K
K
M
M

A subnet A sink tree for router I 71


Internet Control Protocol
• In order to transfer data, the internet has
several control protocols used in the network
layer. Some of them are:
– ICMP
– ARP
– RARP, etc.
ICMP(Internet Control Message
Protocol)
• ICMP is a network layer protocol that helps IP to
handle some errors that may occur in the network
layer delivery.
• ICMP is used to test the Internet, which works at the
network layer.
• It can provide hosts with information about network
problem. They are encapsulated within IP datagram.
ICMP
• Some of the messages of ICMP are:
– Destination Unreachable: When router cannot locate the
destination.
– Time exceeded: When a packet is dropped because of time
out.
– Parameter problem: If a router discovers a missing value in
any field of the datagram, it discards the datagram and the
messages is sent to source.
– ECHO : used to see if a given destination is reachable or
alive.
– ECHO reply: Upon receiving echo message, the destination
is expected to send an Echo Reply message back.
ARP( Address Resolution Protocol)
• ARP is a network-specific standard protocol
that is responsible for converting the higher-
level protocol address (IP address) to physical
address.
ARP
• Even though each machine has an IP address, it cannot
be used to send packets as data link layer hardware
does not understand the address.
• ARP is used to find the physical address of the node
when its internet address is known.
• ARP broadcast special packet with the destination’s IP
address which is called ARP request.
• All hosts receive the broadcast and check their IP
address.
• The destination host that finds the matching IP address
sends an ARP reply to the source host along with its
hardware address.
ARP
RARP (Reverse Address Resolution
Protocol)
• Some network hosts, such as diskless
workstations, do not know their own IP
address when they are booted.
• To determine their own IP addresses, they use
TCP/IP with RARP to get IP address from
server.
• In RARP, the hardware address of the host is
the known parameter and the IP address is
the queried parameter.
RARP
• The RARP is performed the same way as the
ARP address resolution.
End of Chapter 4

You might also like