IPv4: Understanding the Internet Protocol Version 4, Study notes of Computer Science

An overview of ipv4, including its functions, datagram format, header checksum, type of service field, fragmentation and reassembly, and routing fields. It also covers various ip options such as record route, source route, timestamping, and router alert.

Typology: Study notes

Pre 2010

Uploaded on 03/18/2009

koofers-user-7hi-1
koofers-user-7hi-1 🇺🇸

9 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
copyright 2005 Douglas S. Reeves 1
The Internet Protocol,
Version 4 (IPv4)
Internet Protocols
CSC / ECE 573
Fall, 2005
N.C. State University
copyright 2005 Douglas S. Reeves 2
Today’s Lecture
I. IPv4 Overview
II. IP Fragmentation and Reassembly
III. IP and Routing
IV. IPv4 Options
copyright 2005 Douglas S. Reeves 3
IPv4 Overview
copyright 2005 Douglas S. Reeves 4
Internet Protocol v4 (RFC791) Functions
A universal intermediate layer
Routing
Fragmentation and reassembly
copyright 2005 Douglas S. Reeves 5
“IP over Everything, Everything Over IP”
Everything over IP
TCP, UDP
Appletalk
Netbios
SCSI
ATM
X.25
SNA
Sonet
Fibre Channel
Frame Relay…
Remote Direct Memory Access
Ethernet
IP over everything
Dialup
ISDN
X.25
Ethernet
Wi-Fi
FDDI
ATM
Sonet
Even IP over IP!
copyright 2005 Douglas S. Reeves 6
IP = Basic Delivery Service
Connectionless delivery simplifies router design
and operation
Unreliable, best-effort delivery. Packets may be…
lost (discarded)
duplicated
reordered
and/or corrupted
pf3
pf4
pf5

Partial preview of the text

Download IPv4: Understanding the Internet Protocol Version 4 and more Study notes Computer Science in PDF only on Docsity!

copyright 2005 Douglas S. Reeves 1

The Internet Protocol,

Version 4 (IPv4)

Internet Protocols CSC / ECE 573 Fall, 2005 N.C. State University copyright 2005 Douglas S. Reeves 2

Today’s Lecture

I. IPv4 Overview

II. IP Fragmentation and Reassembly

III. IP and Routing

IV. IPv4 Options

copyright 2005 Douglas S. Reeves 3

IPv4 Overview

copyright 2005 Douglas S. Reeves 4

Internet Protocol v4 (RFC791) Functions

• A universal intermediate layer

• Routing

• Fragmentation and reassembly

copyright 2005 Douglas S. Reeves 5

“IP over Everything, Everything Over IP”

  • Everything over IP
    • TCP, UDP
    • Appletalk
    • Netbios
    • SCSI
    • ATM
    • X.
    • SNA
    • Sonet
    • Fibre Channel
    • Frame Relay…
    • Remote Direct Memory Access
    • Ethernet
      • IP over everything
        • Dialup
        • ISDN
        • X.
        • Ethernet
        • Wi-Fi
        • FDDI
        • ATM
        • Sonet

• Even IP over IP!

copyright 2005 Douglas S. Reeves 6

IP = Basic Delivery Service

• Connectionless delivery simplifies router design

and operation

• Unreliable, best-effort delivery. Packets may be…

  • lost (discarded)
  • duplicated
  • reordered
  • and/or corrupted

copyright 2005 Douglas S. Reeves 7

IPv4 Datagram Format

version (^) length (x4)header prec^ type of service | D T R C 0 total length (in bytes) 0 4 8 16 31 identification (^) 0 DF MFflags fragment offset (x8) time-to-live (hop count) (next) protocol identifier header checksum source IP address destination IP address IP options (if any) payload 20 bytes ≤40 bytes ≤65515 bytes copyright 2005 Douglas S. Reeves 8

IPv4 Header Contents

  • Functions 1. universal intermediate layer
    1. routing
    2. fragmentation and reassembly
    3. Options
      • Version (4 bits)
      • Header Length x4 (4)
      • Type of Service (8)
      • Total Length (16)
      • Identification (16)
      • Flags (3)
      • Fragment Offset ×8 (13)
      • Time-to-Live (8)
      • Protocol Identifier (8)
      • Header Checksum (16)
      • Source IP Address (32)
      • Destination IP Address (32)
      • IP Options (≤ 320) copyright 2005 Douglas S. Reeves 9

IPv4 “Universal Common Layer” Fields

  • Version: 4 (i.e., IPv4)
  • Header Length ×4 (i.e., header length is always a

multiple of 4 bytes)

  • normally = 5 (×4 = 20)
  • at most = 15 (×4 = 60)
  • Total Length (incl. IP header) < 2^16 -1 (65535 10 )
  • Protocol Identifier: how to interpret the payload
  • e.g., TCP = 6, UDP = 17, … copyright 2005 Douglas S. Reeves 10

Header Checksum

  • Only for detecting errors in the IP header
    • needed?
  • Algorithm
    • add (ones-complement addition) consecutive 16-bit words to generate a 16 bit sum
    • then one’s-complement this sum
    • (for purposes of computation, assume an “initial” checksum value of all zeros) copyright 2005 Douglas S. Reeves 11

Header Checksum (cont’d)

  • Receiver generates checksum on received header

and compares. If differs from received

checksum…

  • IP packet is discarded
  • no error messages are sent (why not?)
  • What type of errors is this guaranteed to detect? copyright 2005 Douglas S. Reeves 12

Checksum Code

  • Given… a) IP header b) length of the header (in units of 16 bit words) **u_short checksum(u_short header, int length) { register u_long sum = 0; while (length--) { sum += header++; _/ This is twos-complement addition /_ if (sum & 0xFFFF0000) { _/ carry occurred, wrap around /_ sum &= 0x0000FFFF; sum++; } } return ~(sum & 0x0000FFFF); _/ 1 ’s complement the sum /_ }

copyright 2005 Douglas S. Reeves 19

Fragmentation Example

  • Example below: path MTU = 620 host A host B router R router R Network 1, MTU= Network 2, MTU= Network 3, MTU= 20 1480 (^20 ) 20 600 20 280 20 600 20 600 20 280 copyright 2005 Douglas S. Reeves 20
  • Fragment payload size must be a multiple of 8

bytes, except for the last one

1 packet 3 fragments (Stored as 75 (= 600/8) in the header) (Stored as 150 (= 1200/8) in the header) offset = 0^ offset = 600^ offset = 1200 copyright 2005 Douglas S. Reeves 21

Fragmentation Fields

  • Identification field uniquely identifies each

datagram

  • allows fragments of a datagram to be matched together
  • Each fragment has the same IP header as the

original IP datagram, except for the following:

  • Fragment Offset
  • More Fragments flag
  • Options
  • IP Header Length
  • Total Length
  • Header Checksum copyright 2005 Douglas S. Reeves 22

Fragmentation Fields (cont’d)

  • IP Checksum will of course be different in

fragment than for original datagram

  • More Fragments flag = 0 if this is the last (or only)

fragment of the datagram, 1 otherwise

  • The Fragment Offset field gives offset of the data

(payload) portion of the fragment relative to the

start of data in the original IP datagram

  • in units of 8 bytes
  • 13 bits are enough to represent a maximum datagram length of 2^13 * 8 = 2^16 copyright 2005 Douglas S. Reeves 23

Fragmentation Fields (cont’d)

  • IP Options may or may not be included in fragment

IP headers (option-dependent)

  • IP Header Length may therefore be different than in original datagram
  • Total Length is length of the fragment, not length

of the original datagram

copyright 2005 Douglas S. Reeves 24

Reassembly

  • Fragments reassembled at final destination in a

reassembly buffer

  • good? bad?
  • What if some fragments never arrive? Problems?
  • ???
  • What if two fragments overlap?
  • ???

copyright 2005 Douglas S. Reeves 25

Avoiding Fragmentation

  • Is fragmentation even a good idea?
  • Do Not Fragment flag “forbids” fragmentation by

the network. If datagram exceeds MTU of the

outgoing router interface, the router…

  • discards the datagram, and
  • sends ICMP error message back to the source
  • Better approach: Path MTU Discovery (we’ll

discuss later)

copyright 2005 Douglas S. Reeves 26 IP Routing Fields copyright 2005 Douglas S. Reeves 27

Basic IP Routing Fields

  • Source IP Address, Destination IP Address
  • Time-to-Live (TTL) (max allowable “hop” count)
    • max of 255, usually initialized to 128 or greater
    • decremented by each router the datagram passes through
  • When TTL=0…
    • datagram will be discarded
    • error message sent back to source by ICMP
    • purpose?
  • What’s the longest valid IP path length??? copyright 2005 Douglas S. Reeves 28 IP Options copyright 2005 Douglas S. Reeves 29

IP Options

  • Basic protocol property: extensibility
  • IP options mainly used for testing / debugging
    • infrequently used; 40 bytes doesn’t give you much to work with
  • Every IP option must start with:
    • Code (i.e., option type)
    • Option Length (maximum of 40 bytes) copyright 2005 Douglas S. Reeves 30

What Options Are Used?

  • Record Route [RFC791]
  • Loose Source Route [RFC791]
  • Strict Source Route [RFC791]
  • Time Stamp [RFC791]
  • MTU Probe and Reply [RFC1191, we’ll discuss in

ICMP lecture]

  • Router Alert [RFC2113]

copyright 2005 Douglas S. Reeves 37

IP Strict Source Route Option Example

copyright 2005 Douglas S. Reeves 38

Option #3: Timestamping

  • Allows intermediate routers to insert 32-bit (ms

since midnight UT) timestamps in the option

  • right now: 6,480,000,
  • If IP addresses filled by source, only specified

routers will insert timestamp

Code Length Pointer First IP address (may be filled by source) First timestamp Last IP address (may be filled by source) Last timestamp

32 bits Overflow Flags copyright 2005 Douglas S. Reeves 39

Option #3: Timestamping (cont’d)

  • How many entries possible?
  • Problem of unsynchronized clocks?
  • Not copied on fragmentation; in first fragment only copyright 2005 Douglas S. Reeves 40

Option #5: Router Alert

  • Alerts routers to more closely examine the

contents of a “special” IP packet

  • example protocol benefiting from this: RSVP
  • Value has only one interesting interpretation: “pay

attention to this packet”

  • All fragments carry the option Code Length Value 32 bits copyright 2005 Douglas S. Reeves 41

Summary

1. IP provides a universal intermediate layer,

routing, and fragmentation and reassembly

  • IP is unreliable, best-effort delivery
  • Fragmentation is infrequent, undesirable; is it

necessary?

  • IP is extensible through the 40-byte Options field copyright 2005 Douglas S. Reeves 42

Next Lecture

  • The Address Resolution Protocol (ARP)