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

Chapter 8

Chapter 8 discusses the Internet Protocol (IP), detailing its structure, including datagrams, fragmentation, and options. It explains the characteristics of IP as an unreliable and connectionless protocol, the format of IP datagrams, and the importance of fields like total length, identification, and checksum. Additionally, the chapter covers fragmentation processes, the maximum transfer unit (MTU), and the options format used in IP packets.

Uploaded by

Ferdous
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Chapter 8

Chapter 8 discusses the Internet Protocol (IP), detailing its structure, including datagrams, fragmentation, and options. It explains the characteristics of IP as an unreliable and connectionless protocol, the format of IP datagrams, and the importance of fields like total length, identification, and checksum. Additionally, the chapter covers fragmentation processes, the maximum transfer unit (MTU), and the options format used in IP packets.

Uploaded by

Ferdous
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 116

Chapter 8

Internet Protocol (IP)


Outline
o Datagram
o Fragmentation
o Options
o Checksum
o IP package
Figure 8-1

Position of IP in TCP/IP Protocol Suite

The McGraw-Hill Companies, Inc., 2000


IP: Internet Protocol
o An unreliable and connectionless datagram
protocol

o A best-effort delivery service


8.1

DATAGRAM

The McGraw-Hill Companies, Inc., 2000


Datagram
o Datagrams
n Packets in the IP layers are called in datagrams
n A variable-length packet
n Consist of two parts
o Header
o Data
Figure 8-2

IP Datagram

The McGraw-Hill Companies, Inc., 2000


IP Datagram
o Version (VER)
o Header length (HLEN)
n Total length of the datagram header in 4-byte
words
n The length of the header is variable
o 20-60 bytes
n If no options, header length is 20 bytes
o HLEN = 5
IP Datagram (Cont.)
o Differentiated Services (DS)
n IETF has recently changed the interpretation and
name of this field
n Formerly Service Type
n See the following slides
Figure 8-3

Service Type or Differentiated Services

The McGraw-Hill Companies, Inc., 2000


Services Type
o Precedence
n 3-bit subfield defines the priority of the datagram
in issues such as congestion
n However, this subfield is not used in version 4
o TOS (Type of Service) bits
n 4-bit subfield with each bit having a special
meaning
n However, one and only one of the bits can be set
The precedence subfield is
not used in version 4.

The McGraw-Hill Companies, Inc., 2000


Types of Services
TOS Bits Description

0000 Normal (default)

0001 Minimize cost

0010 Maximize reliability

0100 Maximize throughput

1000 Minimize delay


Default Types of Service
Protocol TOS Bits Description
ICMP 0000 Normal
BOOTP 0000 Normal
NNTP 0001 Minimize cost
IGP 0010 Maximize reliability
SNMP 0010 Maximize reliability
TELNET 1000 Minimize delay
FTP (data) 0100 Maximize throughput
FTP (control) 1000 Minimize delay
TFTP 1000 Minimize delay
SMTP (command) 1000 Minimize delay
SMTP (data) 0100 Maximize throughput
DNS (UDP query) 1000 Minimize delay
DNS (TCP query) 0000 Normal
DNS (zone) 0100 Maximize throughput
Default Types of Service (Cont.)
o Minimum delay
n Interactive activities
n Activities requiring immediate attention
n Activities requiring immediate response
o Maximum throughput
n Send bulk data
o Maximum reliability
n Management activities
o Minimum monetary cost
n Background activities, like Usenet News (NNTP)
Differentiated Services
o The first 6 bits make up the codepoint
o The last two bits are not used
o The 3 right-most bits are 0s
n The 3 left-most bits are interpreted the same as
the precedence bits in the Service Type
o The 3 right-most bits are not all 0s
n The 6 bits define 64 services based on the priority
assignment by the Internet or local authorities
Values for Codepoints

Category Codepoint Assigning Authority

1 XXXXX0 Internet (IEFT)

2 XXXX11 Local

3 XXXX01 Temporary or experimental


IP Datagram (Cont.)
o Total length
n The total length (header plus data) of the IP datagram in
bytes
n Length of data = total length – header length
o Identification
n Used in fragmentation
o Flags
n Used in fragmentation
o Fragmentation offset
n Used in fragmentation
The total length field defines the
total length of the
datagram including the header.

The McGraw-Hill Companies, Inc., 2000


Figure 8-4

Encapsulation of a Small Datagram


in an Ethernet Frame
o Why we need the total length field
n Layer 2 just drop the header and trailer
n The remaining is the datagram (length)
o However, in some cases, padding is occurred
n Ethernet’s minimum frame data length is 46 bytes
n If size of the IP datagram is less than 46, some padding
will be added
n Thus, check the total length field to determine how much
is really data

The McGraw-Hill Companies, Inc., 2000


Encapsulation of a Small Datagram
in an Ethernet Frame (Cont.)
IP Datagram (Cont.)
o Time to live
n The maximum number of hops visited by the datagram
o Routing table can become corrupted
o Intentionally limit the journey of the packet
n Usually two times the maximum number of routers
between any two hosts
o Protocol
n Define the higher-level protocol that uses the services of
the IP layer
n Help in the demulplexing proccess
Protocols
Value Protocol

1 ICMP

2 IGMP

6 TCP

17 UDP

89 OSPF
Figure 8-5

DeMultiplexing

The McGraw-Hill Companies, Inc., 2000


IP Datagram (Cont.)
o Checksum
o Source address
n Define the IP address of the source
n Never changed between the trip
o Destination address
n Define the IP address of the destination
n Never changed between the trip
Example 1

An IP packet has arrived with the first 8 bits


as shown:
ç 01000010
The receiver discards the packet. Why?

The McGraw-Hill Companies, Inc., 2000


Solution

o There is an error in this packet


o The 4 left-most bits (0100) show the version
n which is correct
o The next 4 bits (0010) show the header length
n which means (2 ´ 4 = 8), which is wrong
n The minimum number of bytes in the header must
be 20
n The packet has been corrupted in transmission
Example 2

In an IP packet, the value of HLEN is 1000


in binary. How many bytes of options are
being carried by this packet?

The McGraw-Hill Companies, Inc., 2000


Solution

o The HLEN value is 8


n The total number of bytes in the header is 8 ´ 4 or
32 bytes

o The first 20 bytes are the main header

o The next 12 bytes are the options.


Example 3

In an IP packet, the value of HLEN is 516


and the value of the total length field is
002816. How many bytes of data are being
carried by this packet?

The McGraw-Hill Companies, Inc., 2000


Solution

o The HLEN value is 5


n the total number of bytes in the header is 5 ´ 4 or
20 bytes (no options)

o The total length is 40 bytes

o The packet is carrying 20 bytes of data (40-20)


Example 4

An IP packet has arrived with the first few


hexadecimal digits as shown below:

ç 45000028000100000102...................
How many hops can this packet travel before
being dropped? The data belong to what
upper layer protocol?
The McGraw-Hill Companies, Inc., 2000
Solution

o To find the time-to-live field, we should skip


8 bytes (16 hexadecimal digits)
o The time-to-live field is the ninth byte
n Which is 01
o The packet can travel only one hop
o The protocol field is the next byte (02)
n The upper layer protocol is IGMP
8.2

FRAGMENTATION

The McGraw-Hill Companies, Inc., 2000


Maximum Transfer Unit (MTU)
o Each data link layer protocol has its own
frame format
n One of this field defines the maximum size of the
data field
o The maximum length of the IP datagram
n 65,535 bytes
o Fragmentation
n We must divide the IP datagram to make it
possible to pass through the underlying network
Figure 8-6

MTU

The McGraw-Hill Companies, Inc., 2000


MTUs for Different Networks
Protocol MTU
Hyperchannel 65,535
Token Ring (16 17, 914
Mbps)
Token Ring (4 Mbps) 4, 464
FDDI 4, 352
Ethernet 1, 500
X.25 576
PPP 296
Fragmentation
o When a IP datagram is fragmented
n Each fragment has its own IP header
n Most of the fields repeated but some changed

o A fragmented datagram may itself be


fragmented
n A datagram can be fragmented several times
Fragmentation (Cont.)
o A datagram can be fragmented by the source
host or any router in the path

o However, the reassembly is done only by the


destination host
n Each fragment becomes an independent datagram
Fragmentation (Cont.)
o When a datagram is fragmented
n Router must change the values of three fields
o Flags, fragmentation offset, and total length

n Option field may or may not be copied

n The value of checksum must be recalculated


regardless of fragmentation
Figure 8-2

IP Datagram

The McGraw-Hill Companies, Inc., 2000


Fields Related to Fragmentation
o Identification
n 16-bit field identifies a datagram originating from
the source host
n The combination of the identification and source
IP address uniquely define a datagram
n IP uses a counter to label the datagram
n When fragmented, identification field is copied
into all fragmentation
n All fragments have the same identification number
Fields Related to Fragmentation (Cont.)
o Flags: 3-bit field
n 1st bit: reserved
n 2nd bit: called do not fragment bit
o 1: do not fragment.
n If cannot pass through the physical network, router discards
the datagram and send an ICMP error message to the source
o 0: can be fragmented if necessary
n 3rd bit: called the more fragment bit
o 1: the datagram is not the last fragment
o 0: this is the last or only fragment
Figure 8-7

Flag Field

The McGraw-Hill Companies, Inc., 2000


Fields Related to Fragmentation (Cont.)
o Fragmentation offset
n The relative position of this fragment with respect
to the whole datagram

n Measured in units of 8 bytes

n Thus, the first byte number of each fragment is


divisible by 8
Figure 8-8

Fragmentation Example

The McGraw-Hill Companies, Inc., 2000


Figure 8-9

Detailed Example

The McGraw-Hill Companies, Inc., 2000


Reassembly
o The first fragment has an offset value of zero
o Divide the length of the first fragment by 8
n The second fragment has an offset value equal to that
result
o Divide the total length of the first and second
fragment by 8
n The third fragment has an offset value equal to that result
o Continue the process until the last fragment has a
more bit value 0
Example 5

A packet has arrived with an M bit value of


0. Is this the first fragment, the last fragment,
or a middle fragment? Do we know if the
packet was fragmented?

The McGraw-Hill Companies, Inc., 2000


Solution

o If the M bit is 0
n There are no more fragments
n The fragment is the last one
o However, we cannot say if the original packet
was fragmented or not
o A nonfragmented packet is considered the last
fragment
Example 6

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?

The McGraw-Hill Companies, Inc., 2000


Solution

o If the M bit is 1
n There is at least one more fragment
o This fragment can be the first one or a middle one,
but not the last one
o We don’t know if it is the first one or a middle one;
we need more information
n The value of the fragmentation offset
o However, we can definitely say the original packet
has been fragmented because the M bit value is 1
Example 7

A packet has arrived with an M bit value of


1 and a fragmentation offset value of zero. Is
this the first fragment, the last fragment, or a
middle fragment?

The McGraw-Hill Companies, Inc., 2000


Solution

o The M bit is 1
n Either the first fragment or a middle one.

o The offset value is 0


n It is the first fragment
Example 8

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?

The McGraw-Hill Companies, Inc., 2000


Solution

o To find the number of the first byte


n Multiply the offset value by 8
n The first byte number is 800.

o We cannot determine the number of the last


byte unless we know the length of the data
Example 9

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 is
the number of the first byte and the last byte?

The McGraw-Hill Companies, Inc., 2000


Solution

o The first byte number is 100 ´ 8 = 800


o The header length is 20 bytes (5 ´ 4)
o The total length is 100 bytes
n There are 80 bytes in this datagram
o If the first byte number is 800, the last byte
number must 879
8.3

OPTIONS

The McGraw-Hill Companies, Inc., 2000


Options Format
o Code field: 1-byte
o Length field: 1-byte
n Total length of the option
o Include the code field and the length field
n Not present in all of the option types
o Data field: variable-sized
n Contain the data that specific option required
n Not present in all option types
Figure 8-10

Option Format

The McGraw-Hill Companies, Inc., 2000


Code Field
o Copy: 1-bit controls the presence of the option in
fragmentation
n 0: the option only appear in the first fragment
n 1: the option appear in all fragments
o Class: 2-bit defines the general purposes of the
option
n 00: the option is used for datagram control
n 10: the option is used for debugging and management
n 01 and 11: have not yet been defined
o Number: 5-bit defines the type of the option
n only 6 types are in use
Option Types
o Only 6 options are currently being used

o Two of them are 1-byte option


n Do not require the length or the data fields

o Four of them are multiple-byte option


n Require the length and the data fields
Figure 8-11

Categories of Options

The McGraw-Hill Companies, Inc., 2000


No Operation
o Used as a filler between options
o For example, used to align the next option on
a 16-bit or 32-bit boundary
End of Option
o Used for padding at the end of the option field
n Can only be used as the last option
n Only one end of option option can be used
n After this option
o The receiver check for the payload data
n Thus, if more than 1 byte is needed to align the
option field
o Some no operation options must be used followed by
an end of option option
End of Option (Cont.)
Record Route
o Used to record the internet routers that handle
the datagram
n Can list up to nine router IP address since the
maximum size of option part in an IP header is 40
bytes
o Pointer: an offset integer field containing the
byte number of the first empty entry
n Point to the first available entry
Figure 8-14

Record Route Option

The McGraw-Hill Companies, Inc., 2000


Record Route (Cont.)
o Initially the pointer field has a value of 4

o When receiving this datagram, the router


n Insert its outgoing IP address in the empty field
n Increment the value of the pointer by 4
Figure 8-15

Record Route Concept

The McGraw-Hill Companies, Inc., 2000


Strict Source Route
o Used by the source to predetermine a route for
the datagram
o Rule
n All the routers defined in the option must be
visited
n A router must not be visited if its IP address is not
listed in the datagram
Strict Source Route (Cont.)
o If the datagram visits a router not on the list
n Discard the datagram and issue an error message

o If the datagram arrives at the destination and


some of the entries were not visited
n Discard the datagram and issue an error message
Figure 8-16

Strict Source Route Option

The McGraw-Hill Companies, Inc., 2000


Strict Source Route Operations
o When a datagram arriving at a router, compare the
pointer value with the length field
n If pointer <= length, compare the IP address pointed by the
pointer with its incoming IP address
o If equal,
n Process the packet
n Overwrite the current IP address with its outgoing IP address
n Increment the pointer by 4
n Forward the packet
o If not equal, discard the datagram and issue an error message
n If pointer > length, discard the datagram and issue an error
message
Strict Source Route Concept
Loose Source Route
o Each router in the list must be visited
o But the datagram can visit other routers as
well
Timestamp
o Used to record the time of datagram
processing by a router
n Expressed in millisecond from midnight,
Universal Time

n Help to track the behavior of the router


Figure 8-19

Timestamp Option

The McGraw-Hill Companies, Inc., 2000


Timestamp Option Format
o Overflow field
n The number of routers that could not add their timestamp
because no more fields were available

o Flag: the visited router responsibilities


n 0: each router add only timestamp in the provided field
n 1: each router add its outgoing IP address and timestamp
n 3: the IP address are given. Each router check the given IP
address with its own incoming IP address
o If match, overwrite with its outgoing IP address and add timestamp
Figure 8-20

Use of Flag in Timestamp

The McGraw-Hill Companies, Inc., 2000


Figure 8-21

Timestamp Concept with Flag Value of 1

The McGraw-Hill Companies, Inc., 2000


Example 10

Which of the six options must be copied to


each fragment?

The McGraw-Hill Companies, Inc., 2000


Solution

o Look at the first (left-most) bit of the code for


each option
n No operation: Code is 00000001; no copy.
n End of option: Code is 00000000; no copy
n Record route: Code is 00000111; no copy
n Strict source route: Code is 10001001; copied
n Loose source route: Code is 10000011; copied
n Timestamp: Code is 01000100; no copy
Example 11

Which of the six options are used for


datagram control and which are used for
debugging and management?

The McGraw-Hill Companies, Inc., 2000


Solution

o Look at the second and third (left-most) bits


of the code
n No operation: Code is 00000001; control
n End of option: Code is 00000000; control
n Record route: Code is 00000111; control
n Strict source route: Code is 10001001; control
n Loose source route: Code is 10000011; control
n Timestamp: Code is 01000100; debugging
Example 12
o One of the utilities available in UNIX to check the
travelling of the IP packets is ping.
o Oing a server named fhda.edu and the result shows
that the IP address of the host is 153.18.8.1

$ ping fhda.edu
PING fhda.edu (153.18.8.1) 56(84) bytes of data.
64 bytes from tiptoe.fhda.edu (153.18.8.1): ....
Example 13
o We can also use the ping utility with the -R
option to implement the record route option
$ ping -R fhda.edu
PING fhda.edu (153.18.8.1) 56(124) bytes of data.
64 bytes from tiptoe.fhda.edu (153.18.8.1): icmp_seq=0 ttl=62 time=2.70 ms
RR: voyager.deanza.fhda.edu (153.18.17.11)
Dcore_G0_3-69.fhda.edu (153.18.251.3)
Dbackup_V13.fhda.edu (153.18.191.249) tiptoe.fhda.edu (153.18.8.1)
Dbackup_V62.fhda.edu (153.18.251.34)
Dcore_G0_1-6.fhda.edu (153.18.31.254)
voyager.deanza.fhda.edu (153.18.17.11)
Example 14
o The traceroute utility can also be used to keep
track of the route of a packet
$ traceroute fhda.edu
traceroute to fhda.edu (153.18.8.1), 30 hops max, 38 byte packets
1 Dcore_G0_1-6.fhda.edu (153.18.31.254) 0.972 ms 0.902 ms 0.881 ms
2 Dbackup_V69.fhda.edu (153.18.251.4) 2.113 ms 1.996 ms 2.059 ms
3 tiptoe.fhda.edu (153.18.8.1) 1.791 ms 1.741 ms 1.751 ms

The result shows the three routers visited.


Example 15
o The traceroute program can be used to
implement loose source routing.
n The -g option allows us to define the routers to be
visited, from the source to destination.
n Following shows how we send a packet to the
fhda.edu server with the requirement that the
packet visit the router 153.18.251.4
$ traceroute -g 153.18.251.4 fhda.edu.
traceroute to fhda.edu (153.18.8.1), 30 hops max, 46 byte packets
1 Dcore_G0_1-6.fhda.edu (153.18.31.254) 0.976 ms 0.906 ms 0.889 ms
2 Dbackup_V69.fhda.edu (153.18.251.4) 2.168 ms 2.148 ms 2.037 ms
Example 16
o The traceroute program can also be used to
implement strict source routing.
n The -G option forces the packet to visit the
routers defined in the command line.
n Following shows how we send a packet to the
fhda.edu server and force the packet to visit the
router 153.18.251.4

$ traceroute -G 153.18.251.4 fhda.edu.


traceroute to fhda.edu (153.18.8.1), 30 hops max, 46 byte packets
1 Dbackup_V69.fhda.edu (153.18.251.4) 2.168 ms 2.148 ms 2.037 ms
8.4

CHECKSUM

The McGraw-Hill Companies, Inc., 2000


Checksum
o Error detection method
o Checksum calculation at the sender
n The packet is divided into k section, each of n bits
n All sections are added together using one’s
complement arithmetic
n The final result is complemented to make the
checksum
Checksum (Cont.)
o Checksum calculation at the receiver
n Divides the received packet, including the
checksum, into k section

n Add all section and then complement the result

n If the final result is 0, the packet is accepted


o Otherwise, reject the packet
To create the checksum the sender does
the following:
1. The packet is divided into k sections,
each of n bits.
2. All sections are added together using
one’s complement arithmetic.
3. The final result is complemented
to make the checksum.
The McGraw-Hill Companies, Inc., 2000
Figure 8-2

IP Datagram

The McGraw-Hill Companies, Inc., 2000


Figure 8-22

Checksum Concept

The McGraw-Hill Companies, Inc., 2000


Checksum Concept
o According to the one’s complement arithmetic
n If all the section are added and the number is T
n Complement T in one’s complement is –T
n Thus, if the sum is T, the checksum is –T
o When the sender receives the packet
n T + (-T) in one’s complement is -0
n Complement -0 derive 0
n Thus, the final result should be 0
Figure 8-23

Checksum in One’s Complement Arithmetic

The McGraw-Hill Companies, Inc., 2000


Checksum in the IP Packet
o The checksum in the IP packet covers only
the header, not the data. This is because
n All higher-level protocols that encapsulate data in
the IP datagram have a checksum field
o Checksum for the IP datagram do no have to check
the encapsulated data
n The header of the IP datagram changes with each
visited router, but the data does not
o If the data is included, each router must recalculate the
check for the whole packet and increase the overhead
Example of Checksum Calculation
in Binary
Example of Checksum Calculation
in Hexadecimal
8.5

IP PACKAGE

The McGraw-Hill Companies, Inc., 2000


IP Package
o IP package may involves following components
n Header-adding module
n Processing module
n Routing module
n Fragmentation module
n Reassembly module
n Routing module
n MTU table
n Reassembly table
n Input/output queue
o Omit the option processing module in the package
Figure 8-26

IP Components

The McGraw-Hill Companies, Inc., 2000


Header-Adding Module
o Receives data from an upper-level protocol
and destination IP address
1. Encapsulate the data in an IP datagram
2. Calculate the checksum and insert it in the
checksum field
3. Send the data to the corresponding input queue
4. Return
Processing Module
o The heart of the IP package

o Receive a datagram from either an interface or


the header-adding module
Processing Module (Cont.)
o Remove one datagram from one of the input queues
o If (destination address is 127.X.Y.Z or match one of the local
address )
n Send the datagram to the reassembly module
n Return
o If (machine is a router )
n Decrement TTL
o If (TTL less than or equal to zero)
n Discard the datagram
n Send an ICMP error message
n Return
o Send the datagram to the routing module
o Return
Queues
o Input queue:
n Store the datagram coming from the data link
layer or the upper-layer protocols
n Dequeued by the processing module
o Output queue:
n Store the datagram going to the data link layer or
the upper-layer protocol
n Enqueued by the fragmentation and reassembly
module
Routing Table, Routing Module, and
MTU Table
o Routing Table
n Discussed before in Chapter 6
o Routing Module
n Discussed before in Chapter 6
o MTU Table
n Used by the fragmentation module to find the
maximum transfer unit of a particular interface
Figure 8-27

MTU Table

The McGraw-Hill Companies, Inc., 2000


Fragmentation Module
o Receive: an IP datagram from the routing module
1. Extract the size of the datagram
2. If (size > MTU of the corresponding interface)
1. If [ D (do not fragment) bit is set ]
1. Discard the datagram and send an ICMP error message
2. Return
2. Else
1. Calculate the maximum size
2. Divide the datagram into fragments
3. Add header to each fragment
4. Add require options to each fragment
5. Send the datagrams
6. Return
3. Else
1. Send the datagram
4. Return
Reassembly Table
o Used by the reassembly module
o Has five fields
n State: FREE or IN-USE
n Source IP address: source IP address of datagram
n Datagram ID
o A number unique defines a datagram and all of the fragments
belonging to that datagram
n Time-out
o A predetermined amount of time in which all fragments must arrive
n Fragments
o A pointer to a linked list of fragments
Figure 8-28

Reassembly Table

The McGraw-Hill Companies, Inc., 2000


Reassembly Module
o Receive, from the processing module, those
datagram fragments arriving at their final
destinations
o Since IP is connectionless
n The fragment may arrive out of order
n Fragments may be intermixed
n Use a reassembly table to keep track of these
fragments
Reassembly Module (Cont.)
o Receive: an IP datagram from the processing module
1. If (fragment offset value is zero and M (more fragment) bits is 0)
1. Send the datagram to the appropriate queue
2. Return
2. Search the reassembly table for the entry
3. If ( not found)
1. Create a new entry
4. Insert the fragment at the appropriate place in the linked list
1. If (all fragments have arrived)
1. Reassembly the fragments
2. Deliver the datagram to the corresponding upper layer protocol
3. Return
2. Else
1. Check the time-out
2. If (time-out expired)
1. Discard all fragments and send an ICMP error message
5. Return

You might also like