Вы находитесь на странице: 1из 19

Position of IP in TCP/IP protocol suite

Topic 3

Internet Protocol
(IP)
TCP/IP Protocol Suite 2

Various protocols at the different layers in the TCP/IP protocol suite


TCP & UDP
• TCP and UDP are the two predominant transport
layer protocols. Both use IP as the network layer
to transfer data around an Internet.
• TCP provides a reliable transport layer, even
though the service it uses (IP) is unreliable - it
guarantee that the datagram arrived to its final
destination.
• UDP is unreliable. There is no guarantee that the
datagram arrived to its final destination.

TCP/IP Illustrated volume 1, Richard Steven

ICMP IGMP
• ICMP is an adjunct to IP. It is used by the IP • IGMP is the Internet Group Management
layer to exchange error messages and other Protocol. It is used with multicasting: sending
vital information with the IP layer in another a UDP datagram to multiple hosts.
host or router.
ARP & RARP Encapsulation
• ARP (Address Resolution Protocol) and RARP • When an application sends data using TCP,
(Reverse Address Resolution Protocol) are the data is sent down the protocol stack,
specialized protocols used only with certain through each layer, until it is sent as a stream
types of network interfaces (such as Ethernet of bits across the network.
and token ring) to convert between the • Each layer adds information to the data by
addresses used by the IP layer and the prepending headers (and sometimes adding
addresses used by the network interface. trailer information) to the data that it
receives.

Encapsulation of data as it goes down the protocol stack TCP/IP hierarchy - Encapsulation
- each layer adds header to the data unit. Trailer only
at Ethernet frame. -unit of data UDP
sends to IP = UDP
datagram

or

-unit of data TCP sends to


IP = TCP segment

-unit of data IP sends to


network interface = packet /
IP Datagram.
-data flows across
physical network =
Frame.
TCP/IP Illustrated volume 1, Richard Steven

Encapsulation 3.1 IP DATAGRAM


• The unit of data that TCP (transport layer) sends to IP A packet in the IP layer is called an IP
(network layer) is called a TCP segment OR
datagram.
• The unit of data that UDP (transport layer) sends to IP
(network layer) is called a UDP datagram. IP datagram is a variable-
variable-length packet
• The unit of data that IP (network layer) sends to the consisting of two parts: header and data.
network interface (datalink layer) is called a packet / The header is 20 to 60 bytes in length and
IP datagram. This packet can be either an IP datagram contains information essential to routing
or a fragment of an IP datagram. and delivery.
• The stream of bits that flows across the Ethernet
(physical network) is called a frame. It is sent by data-
link to physical layer. TCP/IP Protocol Suite 12
Structure of IP datagram Structure of IP datagram

Service type Service type

TCP/IP Protocol Suite 13 TCP/IP Protocol Suite 14

Structure of IP datagram
Version

Defines the version of IP protocol


(IPv4).
Service type

It tells the IP software running in the


host that the IP datagram has the
format of version 4 and need to be
process according to version IPv4.
If not -> discard
TCP/IP Protocol Suite 15 TCP/IP Protocol Suite 16

Structure of IP datagram
Header Length (HLEN)
Defines the total length of the IP datagram
in bytes words.
When no option, the HLE) is 20 bytes. So, Service type

the value of this field is: ? x 4 = 20,


=5
When option is max, the HLE) is 60 bytes.
So, the value of this field is: ? x 4 = 60,
TCP/IP Protocol Suite = 15
17 TCP/IP Protocol Suite 18
Service type Previous format

Also called Type of service (TOS).


bits
Defines how the IP datagram should be handled.
Have 3 categories of services (new):
-Minimize delay
-Maximize throughput
-Maximize reliability
TCP/IP Protocol Suite 19

Structure of IP datagram

New format

X
bits Service type
Codepoint = 6 bits
Value
Unused
from 0 - = 2 bits
7

TCP/IP Protocol Suite 22

Structure of IP datagram
Total length
Defines the total length (header + data) of IP
datagram in bytes.
Service type
Header length = HLE value x 4
Length of data = Total length – Header length
It is 16 bits, so the maximum size of IP
datagram = 216 -1 = 65535 bytes.

TCP/IP Protocol Suite 23 TCP/IP Protocol Suite 24


Structure of IP datagram
Identification

Identify the fragmented IP datagram sent by


sender to ease the reassemble processes at
receiver. Service type

IP address + Identification = must be unique for


each IP datagram

TCP/IP Protocol Suite 25 TCP/IP Protocol Suite 26

Structure of IP datagram
Flags
Used in fragmentation.

Have 3 bits:

1)First bit – not used


Service type
2)Second bit = do not fragment bit

if 1 = must not fragment

if 0 = may be fragment

3) Third bit – more fragment bit

if 1 = this not the last fragment

TCP/IP Protocol Suite


if 0 = this is the last
27
/ only fragment TCP/IP Protocol Suite 28

Structure of IP datagram
Time to live

Used to hold a timestamp / lifetime of a IP


datagram.
Service type
Decremented by 1, each time visited router.
If 0 = IP datagram will be discarded by router.

TCP/IP Protocol Suite 29 TCP/IP Protocol Suite 30


Protocol Example: Value of Protocols

Defines protocols that uses a )etwork layer


services.

TCP/IP Protocol Suite 31 TCP/IP Protocol Suite 32

Structure of IP datagram
Header checksum

Used for error detection of IP header.

Service type
-will be discussed later-

TCP/IP Protocol Suite 33 TCP/IP Protocol Suite 34

Structure of IP datagram
Source IP Address

IP address of sender / source.

Service type

TCP/IP Protocol Suite 35 TCP/IP Protocol Suite 36


Structure of IP datagram
Destination IP Address

IP address of receiver / destination.

Service type

TCP/IP Protocol Suite 37 TCP/IP Protocol Suite 38

EXAMPLE 1 EXAMPLE 2

An IP packet has arrived with the first 8 bits as shown: In an IP packet, the value of HLE) is 1000 in binary. How many
bytes of options are being carried by this packet?
01000010

The receiver discards the packet. Why? Solution


The HLE) value is 8, which means the total number of bytes in
Solution the header is 8 × 4 or 32 bytes. The first 20 bytes are the base
There is an error in this packet. The 4 left-most bits (0100) show header, the next 12 bytes are the options.
the version, which is correct. The next 4 bits (0010) show the
header length; which means (2 × 4 = 8), which is wrong. The
minimum number of bytes in the header must be 20. The packet
has been corrupted in transmission.
TCP/IP Protocol Suite 39 TCP/IP Protocol Suite 40

EXAMPLE 3 EXAMPLE 4

In an IP packet, the value of HLE) is 516 An IP packet has arrived with the first few hexadecimal digits as
and the value of the total length field is 002816 . How shown below:
many bytes of data are being carried by this packet?
45000028000100000102 . . .

Solution How many hops can this packet travel before being dropped?
The HLE) value is 5, which means the total number of bytes in The data belong to what upper layer protocol?
the header is 5 × 4 or 20 bytes (no options). The total length is
40 bytes, which means the packet is carrying 20 bytes of data (40 Solution
− 20). To find the time-to-live field, we skip 8 bytes (16 hexadecimal
digits). The time-to-live field is the ninth byte, which is 01. This
means the packet can travel only one hop. The protocol field is
the next byte (02), which means that the upper layer protocol is
IGMP.
TCP/IP Protocol Suite 41 TCP/IP Protocol Suite 42
3.2 FRAGMENTATION MTU
The format and size of a frame depend on the
Maximum Transmission Unit (MTU) is the
protocol used by the physical network. A
characteristic of the link layer protocols.
datagram may have to be fragmented to fit the
Each data link layer protocol has own frame
protocol regulations.
format.
The topics discussed in this section include: It is different according to different physical
Maximum Transfer Unit (MTU) network protocols.
Fields Related to Fragmentation The designers of TCP/IP decided to make the max
length of IP datagram = 65535 bytes.
TCP/IP Protocol Suite 43 TCP/IP Protocol Suite 44

MTU

MTUs for some physical networks

TCP/IP Protocol Suite 45 TCP/IP Protocol Suite 46

Fragmentation Fragmentation

If IP has a datagram to send, and the


Identify the fragmented IP datagram sent by
datagram is larger than the link layer's MTU,
sender to ease the reassemble processes at
receiver. IP performs
Fragmentation: breaking the datagram up
Only data in a datagram is fragmented. into smaller pieces (fragments), so that each
IP address + Identification = must be unique for fragment is smaller
each IP datagram than the MTU.

TCP/IP Protocol Suite 47 TCP/IP Protocol Suite 48


Fields Related to Fragmentation Fields Related to Fragmentation
1) Identification 2) Flags
Identify a datagram originating from the source host.
Combination of identification & source IP address = Have 3 bits:
uniquely identified a datagram. 1)First bit – not used
2)Second bit = do not fragment bit
Done by IP protocol using counter (main memory) of
if 1 = must not fragment
positive number (copy current value and increment 1).
if 0 = may be fragment
If datagram was fragmented, the identification value is 3) Third bit – more fragment bit
copied to all fragments. if 1 = this not the last fragment
Identification helps destination host to reassemble the if 0 = this is the last / only fragment
datagram.
TCP/IP Protocol Suite 49 TCP/IP Protocol Suite 50

Flags field

Fields Related to Fragmentation


3) Fragmentation Offset
Shows the relative position of this fragment with respect
to the whole datagram.
It shows the location of the first bytes of the fragment.
The offset is measured in units of 8 bytes.

The value of the offset field always relative to the original


unused datagram.

TCP/IP Protocol Suite 51 TCP/IP Protocol Suite 52

Example 1: Second Fragmentation was done to the


Example 1 second fragments
First fragmentation:
-Identification = 14,567.
Data Size = 4000 bytes -Flags = M = 1 = this is not the last
fragments.
MTU = 1400 M = 0 = this is the last fragment.
-Frag. Offset = 0, 175, 350
Offset value = 0, 175, 350

Second fragmentation:
-Identification = 14,567.
-Flags = M = 1 = this is not the last
fragments.
TCP/IP Protocol Suite 53 TCP/IP Protocol Suite 54 M = 0 = this is the last fragment.
-Frag. Offset = 175, 275
Example 2
Example 2
Answer: Fragmentation in Network 1 -Total length
F 1.1 = 660 bytes
Question: Host 1 was communicating with Host 2 -Data = 640
bytes
sending 1400 bytes of data. Show all the -Identification
= 1956
fragmentation processes happen in Network 1 and MTU = 660 -M = 1 = this
is not the last
the fragmentation processes happen to the 0 1479
0 F 1.2 639
fragment.
-Total length = -Total length = 660 bytes
second fragments when entering Network 2 via 1500 bytes - Data = 640 bytes
-Frag. Offset =
0/8=0
router (R). -- Data = 1480
bytes
- Identification = 1956
- M = 1 = this is not the
- Identification last fragment.
= 1956 -Frag. Offset = 640/8 = 80 640 1279
F 1.3
- M = 1 = this is
not the last -Total length = 220 bytes
fragment -Data = 200 bytes
-Offset = 0/8=0 -Identification = 1956
- M = 0 = this is the last
fragment
-Frag. Offset = 1280/8 = 160 1280 1479

Example 2
Answer: Fragmentation in Network 2
(From Net. 1)
-Total length
= 300 bytes
How to reassemble?
F 1.2
-Data = 280
bytes
-Identification
= 1956
The reassemble processes happen based on
640 1279
-M = 1 = this
is not the last
fragment offset:
-Total length -Total length = 300 fragment.
640 919 -Frag. Offset =
= 660 bytes bytes
- Data = 640 - Data = 280 bytes 640/8 = 80 The first fragment has offset = 0
bytes - Identification = -Total length =
- 1956 100 bytes
Identification - M = 1 = this is not -Data = 80
The second fragment has offset = length of first fragment/8
= 1956 the last fragment.
920 1199 bytes
= 1400/8 = 175
- M = 1 = this -Frag. Offset = 920/8 -Identification
is not the = 115 = 1956
last - M = 0 = this The third fragment has offset = total length of first
fragment. is the last
-Frag. Offset fragment fragment and second fragment/8 = 350
= 640/8 = 80 -Frag. Offset =
1200 1279 1200/8 = 150 TCP/IP Protocol Suite 58

EXAMPLE 5 EXAMPLE 6

A packet has arrived with an M bit value of 0. Is this the first A packet has arrived with an M bit value of 1. Is this the first
fragment, the last fragment, or a middle fragment? fragment, the last fragment, or a middle fragment?

Do we know if the packet was fragmented? Do we know if the packet was fragmented?

Solution
Solution If the M bit is 1, it means that there is at least one more
If the M bit is 0, it means that there are no more fragments; the fragment. This fragment can be the first one or a middle one, but
fragment is the last one. 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
However, we cannot say if the original packet was fragmented or offset).
not. A nonfragmented packet is considered the last fragment.

TCP/IP Protocol Suite 59 TCP/IP Protocol Suite 60


EXAMPLE 7 EXAMPLE 8

A packet has arrived with an M bit value of 1 and a A packet has arrived in which the offset value is 100. What is the
fragmentation offset value of zero. Is this the first fragment, the number of the first byte? Do we know the number of the last
last fragment, or a middle fragment?. byte?

Solution Solution
Because the M bit is 1, it is either the first fragment or a middle To find the number of the first byte, we multiply the offset value
one. But, because the offset value is 0, it is the first fragment. 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.

TCP/IP Protocol Suite 61 TCP/IP Protocol Suite 62

EXAMPLE 9 3.3 OPTIONS


A packet has arrived in which the offset value is 100, the value of The header of the IP datagram is made of two parts: a fixed part and a
HLE) is 5 and the value of the total length field is 100. What is variable part. The variable part comprises the options that can be a
maximum of 40 bytes.
the number of the first byte and the last byte?

Solution
The first byte number is 100 × 8 = 800. The total length is 100 The topics discussed in this section include:
bytes and the header length is 20 bytes (5 × 4), which means that Format
Option Types
there are 80 bytes in this datagram. If the first byte number is
800, the last byte number must be 879.

TCP/IP Protocol Suite 63 TCP/IP Protocol Suite 64

Structure of IP datagram
OPTIONS

- Is the variable part of the IP datagram.

Service type
- Only 40 bytes long (max), left for Option.

- It is optional – for network testing and debugging.

TCP/IP Protocol Suite 65


Option format
Option Format
Type
-8 bits long.
-Contains 3 subfields: copy, class, number.

Subfield Long Function Value


1) Copy 1 bit Controls the presence of option 0 – option must be copied
in fragmentation. only to the first fragment
1 – option must be copied to
all fragments
2) Class 2 bits Defines the general purpose of 00 – option used for
the option datagram control
10 – option used for
debugging and management.
01 & 11 – not defined yet

3) 5 bits Defines type of option. Has 32


TCP/IP Protocol Suite 67 Number types but only 6 options used.

Option format Option format

Only 6
options
used
from 32

TCP/IP Protocol Suite 69 TCP/IP Protocol Suite 70

Option Format Option format

Length
-8 bits long.
-Defines the total length of the option including the type
field and the length field itself.

TCP/IP Protocol Suite 72


Option Format Option format

Value
-Is a variable-length long.
-Contains the data that specific option require.
-An optional field.

Only 6
options
used
from 32

TCP/IP Protocol Suite 74

Option Types 1) No Operation Option


-A 1-byte option.
-Used as a filler at the beginning of option OR at the next
option.

TCP/IP Protocol Suite 75 TCP/IP Protocol Suite 76

2) End-of-Option Option 3) Record-Route Option


-Used to record IP addresses of Internet routers that handle
-A 1-byte option.
datagram.
-Used for padding at the end of option field.
-Max = 9 IP addresses (to occupy 40 bytes)
-Locate immediately before payload data.

TCP/IP Protocol Suite 77 TCP/IP Protocol Suite 78


Pointer (ptr) Pointer (ptr)
-It is a 1-based index / offset.
-Was created as empty by source / sender. -When each IP address recorded into the list, the value of ptr
increase by 4, becomes 8, 12, up to 36. After the ninth address is
-Initial (min) value = 4, pointing to first empty field.
recorded, ptr becomes 40, indicating the list is full.
-Used to act as a pointer to point to the first available empty
-Each router compares the value of pointer and length. If Pointer
entry (where to store the next IP address?). > Length = Option is full and no changes is made. If Pointer <
Length = Option not full and router inserts its out-going IP
address. Router increments the value of pointer by 4.

R.S, Page: 92 R.S, Page: 92

3) Record-Route Option 4) Strict-Source-Route Option


As each IP address is recorded into the list, the value of ptr
becomes 8, 12, 16, up to 36. After the ninth address is recorded,
ptr becomes 40, indicating the list is full. -Used by source to determine a route for datagram.
-Sender can choose route with specific type of service
(TOS).
-‘strict’ – ALL routers defined in the option MUST be
visited by the datagram. If not, datagram discarded & an
error message will be issued.
-Rarely used.

TCP/IP Protocol Suite 81

4) Strict-Source-Route Option 4) Strict-Source-Route Option


-Each router compares the value of pointer and length. If
Pointer > Length = Datagram has visited all predefined
The list of routers. Datagram cannot travel anymore, discarded and
IP
error message created.
addresses
of a -If Pointer < Length = Router compares destination IP
routers address with its incoming IP address. If equal = router
inserted process the datagram, swap the IP address pointed by the
by the pointer with the destination IP address, increments the
sender pointer by 4, & forward the datagram.
-If not equal = router discard the datagram and issue error
message.
TCP/IP Protocol Suite 83
4) Strict-Source-Route Option 5) Loose-Source-Route Option

-Used by source to determine a route for datagram.


-Sender can choose route with specific type of service
(TOS).
-‘loose’ – routers defined in the option MAY OR MAY
NOT be visited by the datagram. Datagram may visit other
routers.

TCP/IP Protocol Suite 85

5) Loose-Source-Route Option 6) Timestamp Option

-Used to record the time of datagram processing by a


router.
-Time expressed in milliseconds.
-Rarely used.

TCP/IP Protocol Suite 87

6) Timestamp Option 6) Timestamp Option


-O-Flow = Overflow field – record the number of routers
that could not add their timestamp because no more fields
available.
-Flags field – record the visited router responsibilities.
-If value = 0 – each router only add the timestamp in the
provided field.
-If value = 1 – each router must add its outgoing IP address
and the timestamp.
-If value = 3 – the IP addresses are given & each router must
check the given IP address with its own incoming IP
address.
If match = router overwrites the IP address with its outgoing
TCP/IP Protocol Suite 89 IP address and adds the timestamp.
Timestamp concept
Use of flag in timestamp -Action taken by router when datagram travel from sender
to receiver.
-Assume flag = 1.

TCP/IP Protocol Suite 91 TCP/IP Protocol Suite 92

EXAMPLE 10 EXAMPLE 11

Which of the six options must be copied to each fragment? Which of the six options are used for datagram control and
which are used for debugging and management?
Solution
We look at the first (left-most) bit of the code for each option. Solution
We look at the second and third (left-most) bits of the code.
a. )o operation: Code is 00000001; not copied.
b. End of option: Code is 00000000; not copied. a. )o operation: Code is 00000001; datagram control.
c. Record route: Code is 00000111; not copied. b. End of option: Code is 00000000; datagram control.
d. Strict source route: Code is 10001001; copied. c. Record route: Code is 00000111; datagram control.
e. Loose source route: Code is 10000011; copied. d. Strict source route: Code is 10001001; datagram control.
f. Timestamp: Code is 01000100; not copied. e. Loose source route: Code is 10000011; datagram control.
f. Time stamp: Code is 01000100; debugging and management
control.

TCP/IP Protocol Suite 93 TCP/IP Protocol Suite 94

EXAMPLE 12 EXAMPLE 13

One of the utilities available in U)IX to check the travelling of We can also use the ping utility with the -R option to implement
the IP packets is ping. In the next chapter, we talk about the ping the record route option.
program in more detail. In this example, we want to show how to
$ ping -R fhda.edu
use the program to see if a host is available. We ping a server at PI)G fhda.edu (153.18.8.1) 56(124) bytes of data.
De Anza College named fhda.edu. The result shows that the IP 64 bytes from tiptoe.fhda.edu (153.18.8.1): icmp_seq=0 ttl=62 time=2.70 ms
address of the host is 153.18.8.1. RR: voyager.deanza.fhda.edu (153.18.17.11)
Dcore_G0_3-69.fhda.edu (153.18.251.3)
$ ping fhda.edu Dbackup_V13.fhda.edu (153.18.191.249) tiptoe.fhda.edu (153.18.8.1)
PI)G fhda.edu (153.18.8.1) 56(84) bytes of data. Dbackup_V62.fhda.edu (153.18.251.34)
64 bytes from tiptoe.fhda.edu (153.18.8.1): .... Dcore_G0_1-6.fhda.edu (153.18.31.254)
voyager.deanza.fhda.edu (153.18.17.11)
The result shows the IP address of the host and the number of The result shows the interfaces and IP addresses.
bytes used.

TCP/IP Protocol Suite 95 TCP/IP Protocol Suite 96


EXAMPLE 14 EXAMPLE 15

The traceroute program can also be used to implement strict The traceroute program can be used to implement loose source
source routing. The -G option forces the packet to visit the routing. The -g option allows us to define the routers to be
routers defined in the command line. The following shows how visited, from the source to destination. The following shows how
we can send a packet to the fhda.edu server and force the packet we can send a packet to the fhda.edu server with the requirement
to visit only the router 153.18.251.4, not any other one. that the packet visit the router 153.18.251.4.

$ traceroute -g 153.18.251.4 fhda.edu.


$ traceroute -G 153.18.251.4 fhda.edu. traceroute to fhda.edu (153.18.8.1), 30 hops max, 46 byte packets
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
1 Dbackup_V69.fhda.edu (153.18.251.4) 2.168 ms 2.148 ms 2.037 ms 2 Dbackup_V69.fhda.edu (153.18.251.4) 2.168 ms 2.148 ms 2.037 ms

TCP/IP Protocol Suite 97 TCP/IP Protocol Suite 98

3.4 CHECKSUM
Checksum
The error detection method used by most TCP/IP protocols is called
called the
checksum. The checksum protects against the corruption that may occur
during the transmission of a packet. It is redundant information added to The header checksum is calculated over the IP
the packet.
header only.
It does not cover any data that follows the header.
The topics discussed in this section include:
Checksum Calculation at the Sender
Checksum Calculation at the Receiver
ICMP, IGMP, UDP, and TCP all have a checksum in
Checksum in the IP Packet their own headers to cover their header and data.

TCP/IP Protocol Suite 99

Header Checksum

Checksum

-Checksum calculated at sender and the value is


Service type sent with the packet to receiver.
-The receiver repeat the same calculation. If the
result satisfactory, the packet accepted, otherwise,
rejected.

TCP/IP Protocol Suite 101


Checksum Calculation at Sender Checksum Calculation at Receiver
To create the checksum the sender does the following: To verify the packet, receiver does the following:
❏ The packet is divided into k sections, each of n bits. ❏ The packet is divided into k sections, each of n bits.

❏ All sections are added together using complement


❏ All sections are added together using complement arithmetic. The sum (result) is n bits long.
arithmetic. The sum (result) is n bits long.
❏ The sum should be ‘0’, if not, the packet is discarded.
❏ The sum is complemented to produce the
checksum.

TCP/IP Protocol Suite 103 TCP/IP Protocol Suite 104

Checksum concept

At sender: Sort all of these fields in 16-bit and convert


them into binary:

TCP/IP Protocol Suite 105

Continue……add all this numbers one by one: Continue adding:


Continue adding: After adding operation, proceed with the complement
operation, and get the result (the IP Header Checksum):

Checksum concept At Receiver: We need


to do the same
operation when
packet arrived at Checksum Calculation
receiver by adding all
the 16 bits (in each
field) with each other
(including IP header
The calculation of checksum can also be shown using a
checksum created diagram format.
just now). After
adding operation, the
result should be ‘0’, The calculation of checksum can also be done using
otherwise the packet hexadecimal value.
will be discarded.

TCP/IP Protocol Suite 111 TCP/IP Protocol Suite 112

Other example on how checksum calculation using binary Example of checksum calculation can be done in
can be shown in a diagram format: hexadecimal - shown in a diagram format

TCP/IP Protocol Suite 113 TCP/IP Protocol Suite 114

Вам также может понравиться