116
Chapter 8 Internet Protocol (IP)

Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

  • Upload
    others

  • View
    11

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Chapter 8

Internet Protocol (IP)

Page 2: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Outlineo Datagramo Fragmentationo Optionso Checksumo IP package

Page 3: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-1

Position of IP in TCP/IP Protocol Suite

The McGraw-Hill Companies, Inc., 2000

Page 4: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

IP: Internet Protocolo An unreliable and connectionless datagram

protocol

o A best-effort delivery service

Page 5: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

DATAGRAM

8.18.1

The McGraw-Hill Companies, Inc., 2000

Page 6: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Datagramo Datagramsn Packets in the IP layers are called in datagramsn A variable-length packetn Consist of two parts

o Header o Data

Page 7: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-2

IP Datagram

The McGraw-Hill Companies, Inc., 2000

Page 8: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

IP Datagramo Version (VER)o Header length (HLEN)n Total length of the datagram header in 4-byte

wordsn The length of the header is variable

o 20-60 bytesn If no options, header length is 20 bytes

o HLEN = 5

Page 9: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

IP Datagram (Cont.)o Differentiated Services (DS)n IETF has recently changed the interpretation and

name of this fieldn Formerly Service Typen See the following slides

Page 10: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-3

Service Type or Differentiated Services

The McGraw-Hill Companies, Inc., 2000

Page 11: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Services Typeo Precedencen 3-bit subfield defines the priority of the datagram

in issues such as congestionn However, this subfield is not used in version 4

o TOS (Type of Service) bitsn 4-bit subfield with each bit having a special

meaningn However, one and only one of the bits can be set

Page 12: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

The precedence subfield is The precedence subfield is not used in version 4.not used in version 4.

The McGraw-Hill Companies, Inc., 2000

Page 13: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Types of Services

Minimize delay1000

Maximize throughput0100

Maximize reliability0010

Minimize cost0001

Normal (default)0000

DescriptionTOS Bits

Page 14: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Default Types of Service

Maximize throughput0100DNS (zone)

Normal0000DNS (TCP query)

Minimize delay1000DNS (UDP query)

Maximize throughput0100SMTP (data)

Minimize delay1000SMTP (command)

Minimize delay1000TFTP

Minimize delay1000FTP (control)

Maximize throughput0100FTP (data)

Minimize delay1000TELNET

Maximize reliability0010SNMP

Maximize reliability0010IGP

Minimize cost0001NNTP

Normal0000BOOTP

Normal0000ICMP

DescriptionTOS BitsProtocol

Page 15: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Default Types of Service (Cont.)o Minimum delay

n Interactive activitiesn Activities requiring immediate attentionn Activities requiring immediate response

o Maximum throughputn Send bulk data

o Maximum reliabilityn Management activities

o Minimum monetary costn Background activities, like Usenet News (NNTP)

Page 16: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Differentiated Serviceso The first 6 bits make up the codepointo The last two bits are not usedo The 3 right-most bits are 0sn The 3 left-most bits are interpreted the same as

the precedence bits in the Service Typeo The 3 right-most bits are not all 0sn The 6 bits define 64 services based on the priority

assignment by the Internet or local authorities

Page 17: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Values for Codepoints

Temporary or experimentalXXXX013

LocalXXXX112

Internet (IEFT)XXXXX01

Assigning AuthorityCodepointCategory

Page 18: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

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 lengtho Identification

n Used in fragmentationo Flags

n Used in fragmentationo Fragmentation offset

n Used in fragmentation

Page 19: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

The total length field defines theThe total length field defines thetotal length of the total length of the

datagram including the header.datagram including the header.

The McGraw-Hill Companies, Inc., 2000

Page 20: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-4

The McGraw-Hill Companies, Inc., 2000

o Why we need the total length fieldn Layer 2 just drop the header and trailern The remaining is the datagram (length)

o However, in some cases, padding is occurredn Ethernet’s minimum frame data length is 46 bytesn If size of the IP datagram is less than 46, some padding

will be addedn Thus, check the total length field to determine how much

is really data

Encapsulation of a Small Datagram in an Ethernet Frame

Page 21: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Encapsulation of a Small Datagram in an Ethernet Frame (Cont.)

Page 22: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

IP Datagram (Cont.)o Time to live

n The maximum number of hops visited by the datagramo Routing table can become corruptedo Intentionally limit the journey of the packet

n Usually two times the maximum number of routers between any two hosts

o Protocoln Define the higher-level protocol that uses the services of

the IP layern Help in the demulplexing proccess

Page 23: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Protocols

OSPF89

UDP17

TCP6

IGMP2

ICMP1

ProtocolValue

Page 24: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-5

DeMultiplexing

The McGraw-Hill Companies, Inc., 2000

Page 25: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

IP Datagram (Cont.)o Checksumo Source addressn Define the IP address of the sourcen Never changed between the trip

o Destination addressn Define the IP address of the destinationn Never changed between the trip

Page 26: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 1Example 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

Page 27: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

o There is an error in this packeto The 4 left-most bits (0100) show the versionn which is correct

o The next 4 bits (0010) show the header lengthn which means (2 × 4 = 8), which is wrongn The minimum number of bytes in the header must

be 20n The packet has been corrupted in transmission

SolutionSolution

Page 28: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 2Example 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

Page 29: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

o The HLEN value is 8n 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.

SolutionSolution

Page 30: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 3Example 3

In an IP packet, the value of HLEN is 516and 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

Page 31: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

o The HLEN value is 5n 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)

SolutionSolution

Page 32: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 4Example 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

Page 33: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

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 byten Which is 01

o The packet can travel only one hopo The protocol field is the next byte (02)n The upper layer protocol is IGMP

SolutionSolution

Page 34: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

FRAGMENTATION

8.28.2

The McGraw-Hill Companies, Inc., 2000

Page 35: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Maximum Transfer Unit (MTU)o Each data link layer protocol has its own

frame formatn One of this field defines the maximum size of the

data fieldo The maximum length of the IP datagramn 65,535 bytes

o Fragmentationn We must divide the IP datagram to make it

possible to pass through the underlying network

Page 36: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-6

MTU

The McGraw-Hill Companies, Inc., 2000

Page 37: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

MTUs for Different Networks

296PPP576X.25

1, 500Ethernet4, 352FDDI4, 464Token Ring (4 Mbps)

17, 914Token Ring (16 Mbps)

65,535HyperchannelMTUProtocol

Page 38: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Fragmentationo When a IP datagram is fragmentedn Each fragment has its own IP headern Most of the fields repeated but some changed

o A fragmented datagram may itself be fragmented n A datagram can be fragmented several times

Page 39: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

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 hostn Each fragment becomes an independent datagram

Page 40: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Fragmentation (Cont.)o When a datagram is fragmentedn 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

Page 41: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-2

IP Datagram

The McGraw-Hill Companies, Inc., 2000

Page 42: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Fields Related to Fragmentationo Identificationn 16-bit field identifies a datagram originating from

the source hostn The combination of the identification and source

IP address uniquely define a datagramn IP uses a counter to label the datagramn When fragmented, identification field is copied

into all fragmentationn All fragments have the same identification number

Page 43: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Fields Related to Fragmentation (Cont.)o Flags: 3-bit fieldn 1st bit: reservedn 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 sourceo 0: can be fragmented if necessary

n 3rd bit: called the more fragment bito 1: the datagram is not the last fragmento 0: this is the last or only fragment

Page 44: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-7

Flag Field

The McGraw-Hill Companies, Inc., 2000

Page 45: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Fields Related to Fragmentation (Cont.)o Fragmentation offsetn 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

Page 46: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-8

Fragmentation Example

The McGraw-Hill Companies, Inc., 2000

Page 47: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-9

Detailed Example

The McGraw-Hill Companies, Inc., 2000

Page 48: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Reassemblyo The first fragment has an offset value of zeroo 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 8n 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

Page 49: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 5Example 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

Page 50: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

o If the M bit is 0n There are no more fragmentsn 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

SolutionSolution

Page 51: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 6Example 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

Page 52: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

o If the M bit is 1n 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 informationn 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

SolutionSolution

Page 53: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 7Example 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

Page 54: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

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

o The offset value is 0n It is the first fragment

SolutionSolution

Page 55: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 8Example 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

Page 56: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

o To find the number of the first byten Multiply the offset value by 8n The first byte number is 800.

o We cannot determine the number of the last byte unless we know the length of the data

SolutionSolution

Page 57: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 9Example 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

Page 58: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

o The first byte number is 100 × 8 = 800o The header length is 20 bytes (5 × 4)o The total length is 100 bytesn There are 80 bytes in this datagram

o If the first byte number is 800, the last byte number must 879

SolutionSolution

Page 59: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

OPTIONS

8.38.3

The McGraw-Hill Companies, Inc., 2000

Page 60: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Options Formato Code field: 1-byteo Length field: 1-byten Total length of the option

o Include the code field and the length fieldn Not present in all of the option types

o Data field: variable-sizedn Contain the data that specific option requiredn Not present in all option types

Page 61: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-10

Option Format

The McGraw-Hill Companies, Inc., 2000

Page 62: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Code Fieldo Copy: 1-bit controls the presence of the option in

fragmentationn 0: the option only appear in the first fragmentn 1: the option appear in all fragments

o Class: 2-bit defines the general purposes of the optionn 00: the option is used for datagram controln 10: the option is used for debugging and managementn 01 and 11: have not yet been defined

o Number: 5-bit defines the type of the optionn only 6 types are in use

Page 63: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Option Typeso Only 6 options are currently being used

o Two of them are 1-byte optionn Do not require the length or the data fields

o Four of them are multiple-byte optionn Require the length and the data fields

Page 64: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-11

Categories of Options

The McGraw-Hill Companies, Inc., 2000

Page 65: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

No Operationo Used as a filler between optionso For example, used to align the next option on

a 16-bit or 32-bit boundary

Page 66: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

End of Optiono Used for padding at the end of the option fieldn Can only be used as the last optionn Only one end of option option can be usedn After this option

o The receiver check for the payload data

n Thus, if more than 1 byte is needed to align the option fieldo Some no operation options must be used followed by

an end of option option

Page 67: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

End of Option (Cont.)

Page 68: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Record Routeo Used to record the internet routers that handle

the datagramn 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 entryn Point to the first available entry

Page 69: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-14

Record Route Option

The McGraw-Hill Companies, Inc., 2000

Page 70: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

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

o When receiving this datagram, the routern Insert its outgoing IP address in the empty fieldn Increment the value of the pointer by 4

Page 71: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-15

Record Route Concept

The McGraw-Hill Companies, Inc., 2000

Page 72: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Strict Source Routeo Used by the source to predetermine a route for

the datagramo Rulen All the routers defined in the option must be

visitedn A router must not be visited if its IP address is not

listed in the datagram

Page 73: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Strict Source Route (Cont.)o If the datagram visits a router not on the listn Discard the datagram and issue an error message

o If the datagram arrives at the destination and some of the entries were not visitedn Discard the datagram and issue an error message

Page 74: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-16

Strict Source Route Option

The McGraw-Hill Companies, Inc., 2000

Page 75: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Strict Source Route Operationso When a datagram arriving at a router, compare the

pointer value with the length fieldn If pointer <= length, compare the IP address pointed by the

pointer with its incoming IP addresso If equal,

n Process the packetn Overwrite the current IP address with its outgoing IP address n Increment the pointer by 4n 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

Page 76: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Strict Source Route Concept

Page 77: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Loose Source Routeo Each router in the list must be visitedo But the datagram can visit other routers as

well

Page 78: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Timestampo Used to record the time of datagram

processing by a routern Expressed in millisecond from midnight,

Universal Time

n Help to track the behavior of the router

Page 79: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-19

Timestamp Option

The McGraw-Hill Companies, Inc., 2000

Page 80: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Timestamp Option Formato Overflow field

n The number of routers that could not add their timestamp because no more fields were available

o Flag: the visited router responsibilitiesn 0: each router add only timestamp in the provided fieldn 1: each router add its outgoing IP address and timestampn 3: the IP address are given. Each router check the given IP

address with its own incoming IP addresso If match, overwrite with its outgoing IP address and add timestamp

Page 81: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-20

Use of Flag in Timestamp

The McGraw-Hill Companies, Inc., 2000

Page 82: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-21

Timestamp Concept with Flag Value of 1

The McGraw-Hill Companies, Inc., 2000

Page 83: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 10Example 10

Which of the six options must be copied to each fragment?

The McGraw-Hill Companies, Inc., 2000

Page 84: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

o Look at the first (left-most) bit of the code for each optionn No operation: Code is 00000001; no copy.n End of option: Code is 00000000; no copyn Record route: Code is 00000111; no copyn Strict source route: Code is 10001001; copiedn Loose source route: Code is 10000011; copiedn Timestamp: Code is 01000100; no copy

SolutionSolution

Page 85: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 11Example 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

Page 86: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

o Look at the second and third (left-most) bits of the coden No operation: Code is 00000001; controln End of option: Code is 00000000; controln Record route: Code is 00000111; controln Strict source route: Code is 10001001; controln Loose source route: Code is 10000011; controln Timestamp: Code is 01000100; debugging

SolutionSolution

Page 87: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 12o 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.eduPING fhda.edu (153.18.8.1) 56(84) bytes of data.64 bytes from tiptoe.fhda.edu (153.18.8.1): ....

Page 88: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 13o We can also use the ping utility with the -R

option to implement the record route option

$ ping -R fhda.eduPING 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 msRR: 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)

Page 89: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 14o The traceroute utility can also be used to keep

track of the route of a packet

$ traceroute fhda.edutraceroute 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 ms2 Dbackup_V69.fhda.edu (153.18.251.4) 2.113 ms 1.996 ms 2.059 ms3 tiptoe.fhda.edu (153.18.8.1) 1.791 ms 1.741 ms 1.751 ms

The result shows the three routers visited.

Page 90: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 15o 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 ms2 Dbackup_V69.fhda.edu (153.18.251.4) 2.168 ms 2.148 ms 2.037 ms

Page 91: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example 16o 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 packets1 Dbackup_V69.fhda.edu (153.18.251.4) 2.168 ms 2.148 ms 2.037 ms

Page 92: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

CHECKSUM

8.48.4

The McGraw-Hill Companies, Inc., 2000

Page 93: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Checksumo Error detection methodo Checksum calculation at the sendern The packet is divided into k section, each of n bitsn All sections are added together using one’s

complement arithmeticn The final result is complemented to make the

checksum

Page 94: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Checksum (Cont.)o Checksum calculation at the receivern 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 acceptedo Otherwise, reject the packet

Page 95: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

To create the checksum the sender does To create the checksum the sender does the following:the following:

1.1. The packet is divided into k sections, The packet is divided into k sections, each of n bits.each of n bits.

2.2. All sections are added together using All sections are added together using oneone’’s complement arithmetic.s complement arithmetic.

3.3. The final result is complemented The final result is complemented to make the checksum.to make the checksum.

The McGraw-Hill Companies, Inc., 2000

Page 96: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-2

IP Datagram

The McGraw-Hill Companies, Inc., 2000

Page 97: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-22

Checksum Concept

The McGraw-Hill Companies, Inc., 2000

Page 98: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Checksum Concepto According to the one’s complement arithmeticn If all the section are added and the number is Tn Complement T in one’s complement is –Tn Thus, if the sum is T, the checksum is –T

o When the sender receives the packetn T + (-T) in one’s complement is -0n Complement -0 derive 0n Thus, the final result should be 0

Page 99: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-23

Checksum in One’s Complement Arithmetic

The McGraw-Hill Companies, Inc., 2000

Page 100: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Checksum in the IP Packeto The checksum in the IP packet covers only

the header, not the data. This is becausen All higher-level protocols that encapsulate data in

the IP datagram have a checksum fieldo Checksum for the IP datagram do no have to check

the encapsulated datan The header of the IP datagram changes with each

visited router, but the data does noto If the data is included, each router must recalculate the

check for the whole packet and increase the overhead

Page 101: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example of Checksum Calculationin Binary

Page 102: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Example of Checksum Calculationin Hexadecimal

Page 103: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

IP PACKAGE

8.58.5

The McGraw-Hill Companies, Inc., 2000

Page 104: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

IP Packageo IP package may involves following components

n Header-adding modulen Processing modulen Routing modulen Fragmentation modulen Reassembly modulen Routing modulen MTU tablen Reassembly tablen Input/output queue

o Omit the option processing module in the package

Page 105: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-26

IP Components

The McGraw-Hill Companies, Inc., 2000

Page 106: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Header-Adding Moduleo Receives data from an upper-level protocol

and destination IP address1. Encapsulate the data in an IP datagram2. Calculate the checksum and insert it in the

checksum field3. Send the data to the corresponding input queue4. Return

Page 107: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Processing Moduleo The heart of the IP package

o Receive a datagram from either an interface or the header-adding module

Page 108: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Processing Module (Cont.)o Remove one datagram from one of the input queueso If (destination address is 127.X.Y.Z or match one of the local

address )n Send the datagram to the reassembly modulen Return

o If (machine is a router )n Decrement TTL

o If (TTL less than or equal to zero)n Discard the datagramn Send an ICMP error messagen Return

o Send the datagram to the routing moduleo Return

Page 109: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Queueso Input queue: n Store the datagram coming from the data link

layer or the upper-layer protocolsn Dequeued by the processing module

o Output queue: n Store the datagram going to the data link layer or

the upper-layer protocoln Enqueued by the fragmentation and reassembly

module

Page 110: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Routing Table, Routing Module, and MTU Tableo Routing Tablen Discussed before in Chapter 6

o Routing Modulen Discussed before in Chapter 6

o MTU Tablen Used by the fragmentation module to find the

maximum transfer unit of a particular interface

Page 111: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-27

MTU Table

The McGraw-Hill Companies, Inc., 2000

Page 112: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Fragmentation Moduleo Receive: an IP datagram from the routing module1. Extract the size of the datagram2. 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 message2. Return

2. Else1. Calculate the maximum size2. Divide the datagram into fragments3. Add header to each fragment4. Add require options to each fragment5. Send the datagrams6. Return

3. Else1. Send the datagram

4. Return

Page 113: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Reassembly Tableo Used by the reassembly moduleo Has five fields

n State: FREE or IN-USEn Source IP address: source IP address of datagramn Datagram ID

o A number unique defines a datagram and all of the fragments belonging to that datagram

n Time-outo A predetermined amount of time in which all fragments must arrive

n Fragmentso A pointer to a linked list of fragments

Page 114: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Figure 8-28

Reassembly Table

The McGraw-Hill Companies, Inc., 2000

Page 115: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Reassembly Moduleo Receive, from the processing module, those

datagram fragments arriving at their final destinations

o Since IP is connectionlessn The fragment may arrive out of ordern Fragments may be intermixedn Use a reassembly table to keep track of these

fragments

Page 116: Chapter 8 Internet Protocol (IP) - 國立中興大學 8.pdf · Internet Protocol (IP) Outline o Datagram oFragmentation o Options o Checksum o IP package. Figure 8-1 Position of IP

Reassembly Module (Cont.)o Receive: an IP datagram from the processing module1. If (fragment offset value is zero and M (more fragment) bits is 0)

1. Send the datagram to the appropriate queue2. Return

2. Search the reassembly table for the entry3. If ( not found)

1. Create a new entry4. Insert the fragment at the appropriate place in the linked list

1. If (all fragments have arrived)1. Reassembly the fragments2. Deliver the datagram to the corresponding upper layer protocol3. Return

2. Else1. Check the time-out2. If (time-out expired)

1. Discard all fragments and send an ICMP error message

5. Return