Chapter 4 - Network Layer
Chapter 4 - Network Layer
Port
Transport layer SCTP TCP UDP
addresses
Logical
Network layer IP and other protocols
addresses
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.
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
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
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
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
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