Transcript NetLyr-icmp
Error and Control
• An IP datagram travels from node to node
on the way to its destination
• Each router operates autonomously
• Failures or problems may occur or develop
along the way to a destination
Destinations may not be reachable
Referenced host may not have the
appropriate application running
The Time to Live field may decrement to 0
before reaching destination
Error and Control
• To assist with such situations a protocol
was included within the IP module
• Internet Control Message Protocol (ICMP)
• Routers and hosts can report certain
conditions back to the source of the
original datagram
• This is strictly a reporting mechanism to
the source of the datagram that triggered
the condition
ICMP
• The ICMP protocol is documented in RFC792
(1981)
• ICMP messages are themselves encapsulated as
IP datagrams
• ICMP messages may themselves encounter
reportable conditions
• By convention, when ICMP datagrams encounter
normally reportable conditions, these are not sent
• The reporting of conditions are not mandatory
ICMP
• No ICMP message is sent for a fragment
datagram except for the first fragment
• No ICMP message is sent if source is a
multicast address
• No ICMP message is sent to special
addresses, 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 the
datagram 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 this
ICMP 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 a
default router
• As time goes on, this table can be augmented as
more information becomes available
• For example, the defined default router may not
always be the best choice for a destination
• The occurs when more than one router is
connected to the same network
• When this occurs, a router may send a redirection
message 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
• A host or a router may send an Echo Request
• When a host or router receives an Echo
Request it should send the same message to
the source of the request as a Reply
• This is essentially what the command PING
does
• This is a useful diagnostic to verify
reachability of a destination
Echo-request and echo-reply message format
Ping command can use ICMP
Request/Reply
Timestamp-request and
timestamp-reply message format
• Time values are in milliseconds since midnight Universal
Time (UT)
• UT is the same as Greenwich Mean Time (GMT)
Timestamp Request/Reply
• Originate timestamp set by the source of datagram, other
values set to 0
• Receive timestamp set by destination when datagram
received
• 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 not
synchronized
Timestamp Request/Reply
• Synchronizing clocks using timestamp request/reply
One-way time = Round-trip/2
Time difference = Receive – (Originate + One-way)
• Example
Originate timestamp
Receive timestamp
Transmit timestamp
Reply timestamp
=
=
=
=
46
59
60
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 discover
others 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 Checksum
much like an IP header
• The Checksum calculation is the same as
previously described
• The Checksum covers the entire ICMP
message, the header and the data
ICMP package
Traceroute
• Command that attempts to track the path a
datagram takes to its destination
• Traceroute uses ICMP and the TTL field in
the IP header
• When TTL decrements to 0 ICMP Time
Exceeded message sent to host
• ICMP message contains IP address of
router 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 the
same each time
Some routers along the way may not respond