SWE-306
Computer Communication &
Networks (CC&N)
Internet Layer
(Week 6 Lecture)
Internet Protocol
IP has the task of delivering packets from
the source host to the destination host
solely based on the IP addresses in the
packet headers.
2
Internet Protocol
Introduced by Vint Cerf and Bob Kahn in
1974
IP versions 0 to 3 were experimental
versions, used between 1977 and 1979.
The first major version of IP, Internet
Protocol Version 4 (IPv4), is the dominant
protocol of the Internet. Its successor is
Internet Protocol Version 6 (IPv6).
3
Internet Protocol - IP
All Internet transport protocols use the
Internet Protocol (IP) to carry data
from source host to destination host.
4
IP Features
IP is a connectionless or datagram
internetwork service, providing no end-to-
end delivery guarantees.
IP datagrams may arrive at the destination
host damaged, duplicated, out of order, or
not at all.
5
IP Features
The layers above IP are responsible for
reliable delivery service when it is required.
The IP protocol includes provision for
addressing, type-of-service specification,
fragmentation and re-assembly, and
security.
The datagram or connectionless nature of
IP is a fundamental and characteristic
feature of the Internet architecture.
6
Connectionless IP
Internetworking
Advantages
Flexibility
Robust
No unnecessary overhead
Unreliable
Not guaranteed delivery
Not guaranteed order of delivery
Packets can take different routes
Reliability is responsibility of next layer up
(e.g. TCP)
7
IP
Operation
8
Router-based Networking
9
Internetworking Protocols
10
IP provides several services:
Addressing. IP headers contain 32-bit addresses which identify the sending and
receiving hosts. These addresses are used by intermediate routers to select a path
through the network for the packet.
Fragmentation. IP packets may be split, or fragmented, into smaller packets. This
permits a large packet to travel across a network which can only handle smaller
packets. IP fragments and reassembles packets transparently.
Packet timeouts. Each IP packet contains a Time To Live (TTL) field, which is
decremented every time a router handles the packet. If TTL reaches zero, the packet
is discarded, preventing packets from running in circles forever and flooding a
network.
Type of Service. IP supports traffic prioritization by allowing packets to be labeled
with an abstract type of service.
Options. IP provides several optional features, allowing a packet's sender to set
requirements on the path it takes through the network (source routing), trace the
route a packet takes (record route), and label packets with security features.
11
Internet Protocol Packet
Header
12
VERS - Version
The version of the IP protocol. The current
version is 4. 5 is experimental and 6 is
IPng (see IP: The Next Generation (IPng)).
The version
of the IP
protocol
13
LEN - Length
The length of the IP header counted in 32-
bit quantities. This does not include the
data field.
The length
of the IP
header
14
Type of Service
The type of service is an indication of the
quality of service requested for this IP
datagram.
quality of
service??
15
Type of Service - Precedence
Is a measure of the nature and
priority of this datagram:
000 Routine
001 Priority
010 Immediate
011 Flash
100 Flash override
101 Critical
110 Internetwork control
111 Network control
16
TOS - Type Of Service
Specifies the type of
service value:
1000 Minimize delay
0100 Maximize
throughput
0010 Maximize reliability
0001 Minimize monetary
cost
0000 Normal service
A detailed description of the type
of service can be found in the RFC
1349 17
MBZ - Must Be Zero
Reserved for
future use
("must be
zero" unless
participating in
an Internet
protocol
experiment
which makes
use of this bit)
18
Total Length
Total length of the IP datagram in bytes
Maximum size is 64k because there are 16
bits for it
That means a single IP datagram cannot
be bigger than 65536 bytes including the
header
19
Fragmentation Related
Information
The next 32 bits contain information related to
fragmentation
This information can be used to reassemble a
fragmented IP datagram
Fragmentation means that on its way a single IP
datagram was broken into smaller IP datagrams
because the intervening network was unable to
carry the original datagram because it was too big
20
Why Fragment?
When an IP datagram travels from one host to another, it can cross
different physical networks. Physical networks have a maximum frame
size, called the Maximum Transmission Unit (MTU), which limits the length
of a datagram that can be placed in one physical frame. Therefore, a
scheme has been put in place to fragment long IP datagrams into smaller
ones, and to reassemble them at the destination host. IP requires that
each link has an MTU of at least 68 bytes, so if any network provides a
lower value than this, fragmentation and re-assembly must be
implemented in the network interface layer in a way that is transparent to
IP. 68 is the sum of the maximum IP header length of 60 bytes and the
minimum possible length of data in a non-final fragment (8 bytes). IP
implementations are not required to handle unfragmented datagrams
larger than 576 bytes, but most implementations will handle larger values,
typically slightly more than 8192 bytes or higher, and rarely less than
1500.
21
Why Fragment?
Host - A in LAN -1 is commnicating
with Host - B in LAN -2 using IP
Host - A Host - B
LAN -1 WAN -1 LAN - 2
Router Router
Ethernet X.25 Ethernet -2
A B
MTU = 1500 bytes MTU = 128 bytes MTU = 1500 bytes
Router A has to perform
fragmentation of IP datagrams
when forwarding them from
LAN-1 to WAN-1
22
Fragmentation Procedure
An unfragmented datagram has all-zero
fragmentation information. That is, the
more fragments flag bit is zero and the
fragment offset is zero. When
fragmentation is to be done, the following
steps are performed:
23
Fragmentation Procedure
The DF flag bit is checked to see if
fragmentation is allowed. If the bit is set,
the datagram will be discarded and an
error will be returned to the originator
using ICMP.
Based on the MTU value, the data field is
split into two or more parts. All newly
created data portions must have a length
which is a multiple of 8 bytes, with the
exception of the last data portion.
24
Fragmentation Example
25
Fragmentation Procedure - 2
All data portions are placed in IP datagrams. The header of these
datagrams are copies of the original one, with some modifications:
The more fragments flag bit is set in all fragments except the last.
The fragment offset field in each is set to the location this data
portion occupied in the original datagram, relative to the
beginning of the original unfragmented datagram. The offset is
measured in 8-byte units.
If options were included in the original datagram, the high order
bit of the option type byte determines whether or not they will be
copied to all fragment datagrams or just to the first one. For
instance, source route options have to be copied in all fragments
and therefore they have this bit set.
The header length field is of the new datagram is set.
The total length field of the new datagram is set.
The header checksum field is re-calculated.
26
Fragmentation Procedure - 3
Each of these fragmented datagrams is
now forwarded as a normal IP datagram.
IP handles each fragment independently,
that is, the fragments may traverse
different routers to the intended
destination, and they may be subject to
further fragmentation if they pass through
networks that have smaller MTUs.
27
28
Correction in Previous Slide
There are two major points that should be considered in the
previous slide
1. Size of header during the process of fragmentation
2. Size of fragmented data should be taken as integral
multiple of 8. So that the offset field of the next fragment
can be mentioned.
Now considering these two factors the new calculation would
be as follows
Note: Consider the default header size that is 20 Bytes
29
Correction
Fill in the remaining fields
30
Reassembley Procedure
At the destination host, the data has to be
reassembled into one datagram. The identification
field of the datagram was set by the sending host
to a unique number (for the source host, within
the limits imposed by the use of a 16-bit number).
As fragmentation doesn't alter this field, incoming
fragments at the receiving side can be identified, if
this ID field is used together with the Source and
Destination IP addresses in the datagram. The
Protocol field is also to be checked for this
identification.
31
Reassembley Procedure - 2
In order to reassemble the fragments, the
receiving host allocates a buffer in storage as
soon as the first fragment arrives. A timer routine
is then started. When the timer timeouts and not
all of the fragments have been received, the
datagram is discarded. The initial value of this
timer is called the IP datagram time-to-live (TTL)
value. It is implementation dependent, and some
implementations allow it to be configured; for
example AIX Version 3.2 provides an ipfragttl
option with a default value of 60 seconds.
32
Re-assembly Procedure - 3
When subsequent fragments of the
datagram arrive, before the timer expires,
the data is simply copied into the buffer
storage, at the location indicated by the
fragment offset field. As soon as all
fragments have arrived, the complete
original unfragmented datagram is
restored, and processing continues, just as
for unfragmented datagrams.
33
Fragmentation Fields
Identification - A unique number assigned by
the sender to aid in reassembling a fragmented
datagram. Fragments of a datagram will have the
same identification number.
Fragment Offset - Used with fragmented
datagrams, to aid in reassembly of the full
datagram. The value is the number of 64-bit
pieces (header bytes are not counted) that are
contained in earlier fragments. In the first (or
only) fragment, this value is always zero.
34
Flags
Where:
0 Reserved, must be zero
DF Don't Fragment:
0 means
allow fragmentation
1 means do not allow
fragmentation
MF More Fragments: 0 means that this is
the last fragment of this datagram, 1
means that this is not the last fragment. 35
Dealing with Failure in Re-
assembly
Re-assembly may fail if some fragments
get lost
Need to detect failure
Re-assembly time out
Assigned to first fragment to arrive
If timeout expires before all fragments arrive,
discard partial data
Use packet lifetime (time to live in IP)
If time to live runs out, kill partial data
36
TTL - Time To Live
Specifies the time (in seconds) this
datagram is allowed to travel. Each
router where this datagram passes is
supposed to subtract from this field
its processing time for this datagram.
Actually a router is able to process a
datagram in less than 1 second; thus
it will subtract one from this field, and the
TTL becomes a hop-count metric rather than a time
metric. When the value reaches zero, it is assumed that
this datagram has been traveling in a closed loop and it
is discarded. The initial value should be set by the
higher-level protocol which creates the datagram.
37
Protocol- Protocol Number
Indicates the higher-level protocol to which IP should deliver the data in
this datagram. Some important values are:
0 Reserved
1 Internet Control Message Protocol (ICMP)
2 Internet Group Management Protocol (IGMP)
3 Gateway-to-Gateway Protocol (GGP)
4 IP (IP encapsulation)
5 Stream
6 Transmission Control (TCP)
8 Exterior Gateway Protocol (EGP)
9 Private Interior Routing Protocol
17 User Datagram (UDP)
89 Open Shortest Path First
The full list can be found in STD 2 - Assigned Internet Numbers.
38
Header Checksum
Is a checksum on the header only. It does
not include the data. The checksum is
calculated as the 16-bit one's complement
of the one's complement sum of all 16-bit
words in the header. For the purpose of
this calculation, the checksum field is
assumed to be zero. If the header
checksum does not match the contents,
the datagram is discarded because at least
one bit in the header is corrupt, and the
datagram may even have arrived at the
wrong destination.
39
Options
Various options
regarding this
datagram, including
how to route it, how
to identify it (security
labeling), how to
trace the places
through which it •Security
passes, how to time- •Source routing
•Route recording
stamp it for delay •Timestamping
measurement, etc. 40
Options
Options – Up to 40 bytes of option data added by source
host or intermediate routers
1 byte Option id, followed by an optional 1 byte Option
length, followed by Option data
Padded to a multiple of 4 bytes
5 options currently defined
Security – Security identifier
source routing – Complete route specified
Record route – Each router appends its address to
the list
Timestamp – Each router appends address &
timestamp
stream id (used for voice) for stream line
transmission
41