Error and Control
An IP datagram travels from node to nodeon the way to its destination
Each router operates autonomously
Failures or problems may occur or developalong the way to a destination
Destinations may not be reachable
Referenced host may not have theappropriate application running
The Time to Live field may decrement to 0before reaching destination
Error and Control
To assist with such situations a protocolwas included within the IP module
Internet Control Message Protocol (ICMP)
Routers and hosts can report certainconditions back to the source of theoriginal datagram
This is strictly a reporting mechanism tothe source of the datagram that triggeredthe condition
ICMP
The ICMP protocol is documented in RFC792(1981)
ICMP messages are themselves encapsulated asIP datagrams
ICMP messages may themselves encounterreportable conditions
By convention, when ICMP datagrams encounternormally reportable conditions, these are not sent
The reporting of conditions are not mandatory
ICMP
No ICMP message is sent for a fragmentdatagram except for the first fragment
No ICMP message is sent if source is amulticast address
No ICMP message is sent to specialaddresses, such as 127.0.0.0
Position of ICMP in the network layer
Encapsulation of ICMP packet
ICMP messages
General format of ICMP messages
Error-reporting messages
Contents of data field for error messages
Destination-unreachable format
Common Codes
    0   Network Unreachable  (router)
    1   Host Unreachable  (router)
    2   Protocol (IP) Unreachable (host)
    3   Port Unreachable (host)
    4   Fragmentation required, NOFRAG bit set (router)
    5   Source Route failed  (router)
Source-quench format
 Routers may become congested and traffic may backup
 If there is no buffer for an incoming datagram the router discards thedatagram and sends a Source Quench ICMP to the source host
 A source Quench ICMP is sent for every datagram discarded
 Source must reduce rate of traffic
 There is no indication sent when rate can again be increased
 Source host can later gradually increase traffic
Time-exceeded message format
Code 0 :   Time to Live field has decremented to 0
    A Time exceeded ICMP is sent to the source host  and datagram        discarded
    This is sent by a router
Code 1:    When all fragments of an original datagram do not arrive at a        destination  within a certain time, all fragments are discarded        and an ICMP Time exceed message sent to source host       (by host)
Parameter-problem message format
 Code 0:  Problem exists in the basic IP header
 Code 1:  Problem exits in an Options field
 Pointer points to the first byte where error is detected
 When a parameter problem is detected, datagram is discarded and thisICMP message is sent
 This message may be created by a router or a host
Host Routing Table
Each host start with some minimal routing table
In the simplest case, it contains the address of adefault router
As time goes on, this table can be augmented asmore information becomes available
For example, the defined default router may notalways be the best choice for a destination
The occurs when more than one router isconnected to the same network
When this occurs, a router may send a redirectionmessage to the host to notify it of the better choice
Redirection concept
Redirection message format
Code 0:  Network specific
Code 1:  Host specific
Code 2:  Network specific (specified service)
Code 3:  Host specific (specified service)
Note: This is sent by a router to a host on
 the same local network
Query messages
Echo Request/Reply
host or a router may send an Echo Request
When a host or router receives an EchoRequest it should send the same message tothe source of the request as a Reply
This is essentially what the command PINGdoes
This is a useful diagnostic to verifyreachability  of a destination
Echo-request and echo-reply message format
Ping command can use ICMPRequest/Reply
Timestamp-request and
timestamp-reply message format
 Time values are in milliseconds since midnight UniversalTime (UT)
 UT is the same as Greenwich Mean Time (GMT)
Timestamp Request/Reply
Originate timestamp set by the source of datagram, othervalues set to 0
Receive timestamp set by destination when datagramreceived
Transmit timestamp set when destination sends reply
When reply arrives at source, time of reply noted
Sending time = Receive – Originate
Receive time  = Reply – Transmit
Round trip = Sending time + Receive time
The round trip time is accurate even if  the two clocks are notsynchronized
Timestamp Request/Reply
Synchronizing clocks using timestamp request/reply
One-way time =   Round-trip/2
Time difference = Receive – (Originate + One-way)
Example
       Originate timestamp  =46
Receive timestamp    =59
Transmit timestamp   =60
Reply timestamp        = 67
       Sending time =  59 – 46 = 13
       Receive time =  67 – 60 =  7
       Round-trip   =   13 + 7   =   20
  Time difference = 59 – (46 + 10) =  3
Mask-request and mask-reply message format
 Purpose is for a host to obtain the mask associated with  its IP address
 Host sends this request to a router on the local network
 If host does not know the address of the router it broadcasts this request
 Router responds with the mask for this network
 Not really used today
 BOOTP and DHCP used instead
Router solicitation message format
 Purpose is to allow a host to discover routers on the local network
 Even if it has a default gateway configured, this is a way to discoverothers connected to the local network
 A host broadcasts this message
 Routers will reply with advertisement messages
Router advertisement message format
 May be sent even when not solicited by a request
 Advertisement is broadcast on the local network
ICMP Checksum
An ICMP message contains a Checksummuch like an IP header
The Checksum calculation is the same aspreviously described
The Checksum covers the entire ICMPmessage, the header and the data
ICMP package
Traceroute
Command that attempts to track the path adatagram takes to its destination
Traceroute uses ICMP and the TTL field inthe IP header
When TTL decrements to 0 ICMP TimeExceeded message sent to host
ICMP message contains IP address ofrouter generating message
Traceroute
Traceroute sends datagram with TTL = 1
First router sends ICMP Time Exceeded
Traceroute next sends datagram with TTL =2
Second router sends ICMP Time Exceeded
This continues until destination reached
Each step logs a hop to the destination
Notes:
 Path of subsequent datagrams not guaranteed to be thesame each time
Some routers along the way may not respond