Unit 4 PPT NL
Unit 4 PPT NL
Unit 4 PPT NL
• If the hosts are located within the same local network, then they are
assigned with the same network ID.
The following are the rules for assigning Network ID:
1. The network ID cannot start with 127 as 127 is used by Class A.
2. The Network ID in which all the bits are set to 0 cannot be assigned
as it is used to specify a particular host on the local network.
3. The Network ID in which all the bits are set to 1 cannot be assigned
as it is reserved for the multicast address.
Classful Network Architecture
Class Higher bits NET ID HOST ID No.of No.of Range
bits bits networks hosts per
network
• Host ID’s are used to identify a host within a network. The host ID are
assigned based on the following rules:
• Hosts that are located on the same physical network are identified by the
network ID, as all host on the same physical network is assigned the same
network ID. The network ID is assigned based on the following rules:
• The network ID cannot start with 127 because 127 belongs to class A address
and is reserved for internal loop-back functions.
• All bits of network ID set to 1 are reserved for use as an IP broadcast address
and therefore, cannot be used.
• All bits of network ID set to 0 are used to denote a specific host on the local
network and are not routed and therefore, aren’t used.
Summary of Classful addressing :
Problems with Classful Addressing:
• Classful addressing was inefficient because it assigned large blocks of
addresses regardless of the actual network size. This led to wasted addresses
and inefficient usage of the IP address space. To address this, Classless Inter-
Domain Routing (CIDR) was introduced, allowing more flexible allocation of IP
addresses.
• The problem with this classful addressing method is that millions of class A
address are wasted, many of the class B address are wasted, whereas, number
of addresses available in class C is so small that it cannot cater the needs of
organizations.
• Class D addresses are used for multicast routing and are therefore available as
a single block only. Class E addresses are reserved.
• Since there are these problems, Classful networking was replaced by Classless
Inter-Domain Routing (CIDR) in 1993.
Classless Inter Domain Routing (CIDR)
• which is also known as Classless addressing. In the Classful addressing
the no of Hosts within a network always remains the same depending
upon the class of the Network.
• Given any address in the block, we normally like to know three pieces
of information about the block to which the address belongs:
• The number of addresses, the first address in the block, and the last
address. Since the value of prefix length, n, is given, we can easily find
these three pieces of information, as shown in Figure.
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.
Example-A classless address is given as 167.199.170.82/27. We can find
the above three pieces of information
This-host Address
• The only address in the block 0.0.0.0/32 is called the this-host
address. It is used whenever a host needs to send an IP datagram but
it does not know its own address to use as the source address.
Limited-broadcast Address
• The only address in the block 255.255.255.255/32 is called the
limited-broadcast address. It is used whenever a router or a host
needs to send a datagram to all devices in a network. The routers in
the network, however, block the packet having this address as the
destination; the packet cannot travel outside the network.
Special Addresses( this-host address, limited-broadcast address, loopback address, private
addresses, and multicast addresses.)
Loopback Address
• The block 127.0.0.0/8 is called the loopback address. A packet with one of the
addresses in this block as the destination address never leaves the host; it will
remain in the host. Any address in the block is used to test a piece of software
in the machine.
• For example, we can write a client and a server program in which one of the
addresses in the block is used as the server address. We can test the programs
using the same host to see if they work before running them on different
computers.
Private Addresses
• 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 Addresses
• The block 224.0.0.0/4 is reserved for multicast addresses.
IPV4
• The network layer is the third layer (from bottom) in the OSI Model.
• The network layer is concerned with the delivery of a packet across multiple
networks.
• The network layer is considered the backbone of the OSI Model.
• It selects and manages the best logical path for data transfer between nodes.
• This layer contains hardware devices such as routers, bridges, firewalls, and
switches, but it actually creates a logical image of the most efficient
communication route and implements it with a physical medium.
• Network layer protocols exist in every host or router. The router examines the
header fields of all the IP packets that pass through it.
• Internet Protocol and Netware IPX/SPX are the most common protocols
associated with the network layer.
IPV4 HEADER FORMAT
• VERSION: Version of the IP protocol (4 bits), which is 4 for IPv4
• HLEN: IP header length (4 bits), which is the number of 32 bit words in the header. The minimum value for
this field is 5 and the maximum is 15.
• Type of service: Low Delay, High Throughput, Reliability (8 bits)
• Total Length: Length of header + Data (16 bits), which has a minimum value 20 bytes and the maximum is
65,535 bytes.
• Identification: Unique Packet Id for identifying the group of fragments of a single IP datagram (16 bits)
• Flags: 3 flags of 1 bit each : reserved bit (must be zero), do not fragment flag, more fragments flag (same
order)
• Fragment Offset: Represents the number of Data Bytes ahead of the particular fragment in the particular
Datagram. Specified in terms of number of 8 bytes, which has the maximum value of 65,528 bytes.
• Time to live: Datagram’s lifetime (8 bits), It prevents the datagram to loop through the network by restricting
the number of Hops taken by a Packet before delivering to the Destination.
• Protocol: Name of the protocol to which the data is to be passed (8 bits)
• Header Checksum: 16 bits header checksum for checking errors in the datagram header
• Source IP address: 32 bits IP address of the sender
• Destination IP address: 32 bits IP address of the receiver
• Option: Optional information such as source route, record route. Used by the Network administrator to
check whether a path is working or not. Due to the presence of options, the size of the datagram header can
be of variable length (20 bytes to 60 bytes).
Internet Protocol version 6 (IPv6) Header
• IP version 6 is the new version of Internet Protocol, which is way
better than IP version 4 in terms of complexity and efficiency.
IPv6 Header FORMAT
• Version (4-bits) : Indicates version of Internet Protocol which contains
bit sequence 0110.
• Traffic Class (8-bits) : The Traffic Class field indicates class or priority of
IPv6 packet which is similar to Service Field in IPv4 packet. It helps
routers to handle the traffic based on priority of the packet. If
congestion occurs on router then packets with least priority will be
discarded.
• As of now only 4-bits are being used (and remaining bits are under
research), in which 0 to 7 are assigned to Congestion controlled traffic
and 8 to 15 are assigned to Uncontrolled traffic.
• Priority assignment of Congestion controlled traffic :
Differences between Virtual Circuits & Datagram Networks
Key Virtual Circuits Datagram Networks
Definition Virtual Circuit is the connection oriented service On other hand Datagram is the connection less
in which there is a implementation of resources service where no such resources are required for
like buffers, CPU, bandwidth, etc., used by the data transmission.
virtual circuit for a data transfer session.
Path In Virtual circuits as all the resources and On other hand in case Datagram network, the
bandwidth get reserved before the path is not fixed as data packets are free to
transmission, the path which is utilized or decide the path on any intermediate router on
followed by first data packet would get fixed the go by dynamically changing routing tables
and all other data packets will use the same on routers.
path and consume same resources.
Header Same path followed by all the data packets, a On other hand different headers with
common and same header is being used by all information of other data packet is being used in
the packets. Datagram network.
Differences between Virtual Circuits & Datagram Networks
Key Virtual Circuits Datagram Networks
Complexity Virtual Circuit is less complex as compared to More complex as compared to Virtual
that of Datagram network. circuit.
Reliability Due to fixed path and assurance of fixed On other hand Datagram network due to
resources, Virtual Circuits are more reliable for dynamic resource allocation and follow
data transmission as compared to Datagram dynamic path is more prone to error and is
network. less reliable than Virtual circuits.
Example and Virtual circuits are costlier in installation and Datagram network are cheaper as
Cost maintenance and are widely used by ATM compared to the Virtual Circuits and are
(Asynchronous Transfer Mode) Network, mainly used by IP network, which is used
which is used for the Telephone calls. for Data services like Internet.
Virtual Circuits:
1. It is connection-oriented, meaning that there is a reservation of resources like buffers, CPU,
bandwidth, etc. for the time in which the newly setup VC is going to be used by a data transfer
session.
2. The first sent packet reserves resources at each server along the path. Subsequent packets will
follow the same path as the first sent packet for the connection time.
3. Since all the packets are going to follow the same path, a global header is required. Only the first
packet of the connection requires a global header, the remaining packets generally don’t require
global headers.
4. Since all packets follow a specific path, packets are received in-order at the destination.
5. Virtual Circuit Switching ensures that all packets successfully reach the Destination. No packet
will be discarded due to unavailability of resources.
6. From the above points, it can be concluded that Virtual Circuits are a highly reliable method of
data transfer.
7. The issue with virtual circuits is that each time a new connection is set up, resources and extra
information have to be reserved at every router along the path, which becomes problematic if
many clients are trying to reserve a routers resources simultaneously.
8. It is used by the ATM (Asynchronous Transfer Mode) Network, specifically for Telephone calls.
Datagram Networks :
1. It is a connection-less service. There is no need for reservation of resources as there is no
dedicated path for a connection session.
2. All packets are free to use any available path. As a result, intermediate routers calculate routes
on the go due to dynamically changing routing tables on routers.
3. Since every packet is free to choose any path, all packets must be associated with a header with
proper information about the source and the upper layer data.
4. The connection-less property makes data packets reach the destination in any order, which
means that they can potentially be received out of order at the receiver’s end.
5. Datagram networks are not as reliable as Virtual Circuits.
6. The major drawback of Datagram Packet switching is that a packet can only be forwarded if
resources such as the buffer, CPU, and bandwidth are available. Otherwise, the packet will be
discarded.
7. But it is always easy and cost-efficient to implement datagram networks as there is no extra
headache of reserving resources and making a dedicated each time an application has to
communicate.
8. It is generally used by the IP network, which is used for Data services like the Internet.
Other Services-NETWORK LAYER
1. Error Control-the network layer in the Internet does not directly provide error control,
the Internet uses an auxiliary protocol, ICMP, that provides some kind of error control
if the datagram is discarded or has some unknown information in the header.
2. Flow Control-The network layer in the Internet, however, does not directly provide
any flow con_x0002_trol. The datagrams are sent by the sender when they are ready,
without any attention to the readiness of the receiver.
3. Congestion Control
4. Quality of Service-multimedia communication (in particular real-time communication
of audio and video), the quality of service (QoS) of the communication has become
more and more important.
5. Security-To provide security for a connectionless network layer, we need to have
another virtual level that changes the connectionless service to a connection-oriented
service.
NETWORK-LAYER PERFORMANCE
• The performance of a network can be measured in terms of delay, throughput, and
packet loss. Congestion control is an issue that can improve the performance.
1. Delay(Transmission Delay,Propagation Delay,Processing Delay,Queuing Delay,Total
Delay)
2. Throughput
3. Packet Loss
4. Congestion Control( open-loop congestion control (prevention) and closed-loop
congestion control (removal))
• open-loop congestion control -Retransmission Policy,Window Policy,Acknowledgment
Policy,Discarding Policy,Admission Policy)
• closed-loop congestion control-Backpressure,Choke Packet,Implicit Signaling,Explicit
Signaling)
I Delay
• The delays in a network can be divided into four types: transmission delay, propagation
delay, processing delay, and queuing delay.
A)Transmission Delay:
• A source host or a router cannot send a packet instantaneously. A sender needs to put
the bits in a packet on the line one by one. If the first bit of the packet is put on the line
at time t1 and the last bit is put on the line at time t2, transmission delay of the packet is
(t2 − t1).
Delaytr = (Packet length) / (Transmission rate).
B)Propagation Delay:
Propagation delay is the time it takes for a bit to travel from point A to point B in the
trans_x0002_mission media. The propagation delay for a packet-switched network
depends on the propagation delay of each network (LAN or WAN). The propagation delay
depends on the propagation speed of the media, which is 3 × 10^8 meters/second in a
vacuum and normally much less in a wired medium; it also depends on the distance of the
link. In other words, propagation delay is
Delaypg = (Distance) / (Propagation speed).
C)Processing Delay
• The processing delay is the time required for a router or a destination host to receive a packet
from its input port, remove the header, perform an error detection procedure, and deliver the
packet to the output port (in the case of a router) or deliver the packet to the upper-layer
protocol
Delaypr = Time required to process a packet in a router or a destination host
D)Queuing Delay
Queuing delay can normally happen in a router. The queuing delay for a packet in a router is
measured as the time a packet waits in the input queue and output queue of a router.
Delayqu = The time a packet waits in input and output queues in a router
E)Total Delay
Assuming equal delays for the sender, routers, and receiver, the total delay (source-
to_x0002_destination delay) Total delay = (n + 1) (Delaytr + Delaypg + Delaypr) + (n) (
Delayqu)
For n routers, we have (n + 1) links.
II Throughput
• Throughput at any point in a network is defined as the number of bits passing
through the point in a second, which is actually the transmission rate of data
at that point.
Throughput = minimum {TR1, TR2, . . . TRn}.
TR: Transmission rate
III Packet Loss -
Number of packets lost during transmission
The effect of packet loss on the Internet network layer is that the packet needs
to be resent, which in turn may create overflow and cause more packet loss.
IV Congestion Control
• Congestion control is a mechanism for improving performance.
• congestion at the network layer is not explicitly addressed in the Internet model.
• Congestion at the network layer is related to two issues, throughput and delay.
i. When the load is much less than the capacity of the network, the delay is at a minimum. This minimum delay is
composed of propagation delay and processing delay, both of which are negligible.
ii. However, when the load reaches the network capacity, the delay increases sharply because we now need to add the
queuing delay to the total delay.
iii. Note that the delay becomes infinite when the load is greater than the capacity.
iv. When the load is much less than the capacity of the network, the delay is at a minimum. This minimum delay is
composed of propagation delay and processing delay, both of which are negligible.
v. However, when the load reaches the network capacity, the delay increases sharply because we now need to add the
queuing delay to the total delay.
vi. Note that the delay becomes infinite when the load is greater than the capacity .
vii. When the load is below the capacity of the network, the throughput increases pro_x0002_portionally with the load. We
expect the throughput to remain constant after the load reaches the capacity, but instead the throughput declines
sharply.
viii. The reason is the discarding of packets by the routers. When the load exceeds the capacity, the queues become full and
the routers have to discard some packets. Discarding packets does not reduce the number of packets in the network
because the sources retransmit the packets, using time-out mechanisms, when the packets do not reach the
destinations.
Congestion Control
• Congestion control refers to techniques and mechanisms that can either prevent
congestion before it happens or remove congestion after it has happened. In general, we
can divide congestion control mechanisms into two broad categories: open-loop
congestion control (prevention) and closed-loop congestion control (removal).
I)Open-Loop Congestion Control
• In open-loop congestion control, policies are applied to prevent congestion before it
happens. In these mechanisms, congestion control is handled by either the source or the
destination.
A)Retransmission Policy
• Retransmission is sometimes unavoidable. If the sender feels that a sent packet is lost or
corrupted, the packet needs to be retransmitted. Retransmission in general may increase
congestion in the network. However, a good retransmission policy can prevent
congestion. The retransmission policy and the retransmission timers must be designed to
optimize efficiency and at the same time prevent congestion.
B)Window Policy
• The type of window at the sender may also affect congestion. The Selective Repeat window is
better than the Go-Back-N window for congestion control.
• In the Go-Back-N window, when the timer for a packet times out, several packets may be resent,
although some may have arrived safe and sound at the receiver. This duplication may make the
congestion worse.
• The Selective Repeat window, on the other hand, tries to send the specific packets that have been
lost or corrupted.
C)Acknowledgment Policy
• The acknowledgment policy imposed by the receiver may also affect congestion. If the receiver
does not acknowledge every packet it receives, it may slow down the sender and help prevent
congestion.
• Several approaches are used in this case. A receiver may send an acknowledgment only if it has a
packet to be sent or a special timer expires. A receiver may decide to acknowledge only N packets
at a time.
• We need to know that the acknowledgments are also part of the load in a network. Sending fewer
acknowledgments means imposing less load on the network.
Packet delay and throughput as functions of load
D)Discarding Policy
• A good discarding policy by the routers may prevent congestion and at the
same time may not harm the integrity of the transmission. For example, in
audio transmission, if the policy is to discard less sensitive packets when
congestion is likely to happen, the quality of sound is still preserved and
congestion is prevented or alleviated.
E)Admission Policy
• An admission policy, which is a quality-of-service mechanism can also
prevent congestion in virtual-circuit networks. Switches in a flow first check
the resource requirement of a flow before admitting it to the network. A
router can deny establishing a virtual-circuit connection if there is congestion
in the network or if there is a possibility of future congestion.
II)Closed-Loop Congestion Control
• Closed-loop congestion control mechanisms try to alleviate congestion after it
hap_x0002_pens. Several mechanisms have been used by different protocols.
We describe a few of them here.
A)Backpressure
• The technique of backpressure refers to a congestion control mechanism in which a
congested node stops receiving data from the immediate upstream node or nodes. This
may cause the upstream node or nodes to become congested, and they, in turn, reject
data from their upstream node or nodes, and so on. Backpressure is a node to-node
congestion control that starts with a node and propagates, in the opposite direction of
data flow, to the source. The backpressure technique can be applied only to virtual circuit
networks, in which each node knows the upstream node from which a flow of data is
coming.
B)Choke Packet
• A choke packet is a packet sent by a node to the source to inform it
of congestion. Note the difference between the backpressure and
choke-packet methods.
• In backpressure, the warning is from one node to its upstream node,
although the warning may eventually reach the source station.
• In the choke-packet method, the warning is from the router, which
has encountered congestion, directly to the source station. The
intermediate nodes through which the packet has traveled are not
warned.
C)Implicit Signaling
• In implicit signaling, there is no communication between the congested node
or nodes and the source. The source guesses that there is congestion
somewhere in the network from other symptoms.
• For example, when a source sends several packets and there is no
acknowledgment for a while, one assumption is that the network is
congested. The delay in receiving an acknowledgment is interpreted as
congestion in the network; the source should slow down.
D)Explicit Signaling
• The node that experiences congestion can explicitly send a signal to the
source or destination. The explicit-signaling method, however, is different
from the choke-packet method. In the choke-packet method, a separate
packet is used for this purpose;
• in the explicit-signaling method, the signal is included in the packets that carry
data. Explicit signaling can occur in either the forward or the backward
direction.
Dynamic Host Configuration Protocol (DHCP)
• Obtaining a Host Address: the Dynamic Host Configuration Protocol
ICMP
What is a Router?
• The router is a physical or virtual internetworking device that is designed to receive, analyze, and forward data
packets between computer networks.
• A router examines a destination IP address of a given data packet, and it uses the headers and forwarding tables to
decide the best way to transfer the packets.
• There are some popular companies that develop routers; such are Cisco, 3Com, HP, Juniper, D-Link, Nortel, etc.
• A router is used in LAN (Local Area Network) and WAN (Wide Area Network) environments. For example, it is used
in offices for connectivity, and you can also establish the connection between distant networks .
• It shares information with other routers in networking.
• It uses the routing protocol to transfer the data across a network.
• it is more expensive than other networking devices like switches and hubs.
• A router works on the third layer of the OSI model, and it is based on the IP address of a computer.
• It uses protocols such as ICMP to communicate between two or more networks.
• It is also known as an intelligent device as it can calculate the best route to pass the network packets from source
to the destination automatically.
Router
virtual router
• A virtual router is a software function or software-based framework
that performs the same functions as a physical router.
• It may be used to increase the reliability of the network by virtual
router redundancy protocol, which is done by configuring a virtual
router as a default gateway.
• A virtual router runs on commodity servers, and it is packaged with
alone or other network functions, like load balancing, firewall packet
filtering, and wide area network optimization capabilities.
How does Router work?
• A router analyzes a destination IP address of a
given packet header and compares it with the
routing table to decide the packet's next path.
• The list of routing tables provides directions
to transfer the data to a particular network
destination.
• They have a set of rules that compute the
best path to forward the data to the given IP
address.
• Routers use a modem such as a cable, fiber,
or DSL modem to allow communication
between other devices and the internet.
• Most of the routers have several ports to
connect different devices to the internet at
the same time. It uses the routing tables to
determine where to send data and from
where the traffic is coming.
Features of Router
• A router provides high-speed internet connectivity with the different types of
ports like gigabit, fast-Ethernet, and STM link port.
• It allows the users to configure the port as per their requirements in the
network.
• Routers' main components are central processing unit (CPU), flash memory,
RAM, Non-Volatile RAM, console, network, and interface card.
• Routers are capable of routing the traffic in a large networking system by
considering the sub-network as an intact network.
• Routers filter out the unwanted interference, as well as carry out the data
encapsulation and decapsulation process.
• Routers provide the redundancy as it always works in master and slave mode.
• It allows the users to connect several LAN and WAN.
Single router connects 2 LANs with internet
Networking devices- Hub, Switch, and Router(connect one computer to another)
HUB SWITCH ROUTER
used to connect computers or hardware device that also connects computers to each commonly found in homes and offices as it
other networking devices other. allows your network to communicate with
together other networks through the internet
does not use any routing table to it handles packets of data. Whenever a switch receives used to route the data packets to another
send the data to the destination a packet, it decides the device to which the packet can network instead of transmitting the data to
be sent, and sends it to that device only. the local networks only
3. Dynamic Routing
Static routing
• Static routing is a form of routing that occurs when a router uses a manually-configured routing entry,routes are
manually configured by a network administrator by adding in entries into a routing table.
• static routes are fixed and do not change if the network is changed or reconfigured.
Static Routing is also known as non-adaptive routing which doesn’t change routing table unless the network
administrator changes or modify them manually. Static routing does not use complex routing algorithms and It
provides high or more security than dynamic routing.
In Linux
• Router(config)#ip route [destination_network][subnet_mask][next-hop_address or exitinterface]
Advantages
1. Static routing causes very little load on the CPU of the router, and produces no traffic to other routers.
2. Static routing leaves the network administrator with full control over the routing behavior of the network.
3. Static Routing Is very easy to configure on small networks.
Disadvantages
Human error,Fault tolerance,Administrative distance and Administrative overhead
Dynamic Routing
Sharing Information
• Each cloud represents the network, and the
number inside the cloud represents the
network ID.
• All the LANs are connected by routers, and
they are represented in boxes labeled as A, B,
C, D, E, F.
• Distance vector routing algorithm simplifies
the routing process by assuming the cost of
every link is one unit. Therefore, the
efficiency of transmission can be measured by
the number of links to reach the destination.
• In Distance vector routing, the cost is based
on hop count.
• The router sends the knowledge
to the immediate neighbors.
• The neighbors add this
knowledge to their own
knowledge and sends the
updated table to their own
neighbors.
• In this way, routers get its own
information plus the new
information about the
neighbors.
• Routing Table
• Two process occurs:
• v = F, w = C
• D(B) = min( D(F) , D(C) + c(C,F) )
• = min( 4, 3+5)
• = min(4,8)
• The minimum value is 4. Therefore, the currently shortest path from A to F is 4.
Step N D(B),P(B) D(C),P(C) D(D),P(D) D(E),P(E) D(F),P(F)
1 A 2,A 5,A 1,A ∞ ∞
2 AD 2,A 4,D 2,D ∞
3 ADE 2,A 3,E 4,E
4 ADEB 3,E 4,E
5 ADEBC 4,E
Final table:
Step N D(B),P(B) D(C),P(C) D(D),P(D) D(E),P(E) D(F),P(F)
1 A 2,A 5,A 1,A ∞ ∞
2 AD 2,A 4,D 2,D ∞
3 ADE 2,A 3,E 4,E
4 ADEB 3,E 4,E
5 ADEBC 4,E
6 ADEBCF
Disadvantage:
Heavy traffic is created in Line state routing due to Flooding. Flooding can cause an infinite looping, this
problem can be solved by using Time-to-leave field
1.Distance Vector Routing(Example protocol:RIP)
• The network uses a Distance Vector Routing protocol. Once the
routes have stabilized, the distance vectors at different nodes are as
following.
• N1: (0, 1, 7, 8, 4)
• N2: (1, 0, 6, 7, 3)
• N3: (7, 6, 0, 2, 6)
• N4: (8, 7, 2, 0, 4)
• N5: (4, 3, 6, 4, 0)
• Each distance vector is the distance of the best known path at the instance to
nodes, N1 to N5, where the distance to itself is 0. Also, all links are symmetric
and the cost is identical in both directions. In each round, all nodes exchange
their distance vectors with their respective neighbors. Then all nodes update
their distance vectors. In between two rounds, any change in cost of a link will
cause the two incident nodes to change only that entry in their distance
vectors. 52. The cost of link N2-N3 reduces to 2(in both directions). After the
next round of updates, what will be the new distance vector at node, N3.
• (A) (3, 2, 0, 2, 5)
• (B) (3, 2, 0, 2, 6)
• (C) (7, 2, 0, 2, 5)
• (D) (7, 2, 0, 2, 6)
CREATING ROUTING TABLE
• SAME SOURCE AND SAME DESTINATION=0
• A TO B AND B TO A IS SAME THAT IS BIDIRECTIONAL
• IF 2 ROUTERS ARE INDIRECT ASSIGN INFINITE COST
Roing table for N1
N1 N1 N2 N3 N4 N5
N1 0 1 - - -
N2 1
N3
N4
N5
N1 N1 N2 N3 N4 N5 N2 N1 N2 N3 N4 N5
N1 0 1 - - - N1 1
N2 1 N2 1 0 6 - 3
N3 N3 6
N4 N4
N5 N5 3
N3 N1 N2 N3 N4 N5 N5 N1 N2 N3 N4 N5
N4 N1 N2 N3 N4 N5
N1
N1 N1
N2 6
N2 N2 1 0 6 - 3
N3 - 6 0 2 -
N3 2 N3 6
N4 2 N4 4
N4 - - 2 0 4
N5 N5 4 N5 - 3 - 4 0
• AFTER EVERY PERIOD OF TIME EACH ROUTER GETS INFORMATION
FROM ITS NEIGHBOURS.
N3 N1 N2 N3 N4 N5 N5 N1 N2 N3 N4 N5
N4 N1 N2 N3 N4 N5
N1 1
N1 N1
N2 1 0 6 - 3
N2 3 N2 1 0 6 - 3
N3 6 0 2
N3 2 N3 6 2
N4 - - 2 0 4 N4 - - 2 0 4
N4 - - 2 0 4
N5 3 4 N5 - 3 - 4 0 N5 - 3 - 4 0
N1 N1 N2 N3 N4 N5 N2 N1 N2 N3 N4 N5
N1 0 1 7 7 4 N1 0 1 7 7 4
N2 1 0 6 7 3 N2 1 0 6 7 3
N3 7 6 0 2 6 N3 7 6 0 2 6
N4 8 7 2 0 4 N4 8 7 2 0 4
N5 4 3 6 4 0 N5 4 3 6 4 0
N3 N1 N2 N3 N4 N5 N5 N1 N2 N3 N4 N5
N4 N1 N2 N3 N4 N5
N1 0 1 7 7 4
N1 0 1 7 7 4 N1 0 1 7 7 4
N2 1 0 6 7 3
N2 1 0 6 7 3 N2 1 0 6 7 3
N3 7 6 0 2 6
N3 7 6 0 2 6 N3 7 6 0 2 6
N4 8 7 2 0 4 N4 8 7 2 0 4
N4 8 7 2 0 4
N5 4 3 6 4 0 N5 4 3 6 4 0 N5 4 3 6 4 0
Assume that the network in Figure uses distance-vector routing with the
forwarding table as shown for each node.
2.Link State Routing(Dijkstras algorithm)
• Find shortest path from one node to every other node in the network.
2 phases:
1. Reliable Flooding
Each node knows cost of its neighbours
Each node knows entire graph
2. Route Calculation
Each node uses Dijkstras algorithm to calculate optimal path.
Use Link state to build the routing table with
Dijkstras algorithm
STEP 1:Each node knows cost of its neighbours
NODE A COST
NODE COST NODE COST NODE COST
B C D
B 3 A 3 A 2 A 5
C 2 D 1 D 2 B 1
D 5 E 4 F 1 C 2
E 3
NODE COST
NODE COST
E
F
B 4
C 1
D 3
E 2
F 2
Dijkstras algorithm
Dijkstra’s Algorithm ( ) repeat
{ {
Tree={root} find a node w with D[w] minimum among
for(y = 1 to N) all nodes not in the Tree
{ Tree = Tree U { w}
if(y is the root) for(every node x,which is a neighbour of w
D[y] = 0 and not in the Tree))
else if(y is a neighbour) {
D[y] = c[root][y] D[x]=min{D[x],(D[w]+c[w][x])
else }
D[y] = ∞ } until(all nodes included in the Tree)
} }/ /End of Dijkstra
STEP 2:Each node uses Dijkstras to calculate
optimal path
ITERATI TREE NODES
ON B C D E F
INITIAL {A} 3 2 5
1’ST {A,C} 3 - 4 3
2ND {A,B,C} - - 4 7 3
3RD {A,B,C,F} - - 4 5 -
4TH {A,B,C,D,F} - - - 5 -
5TH {A,B,C,D,E,F} - - - - -
OUTPUT
ITERA TREE NODES
TION B C D E F
INITI {A} 3 2 5
AL
1’ST {A,C} 3 - 4 3
2ND {A,B, - - 4 7 3
C}
3RD {A,B, - - 4 5 -
C,F}
4TH {A,B, - - - 5 -
C,D,F}
5TH {A,B, - - - - -
C,D,E,
F}
Use Dijkstra’s algorithm to find the shortest path tree and the
forwarding table for node A in the Figure
3.Path vector routing algorithm(Spanning Trees)
• Both link-state and distance-vector routing are based on the least-cost goal.
• The least-cost goal,applied by LS or DV routing, does not allow a sender to apply specific
policies to the route a packet may take.
• Goal:to allow the packet to reach its destination more efficiently without assigning costs
to the route.
• Path-vector routing does not have the drawbacks of LS or DV routing as described above
because it is not based on least-cost routing.
• The best route is determined by the source using the policy it imposes on the route. In
other words, the source can control the path. Although path-vector routing is not
actually used in an internet, and is mostly designed to route a packet between ISPs,
Spanning Trees
• In path-vector routing, the path from a source to all destinations is
also determined by the best spanning tree.
• The best spanning tree, however, is not the least-cost tree; it is the
tree determined by the source when it imposes its own policy. If there
is more than one route to a destination, the source can choose the
route that meets its policy best.
• A source may apply several policies at the same time.
1. One of the common policies uses the minimum number of nodes to
be visited (something similar to least-cost).
2. Another common policy is to avoid some nodes as the middle node
in a route.
Spanning trees in path-vector routing
• Path-vector routing, like distance-vector routing, is an asynchronous and
distributed routing algorithm.
• The spanning trees are made, gradually and asynchronously, by each node.
• When a node is booted, it creates a path vector based on the information it
can obtain about its immediate neighbor.
• A node sends greeting messages to its immediate neighbors to collect these
pieces of information.
• Each node, after the creation of the initial path vector, sends it to all its
immediate neighbors.
• Each node, when it receives a path vector from a neighbor, updates its path
vector using an equation similar to the Bellman-Ford, but applying its own
policy instead of looking for the least cost. We can define this equation as
• Path(x, y) = best {Path(x, y), [(x + Path(v, y)]} for all v’s in the internet.
• Path vectors made at booting • Updating path vectors
time
Path-Vector Algorithm
Path_Vector_Routing ( ) // Update
{ repeat (forever)
{
// Initialization
wait (for a vector Pathw from a neighbor w)
for (y = 1 to N)
for (y = 1 to N)
{
{
if (y is myself) if (Pathw includes myself)
Path[y] = myself discard the path // Avoid any loop
else if (y is a neighbor) else
else }
If (there is a change in the vector)
Path[y] = empty
Send vector {Path[1], Path[2], …, Path[y]} to all neighbors
}
}
Send vector {Path[1], Path[2], …, Path[y]} to all
} // End of Path Vector
neighbors
Multicast Addresses
• When we send a unicast packet to a destination, the source address of the packet defines the
sender and the destination address of the packet defines the receiver of the packet. In multicast
communication, the sender is only one, but the receiver is many, sometimes thousands or
millions spread all over the world.
• It should be clear that we cannot include the addresses of all recipients in the packet. The
destination address of a packet, as described in the Internet Protocol (IP) should be only one. For
this reason we need multicast addresses. A multicast address defines a group of recipients, not a
single one.
• In other words, a multicast address is an identifier for a group. If a new group is formed with
some active members, an authority can assign an unused multicast address to this group to
uniquely define it.
• This means that the source address of a packet in multicast communication can be a unicast
address that uniquely defines the sender, but the destination address can be the multicast
address that defines a group. In this way, a host, which is a member of n groups, actually has (n +
1) addresses: one unicast address that is used for source or destination address in unicast
communication and n multicast addresses that are used only for destination addresses to receive
messages sent to a group.
A multicast address in binary
INTRADOMAIN MULTICAST PROTOCOLS
• Two are extensions of unicast routing protocols (RIP and OSPF), using the source-based
tree approach;
• The third is an independent protocol which is becoming more and more popular. It can
be used in two modes,employing either the source-based tree approach or the shared-
group tree approach.
1.Source-Based Tree Approach
• In the source-based tree approach to multicasting, each router needs to create a
separate tree for each source-group combination. In other words, if there are m groups
and n sources in the internet, a router needs to create (m × n) routing trees.
2.Group-Shared Tree Approach
• In the group-shared tree approach, we designate a router to act as the phony source for
each group. The designated router, which is called the core router or the rendezvous
point router, acts as the representative for the group. Any source that has a packet to
send to a member of that group sends it to the core center (unicast communication) and
the core center is responsible for multicasting.
INTRADOMAIN MULTICAST PROTOCOLS
3Protocols Designed to provide multicast communication inside an
autonomous system-
1.Multicast Distance Vector (DVMRP)-Distance Vector Multicast
Routing Protocol (DVMRP)
• Reverse Path Forwarding (RPF)
• Reverse Path Broadcasting (RPB)
• Reverse Path Multicasting (RPM)
2.Multicast Link State (MOSPF)-Multicast Open Shortest Path First
(MOSPF)
3.Protocol Independent Multicast (PIM)
Protocol Independent Multicast-Dense Mode (PIM-DM)
Protocol Independent Multicast-Sparse Mode (PIM-SM)
1)Multicast Distance Vector (DVMRP)-Distance
Vector Multicast Routing Protocol
• DVMRP is the extension of the Routing Information Protocol (RIP) which is used in
unicast routing.
• It uses the source based tree approach to multicasting.
• Each router in this protocol that receives a multicast packet to be forwarded implicitly
creates a source-based multicast tree in three steps:
• 1. The router uses an algorithm called reverse path forwarding (RPF) to simulate
creating part of the optimal source-based tree between the source and itself.
• 2. The router uses an algorithm called reverse path broadcasting (RPB) to create a
broadcast (spanning) tree whose root is the router itself and whose leaves are all
networks in the internet.
• 3. The router uses an algorithm called reverse path multicasting (RPM) to create a
multicast tree by cutting some branches of the tree that end in networks with no
member in the group.
A)Reverse Path Forwarding (RPF)
• Forces the router to forward a multicast packet from one specific interface: the one which has come through the
short_x0002_est path from the source to the router.
• How can a router know which interface is in this path if the router does not have a shortest-path tree rooted at the
source? The router uses the first property of the shortest-path tree we discussed in unicast routing, which says that
the shortest path from A to B is also the shortest path from B to A.
• The router does not know the shortest path from the source to itself, but it can find which is the next router in the
shortest path from itself to the source (reverse path).
• The router simply consults its unicast forwarding table, pretending that it wants to send a packet to the source; the
forwarding table gives the next router and the interface the message that the packet should be sent out in this
reverse direction.
• The router uses this information to accept a multicast packet only if it arrives from this interface. This is needed to
prevent looping.
• In multicasting, a packet may arrive at the same router that has forwarded it. If the router does not drop all arrived
packets except the one, multiple copies of the packet will be circulating in the internet. Of course, the router may
add a tag to the packet when it arrives the first time and discard packets that arrive with the same tag, but the RPF
strategy is simpler.
B)Reverse Path Broadcasting (RPB)
• The RPF algorithm helps a router to forward only one copy received from a source and drop the rest.
• However, when we think about broadcasting in the second step, we need to remember that destinations are all the networks (LANs) in the
internet.
• To be efficient,we need to prevent each network from receiving more than one copy of the packet.
• If a network is connected to more than one router, it may receive a copy of the packet from each router.
• RPF cannot help here, because a network does not have the intelligence to apply the RPF algorithm; we need to allow only one of the
routers attached to a network to pass the packet to the network.
• One way to do so is to designate only one router as the parent of a network related to a specific source. When a router that is not the
parent of the attached network receives a multicast packet, it simply drops the packet.
• There are several ways that the parent of the network related to a network can be selected; one way is to select the router that has the
shortest path to the source (using the unicast forward_x0002_ing table, again in the reverse direction).
• If there is a tie in this case, the router with the smaller IP address can be selected. The reader may have noticed that reverse path
broadcasting (RPB) actually creates a broadcast tree from the graph that has been cre_x0002_ated by the RPF algorithm. RPB has cut those
branches of the tree that cause cycles in the graph.
• If we use the shortest path criteria for choosing the parent router, we have actually created a shortest-path broadcast tree. In other words,
after this step, we have a shortest-path tree with the source as the root and all networks (LANs) as the leaves.
• Every packet started from the source reaches all LANs in the internet travelling the shortest path. Figure 21.11 shows how RPB can avoid
duplicate reception in a network by assigning a designated parent router, R1, for network N.
RPF versus RPB
C)Reverse Path Multicasting (RPM)
• As you may have noticed, RPB does not multicast the packet, it broadcasts it. This is not efficient. To increase
efficiency, the multicast packet must reach only those networks that have active members for that particular group.
This is called reverse path multicasting (RPM).
• To change the broadcast shortest-path tree to a multicast shortest-path tree, each router needs to prune (make
inactive) the interfaces that do not reach a network with active members corresponding to a particular source-
group combination.
• This step can be done bottom-up, from the leaves to the root. At the leaf level, the routers connected to the
network collect the membership information using the IGMP protocol discussed before.
• The parent router of the network can then disseminate this information upward using the reverse shortest-path
tree from the router to the source, the same way as the distance vector messages are passed from one neighbor to
another.
• When a router receives all of these membership-related messages, it knows which interfaces need to be pruned. Of
course, since these packets are disseminated periodically, if a new member is added to some networks, all routers
are informed and can change the status of their interfaces accordingly. Joining and leaving is continuously applied.
RPB versus RPM
2)Multicast Link State (MOSPF)
• Extension of the Open Shortest Path First (OSPF) protocol, which is used in
unicast routing.
• It also uses the source based tree approach to multicasting. If the internet is
running a unicast link-state routing algorithm, the idea can be extended to
provide a multicast link-state routing algorithm.
• Recall that in unicast link-state routing, each router in the internet has a link-
state database (LSDB) that can be used to create a shortest-path tree.
• To extend unicasting to multicasting, each router needs to have another
database, as with the case of unicast distance-vector routing, to show which
interface has an active member in a particular group.
Now a router goes through the following steps to forward a
multicast packet received from source S and to be sent to destination G (a group of
recipients):
• 1. The router uses the Dijkstra algorithm to create a shortest-path tree with S as the root and all destinations in the
internet as the leaves. Note that this shortest-path tree is different from the one the router normally uses for
unicast forwarding, in which the root of the tree is the router itself. In this case, the root of the tree is the source of
the packet defined in the source address of the packet.
• The router is capable of creating this tree because it has the LSDB, the whole topology of the internet; the Dijkstra
algorithm can be used to create a tree with any root, no matter which router is using it. The point we need to
remember is that the shortest-path tree created this way depends on the specific source. For each source we need
to create adifferent tree.
• 2. The router finds itself in the shortest-path tree created in the first step. In other words, the router creates a
shortest-path subtree with itself as the root of the subtree.
• 3. The shortest-path subtree is actually a broadcast subtree with the router as the root and all networks as the
leaves. The router now uses a strategy similar to the one we describe in the case of DVMRP to prune the broadcast
tree and to change it to a multicast tree. The IGMP protocol is used to find the information at the leaf level.
• MOSPF has added a new type of link state update packet that floods the member_x0002_ship to all routers. The
router can use the information it receives in this way andprune the broadcast tree to make the multicast tree.
• 4. The router can now forward the received packet out of only those interfaces that correspond to the branches of
the multicast tree. We need to make certain that a copy of the multicast packet reaches all networks that have
active members of the group and that it does not reach those networks that do not.
Example of tree formation in MOSPF
3)Protocol Independent Multicast (PIM)
• Common protocol that needs a unicast routing protocol for its operation, but the unicast protocol can be either a
distance-vector protocol or a link-state protocol.
• In other words, PIM needs to use the forwarding table of a unicast routing protocol to find the next router in a path
to the destination, but it does not matter how the forwarding table is created.
• PIM has another interesting feature: it can work in two different modes: dense and sparse.
• The term dense here means that the number of active members of a group in the internet is large; the probability
that a router has a member in a group is high.
• This may happen, for example, in a popular teleconference that has a lot of members.
• The term sparse, on the other hand, means that only a few routers in the internet have active members in the
group; the probability that a router has a member of the group is low. This may happen, for example, in a very
technical teleconference where a number of members are spread somewhere in the internet. When the protocol is
working in the dense mode, it is referred to as PIM-DM; when it is working in the sparse mode, it is referred to as
PIM_x0002_SM.
3A)Protocol Independent Multicast-Dense Mode (PIM-DM)
• When the number of routers with attached members is large relative to the number of routers in the
internet, PIM works in the dense mode and is called PIM-DM.
• In this mode, the protocol uses a source-based tree approach and is similar to DVMRP, but simpler.
• PIM-DM uses only two strategies described in DVMRP: RPF and RPM. But unlike DVMRP, forwarding of a
packet is not suspended awaiting pruning of the first subtree. Let us explain the two steps used in PIM-DM
to clear the matter.
• 1.A router that has received a multicast packet from the source S destined for the group G first uses the RPF
strategy to avoid receiving a duplicate of the packet. It consults the forwarding table of the underlying
unicast protocol to find the next router if it wants to send a message to the source S (in the reverse
direction). If the packet has not arrived from the next router in the reverse direction, it drops the packet and
sends a prune message in that direction to prevent receiving future packets related to (S, G).
• 2. If the packet in the first step has arrived from the next router in the reverse direction,the receiving router
forwards the packet from all its interfaces except the one fromwhich the packet has arrived and the interface
from which it has already received a prune message related to (S, G). Note that this is actually a broadcasting
instead of a multicasting if the packet is the first packet from the source S to group G.
• However,each router downstream that receives an unwanted packet sends a prune message to the router
upstream, and eventually the broadcasting is changed to multicasting. Note that DVMRP behaves differently:
it requires that the prune messages (which are part of DV packets) arrive and the tree is pruned before
sending any message through unpruned interfaces. PIM-DM does not care about this precaution because it
assumes that most routers have an interest in the group (the idea of the dense mode).
Idea behind PIM-DM-(The first packet is broadcast to all networks, which have or do not
have members. After a prune message arrives from a router with no member, the second
packet is only multicast.)
3B)Protocol Independent Multicast-Sparse Mode
(PIM-SM)
• When the number of routers with attached members is small relative to the number of routers in
the internet, PIM works in the sparse mode and is called PIM-SM. In this environment, the use of
a protocol that broadcasts the packets until the tree is pruned is not justified; PIM-SM uses a
group-shared tree approach to multicasting.
• The core router in PIM-SM is called the rendezvous point (RP). Multicast communication is
achieved in two steps. Any router that has a multicast packet to send to a group of destinations
first encapsulates the multicast packet in a unicast packet (tunneling) and sends it to the RP. The
RP then decapsulates the unicast packet and sends the multicast packet to its destination.
• PIM-SM uses a complex algorithm to select one router among all routers in the internet as the RP
for a specific group. This means that if we have m active groups, we need m RPs, although a
router may serve more than one group. After the RP for each group is selected, each router
creates a database and stores the group identifier and the IP address of the RP for tunneling
multicast packets to it.
• PIM-SM uses a spanning multicast tree rooted at the RP with leaves pointing to
designated routers connected to each network with an active member. A very interesting
point in PIM-SM is the formation of the multicast tree for a group.
• The idea is that each router helps to create the tree. The router should know the unique
interface from which it should accept a multicast packet destined for a group (what was
achieved by RPF in DVMRP).
• The router should also know the interface or interfaces from which it should send out a
multicast packet destined for a group (what was achieved by RPM in DVMRP). To avoid
delivering more than one copy of the same packet to a network through several routers
(what was achieved by RPB in DVMRP), PIM-SM requires that only designated routers
send PIM-SM messages, as we will see shortly.
• To create a multicast tree rooted at the RP, PIM-SM uses join and prune messages.
Idea behind PIM-SM-( shows the operation of join and prune messages in PIM-SM. First, three
networks join group G1 and form a multicast tree. Later, one of the networks leaves the
group and the tree is pruned)
• The join message is used to add possible new branches to the tree; the prune mes_x0002_sage is used to cut
branches that are not needed.
• When a designated router finds out that a network has a new member in the corresponding group (via IGMP), it
sends a join message in a unicast packet destined for the RP.
• The packet travels through the unicast shortest-path tree to reach the RP. Any router in the path receives and
forwards the packet, but at the same time, the router adds two pieces of information to its multicast forwarding
table.
• The number of the interface through which the join message has arrived is marked (if not already marked) as one
of the interfaces through which the multicast packet destined for the group should be sent out in the future.
• The router also adds a count to the number of join messages received here, as we discuss shortly. The number of
the interface through which the join message was sent to the RP is marked (if not already marked) as the only
interface through which the multicast packet destined for the same group should be received.
• In this way, the first join message sent by a designated router creates a path from the RP to one of the networks
with group members.
• To avoid sending multicast packets to networks with no members, PIM-SM uses the prune message. Each
designated router that finds out (via IGMP) that there is no active member in its network, sends a prune message
to the RP.
• When a router receives a prune message, it decrements the join count for the interface through which the
message has arrived and forwards it to the next router.
• When the join count for an interface reaches zero, that interface is not part of the multicast tree anymore.
INTERDOMAIN MULTICAST PROTOCOLS
• Multicast Border Gateway Protocol (MBGP)-MBGP provides two paths between ASs: one for
unicasting and one for multicasting. Information about multicasting is exchanged between border
routers in different ASs. MBGP is a shared-group multicast routing protocol in which one router in
each AS is chosen as the rendezvous point (RP).
• The problem with MBGP protocol is that it is difficult to inform an RP about the sources of groups
in other ASs.
• The Multicast Source Discovery Protocol (MSDP) is a new suggested protocol that assigns a
source representative router in each AS to inform all RPs about the existence of sources in that AS.
• Another protocol that is Border Gateway Multicast Protocol (BGMP)-which allows construction of
shared group trees with a single root in one of the ASs. In other words, for each group, there is only
one shared tree, with leaves in different ASs, but the root is located in one of the ASs. The two
problems, of course, are how to designate an AS as the root of the tree and how to inform all
sources about the location of the root to tunnel their multicast packets to.
IGMP-Internet Group Management Protocol
• collecting information about group membership
• defined at the network layer;IGMP messages, like ICMP messages, are encapsulated in an IP
datagram.
• Messages-There are only two types of messages in IGMP version 3, query and report messages.A
query message is periodically sent by a router to all hosts attached to it to ask them to report
their interests about membership in groups. A report message is sent by a host as a response to a
query message.
• IGMP operation
I )Query Message
• The query message is sent by a router to all hosts in each interface to collect information about
their membership. There are three versions of query messages, as described below:
• a. A general query message is sent about membership in any group. It is encapsulated in a
datagram with the destination address 224.0.0.1 (all hosts and routers). Note that all routers
attached to the same network receive this message to inform them that this message is already sent
and that they should refrain from resending it.
• b. A group-specific query message is sent from a router to ask about the membership related to a
specific group. This is sent when a router does not receive a response about a specific group and
wants to be sure that there is no active member of that group in the network.
• The group identifier (multicast address) is mentioned in the message. The message is encapsulated
in a datagram with the destination address set to the corresponding multicast address. Although all
hosts receive this message, those not interested drop it.
• c. A source-and-group-specific query message is sent from a router to ask about the membership
related to a specific group when the message comes from a specific source or sources. Again the
message is sent when the router does not hear about a specific group related to a specific host or
hosts. The message is encapsulated in a datagram with the destination address set to the
corresponding multicast address. Although all hosts receive this message, those not interested drop
it.
II )Report Message
• A report message is sent by a host as a response to a query message. The
message contains a list of records in which each record gives the identifier of
the corresponding group (multicast address) and the addresses of all sources
that the host is interested in receiving messages from (inclusion).
• The record can also mention the source addresses from which the host does
not desire to receive a group message (exclusion). The message is
encapsulated in a datagram with the multicast address 224.0.0.22 (multicast
address assigned to IGMPv3). In IGMPv3, if a host needs to join a group, it
waits until it receives a query message and then sends a report message.
• If a host needs to leave a group, it does not respond to a query message. If no
other host responds to the corresponding message, the group is purged from
the router database.
Propagation of Membership Information
• After a router has collected membership information from the hosts
and other routers at its own level in the tree, it can propagate it to
the router located in a higher level of the tree.
• Finally, the router at the tree root can get the membership
information to build the multicast tree.
• The process, however, is more complex than what we can explain in
one paragraph. Interested readers can check the book website for the
complete description of this protocol.
Encapsulation
• The IGMP message is encapsulated in an IP datagram with the value of
the protocol field set to 2 and the TTL field set to 1. The destination IP
address of the datagram, however, depends on the type of message,
as shown in Table
• Destination IP Addresses
ICMPv4
• The IPv4 has no error-reporting or error-correcting mechanism. What happens if something goes
wrong?
• What happens if a router must discard a datagram because it cannot find a route to the final
destination, or because the time-to-live field has a zero value?
• What happens if the final destination host must discard the received fragments of a datagram
because it has not received all fragments within a predetermined time limit?
• These are examples of situations where an error has occurred and the IP protocol has no built-in
mechanism to notify the original host.
• The IP protocol also lacks a mechanism for host and management queries. A host sometimes needs
to determine if a router or another host is alive. And sometimes a network manager needs
information from another host or router.
• The Internet Control Message Protocol version 4 (ICMPv4) has been designed to compensate for
the above two deficiencies. It is a companion to the IP protocol.
• ICMP itself is a network-layer protocol. However, its messages are not passed directly to the data-
link layer as would be expected. Instead, the messages are first encapsulated inside IP datagrams
before going to the lower layer. When an IP datagram encapsulates an ICMP message, the value of
the protocol field in the IP datagram is set to 1 to indicate that the IP payroll is an ICMP message.
ICMPV4 MESSAGES
• General format of ICMP 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.
For example, nodes can discover their neighbors.
• Also, hosts can discover and learn about routers on their network and routers can help a node redirect its messages.
• An ICMP message has an 8-byte header and a variable-size data section. Although the general format of the header is
different for each message type, the first 4 bytes are common to all. As Figure shows, the first field, ICMP type, defines the
type of the message. The code field specifies the reason for the particular message type.
• The last common field is the checksum field . The rest of the header is specific for each message type The 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 query.
• We give a brief description of the ICMPv4 messages here;
• 1)Error Reporting Messages-Since IP is an unreliable protocol, one of the main responsibilities of ICMP is to report some
errors that may occur during the processing of the IP datagram. ICMP does not correct errors, it simply reports them.
• Error correction is left to the higher-level protocols. 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. To make the error-
reporting process simple, ICMP follows some rules in reporting messages.
• First, no error message will be generated for a datagram having a multicast address or special address (such as this host or
loopback).
• Second, no ICMP error message will be generated in response to a datagram carrying an ICMP error message.
• Third, no ICMP error message will be generated for a fragmented datagram that is not the first fragment.
• Note that all error messages contain a data section that includes the IP header of the
original datagram plus the first 8 bytes of data in that datagram.
• The original datagram header is added to give the original source, which receives the
error message, information about the datagram itself.
• The 8 bytes of data are included because the first 8 bytes provide information about the
port numbers (UDP and TCP) and sequence number (TCP).
• This information is needed so the source can inform the protocols (TCP or UDP) about
the error.
• Note that all error messages contain a data section that includes the IP header of the
original datagram plus the first 8 bytes of data in that datagram. The original datagram
header is added to give the original source, which receives the error message,
informa_x0002_tion about the datagram itself.
• The 8 bytes of data are included because, the first 8 bytes provide information about the
port numbers (UDP and TCP) and sequence number (TCP). This information is needed so
the source can inform the protocols (TCP or UDP) about the error. ICMP forms an error
packet, which is then encapsulated in an IP datagram
Contents of data field for the error messages
1)Destination Unreachable
• The most widely used error message is the destination unreachable (type 3). This message uses different codes (0 to 15) to define the type
of error message and the reason why a datagram has not reached its final destination. For example, code 0 tells the source that a host is
unreachable. This may happen, for example, when we use the HTTP protocol to access a web page, but the server is down. The message
“destination host is not reachable” is created and sent back to the source.
2)Source Quench
• Another error message is called the source quench (type 4) message, which informs the sender that the network has encountered
congestion and the datagram has been dropped; the source needs to slow down sending more datagrams. In other words,
• ICMP adds a kind of congestion control mechanism to the IP protocol by using this type of message.
3)Redirection Message
• The redirection message (type 5) is used when the source uses a wrong router to send out its message. The router redirects the message to
the appropriate router, but informs the source that it needs to change its default router in the future. The IP address of the default router is
sent in the message.
• We discussed the purpose of the time-to-live (TTL) field in the IP datagram and explained that it prevents a datagram from being aimlessly
circulated in the Internet. When the TTL value becomes 0, the datagram is dropped by the visiting router and a time exceeded message
(type 11) with code 0 is sent to the source to inform it about the situation. The time-exceeded message (with code 1) can also be sent when
not all frag_x0002_ments of a datagram arrive within a predefined period of time.
• Parameter Problem
• A parameter problem message (type 12) can be sent when either there is a problem in the header of a datagram (code 0) or some options
are missing or cannot be interpreted (code 1).
Query Messages
• Interestingly, query messages in ICMP can be used independently without relation to an IP datagram.
• Of course, a query message needs to be encapsulated in a datagram, as a carrier.
• Query messages are used to probe or test the liveliness of hosts or routers in the Internet, find the one -way or the round-trip time for an IP datagram
between two devices, or even find out whether the clocks in two devices are synchronized.
• Naturally, query messages come in pairs: request and reply. The echo request (type 8) and the echo reply (type 0) pair of me ssages are used by a host
or a router to test the liveliness of another host or router.
• A host or router sends an echo request message to another host or router; if the latter is alive, it responds with an echo reply message. We shortly see
the applications of this pair in two debugging tools: ping and traceroute.
• The timestamp request (type 13) and the timestamp reply (type 14) pair of mes_x0002_sages are used to find the round -trip time between two
devices or to check whether the clocks in two devices are synchronized. The timestamp request message sends a 32 -bit number, which defines the
time the message is sent.
• The timestamp reply resends that number, but also includes two new 32-bit numbers representing the time the request was received and the time
the response was sent. If all timestamps represent Universal time, the sender can calculate the one-way and round-trip time.
Deprecated Messages
• Three pairs of messages are declared obsolete by IETF:
• 1. Information request and replay messages are not used today because their duties are done by the Address Resolution Protoco l (ARP) discussed in
Chapter 9.
• 2. Address mask request and reply messages are not used today because their duties are done by the Dynamic Host Configuration Protocol (DHCP),
discussed in Chapter 18.
• 3. Router solicitation and advertisement messages are not used today because their duties are done by the Dynamic Host Config uration Protocol
(DHCP),
Debugging Tools
• There are several tools that can be used in the Internet for debugging. We can determine the viability of a host or router. We can trace the
route of a packet. We introduce two tools that use ICMP for debugging: ping and traceroute.
• Ping
• We can use the ping program to find if a host is alive and responding. We use ping here to see how it uses ICMP packets.
• The source host sends ICMP echo-request messages; the destination, if alive, responds with ICMP echo-reply messages.
• The ping program sets the identifier field in the echo-request and echo-reply message and starts the sequence number from 0; this number
is incremented by 1 each time a new message is sent.
• Note that ping can calculate the round-trip time. It inserts the sending time in the data section of the message.
• When the packet arrives, it subtracts the arrival time from the departure time to get the round-trip time (RTT).
• Traceroute or Tracert
• The traceroute program in UNIX or tracert in Windows can be used to trace the path of a packet from a source to the destination. It can find
the IP addresses of all the routers that are visited along the path. The program is usually set to check for the maximum of 30 hops (routers)
to be visited. The number of hops in the Internet is normally less than this. Since these two programs behave differently in Unix and
Windows, we explain them separately
Use of ICMPv4 in traceroute
ICMP Checksum(In ICMP the checksum is calculated over the entire message (header and
data).