0% found this document useful (0 votes)
10 views

Module 4 Lec 28-30 - Introduction and Basics of IPv4 Header

Uploaded by

parvezimad123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Module 4 Lec 28-30 - Introduction and Basics of IPv4 Header

Uploaded by

parvezimad123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

CN (IT-3001)

Network Layer: Introduction & basics of IPv4 Datagram


Prof. Amit Jha
School of Electronics Engineering (SOEE)
KIIT Deemed to be University

Disclaimer: The contents in this slide have been referred from many sources which I do not claim as my own. Some of the content has been modified for easier
understanding of the students without any malafide intention. This slide is only for educational purpose strictly, and not for the commercial purpose.
Objectives
• The objective of this module is to discus following concepts…
1. Position of Network Layer
2. Services and Responsibilities of Network Layer
3. Performance parameter at the Network Layer
4. Network Layer Protocol
1. IPv4 Datagram Format
5. Fragmentation

Amit Jha, SOEE, KIIT-DU


Communication at the Network Layer
Responsibilities of the Network Layer
• Packetizing: the first responsibility of the network layer is
encapsulating the payload in a network-layer packet at the source and
decapsulating the payload from the network layer packet at the
destination.
• Addressing: It adds a header that includes the logical addresses of
source and destination to the packet coming from the upper layer.
• Routing: The most vital responsibility of the network layer is routing
mechanism.
• Delivery: The network layer is responsible for the delivery of
individual packets from the source to the destination host.
Amit Jha, SOEE, KIIT-DU
Network Layer Performance
• The performance of the network can be measured in terms of delay,
throughput, and packet loss.
• Delay includes:
1. Transmission Delay
2. Propagation Delay All these are already discussed in Module-1
3. Processing Delay
4. Queuing Delay
• Throughput
• Packet Loss

Amit Jha, SOEE, KIIT-DU


• If we assume equal delays for the sender, routers, and receiver, then
total delay (source-to-destination) a packet encounters can be
calculated if we know the number of routers, n, in the whole path as
follows.
𝑇𝑜𝑡𝑎𝑙 𝐷𝑒𝑙𝑎𝑦 = 𝑛 + 1 𝑇𝑡𝑟 + 𝑇𝑝𝑟𝑜𝑝 + 𝑇𝑝𝑟𝑜𝑐 + 𝑛 {𝑇𝑞𝑢𝑒𝑢 }
• Throughput: Throughput at any point in the network is defined as the
number of bits passing through the point in a second successfully,
which is actually the transmission rate of the data at that point.

Example 4.1: Calculate the throughput for the diagram shown above.
Answer- 100 Kbps
Explanation:- 𝑇ℎ𝑟𝑜𝑢𝑔ℎ𝑝𝑢𝑡 = 𝑚𝑖𝑛𝑖𝑚𝑢𝑚{𝑇𝑅1 , 𝑇𝑅2 , … . . 𝑇𝑅𝑛 , }
• Packet Loss: When a router receives a packet while processing another packet, the
received packet needs to be stored in the input buffer waiting for its turn. A router,
however, has an input buffer with a limited size. A time may come when the buffer
is full and the next packet needs to be dropped. This results in packet loss. 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.
Structure of a Router
• The overview of a router is shown below briefly.

Amit Jha, SOEE, KIIT-DU


• Input port:
• An input port performs the physical and link-layer functions of the router.
• The bits are constructed from the received signal. The bits are decapsulated from the frame,
checked for errors, and discarded if corrupted.
• The packet is then ready to be processed by the network layer.
• In addition to a physical-layer processor and a link-layer processor, the input port has buffers
(queues) to hold the packets before they are directed to the switching fabric.
• Output Port:
• An output port performs the same functions as the input port, but in the reverse order.
• First the outgoing packets are queued, then each packet is encapsulated in a frame, and finally the
physical layer function is applied to the frame to create the signals to be sent on the line.
• Routing Processor:
• Routing processor searches the forwarding table.
• Routing processor uses the destination address to find the address of the next hop and, at the same
time, the output port number from which the packet is sent out.
• Switching Fabrics:
• Switching fabrics is used to move the packets from the input queue to the output queue.
• Some of the switching fabrics include:
• Crossbar Switch
• Banyan Switch
• Batcher-Banyan Switch
Network Layer Protocols

Amit Jha, SOEE, KIIT-DU


Internet as a Datagram Network
- Out of three switching techniques: circuit, message and packet
switching; the Internet has chosen packet switching.
- Out of two available approaches: virtual circuit and datagram;
switching at the network layer in the Internet uses the datagram
approach to packet switching.
- Thus, communication at the network layer in the Internet is
connectionless.
- Packets at the IP layer are called datagrams.

Amit Jha, SOEE, KIIT-DU


IPv4 Datagram Format
Total length including header, Option
and data
Defines version 4 or 6

This 4 bytes are related


to fragmentation

Maximum time for which a packet


can be in the network or
maximum number of hops it can
visit
32 bits
Note: It is customary in TCP/IP to show the header in 4-byte sections.
Amit Jha, SOEE, KIIT-DU
• HLEN:
• It defines he total length of the datagram header in 4-bytewords.
• When there are no options, the header length is 20 bytes, and the value of this field is
5 (5 x 4=20). When the option field is at its maximum size, the value of this field is
15 (15 x 4=60).
• Service Type: In this interpretation, the first 3-bits are called precedence bits. The next
4- bits are called type of service (TOS) bits, and the last bit is not used.
a. Precedence: It is a 3-bit sub field ranging from 0 to 7. It defines the priority of the
datagram in issues such as congestion. If a router is congested and needs to discard
some datagrams, those datagrams with lowest precedence are discarded first.
b. TOS: Only one bit can be set at a time.

Amit Jha, SOEE, KIIT-DU


Fig: Service type
• TTL: Maximum time for which a packet can be in the network or maximum number of hops it can visit. A
router which processes a datagram decrements the value of TTL field by 1.
• Protocol: This 8-bit field defines the higher-level protocol that uses the services
of the IP layer.

Question: After processing a packet, if TTL becomes zero, then comment whether this packet will be sent to the next
router or not?
Question: Can a router receive a packet with TTL=0?

Fig: Protocol field and encapsulated data


SCTP: Stream control transmission protocol ICMP: Internet Control Message Protocol
TCP: Transmission control protocol IGMP: Internet Group Management Protocol
UDP: User Datagram Protocol OSPF: Open Shortest Path First
Amit Jha, SOEE, KIIT-DU
• Checksum: Used for error detection of the header parts only but not the data.
This is because;
- First, all higher-level protocols that encapsulate data in the IPv4 datagram
have a checksum field that covers the whole packet.
- Second, the header of the IPv4 packet changes with each visited router, but
the data do not.

Note: First, the value in the checksum field is kept 0. Then the entire header is divided
into 16-bit sections and added together. The result (sum) is complemented and
inserted into the checksum field.

• Option: It is not compulsory part of the IPv4 header. Its maximum size is of 40
bytes and this field is used for network testing and debugging.
Fragmentation
What is fragmentation and why it is needed?
• Need: The value of maximum transfer unit (MTU) depends upon the physical
layer protocol. For e.g., the maximum and minimum value of MTU is 65,535 in
case of Hyperchannel and 296 in case of PPP. If size of IPv4 datagram equals to
65,535 then transmission becomes more efficient. But at the same time, it is not
possible to send this size of datagram over other than Hyperchannel network.
Hence, we need to divide a datagram into smaller datagrams such that it can pass
over any physical networks. This is called fragmentation.
Maximum Transfer Unit (MTU): It is the maximum size of the data field.
In other words, when a datagram is encapsulated in a frame, the total size of the
datagram must be less than this maximum size.

IP datagram

MTU
Header Maximum length of data to be encapsulated in a frame Trailer
Fields Related to Fragmentation
• Identification: The identification number helps the destination in
reassembling the datagram. It knows that all fragments having the
same identification value must be assembled into one datagram.
• Flags: The first bit is reserved. If D=1, then datagram can not be
fragmented. If M=1, there are more fragments after this one. If M=0, it
means this is the last or only fragment.

D M
Fig: Flags used in fragment D: Do not fragment
M: More fragment

Amit Jha, SOEE, KIIT-DU


• Fragment Offset: This 13-bit field shows the relative position of this fragment
with respect to the whole datagram. It is measured in units of 8 bytes.

Example 4.2: Fragmentation in a datagram with a data size of 4000 bytes if MTU
allowed is 1420 bytes only.

Fig: Fragmentation example Amit Jha, SOEE, KIIT-DU


Do we need reassembly? If yes, then how?

Example 4.3: Refer Class Notebook


Question: Do we need reassembly?

Yes, we need reassembly of the packets at the receiver side: It is obvious that even if each fragment follows a
different path and arrives out of order, the final destination host needs to arrange the datagram in proper order.

Question: How the different fragmentations of a datagram will be rearranged?

Answer: The original datagram from the fragments received (if none of them is lost) can be rearranged by using
the following strategy:
1. The first fragment has an offset field value of zero.
2. Divide the length of the first fragment by 8. The second fragment has an offset value equal to that result.
3. Divide the total length of the first and second fragments by 8. The third fragment has an offset value
equal to that result.
4. Continue the process. The last fragment has a more fragment bit value of 0.

Amit Jha, SOEE, KIIT-DU


Amit Jha, SOEE, KIIT-DU
Blind Rule to decide fragment offset.

Blind Rule: Divide the first data of the fragment by 8 to get the offset value
of that fragment.

Amit Jha, SOEE, KIIT-DU


HYU 4.1:
A 1480 byte IPv4 datagram is fragmented into 800 byte, 400 byte and 280 byte datagram.
The second fragment is again fragmented into two fragments of 200 byte each. Neglect the
optional header. Explain the process by mention the following fields for each fragmented
datagram.
i) Total length
ii) Identification
iii) Flag
iv) Offset
Assume identification field value for original datagram is 14,657.

Amit Jha, SOEE, KIIT-DU


Example 4.4: A packet has arrived with an M bit value 0. Is this the first
fragment, the last fragment, or a middle fragment? Do you know if the
packet was fragmented?

Answer: It is the last fragment. However, we can’t say whether original packet is fragmented or not. A non-fragmented
packet is considered the last fragmented.

Example 4.5: Repeat example 1 if value of M bit is 1.

Amit Jha, SOEE, KIIT-DU


All in One concept !!!!!!!!!!!!
Example 4.6: An IPv4 packet has arrived with the first few hexadecimal digits as “0x4802002800210000020001…..”.
Answer the following questions.
a) This packet belongs to version 4 or 6?
b) How many bytes of options are carried by this packet?
c) Which type of the service is associated with this packet viz. delay, throughput, reliability and cost?
d) How many bytes of data are being carried by this packet?
e) What is the sequence number of this packet?
f) Is it first or last fragment?
g) How many hops can it pass through?
h) Is the packet correctly received?
Answers:
a) Version 4 since first byte is 4.
b) Second byte is 8. so HLEN is 8*4=32 bytes. So 32-20= 12 bytes of options are being carried.
c) 0x02 in binary = 00000010 thus minimize cost.
d) 0x0028 in binary = 0000 0000 0010 1000 = 40 in decimal. Thus (40-32)= 8 bytes of data.
e) 0x0021 in binary = 0000 0000 0010 0001 = 33 in decimal. Thus sequence number is 33
f) First fragment since offset value is 0. (Note: If offset would not have been 0, it would have been last
fragment.)
g) 9th byte is 02 which says 2 number of hops.
h) It cant be said since we don’t know the value of rest of the fields.
Amit Jha, SOEE, KIIT-DU
Practice Questions as HYU
2. A 64 bytes of packet is sent over a 100 Mbps link. If the value of
TTL field is 61 at the destination (assume TTL= 63 at source) then
find the total time required to reach the packet to destination.
Assume that the waiting time at each intermediate router is 20 msec.
3. What is the content of HLEN field in IPv4 datagram when header is
followed by two optional header of 16 bytes each?
4. An IPv4 packet has arrived with the first 8 bits as “01000010”. Will
packet be discarded or accepted?
5. In an IPv4 packet, the value of HLEN is 1000 in binary. How many
bytes options are being carried by this packet?
Amit Jha, SOEE, KIIT-DU

You might also like