Data Communications
and
Computer Networks
Assistant Professor
Department of Computer Science & Engineering
IIIT Naya Raipur
Module – IV
Network Layer
Switching
• A network is a set of connected devices.
• Whenever we have multiple devices we
have the problem of how to connect them to
make one to one communication possible.
• A Better solution is switching.
• A switched network consist of a series of
interlinked nodes called switches.
• Switches are devices capable of creating
temporary connection between two or more
devices linked to the switch.
Circuit Switching
Figure Delay in a circuit-switched network
Packet Switching
Datagram Networks
• A switch in a datagram network uses a
ro u t i n g ta b l e t h at i s b a s e d o n t h e
destination address.
• The destination address in the header of
a packet in a datagram networkremains
the same during the entire journey of the
packet.
Figure Delay in a datagram network
Virtual-Ciruit Networks
• A virtual-circuit network is a cross between
a circuit-switched network and a datagram
network. It has some characteristics of both.
• As in a circuit-switched network, there are
setup and teardown phases in addition o to
the data transfer phase.
• A s i n a d a ta g ra m n e t w o r k , d ata a re
packetized and each packet carries an
address in the header. However, the address
in the header has local jurisdiction (it
defines what the next switch should be and
the channel on which the packet is being
carried)
Figure Source-to-destination data transfer in a virtual-circuit network
Figure Delay in a virtual-circuit network
Example:
The following Figure shows switch (router) in a datagram network. Find the output
port for packets with the following destination addresses:
Packet 1: 7176
Packet 2: 1233
Packet 3: 8766
Packet 4: 9144
Example:
The following Figure shows a switch in a virtual circuit network. Find the output
port and the output VCI for packets with the following input port and input VCI
addresses:
Packet 1: 3, 78
Packet 2: 2, 92
Packet 3: 4, 56
Packet 4: 2, 71
Task:
Q.1 A path in a digital circuit-switched network has a data rate of 1 Mbps. The
exchange of 1000 bits is required for the setup and teardown phases. The
distance between two parties is 5000 km. answer the following questions if the
propagation speed is 2 X 108 m/s:
[Link] is the total delay if 1000 bits of data are exchanged during the data
transfer phase?
[Link] is the total delay if 100,000 bits of data are exchanged during the data
transfer phase?
[Link] is the total delay if 1,000,000 bits of data are exchanged during the data
transfer phase?
Task:
Q.2 Five equal-size datagrams belonging to the same message leave for the
destination one after another. However, they travel through different paths as
shown in the following table:
We assume that the delay for each switch (including waiting and processing) is 3,
10, 20, 7, and 20 ms respectively. Assuming that the propagation speed is 2 x 108
m/s. Find the order the datagrams arrive at the destination and the delay for each.
Ignore any other delays in transmission
Routing
• A routing table can be either
static or dynamic. A static table
is one with manual entries. A
dynamic table is one that is
updated automatically when
there is a change somewhere in
the Internet.
• A routing protocol is a
combination of rules and
procedures that lets routers in
the Internet inform each other of
changes.
Note
In distance vector routing, each node
shares its routing table with its
immediate neighbors periodically and
when there is a change.
22.18
Figure Distance vector routing tables
Figure Updating in distance vector routing
Figure Concept of link state routing
Figure 22.21 Link state knowledge
Figure Dijkstra algorithm
Figure Example of formation of shortest path tree
22.24
Path Vector Routing
• Path Vector Routing is a routing algorithm in unicast routing protocol of network layer,
and it is useful for interdomain routing.
• The principle of path vector routing is similar to that of distance vector routing.
• It assumes that there is one node in each autonomous system that acts on behalf of the
entire autonomous system is called Speaker node.
• The speaker node in an AS creates a routing cable and advertises to the speaker node in
the neighbouring ASs.
• A speaker node advertises the path, not the metrics of the nodes, in its autonomous
system or other autonomous systems.
• It is the initial table for each speaker node in a system made
four ASs.
• Here Node A1 is the speaker node for AS1, B1 for AS2, C1 for
AS3 and D1 for AS4, Node A1 creates an initial table that
shows A1 to A5 and these are located in AS1, it can be
reached through it
• A speaker in an autonomous system shares its table with
immediate neighbours.
• Here Node A1 share its table with nodes B1 and C1 , Node C1
share its table with nodes A1,B1 and D1 , Node B1 share its
table with nodes A1 and C1 , Node D1 share its table with
node C1
Figure Initial routing tables in path vector routing
Working Principle
• If router A1 receives a packet for nodes A3 , it knows that the
path is in AS1.
• If it receives a packet for D1,it knows that the packet should
go from AS1,to AS2 and then to AS3 ,then the routing table
shows that path completely.
• If the node D1 in AS4 receives a packet for node A2,it knows it
should go through AS4,AS3,and AS1.
Figure Stabilized tables for three autonomous systems
Figure Protocol field and encapsulated data
20.31
Table 20.4 Protocol values
20.32
Figure IPv4 datagram format
20.33
Figure Maximum transfer unit (MTU)
20.34
MTUs for some networks
Figure Flags used in fragmentation
20.39
Figure Fragmentation example
20.40
Figure Detailed fragmentation example
20.41
Example
A packet has arrived with an M bit value of 0. Is this the
first fragment, the last fragment, or a middle fragment? Do
we know if the packet was fragmented?
Solution
If the M bit is 0, it means that there are no more fragments;
the fragment is the last one. However, we cannot say if the
original packet was fragmented or not. A non-fragmented
packet is considered the last fragment.
Example
A packet has arrived with an M bit value of 1. Is this the
first fragment, the last fragment, or a middle fragment? Do
we know if the packet was fragmented?
Solution
If the M bit is 1, it means that there is at least one more
fragment. This fragment can be the first one or a middle
one, but not the last one. We don’t know if it is the first one
or a middle one; we need more information (the value of
the fragmentation offset).
Task:
Consider an IP packet with a length of 3000 bytes is forwarded to an IPv4
router that supports a Maximum Transmission Unit (MTU) of 500 bytes.
a. Find the number of fragments.
b. Details of all fragments with M flag, Offset and Total length.
ICMPV4
• ICMP = Internet Control Message Protocol.
• ICMP is a supporting protocol in the Internet protocol suite.
• It is used by network devices, including routers, to send error messages and
operational information indicating success or failure when communicating
with another IP address.
Examples:
Destination host unreachable due to link /node failure
Reassembly process failed
TTL had reached 0 (so datagrams don't cycle forever)
IP header checksum failed
Types of Messages
ICMP messages are divided into two broad categories:
• Error-reporting messages and
• query messages
The error-reporting messages report problems that a router or a host (destination) may
encounter when it processes an IP packet.
The query messages, which occur in pairs, help a host or a network manager get specific
information from a router or another host.
.
Message Format
An ICMP message has an 8-byte header and a variable-size data section
Type, defines the type of the message.
Code field specifies the reason for the particular message type.
The last common field is the checksum field.
Rest of the header is specific for each message type.
Data section in error messages carries information for finding the
original packet that had the error.
In query messages, the data section carries extra information
based on the type of the query.
Error Reporting
One of the main responsibilities of ICMP is to report errors.
This means that error checking and error control are not a concern of IP.
ICMP was designed, in part, to compensate for this shortcoming.
ICMP does not correct errors-it simply reports them.
. Error messages are always sent to the original source because the
only information available in the datagram about the route is the
source and destination IP addresses.
ICMP uses the source IP address to send the error message to the
source (originator) of the datagram
49
Figure Error-reporting messages
Figure Contents of data field for the error messages
Destination Unreachable
When a router cannot route a datagram or a host cannot deliver a datagram,
the datagram is discarded and the router or the host sends a destination-
unreachable message back to the source host that initiated the datagram.
Note that destination-unreachable messages can be created by either a router
or the destination host.
Source Quench
The IP protocol is a connectionless protocol. There is no communication
between the source host, which produces the datagram, the routers, which
forward it, and the destination host, which processes it.
IP does not have a flow control mechanism embedded in the protocol.
The lack of flow control can create a major problem in the operation of IP:
Congestion.
The source host never knows if the routers or the destination host has been
overwhelmed with datagrams.
The source host never knows if it is producing datagrams faster than can
be forwarded by routers or processed by the destination host.
The lack of flow control can create congestion in routers or the destination
host.
When a router or host discards a datagram due to congestion, it sends a
source-quench message to the sender of the datagram
This message has two purposes.
First, it informs the source that the datagram has been discarded.
Second, it warns the source that there is congestion somewhere in the path
and that the source should slow down (quench) the sending process.
Time Exceeded
The time-exceeded message is generated in two cases:
Routers use routing tables to find the next hop (next router) that must
receive the packet.
If there are errors in one or more routing tables, a packet can travel in a loop
or a cycle, going from one router to the next or visiting a series of routers
endlessly.
Each datagram contains a field called time to live that controls this situation.
When a datagram visits a router, the value of this field is decremented
by 1. When the time-to-live value reaches 0, after decrementing, the
router discards the datagram.
When the datagram is discarded, a time-exceeded message must be sent
by the router to the original source
• In a time-exceeded message, code 0 is used
only by routers to show that the value of the
time-to-live field is zero.
• Code 1 is used only by the destination host to
show that not all of the fragments have arrived
within a set time.
Parameter problem
Redirection
Redirection
• Host A wants to send a datagram to host B
• Router R2 is obviously the most efficient routing
choice, but host A did not choose router R2.
• The datagram goes to R1 instead. Router R1, after
consulting its table, finds that the packet should have
gone to R2.
• It sends the packet to R2 and, at the same time, sends a
redirection message to host A.
• Host A's routing table can now be updated
A redirection message is sent from a router to a host
on the same local network.
57
Figure Query messages
Query
In addition to error reporting, ICMP can diagnose some network problems.
This is accomplished through the query messages
In this type of ICMP message, a node sends a message that is answered in a
specific format by the destination node.
A query message is encapsulated in an IP packet, which in turn is
encapsulated in a data link layer frame.
However, in this case, no bytes of the original IP are included in the
message,
Echo Request and Reply
The echo-request and echo-reply messages are designed for diagnostic
purposes.
Network managers and users utilize this pair of messages to identify
network problems.
The combination of echo-request and echo-reply messages determines
whether two systems (hosts or routers) can communicate with each other.
Echo-request and echo-reply messages can test the reachability of a
host. This is usually done by invoking the ping command.
Timestamp Request and Reply
Two machines (hosts or routers) can use the timestamp request and
timestamp reply messages to determine the round-trip time needed for an IP
datagram to travel between them.
It can also be used to synchronize the clocks in two machines.
Timestamp-request and timestamp-reply messages can be
used to calculate the round-trip time between a source and
a destination machine even if their clocks are not
synchronized.
The timestamp-request and timestamp-reply messages can
be used to synchronize two clocks in two machines if the
exact one-way time duration is known.
Router Solicitation and Advertisement
• A host can broadcast a router solicitation message.
• The router that receive the solicitation message
broadcast their routing information using router
advertisement message.
• A router can also periodically send router advertisement
even if no host has solicited.
Note
Important points about ICMP error messages:
❏ No ICMP error message will be generated in
response to a datagram carrying an ICMP error
message.
❏ No ICMP error message will be generated for a
fragmented datagram that is not the first fragment.
❏ No ICMP error message will be generated for a
datagram having a multicast address.
❏ No ICMP error message will be generated for a
datagram having a special address such as
[Link] or [Link].