Module - 4 - Internet Protocols
Module - 4 - Internet Protocols
The network layer in version 4 can be thought of as one main protocol and three auxiliary.
➢ Internet Protocol version 4 (IPv4), is responsible for packetizing, forwarding, and delivery
of a packet at the network layer.
➢ The Internet Control Message Protocol version 4 (ICMPv4) helps IPv4 to handle some
errors that may occur in the network-layer delivery.
➢ The Internet Group Management Protocol (IGMP) is used to help IPv4 in multicasting.
➢ The Address Resolution Protocol (ARP) is used to glue the network and data-link layers in
mapping network-layer addresses to link-layer addresses.
IPv4:
❖ The Interne Internet Protocol version 4 (IPv4) is the deliver delivery mechanism used by
the TCP/IP protocols.
❖ IPv4 is an unreliable and connectionless datagram protocol called as best-effort delivery
service.
❖ For reliability, IPv4 must be paired with a reliable protocol such as TCP.
❖ Each datagram is handled independently, and each datagram can follow a different route to
the destination.
❖ IPv4 relies on a higher-level protocol to take care of packet lost or corrupted during
transmission
❖ Version (VER): This 4-bit field defines the version of the IPv4 protocol. This field tells the IPv4
software running in the processing machine that the datagram has the format of version 4.
❖ Services: Name of this 8-bit field is previously called service type, and is renamed as
differentiated services.
Below shows the interpretation of both services:
Service Type: Differentiated Services:
❖ Total length: This is a 16-bit field that defines the total length (header plus data) of the IPv4
datagram in bytes.
❖ Length of data = total length − header length
Since the field length is 16 bits, the total length of the IPv4 datagram is limited to 65,535 (216 −
1) bytes, of which 20 to 60 bytes are the header and the rest is data from the upper layer.
Ethernet protocol has a minimum and maximum restriction on the size of data that can be
encapsulated in a frame (46 to 1500 bytes). If the size of an IPv4 datagram is less than 46
bytes, some padding will be added to meet this requirement. The mechanism of decapsulation
needs to check the total length field to determine real data and padding.
Example: 1
An IPv4 packet has arrived with the first 8 bits as (01000010)2. The receiver discards the packet.
Why?
Solution:
There is an error in this packet.
The 4 leftmost bits (0100)2 show the version, which is correct.
The next 4 bits (0010)2 show an invalid header length (2 × 4 = 8).
The minimum number of bytes in the header must be 20.
The packet has been corrupted in transmission.
Example: 2
In an IPv4 packet, the value of HLEN is (1000)2. How many bytes of options are being carried by
this packet?
Solution:
The HLEN value is 8, which means the total number of bytes in the header is 8 × 4, or 32 bytes.
The first 20 bytes are the base header; the next 12 bytes are the options.
Solution:
The HLEN value is 5, which means the total number of bytes in the header is 5 × 4, or 20 bytes (no
options).
The total length is (0028)16 or 40 bytes, which means the packet is carrying 20 bytes of data (40 −
20).
Example: 4
An IPv4 packet has arrived with the first few hexadecimal digits as shown.
(45000028000100000102…) 16
How many hops can this packet travel before being dropped? The data belong to what upper-layer
protocol?
Solution:
To find the time-to-live field, we skip 8 bytes (16 hexadecimal digits).
(45000028000100000102…) 16
The time-to-live field is the ninth byte, which is (01)16. This means the packet can travel only one
hop.
The protocol field is the next byte (02)16, which means that the upper-layer protocol is IGMP.
Example: 5
Figure shows an example of a checksum calculation for an IPv4 header without options. The
header is divided into 16-bit sections. All the sections are added and the sum is complemented
after wrapping the leftmost digit.
Note that the calculation of wrapped sum and checksum can also be done as follows in
hexadecimal: Checksum = Complement of Sum.
Prepared by Aruna R , Dept. of ECE, Sri Sairam College of Engineering, Anekal. 5
Module-4 Internet Protocols
Regulation – 2017 Scheme
COMPUTER COMMUNICATION NETWORKS-17EC64
Module - 4 - Internet Protocols
Fragmentation
A datagram can travel through different networks. Each router decapsulates the IPv4 datagram
from the frame it receives, processes it, and then encapsulates it in another frame. The format and
size of the sent frame depend on the protocol used by the physical network through which the
frame is going to travel.
Identification: This 16-bit field identifies a datagram originating from the source host. The
combination of the identification and source IPv4 address must uniquely define a datagram as it
leaves the source host.
❖ The offset of the data in the original datagram measured in units of 8 bytes.
❖ Datagram with a data size of 4000 bytes fragmented into three fragments.
❖ The bytes in the original datagram are numbered 0 to 3999.
❖ The first fragment carries bytes 0 to 1399. The offset for this datagram is 0/8 = 0.
❖ The second fragment carries bytes 1400 to 2799; the offset value for this fragment is 1400/8 =
175.
❖ Finally, the third fragment carries bytes 2800 to 3999. The offset value for this fragment is
2800/8 = 350.
❖ Remember that the value of the offset is measured in units of 8 bytes. This is done because the
length of the offset field is only 13 bits and cannot represent a sequence of bytes greater than
8191. This forces hosts or routers that fragment datagram’s to choose a fragment size so that
the first byte number is divisible by 8.
The identification field is the same in all fragments and the value of the flags field with the more
bit set for all fragments except the last. Also, the value of the offset field for each fragment is
shown.
The below figure shows a fragment itself is fragmented. In this case the value of the offset field is
always relative to the original datagram.
For example, in the figure, the second fragment is itself fragmented later to two fragments of 800
bytes and 600 bytes, but the offset shows the relative position of the fragments to the original
data.
It is obvious that even if each fragment follows a different path and arrives out of order, the final
destination host can reassemble the original datagram from the fragments received (if none of
them is lost) by using the following strategy:
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: 7
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).
Example: 8
A packet has arrived with an M bit value of 1 and a fragmentation offset value of 0. Is this the first
fragment, the last fragment, or a middle fragment?
Solution:
Because the M bit is 1, it is either the first fragment or a middle one. Because the offset value is 0, it
is the first fragment.
Example: 9
A packet has arrived in which the offset value is 100. What is the number of the first byte? Do we
know the number of the last byte?
Solution:
To find the number of the first byte, we multiply the offset value by 8.
This means that the first byte number is 800.
We cannot determine the number of the last byte unless we know the length of the data.
Example: 10
A packet has arrived in which the offset value is 100, the value of HLEN is 5, and the value of the
total length field is 100. What are the numbers of the first byte and the last byte?
Solution:
The first byte number is 100 × 8 = 800. The total length is 100 bytes, and the header length is 20
bytes (5 × 4), which means that there are 80 bytes in this datagram.
If the first byte number is 800 and the last byte number must be 879.
No Operation
A no-operation option is a 1-byte option used as filler between options.
End of Option
An end-of-option option is a 1-byte option used for padding at the end of the option field. It,
however, can only be used as the last option.
Record Route
A record route option is used to record the Internet routers that handle the datagram. It can list up
to nine router addresses. It can be used for debugging and management purposes.
Example:
❖ If a datagram specifies a strict source route, all the routers defined in the option must be
visited by the datagram.
❖ A router must not be visited if its IPv4 address is not listed in the datagram.
❖ If the datagram visits a router that is not on the list, the datagram is discarded and an error
message is issued.
❖ If the datagram arrives at the destination and some of the entries were not visited, it will
also be discarded and an error message issued.
Timestamp
A timestamp option is used to record the time of datagram processing by a router.
The time is expressed in milliseconds from midnight, Universal time or Greenwich meantime.
Knowing the time a datagram is processed can help users and managers track the behavior of the
routers in the Internet. We can estimate the time it takes for a datagram to go from one router to
another. We say estimate because, although all routers may use Universal time, their local clocks
may not be synchronized.
Packet Sniffing
Packet sniffing cannot be stopped, encryption of the packet can make the attacker’s effort useless.
The attacker may still sniff the packet, but the content is not detectable.
Packet Modification
This type of attack can be detected using a data integrity mechanism. The receiver, before opening
and using the contents of the message, can use this mechanism to make sure that the packet has
not been changed during the transmission.
IP Spoofing
An attacker can send an IP packet to a bank pretending that it is coming from one of the
customers. This type of attack can be prevented using an origin authentication mechanism.
❖ Packet Encryption:
The packets exchanged between two parties can be encrypted for privacy using one of the
encryption algorithms and a shared key agreed upon in the first step. This makes the
packet sniffing attack useless.
❖ Data Integrity:
Data integrity guarantees that the packet is not modified during the transmission. If the
received packet does not pass the data integrity test, it is discarded. This prevents the
second attack, packet modification, described above.
Prepared by Aruna R , Dept. of ECE, Sri Sairam College of Engineering, Anekal. 11
Module-4 Internet Protocols
Regulation – 2017 Scheme
COMPUTER COMMUNICATION NETWORKS-17EC64
Module - 4 - Internet Protocols
❖ Origin Authentication:
IPSec can authenticate the origin of the packet to be sure that the packet is not created by
an imposter. This can prevent IP spoofing attacks as described above.
ICMP MESSAGES
ICMP messages are divided into two broad categories:
➢ Error-reporting messages:
The error-reporting messages report problems that a router or a host (destination) may
encounter when it processes an IP packet.
➢ Query messages:
The query messages, which occur in pairs, help a host or a network manager get specific
information from a router or another host.
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. As shows in below figure, 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.
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 for not reached its final destination.
Source Quench
➢ Source quench (type 4) message, 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.
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.
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
➢ Query messages in ICMP can be used independently without relation to an IP datagram.
➢ Query message needs to be encapsulated in a datagram, as a carrier.
➢ Query messages are used to test the liveliness of hosts or routers in the Internet.
➢ Query messages come in pairs: request and reply.
➢ The echo request (type 8) and the echo reply (type 0) pair of messages is 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 later is
alive, it responds with an echo reply message.
➢ The timestamp request (type 13) and the timestamp reply (type 14) pair of messages is
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 a two new 32-bit number representing the time the request
was received and the time the response was sent.
Prepared by Aruna R , Dept. of ECE, Sri Sairam College of Engineering, Anekal. 13
Module-4 Internet Protocols
Regulation – 2017 Scheme
COMPUTER COMMUNICATION NETWORKS-17EC64
Module - 4 - Internet Protocols
➢ 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 Protocol (ARP).
2. Address mask request and reply messages are not used today because their duties are
done by the Dynamic Host Configuration Protocol (DHCP).
3. Router solicitation and advertisement messages are not used today because their duties
are done by the Dynamic Host Configuration Protocol (DHCP).
Debugging Tools
There are two tools that use ICMP for debugging:
➢ Ping and
➢ Traceroute
Ping
➢ The ping program is to find if a host is alive and responding.
➢ 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.
➢ 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.
Traceroute
The traceroute program gets help from two error-reporting messages: time-exceeded and
destination-unreachable.
The traceroute is an application layer program, but only the client program is needed, because
there is no traceroute server program.
The traceroute application program is encapsulated in a UDP user datagram, but traceroute
intentionally uses a port number that is not available at the destination.
Example:
If there are n routers in the path, the traceroute program sends (n + 1) messages. The first n
messages are discarded by the n routers, one by each router; the last message is discarded by the
destination host.
The traceroute client program uses the (n + 1) ICMP error-reporting messages received to find the
path between the routers.
The first traceroute message is sent with time-to-live (TTL) value set to 1; the message is
discarded at the first router and a time-exceeded ICMP error message is sent, from which the
traceroute program can find the IP address of the first router (the source IP address of the error
message) and the router name (in the data section of the message).
The second traceroute message is sent with TTL set to 2, which can find the IP address and the
name of the second router.
Similarly, the third message can find the information about router 3. The fourth message,
however, reaches the destination host. This host is also dropped, but for another reason.
The destination host cannot find the port number specified in the UDP user datagram.
This time ICMP sends different message, the destination-unreachable message with code 3 to
show the port number is not found.
After receiving this different ICMP message, the traceroute program knows that the final
destination is reached. It uses the information in the received message to find the IP address and
the name of the final destination.
The traceroute program also sets a timer to find the round-trip time for each router and the
destination. Most traceroute programs send three messages to each device, with the same TTL
value, to be able to find a better estimate for the round-trip time.
Tracert
The tracert program in windows behaves differently. The tracert messages are encapsulated
directly in IP datagrams. The tracert, like traceroute, sends echo-request messages. However,
when the last echo request reaches the destination host, an echo replay message is issued.
MOBILE IP
The extension of IP protocol allows mobile computers to be connected to the Internet at any
location; where the connection is possible.
Addressing
The main problem that must be solved in providing mobile communication using the IP protocol is
addressing.
Stationary Hosts
➢ The IP addresses are designed to work with stationary hosts because part of the address
defines the network to which the host is attached.
➢ IP address has two parts: a prefix and a suffix.
➢ The prefix associates a host with a network. They use the prefix to deliver the packet to the
network to which the host is attached. This scheme works perfectly with stationary hosts.
Mobile Hosts
When a host moves from one network to another, the IP addressing structure needs to be
modified.
Two Addresses
❖ Mobile IP has two addresses for a mobile host:
➢ Home address and
➢ Care-of address
❖ The approach that is more feasible is the use of two addresses.
❖ The host has its original address, called the home address, and a temporary address, called the
care-of address.
❖ The home address is permanent; it associates the host with its home network, the network
that is the permanent home of the host.
❖ The care-of address is temporary. When a host moves from one network to another, the care-
of address changes; it is associated with the foreign network, the network to which the host
moves.
❖ Figure shows the concept.
Agents
The position of a home agent relative to the home network and a foreign agent relative to the
foreign network are shown in figure to make the change of address transparent. They are both
routers and hosts.
Home Agent
The home agent is usually a router attached to the home network of the mobile host.
It receives the packet and sends it to the foreign agent.
Prepared by Aruna R , Dept. of ECE, Sri Sairam College of Engineering, Anekal. 17
Module-4 Internet Protocols
Regulation – 2017 Scheme
COMPUTER COMMUNICATION NETWORKS-17EC64
Module - 4 - Internet Protocols
Foreign Agent
The foreign agent is usually a router attached to the foreign network.
The foreign agent receives and delivers packets sent by the home agent to the mobile host. The
mobile host can also act as a foreign agent.
➢ The mobile host can act as foreign agent with care-of address.
➢ In addition, the mobile host needs the necessary software to allow it to communicate with
the home agent and to have two addresses: its home address and its care-of address.
➢ When the mobile host acts as a foreign agent, the care-of address is called a collocated care-
of address.
❖ The advantage of using a collocated care-of address is that the mobile host can move to
any network without worrying about the availability of a foreign agent.
❖ The disadvantage is that the mobile host needs extra software to act as its own foreign
agent.
Three Phases
To communicate with a remote host, a mobile host goes through three phases:
❖ Agent discovery
❖ Registration and
❖ Data transfer
❖ The first phase, agent discovery, involves the mobile host, the foreign agent, and the home
agent.
❖ The second phase, registration, also involves the mobile host and the two agents.
❖ Finally, in the third phase, the remote host is also involved.
Prepared by Aruna R , Dept. of ECE, Sri Sairam College of Engineering, Anekal. 18
Module-4 Internet Protocols
Regulation – 2017 Scheme
COMPUTER COMMUNICATION NETWORKS-17EC64
Module - 4 - Internet Protocols
Agent Discovery
❖ The first phase in mobile communication, agent discovery, consists of two sub phases.
❖ A mobile host must discover (learn the address of) a home agent before it leaves its home
network.
❖ A mobile host must also discover a foreign agent after it has moved to a foreign network.
❖ This discovery consists of learning the care-of address as well as the foreign agent’s
address.
❖ The discovery involves two types of messages:
o Advertisement and
o Solicitation
Agent Advertisement
When a router advertises its presence on a network using an ICMP router advertisement, it can
append an agent advertisement to the packet if it acts as an agent.
Figure shows how an agent advertisement is piggybacked to the router advertisement packet.
The selection of this care-of address is announced in the registration request. Note that this
Prepared by Aruna R , Dept. of ECE, Sri Sairam College of Engineering, Anekal. 19
Module-4 Internet Protocols
Regulation – 2017 Scheme
COMPUTER COMMUNICATION NETWORKS-17EC64
Module - 4 - Internet Protocols
field is used only by a foreign agent.
Agent Solicitation
When a mobile host has moved to a new network and has not received agent advertisements, it
can initiate an agent solicitation. It can use the ICMP solicitation message to inform an agent that it
needs assistance.
Registration
The second phase in mobile communication is registration. After a mobile host has moved to a
foreign network and discovered the foreign agent, it must register. There are four aspects of
registration:
1. The mobile host must register itself with the foreign agent.
2. The mobile host must register itself with its home agent. This is normally done by the
foreign agent on behalf of the mobile host.
3. The mobile host must renew registration if it has expired.
4. The mobile host must cancel its registration (deregistration) when it returns home.
Registration Request
A registration request is sent from the mobile host to the foreign agent to register its care-of
address and also to announce its home address and home agent address. The foreign agent, after
receiving and registering the request, relays the message to the home agent. Note that the home
agent now knows the address of the foreign agent because the IP packet that is used for relaying
has the IP address of the foreign agent as the source address. Figure 19.16 shows the format of the
registration request.
Registration Reply
A registration reply is sent from the home agent to the foreign agent and then relayed to the
mobile host.
The reply confirms or denies the registration request.
The fields are similar to those of the registration request with the following exceptions.
The value of the type field is 3.
The code field replaces the flag field and shows the result of the registration request (acceptance
or denial).
The care-of address field is not needed.
Encapsulation
Registration messages are encapsulated in a UDP user datagram.
An agent uses the well-known port 434; a mobile host uses an ephemeral port.
Data Transfer
After agent discovery and registration, a mobile host can communicate with a remote host.
1. Path 1 of Figure shows this step: From Remote agent to Home Agent
The remote host sends a packet as though the mobile host is at its home network. The packet is
intercepted by the home agent, which pretends it is the mobile host. This is done using the
proxy ARP technique.
2. Path 2 of Figure shows this step: From Home Agent to Foreign Agent
Prepared by Aruna R , Dept. of ECE, Sri Sairam College of Engineering, Anekal. 21
Module-4 Internet Protocols
Regulation – 2017 Scheme
COMPUTER COMMUNICATION NETWORKS-17EC64
Module - 4 - Internet Protocols
After receiving the packet, the home agent sends the packet to the foreign agent, using the
tunneling concept. The home agent encapsulates the whole IP packet inside another IP packet
using its address as the source and the foreign agent’s address as the destination.
3. Path 3 of Figure shows this step: From Foreign Agent to Mobile Host
When the foreign agent receives the packet, it removes the original packet. The packet is then
sent to the care-of address.
4. Path 4 of Figure shows this step: From Mobile Host to Remote Host
When a mobile host wants to send a packet to a remote host, it sends as it does normally. The
mobile host prepares a packet with its home address as the source, and the address of the
remote host as the destination. Although the packet comes from the foreign network, it has the
home address of the mobile host.
Transparency
In this data transfer process, the remote host is unaware of any movement by the mobile host. The
remote host sends packets using the home address of the mobile host as the destination address;
it receives packets that have the home address of the mobile host as the source address. The
movement is totally transparent. The rest of the Internet is not aware of the movement of the
mobile host.
Inefficiency in Mobile IP
Communication involving mobile IP can be inefficient.
The inefficiency can be severe or moderate.
❖ The severe case is called double crossing or 2X.
❖ The moderate case is called triangle routing or dog-leg routing.
Double Crossing
Triangle Routing
Triangle routing, the less severe case, occurs when the remote host communicates with a mobile
host that is not attached to the same network (or site) as the mobile host.
❖ When the mobile host sends a packet to the remote host, there is no inefficiency.
❖ When the remote host sends a packet to the mobile host, the packet goes from the remote
host to the home agent and then to the mobile host.
❖ The packet travels the two sides of a triangle, instead of just one side.