ECE 5600 Introduction to Computer Networking Lecture 15

  • Slides: 26
Download presentation
ECE 5600 Introduction to Computer Networking Lecture 15 – IP and ICMP Prof. Rose

ECE 5600 Introduction to Computer Networking Lecture 15 – IP and ICMP Prof. Rose Qingyang Hu Electrical and Computer Engineering Department Utah State University

READING Book: Andrew S. Tanenbaum, Computer Networks, Fifth Edition, Prentice Hall Chapters 5. 6.

READING Book: Andrew S. Tanenbaum, Computer Networks, Fifth Edition, Prentice Hall Chapters 5. 6. 1, 5. 6. 4

IP PROTOCOL Network Layer Protocol Provides Host-to-Host Datagram Service Independent of LAN

IP PROTOCOL Network Layer Protocol Provides Host-to-Host Datagram Service Independent of LAN

IP DATAGRAM IP Header Data v Encapsulated in an Ethernet II Frame Dest MAC

IP DATAGRAM IP Header Data v Encapsulated in an Ethernet II Frame Dest MAC Source MAC 0800 IP Header Type value: 0 x 0800 => IPv 4 datagram. 0 x 0806 => ARP frame 0 x 8100 => IEEE 802. 1 Q frame 0 x 86 DD =>IPv 6 frame Data CRC

IP HEADER IP Header Length Type of Service IP Version Packet Identifier Time to

IP HEADER IP Header Length Type of Service IP Version Packet Identifier Time to Live IP Protocol Byte 4 IHL TOS Total length ID F Fragment TTL Protocol Header checksum Source IP Address Destination IP Address Options (if IHL > 5) 32 bits Total length of datagram including header Offset of this fragment in the packet Checksum of header and options only

IPV 4 HEADER FIELDS Version (4 bits) § Always 4 IP Header Length (4

IPV 4 HEADER FIELDS Version (4 bits) § Always 4 IP Header Length (4 bits) § Number of 32 -bit words in the IP header § 5 plus the number of option words Type of Service (8 bits) Priority D T R M 0 Minimize Cost Maximize Reliability Maximize Throughput Minimize Delay

IPV 4 HEADER FIELDS Total length (16 bits) § Length of the IP datagram

IPV 4 HEADER FIELDS Total length (16 bits) § Length of the IP datagram in bytes, including both header and data. Identification (16 bits) § Identifies fragments that belong to a datagram. Flags (3 bits) R DF MF More Fragments to come (higher offset exists) Don’t fragment. If MTU too small, re-route or discard Reserved, should be 0

IPV 4 HEADER FIELDS Offset (13 bits) § Offset of this fragment in bytes.

IPV 4 HEADER FIELDS Offset (13 bits) § Offset of this fragment in bytes. § Fragmentation on 8 -byte boundaries only. Time to Live (8 bits) § Number of router hops left to live. § Decremented & checked on each hop. Protocol (8 bits) (defined in RFC 1700) § ICMP = 1 § TCP = 6 § UDP = 17

IPV 4 HEADER FIELDS Checksum (16 bits) § A simple 16 -bit long checksum

IPV 4 HEADER FIELDS Checksum (16 bits) § A simple 16 -bit long checksum which is computed for the header of the datagram. Source (originator’s) IP address (32 -bits) Destination (target’s) IP address (32 -bits) Options § Stream identifier, trace route, etc. § Not often used, your IP stack may ignore them

SENDING AN IP PACKET Assign new ID Fragment if needed For each fragment, create

SENDING AN IP PACKET Assign new ID Fragment if needed For each fragment, create header and send End

RECEIVING AN IP PACKET Version and Checksum ok? no End yes Destination IP address

RECEIVING AN IP PACKET Version and Checksum ok? no End yes Destination IP address is mine? no End yes Reassemble Fragments Packet Complete? no End yes Send Packet to appropriate stack End

ICMP PROTOCOL v The IP (Internet Protocol) relies on several other protocols to perform

ICMP PROTOCOL v The IP (Internet Protocol) relies on several other protocols to perform necessary control and routing functions: v Control functions (ICMP: The Internet Control Message Protocol ) v Multicast signaling (IGMP: Internet Group Management Protocol) v Setting up routing tables (RIP, OSPF, BGP, PIM, …)

ICMP MESSAGES The Internet Control Message Protocol (ICMP) is a helper protocol that supports

ICMP MESSAGES The Internet Control Message Protocol (ICMP) is a helper protocol that supports IP with facility for § Error reporting § Simple queries ICMP messages are encapsulated as IP datagrams:

ICMP MESSAGE ICMP Header ICMP Message v Encapsulated in an Ethernet II Frame Dest

ICMP MESSAGE ICMP Header ICMP Message v Encapsulated in an Ethernet II Frame Dest MAC Source MAC 0800 IPv 4 IP header ICMP header Protocol = 1 ICMP Message CRC

ICMP MESSAGE FORMAT First 4 byte header: § Type (1 byte): type of ICMP

ICMP MESSAGE FORMAT First 4 byte header: § Type (1 byte): type of ICMP message § Code (1 byte): subtype of ICMP message § Checksum (2 bytes): similar to IP header checksum. Checksum is calculated over entire ICMP message If there is no additional header, there are 4 bytes set to zero. § each ICMP messages is at least 8 bytes long

ICMP MESSAGE TYPES Most Messages for query or error reporting. See RFC 792 for

ICMP MESSAGE TYPES Most Messages for query or error reporting. See RFC 792 for a complete list. ICMP messages interesting to us: § Echo Request, type = 8 § Echo Reply, type = 0 § Destination Unreachable, type = 3

ICMP QUERY MESSAGE v ICMP query: v Request sent by host to a router

ICMP QUERY MESSAGE v ICMP query: v Request sent by host to a router or host v Reply sent back to querying host

EXAMPLE OF ICMP QUERIES Type/Code: Description 8/0 0/0 Echo Request Echo Reply 13/0 14/0

EXAMPLE OF ICMP QUERIES Type/Code: Description 8/0 0/0 Echo Request Echo Reply 13/0 14/0 Timestamp Request Timestamp Reply 10/0 9/0 Router Solicitation Router Advertisement The ping command uses Echo Request/ Echo Reply

EXAMPLE OF A QUERY: ECHO REQUEST AND REPLY Ping’s are handled directly by the

EXAMPLE OF A QUERY: ECHO REQUEST AND REPLY Ping’s are handled directly by the kernel Each Ping is translated into an ICMP Echo Request The Ping’ed host responds with an ICMP Echo Reply ICMP ECH O REQUES T Host or Router PLY E R CHO E P ICM Host or router

ECHO REQUEST OR REPLY MESSAGE Unique identifier for ping session Type=8, 0 Code =

ECHO REQUEST OR REPLY MESSAGE Unique identifier for ping session Type=8, 0 Code = 0 Checksum Identifier Sequence # Arbitrary Message Sequence number must change for each message • The Identifier and Sequence Number can be used by the client to match the reply with the request that caused the reply. • The data received by the Echo Request must be entirely included in the Echo Reply.

ICMP ERROR MESSAGE ICMP error messages report error conditions Typically sent when a datagram

ICMP ERROR MESSAGE ICMP error messages report error conditions Typically sent when a datagram is discarded Error message is often passed from ICMP to the application program

ICMP ERROR MESSAGE ICMP error messages include the complete IP header and the first

ICMP ERROR MESSAGE ICMP error messages include the complete IP header and the first 8 bytes of the payload (typically: UDP, TCP)

FREQUENT ICMP ERROR MESSAGE Type 3 Code Description 0– 15 Destination unreachable Notification that

FREQUENT ICMP ERROR MESSAGE Type 3 Code Description 0– 15 Destination unreachable Notification that an IP datagram could not be forwarded and was dropped. The code field contains an explanation. 5 0– 3 Redirect Informs about an alternative route for the datagram and should result in a routing table update. The code field explains the reason for the route change. 11 0, 1 Time exceeded Sent when the TTL field has reached zero (Code 0) or when there is a timeout for the reassembly of segments (Code 1) 12 0, 1 Parameter problem Sent when the IP header is invalid (Code 0) or when an IP header option is missing (Code 1)

SOME DESTINATION UNREACHABLE CODES Code Description Reason for Sending 0 Network Unreachable No routing

SOME DESTINATION UNREACHABLE CODES Code Description Reason for Sending 0 Network Unreachable No routing table entry is available for the destination network. 1 Host Unreachable Destination host should be directly reachable, but does not respond to ARP Requests. 2 Protocol Unreachable The protocol in the protocol field of the IP header is not supported at the destination. 3 Port Unreachable The transport protocol at the destination host cannot pass the datagram to an application. 4 Fragmentation Needed and DF Bit Set IP datagram must be fragmented, but the DF bit in the IP header is set.

EXAMPLE: ICMP PORT UNREACHABLE RFC 792: If, in the destination host, the IP module

EXAMPLE: ICMP PORT UNREACHABLE RFC 792: If, in the destination host, the IP module cannot deliver the datagram because the indicated protocol module or process port is not active, the destination host may send a destination unreachable message to the source host. Scenario:

RECEIVING AN ICMP PACKET yes Echo Request? Send Echo Reply End Send Echo Data

RECEIVING AN ICMP PACKET yes Echo Request? Send Echo Reply End Send Echo Data to Application End Print Error Message End no yes Echo Reply? no Unreachable? no End yes