Upload
yazanalomari
View
232
Download
0
Embed Size (px)
Citation preview
7/25/2019 Chap 08 Modified PP2003
1/68
TCP/IP Protocol Suite 1
Chapter 8Chapter 8
Upon completion you will be able to:
Internet ProtocolInternet Protocol
Understand the format and fields of a datagram
Understand the need for fragmentation and the fields involved
Understand the options available in an IP datagram
Be able to perform a checksum calculation
Understand the components and interactions of an IP package
Objectives
7/25/2019 Chap 08 Modified PP2003
2/68
TCP/IP Protocol Suite 2
Figure 8.1 Position of IP in TCP/IP protocol suite
IP: connectionless, unreliable, packet switching w/ datagrams best-efort delier! serice
7/25/2019 Chap 08 Modified PP2003
3/68
TCP/IP Protocol Suite 3
Internet Protocol (IP) is the transmissionmechanism used by the TCP/IP protocols at thenetwork layer.
The term best-efort means that IP packets canbe corrupted, lost, arrive out o order or delayedand may create con!estion "or the network.
7/25/2019 Chap 08 Modified PP2003
4/68
TCP/IP Protocol Suite #
8.1 DATAGRAM
packet in the IP layer is called a datagram! packet in the IP layer is called a datagram!a variable"length packet consisting of two parts: header and data#a variable"length packet consisting of two parts: header and data#
The header is $% to &% bytes in length and contains information essentialThe header is $% to &% bytes in length and contains information essential
to routing and delivery#to routing and delivery#
'ome of the fields:'ome of the fields:
()* " version numbers! + and &()* " version numbers! + and &
,-). " header length in +"byte words# (alue of means $% byte header,-). " header length in +"byte words# (alue of means $% byte header
7/25/2019 Chap 08 Modified PP2003
5/68
TCP/IP Protocol Suite $
Figure 8.2 IP datagram
7/25/2019 Chap 08 Modified PP2003
6/68
TCP/IP Protocol Suite %
Figure 8.3 'ervice type or 0ifferentiated 'ervices " 0' field
This "eld was preiousl! called Serice t!pe# $ow called%iferentiated Serices#The precedence sub"eld was designed,but neer used in ersion T'S (T!pe o) Serice* bits - see ne+t slide#
7/25/2019 Chap 08 Modified PP2003
7/68
TCP/IP Protocol Suite &
Table 1#2Table 1#2 Types of serviceTypes of service
I) !ou want to send a packet with a special t!pe o) serice,use one o) the aboe -bit sets#
7/25/2019 Chap 08 Modified PP2003
8/68
TCP/IP Protocol Suite '
Table 1#$Table 1#$ 0efault types of service0efault types of service
Some apps
hae de)aultserice t!pes#
7/25/2019 Chap 08 Modified PP2003
9/68
TCP/IP Protocol Suite
Table 1#3Table 1#3 (alues for codepoints(alues for codepoints
I) we call these 8 bits %iferentiated Serices (and not theolder Serice T!pe*, then the "rst si+ bits are called code-points#
hen the . right-most bits are , the . le)t-most bits are the saas the precedence bits )rom the preious slides#hen the . right-most bits are not all s, the 0 bits de"ne 0&Serices based on the priorit! assignment b! the Internet orlocal authorities# 1ssignments hae not !et been "nali2ed#
7/25/2019 Chap 08 Modified PP2003
10/68
TCP/IP Protocol Suite 1
Figure 8.4 )ncapsulation of a small datagram in an )thernet frame
The total length "eld de"nes the total length o) the datagram
including the header#
Total length "eld is 30 bits, or 0,. b!tes# ') which 4 to0 b!tes are the header#
I) an IP datagram is short, and is packaged into an 5thernet
)rame, remember that the minimum pa!load si2e o) an5thernet )rame is &0 b!tes#
7/25/2019 Chap 08 Modified PP2003
11/68
TCP/IP Protocol Suite 11
Identi"cation, 6lags, and 6ragmentation ofset are all usedto per)orm )ragmentation, which we will coer shortl!#
Time to 7ie - 8-bit "eld, so Time to 7ie can be set to 4#1s it passes thru a router, the router decrements thecounter# hen counter hits , the datagram is deleted(and ICP sends an error message back to the source*#
Time to li*e. + data!ram has a limited li"etime in its tra*el throu!h an intern,eld was ori!inally desi!ned to hold a timestamp which was decremented b*isited router. The data!ram was discarded when the *alue became -ero.
h! might a host set the Time to 7ie "eld to 39
7/25/2019 Chap 08 Modified PP2003
12/68
TCP/IP Protocol Suite 12
Figure 8.5 4ultiple5ing
The Protocol "eld (8 bits* identi"es the upper la!er protocol
that is using IP )or transmission o) its data#
7/25/2019 Chap 08 Modified PP2003
13/68
TCP/IP Protocol Suite 13
Table 1#+Table 1#+ ProtocolsProtocols
7/25/2019 Chap 08 Modified PP2003
14/68
TCP/IP Protocol Suite 1#
n IP packet has arrived with the first 1 bits as shown:
Example1
%2%%%%2%
The receiver discards the packet# 6hy7
7/25/2019 Chap 08 Modified PP2003
15/68
TCP/IP Protocol Suite 1$
n IP packet has arrived with the first 1 bits as shown:
Example1
%2%%%%2%
The receiver discards the packet# 6hy7
'olution
There is an error in this packet# The + left"most bits 8%2%%9
show the version! which is correct# The ne5t + bits 8%%2%9 showthe header length which means 8$ ; + < 19! which is wrong#
The minimum number of bytes in the header must be $%# The
packet has been corrupted in transmission#
7/25/2019 Chap 08 Modified PP2003
16/68
TCP/IP Protocol Suite 1%
In an IP packet! the value of ,-). is 2%%% in binary# ,owmany bytes of options are being carried by this packet7
Example2
7/25/2019 Chap 08 Modified PP2003
17/68
TCP/IP Protocol Suite 1&
In an IP packet! the value of ,-). is 2%%% in binary# ,owmany bytes of options are being carried by this packet7
Example2
'olution
The ,-). value is 1! which means the total number of bytes
in the header is 1 ; + or 3$ bytes# The first $% bytes are the
base header! the ne5t 2$bytes are the options#
7/25/2019 Chap 08 Modified PP2003
18/68
TCP/IP Protocol Suite 1'
In an IP packet! the value of ,-). is 2&and the value of the total length field is %%$12& # ,ow
many bytes of data are being carried by this packet7
Example3
7/25/2019 Chap 08 Modified PP2003
19/68
TCP/IP Protocol Suite 1
In an IP packet! the value of ,-). is 2&and the value of the total length field is %%$12& # ,ow
many bytes of data are being carried by this packet7
Example3
'olution
The ,-). value is ! which means the total number of bytes
in the header is ; + or $% bytes 8no options9# The total length
is +% bytes! which means the packet is carrying $%bytes of data
8+% = $%9#
7/25/2019 Chap 08 Modified PP2003
20/68
TCP/IP Protocol Suite 2
n IP packet has arrived with the first few he5adecimal digitsas shown below:
Example4
+%%%%$1%%%2%%%%%2%$ # # #
,ow many hops can this packet travel before being dropped7The data belong to what upper layer protocol7
7/25/2019 Chap 08 Modified PP2003
21/68
TCP/IP Protocol Suite 21
n IP packet has arrived with the first few he5adecimal digitsas shown below:
Example4
+%%%%$1%%%2%%%%%2%$ # # #
,ow many hops can this packet travel before being dropped7The data belong to what upper layer protocol7
'olution
To find the time"to"live field! we skip 1 bytes 82& he5adecimaldigits9# The time"to"live field is the ninth byte! which is %2# This
means the packet can travel only one hop# The protocol field is
the ne5t byte 8%$9! which means that the upper layer protocol is
I>4P 8see Table 1#+9#
7/25/2019 Chap 08 Modified PP2003
22/68
TCP/IP Protocol Suite 22
8.2 FRAGMENTATION
The format and si?e of a frame depend on the protocol used by theThe format and si?e of a frame depend on the protocol used by thephysical network# datagram may have to be fragmented to fit thephysical network# datagram may have to be fragmented to fit the
protocol regulations#protocol regulations#
The topics discussed in this section include:The topics discussed in this section include:
4a5imum Transfer Unit 84TU94a5imum Transfer Unit 84TU9
@ields *elated to @ragmentation@ields *elated to @ragmentation
7/25/2019 Chap 08 Modified PP2003
23/68
TCP/IP Protocol Suite 23
Figure 8.6 4TU
T - a+imum Trans)er nit
7/25/2019 Chap 08 Modified PP2003
24/68
TCP/IP Protocol Suite 2#
Table 1#Table 1# 4TUs for some networks4TUs for some networks
a+ datagram si2e )or IP is 0. b!tes# So i) we hae a ma+si2ed datagram to send oer 5thernet, what do we do9
7/25/2019 Chap 08 Modified PP2003
25/68
TCP/IP Protocol Suite 2$
Figure 8.7 @lags field
1 datagram can be )ragmented b! the source host or an!router in the path# ;eassembl! is done onlyb! the destination
host#
ost "elds are copied )rom one )ragment to the ne+t# The ."elds that are not copied are the
7/25/2019 Chap 08 Modified PP2003
26/68
TCP/IP Protocol Suite 2%
Figure 8.8 @ragmentation e5ample
The 6ragmentation 'fset tells what position this )ragmentis in the whole stream# The ofset counts b! 8# So i) a)ragment is supposed to start at b!te &, the ofset e>uals
#
= It is the ofset o) the data in the original datagram measurein units o) 8 b!tes
7/25/2019 Chap 08 Modified PP2003
27/68
TCP/IP Protocol Suite 2&
Figure 8.9 0etailed fragmentation e5ample
7/25/2019 Chap 08 Modified PP2003
28/68
TCP/IP Protocol Suite 2'
packet has arrived with an 4 bit value of %# Is this the firstfragment! the last fragment! or a middle fragment7 0o we
know if the packet was fragmented7
Example5
7/25/2019 Chap 08 Modified PP2003
29/68
TCP/IP Protocol Suite 2
packet has arrived with an 4 bit value of %# Is this the firstfragment! the last fragment! or a middle fragment7 0o we
know if the packet was fragmented7
Example5
'olution
If the 4 bit is %! it means that there are no more fragments the
fragment is the last one# ,owever! we cannot say if the original
packet was fragmented or not# non"fragmented packet isconsidered the last fragment#
7/25/2019 Chap 08 Modified PP2003
30/68
TCP/IP Protocol Suite 3
packet has arrived with an 4 bit value of 2 and afragmentation offset value of ?ero# Is this the first fragment!
the last fragment! or a middle fragment7#
Example7
7/25/2019 Chap 08 Modified PP2003
31/68
TCP/IP Protocol Suite 31
packet has arrived with an 4 bit value of 2 and afragmentation offset value of ?ero# Is this the first fragment!
the last fragment! or a middle fragment7#
Example7
'olution
Because the 4 bit is 2! it is either the first fragment or a middle
one# Because the offset value is %! it is thefirstfragment#
7/25/2019 Chap 08 Modified PP2003
32/68
TCP/IP Protocol Suite 32
packet has arrived in which the offset value is 2%%# 6hat isthe number of the first byte7 0o we know the number of the
last byte7
Example8
7/25/2019 Chap 08 Modified PP2003
33/68
TCP/IP Protocol Suite 33
packet has arrived in which the offset value is 2%%# 6hat isthe number of the first byte7 0o we know the number of the
last byte7
Example8
'olution
To find the number of the first byte! we multiply the offset
value by 1# This means that the first byte number is 1%%# 6e
cannot determine the number of the last byte unless we know
the length of the data#
7/25/2019 Chap 08 Modified PP2003
34/68
TCP/IP Protocol Suite 3#
packet has arrived in which the offset value is 2%%! the valueof ,-). is and the value of the total length field is 2%%#
6hat is the number of the first byte and the last byte7
Example9
7/25/2019 Chap 08 Modified PP2003
35/68
TCP/IP Protocol Suite 3$
packet has arrived in which the offset value is 2%%! the valueof ,-). is and the value of the total length field is 2%%#
6hat is the number of the first byte and the last byte7
Example9
'olution
The first byte number is 2%% ; 1 < 1%%# The total length is 2%%
bytes and the header length is $% bytes 8 ; +9! which means
that there are 1% bytes in this datagram# If the first byte
number is 1%%! the last byte number must be 1A#
7/25/2019 Chap 08 Modified PP2003
36/68
TCP/IP Protocol Suite 3%
8.3 OPTIONS
The header of the IP datagram is made of two parts: a fi5ed part and aThe header of the IP datagram is made of two parts: a fi5ed part and avariable part# The variable part comprises the options that can be avariable part# The variable part comprises the options that can be a
ma5imum of +% bytes#ma5imum of +% bytes#
The topics discussed in this section include:The topics discussed in this section include:
@ormat@ormat
ption Typesption Types
Figure 8 10 ption format
7/25/2019 Chap 08 Modified PP2003
37/68
TCP/IP Protocol Suite 3&
Figure 8.10 ption format
$ot all routers/hosts use these options, but the! must beread! to do so i) the! are present in the datagram#
Cop! - tells whether to cop! this option into a )ragmentClass - de"nes the general purpose o) the option
Figure 8 11 Categories of options
7/25/2019 Chap 08 Modified PP2003
38/68
TCP/IP Protocol Suite 3'
Figure 8.11 Categories of options
1s we ?ust saw, onl! 0 options in use currentl!# The single-options are onl! 3 b!te in length and do not re>uire lengthdata "elds#
Figure 8 12 .o operation option
7/25/2019 Chap 08 Modified PP2003
39/68
TCP/IP Protocol Suite 3
Figure 8.12 .o operation option
= sed as a "ller between options# 6ore+ample,3#can be used to align the ne+t option #
4#Can be used to align beginning o) anoption #on a 30- or .4-bit boundar!#
Figure 8 13 )nd of option option
7/25/2019 Chap 08 Modified PP2003
40/68
TCP/IP Protocol Suite #
Figure 8.13 )nd of option option
enotes the end o" the options and that the data isne0t. used "or paddin! at the end o" the option ,eld can only be used as the last option. nly one endo"option option can be used
Figure 8 14 *ecord route option
7/25/2019 Chap 08 Modified PP2003
41/68
TCP/IP Protocol Suite #1
Figure 8.14 *ecord route option
;ecords the route a datagram takes thru routers# Can onl! reco@ routers, since ma+ si2e o) the header is 0 b!tes, 4 b!tes )orbase header, leaing onl! & b!tes )or options#
used to record the Internet routers that handle thedata!ram.
en!th4 Total len!th o" the option(includin! code andlen!th ,elds)
Figure 8.15 *ecord route concept
7/25/2019 Chap 08 Modified PP2003
42/68
TCP/IP Protocol Suite #2
Figure 8.15 *ecord route concept
The Pointer ,eld (# then ' then 12 then 1%) is the bytenumber o" the ,rst a*ailable space.
Figure 8.16 'trict source route option
7/25/2019 Chap 08 Modified PP2003
43/68
TCP/IP Protocol Suite #3
Figure 8.16 'trict source route option
6or when a datagram has to )ollow a gien, "+ed route#
Figure 8.17 'trict source route concept
7/25/2019 Chap 08 Modified PP2003
44/68
TCP/IP Protocol Suite ##
Figure 8.17 'trict source route concept
6irst hop address is here
Second hop address is here
$ote that as hops are made, ne+t hop is replaced withaddress o) router !ou ?ust went thru
Figure 8.18 -oose source route option
7/25/2019 Chap 08 Modified PP2003
45/68
TCP/IP Protocol Suite #$
Figure 8.18 -oose source route option
Similar to "+ed route - each router in the list must be isited,but other routers can be isited too#
Figure 8.19 Timestamp option
7/25/2019 Chap 08 Modified PP2003
46/68
TCP/IP Protocol Suite #%
g p p
Can be used i) !ou want to record the time the datagramisits each router# Time in milleseconds, niersal Time#
'-6low bits (oer
7/25/2019 Chap 08 Modified PP2003
47/68
TCP/IP Protocol Suite #&
g f f g p
The 6lag bits tell the router whether to do one o) the)ollowing operations:
: add onl! the timestamp in the proided "eld
3 : add each routerAs outgoing IP address and the timestamp
. : each router must check the gien IP address with its ownincoming IP address# I) matched, the router oerwrites the IPaddress with its outgoing IP address and adds the timestamp
Figure 8.21 Timestamp concept
7/25/2019 Chap 08 Modified PP2003
48/68
TCP/IP Protocol Suite #'
g p p
7/25/2019 Chap 08 Modified PP2003
49/68
TCP/IP Protocol Suite #
6hich of the si5 options must be copied to each fragment7
Example10
7/25/2019 Chap 08 Modified PP2003
50/68
TCP/IP Protocol Suite $
6hich of the si5 options must be copied to each fragment7
Example10
'olution
6e look at the first 8left"most9 bit of the code for each option#
a# .o operation: Code is %%%%%%%2 not copied#b# )nd of option: Code is %%%%%%%% not copied#
c# *ecord route: Code is %%%%%222 not copied#
d# 'trict source route: Code is 2%%%2%%2 copied#
e# -oose source route: Code is 2%%%%%22 copied#f# Timestamp: Code is %2%%%2%% not copied#
7/25/2019 Chap 08 Modified PP2003
51/68
TCP/IP Protocol Suite $1
6hich of the si5 options are used for datagram control andwhich are used for debugging and management7
Example11
7/25/2019 Chap 08 Modified PP2003
52/68
TCP/IP Protocol Suite $2
6hich of the si5 options are used for datagram control andwhich are used for debugging and management7
Example11
'olution
6e look at the second and third 8left"most9 bits of the code#
a# .o operation: Code is %%%%%%%2 datagram control#
b# )nd of option: Code is %%%%%%%% datagram control#
c# *ecord route: Code is %%%%%222 datagram control#
d# 'trict source route: Code is 2%%%2%%2 datagram control#e# -oose source route: Code is 2%%%%%22 datagram control#
f# Time stamp: Code is %2%%%2%% debugging and management
control#
7/25/2019 Chap 08 Modified PP2003
53/68
TCP/IP Protocol Suite $3
8.4 CHECKSUM
The error detection method used by most TCP/IP protocols is called theThe error detection method used by most TCP/IP protocols is called thechecksum# The checksum protects against the corruption that may occurchecksum# The checksum protects against the corruption that may occur
during the transmission of a packet# It is redundant information addedduring the transmission of a packet# It is redundant information added
to the packet#to the packet#
The checksum in the IP packet covers only the header! not the data#The checksum in the IP packet covers only the header! not the data#
Two reasons:Two reasons:
" ll higher level protocols have their own checksum#" ll higher level protocols have their own checksum#
" The header of the IP packet changes with each visited router! but the" The header of the IP packet changes with each visited router! but the
data doesnDt#data doesnDt#
The topics discussed in this section include:The topics discussed in this section include:Checksum Calculation at the 'enderChecksum Calculation at the 'ender
Checksum Calculation at the *eceiverChecksum Calculation at the *eceiver
Checksum in the IP PacketChecksum in the IP Packet
7/25/2019 Chap 08 Modified PP2003
54/68
TCP/IP Protocol Suite $#
To create the checksum the sender does the following:
The packet is divided into k sections! each of n bits#
ll sections are added together using 2Ds complement
arithmetic#
The final result is complemented to make the
checksum#
Note:Note:
Figure 8.22 Checksum concept
7/25/2019 Chap 08 Modified PP2003
55/68
TCP/IP Protocol Suite $$
Figure 8.23 Checksum in oneDs complement arithmetic
7/25/2019 Chap 08 Modified PP2003
56/68
TCP/IP Protocol Suite $%
7/25/2019 Chap 08 Modified PP2003
57/68
Figure 8.24 )5ample of checksum calculation in binary
7/25/2019 Chap 08 Modified PP2003
58/68
TCP/IP Protocol Suite $'
7/25/2019 Chap 08 Modified PP2003
59/68
TCP/IP Protocol Suite $
-et us do the same e5ample in he5adecimal# )ach row has fourhe5adecimal digits# 6e calculate the sum first# .ote that if an
addition results in more than one he5adecimal digit! the right"
most digit becomes the current"column digit and the rest are
carried to other columns# @rom the sum! we make thechecksum by complementing the sum# ,owever! note that we
subtract each digit from 2 in he5adecimal arithmetic 8Eust as
we subtract from 2 in binary arithmetic9# This means the
complement of ) 82+9 is 2 and the complement of + is B 8229#
@igure 1#$ shows the calculation# .ote that the result 81BB29is e5actly the same as in )5ample 2A#
Example18
See Next Slide
Figure 8.25 )5ample of checksum calculation in he5adecimal
7/25/2019 Chap 08 Modified PP2003
60/68
TCP/IP Protocol Suite %
7/25/2019 Chap 08 Modified PP2003
61/68
TCP/IP Protocol Suite %1
Checkppendi5 Cfor a detailed
description of checksum calculationand the handling of carries#
Note:Note:
7/25/2019 Chap 08 Modified PP2003
62/68
TCP/IP Protocol Suite %2
8.5 IP PACKAGE
6e give an e5ample of a simplified IP software package to show its6e give an e5ample of a simplified IP software package to show itscomponents and the relationships between the components# This IPcomponents and the relationships between the components# This IP
package involves eight modules#package involves eight modules#
The topics discussed in this section include:The topics discussed in this section include:
,eader"dding 4odule,eader"dding 4odule
Processing 4oduleProcessing 4odule
FueuesFueues
*outing Table*outing Table
@orwarding 4odule@orwarding 4odule
4TU Table4TU Table@ragmentation 4odule@ragmentation 4odule
*eassembly Table*eassembly Table
*eassembly 4odule*eassembly 4odule
Figure 8.26 IP components
7/25/2019 Chap 08 Modified PP2003
63/68
TCP/IP Protocol Suite %3
5 d ddi d l
7/25/2019 Chap 08 Modified PP2003
64/68
5eaderaddin! module
6ecei*e 4 data destination address
1. 7ncapsulate the data in an IP data!ram by addin! the IP
header
2. Calculate the checksum and insert it in the checksum ,eld3. 8end the data to the correspondin! input 9ueue
#. 6eturn
TCP/IP Protocol Suite %#
P i d l
7/25/2019 Chap 08 Modified PP2003
65/68
Processin! module
1. 6emo*e one data!ram "rom one o" the input 9ueues2. I"(destination address is 12&.:.;.< or matches one o" the
local addresses (hostids))
1. 8end the data!ram to the reassembly module
2. 6eturn
3. I"(machine is a router)1. ecrement TT
#. I"(TT less than or e9ual to -ero)
1. iscard the data!ram
2. 8end an IC=P error messa!e
3. 6eturn$. 8end the data!ram to the routin! module
%. 6eturn
TCP/IP Protocol Suite %$
> t ti d l
7/25/2019 Chap 08 Modified PP2003
66/68
>ra!mentation module? 6ecei*e 4 an IP data!ram "rom the routin! module
1. 70tract the si-e o" the data!ram2. I"(si-e @ =TA o" the correspondin! network)
1. I"((do not "ra!ment) bit is set)
1. iscard the data!ram
2. 8end an IC=P error messa!e
3. 6eturn2. 7lse
1. Calculate the ma0imum si-e
2. i*ide the data!ram into "ra!ments
3. +dd header to each "ra!ment
#. +dd re9uired options to each "ra!ment
$. 8end the data!rams
%. 6eturn3. 7lse
1. 8end the data!ram#. 6eturn
TCP/IP Protocol Suite %%
6 bl t bl
7/25/2019 Chap 08 Modified PP2003
67/68
6eassembly table
? Ased by the reassembly module? >i*e ,elds
8tate(>677 or IBA87) 8ource IP address(source IP o" the data!ram) ata!ram I(uni9uely de,ne a data!ram) Timeout(predetermined amount o" time in which all
"ra!ments must arri*e) >ra!ments(a pointer to a linked list o" "ra!ments)
TCP/IP Protocol Suite %&
6 bl d l
7/25/2019 Chap 08 Modified PP2003
68/68
6eassembly module
6ecei*e 4 an IP data!ram "rom the processin! module
1. I"(oset *alue is -ero and the = bit is )1. 8end the data!ram to the appropriate 9ueue
2. 6eturn.
2. 8earch the reassembly table "or the correspondin! entry
3. I"(not "ound)
1. Create a new entry#. Insert the "ra!ment at the appropriate place in the link list1. I"(all "ra!ments ha*e arri*ed)
1. 6eassemble the "ra!ments
2. eli*er the data!ram to the correspondin! upper layer protocol
3.6eturn
2. 7lse1. Check the timeout
2. I"(timeout e0pired)
1. iscard all "ra!ments
2. 8end an IC=P error messa!e
$. 6eturn