ECE 4110 – Internetwork Programming IP Protocol. 2 * From TCP/IP Protocol Suite, B. A. Forouzan,...

41
ECE 4110 – Internetwork Programming IP Protocol

Transcript of ECE 4110 – Internetwork Programming IP Protocol. 2 * From TCP/IP Protocol Suite, B. A. Forouzan,...

ECE 4110 – Internetwork Programming

IP Protocol

2* From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall

Position of IP in TCP/IP Protocol Suite

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 3

Introduction

Packets in IP are called datagrams. IP service is:

Connectionless Unreliable Best-effort: No error checking or

tracking. IP does its best to get the datagram to the destination with no guarantees.

4* From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall

IPv4 Datagram Format

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 5

IPv4 Header Network byte order (big endian) used. Fields:

Version: 4 Header length: Number of 32-bit words in the header (5 without options) Service type: Discussed later. Total length: Total length of IP datagram in bytes (max

65535). Identification: Uniquely identifies each datagram sent by a

host. Used for fragmentation and reassembly. Flags: Used for fragmentation. Fragmentation offset: Used for fragmentation. In 8-byte units. Time to live: Upper limit on number of hops. Often 32 or 64.

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 6

IPv4 Header (cont’d)

Fields (cont’d): Protocol: Identifies which protocol gave data to IP. Checksum: Only for the header. Source address: 32-bit IP address. Destination address: 32-bit IP address. Options: Variable length list of options. Not all

hosts/routers support all of them. Security and handling restrictions: For military

applications. Record route: Have each router record its IP address Timestamp: Have each router record its IP address and

time Loose source routing: List of IP addresses that must be

traversed. Strict source routing: Similar to above, but only these

addresses must be traversed.

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 7

Encapsulation of IP datagram in an Ethernet Frame

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 8

Multiplexing/Demultiplexing in Network Layer

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 9

Service Type

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 10

Service Type (cont’d)

Also known as type of service. IETF recently changed the name (and the format) as differentiated services.

Service Type: The precedence subfield is not used in IPv4. TOS bits:

Minimize delay Maximize throughput Maximize reliability Minimize monetary cost

Only one of TOS bits can be specified. Last bit is unused and must be zero.

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 11

Differentiated Services: Codepoint:

When the 3 rightmost bits are all zero, the 3 leftmost bits show precedence.

O/w, codepoint defines 64 services.

Last 2 bits are unused.

Service Type (cont’d)

Category

Codepoint

Assigning Authority

1 XXXXX0 Internet

2 XXXX11 Local

3 XXXX01 Temporary or experiemental

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 12

Fragmentation Each router decapsulates the IP

datagram from the incoming frame and encapsulates into the outgoing frame.

MTU: Maximum Transfer Unit

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 13

Fragmentation (cont’d)

Though maximum IP datagram size is 65535, the data link layer imposes restrictions fragmentation

A fragmented datagram may be further fragmented if it crosses a network with smaller MTU.

Reassembly is done only at the destination. Why?

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 14

Fragmentation (cont’d)

IP fields related to fragmentation: Identification (16 bits):

Provides uniqueness of each datagram. Copied into all fragments.

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 15

Fragmentation (cont’d)

IP fields related to fragmentation: Flags (3 bits):

First bit is reserved. If do not fragment bit is set, and datagram does

not fit the frame, datagram is discarded and ICMP error message is sent.

If more fragments bit is set, there are other fragments following.

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 16

Fragmentation (cont’d)

IP fields related to fragmentation (cont’d): Fragmentation offset (13 bits):

Offset of data in the original datagram. Specified in units of 8 bytes.

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 17

Fragmentation Example

18* From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall

Fragmentation Example (cont’d)

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 19

Fragmentation Example 1

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?

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 20

Fragmentation Example 1 (sol’n)

M bit is 0 No more fragments; This is the last

fragment. However, we cannot say if the

original packet was fragmented or not.

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 21

Fragmentation Example 2

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?

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 22

Fragmentation Example 2 (sol’n)

M bit is 1 At least one more fragment.

This fragment can be the first one or a middle one, but 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 offset).

However, we can definitely say the original packet has been fragmented because the M bit value is 1.

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 23

Fragmentation Example 3

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?

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 24

Fragmentation Example 3 (sol’n)

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

Offset value is 0 it is the first fragment.

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 25

Fragmentation Example 4

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?

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 26

Fragmentation Example 4 (sol’n)

Multiply the offset value by 8 First byte number is 800. We cannot determine the number

of the last byte unless we know the length of the data.

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 27

Fragmentation Example 5

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?

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 28

Fragmentation Example 5 (sol’n)

First byte number is 100 8 = 800.

The total length is 100 bytes and the header length is 20 bytes (5 4)

80 bytes of data. If the first byte number is 800, the

last byte number must 879.

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 29

IP Options

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 30

IP Options (cont’d)

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 31

IP Options (cont’d)

No operation option:

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 32

IP Options (cont’d)

End of option option:

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 33

IP Options (cont’d)

Record route option:

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 34

Record Route Concept

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 35

IP Options (cont’d)

Strict Source Route option:

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 36

Strict Source Route Concept

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 37

IP Options (cont’d)

Loose Source Route option:

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 38

IP Options (cont’d)

Timestamp option:

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 39

Use of Flag in Timestamp

Spring 2003Tuna Tugcu ECE 4110 – Internetwork Programming 40

Timestamp Concept

41* From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall

IP Package