Transcript Document

Internet Control Message
Protocol (ICMP)
• IP provides unreliable and
connectionless delivery
– Provides unreliable delivery
– Make efficient use of network
resources
• No error reporting, or
correcting mechanism
• No management of queries
– Network manager might need
information about a host/router
• What happens if
– Router discards a datagram ?
– TTL expires ?
– Host didn’t receive all
datagram’s fragments ?
Position of ICMP in the network layer
And Encapsulation
•
•
•
Special purpose message mechanism added to the TCP/IP protocols
Destination of an ICMP message is the ICMP software module
ICMP is a network layer protocol, but its messages are first encapsulated into
IP datagrams.
Error reporting vs. Error Correction
• ICMP can only report an error to the original source
– Up to the source to deal with it.
• ICMP cannot be used to inform intermediate routers.
– Source has no responsibility of routers problems.
• Why restrict ICMP messages to original source?
– Except for record route option, datagrams only contains source +
destination @.
– No global knowledge of routes (i.e. routers establish and change their own
routing tables)
ICMP messages
Type
Message
3 Destination Unreachable
8 or 0
Echo request or reply
4 Source Quench
13 or 14 Timestamp
Type Message
11 Time Exceeded
17 or 18 Address Mask
12 Parameter problem
10 or 9
5 Redirection
Router Sollicitation/Adv
General format of ICMP messages
• Data section in
– Error Messages carries information to find the original packet that had
the error
• Rest of Header unused (all 0s), except for Redirection message format
– Query Messages carries extra information based on type of the query.
• Rest of Header = Identifier (8 bits) + Sequence Number (8 bits)
Error-reporting messages
Important points about ICMP error messages:
1. No ICMP error message for a datagram
carrying an ICMP error message.
2. No ICMP error message for a fragmented
datagram that is not the first fragment.
3. No ICMP error message for a datagram
having a multicast address.
4. No ICMP error message for a datagram
with a special address such as 127.0.0.0 or 0.0.0.0
Contents of data field for error messages
• In ICMP error messages
– The first 8 bytes of the Transport layer header is included
– Provides Information about the port numbers (TCP or UDP) and sequence
number (TCP)
Destination-unreachable (Type 3)
0 Network is unreachable
8 source host isolated
1 Host is unreachable
9 dest Network administratively prohibited
2 Protocol is unreachable
10 dest Host admin prohibited
3 Port is unreachable
11 Network unreachable for TOS
4 Fragmentation required
12 Host unreachable for TOS
5 Source routing not feasible 13 Administrator put a filter on Host
•
•
6 Network unknown
14 requested precedence not permitted
7 Host is unknown
15 Precedence was cut-off
ICMP destination unreachable message for codes = 2 and 3 only created by a
host
All others are created by a routers
!!! Routers cannot detect all Problems that prevent
the delivery of a packet.
Source-quench (type =4, code =0)
• IP do not provide a flow-control mechanism
– Source never knows if routers of destination is congested
• A source-quench message informs the source that a datagram has been
discarded due to congestion in a router or the destination host
– Two purposes: (1) informs the source of dropped packet (2) inform of
congestion along the path
– Source must slow down (quench) the sending of datagrams until the
congestion is relieved.
• One source-quench message should be sent to each datagram that has
been discarded due to congestion
– One-to-one congestion
– Many-to-one congestion (congested router has no idea which source is
sending datagrams faster)
Time-exceeded message (Type 11)
• If router receives a datagram with TTL = 0
– Discard the datagram
– Inform the source using a Time-exceeded message (code = 0)
• If a host does not receive all fragments of a datagram
during within a certain time of receiving the first fragment
– Discard all fragments
– Inform the source using a Time-exceeded message (code = 1)
Code 0: used only by routers
Code 1: used only by Hosts
Parameter-problem message
• A parameter problem message is created by a router or destination host
– If there is an error or ambiguity in the header field (code = 0), pointer
points to the byte with problem
– An option is missing or incorrect (code = 1) pointer not used
• Router discards the datagram and sends a Parameter-problem message
Redirection message format
• Updates to routers’ routing tables are dynamic
• Updates to hosts’ routing tables are static
– Starts with the small routing tables that gets updated one of the tools is
redirection message format
– Redirection always sent from a router to a host in the same network
Code 0:
Code 1:
Code 2:
Code 3:
Network specific
Host specific
Network specific (specified service)
Host specific (specified service)
Query messages
• Diagnose some network problems.
• Information request/reply is now obsolete (replaced by
RARP/BOOTP)
Timestamp-request and
timestamp-reply message format
• Can be used to determine RTT needed for an IP datagram to travel
between two machines.
• Identifier and Sequence fields allows machine to associate request with
replies
Timestamp-request and
timestamp-reply message
•
•
•
In general:
•
•
SendingT = recv – orig
ReceivingT = packet arrived – trans
– Orig = 83573336, recv =
83573330; trans = 83573330;
– With RTT = 2 ms, |diff| = 6 ms;
implies that recv is 7 ms late.
•
RTT = (sendingT + ReceivingT)
•
If: One_way_time = RTT/2
– Orig = 83573336, recv =
83573000; trans = 83573000;
– With RTT = 2 ms; |diff|=336 ms
Timestamp req/reply is useless
•
outOfSyncT = recv – (orig + RTT/2)
Can be used to synchronize two
machines clocks.
Example:
Router solicitation message format
•
An important issue is how to accommodate routers in the same netwok:
– Designers provided routers advertisement,
– Default value 10 mn
• Compromise between rapid failure detection and low overhead.
•
From a Host point of view this delay is very expensive
– Example: when a host boots cannot wait 10 mn
•
Designers provide Router solicitation message to request immediate
advertisement.
– Host multicasts/broadcasts a router solicitation message
– Identifier + Sequence number not used.
Router Advertisement
• Static routing works well for a network that has only one
router. (no need to discover routes or change routes)
• For a network with many routers, and if a router crashes,
then host uses router advertisement message.
– ICMP route discovery helps in:
• Host can get the router address from the router itself, instead via a
bootstrap protocol (i.e. static configuration)
• Use of Timers to update routes (Soft state technique)
Router advertisement message format
•
•
•
•
Number of addresses (that follows usually 1)
Address size (IPv4 = 1)
Lifetime: time to use the specified address (a default 30 mn)
Address Preference: Shows the preference of the router’s address.
Mask-request and mask-reply message format
• In general to request a subnet mask from a router
• Diskless machine can use Mask-request to get its subnet mask.
Echo-request and echo-reply message format
•
Designed for diagnosis purposes
– Host or router can send a echo-request
– Receivers echoes back the message with an echo-reply
•
•
Echo-request/reply used by network admin to test the reachability of a specific
host
Identifier & Sequence Number are not formally used by the protocol,
– Can be set to anything by the sender
•
Example : Ping program : a statistical tool
– Does not use Transport protocols (TCP or UDP)
Ping Program
•
•
•
•
Ping programs uses Echo-request/reply to test reachability of a host
Identifiers : Process ID
– If many ping programs are running
Sequence Number : increment for each echo-request
RTT = received_reply_time – requested_time(stored in ICMP data packet)
•
•
Other Options:
Use ICMP request message encapsulated into an IP packet with record route option.
–
–
Example: Ping –R machine
Limited number of IP addresses
•
•
•
IP header lenght = 4 bits
Allows 15* 4 bytes (60 – 20 IP header– 3 bytes for option information ) Only 9 IP addresses
Use ICMP request message encapsulated into IP packet with timestamp option
–
More severe limitation
ICMP package
Input Module
(handles all types of received ICMP messages)
•
•
Receive an ICMP packet from the IP layer
1- if (type = request type)
– 1- Create a reply
– 2- Send the reply
•
2- if (type = router solicitation)
– 1- if (station is a router)
• Create router advertisement
• Send the advertisement
•
3- if (type = one of the 3 reply messages or router advertisement)
– 1- Extract information in the data section of the packet
– 2- Deliver extracted information to the process that requested it
•
4- if (type defines a redirection)
– Modify the routing table
•
5- if (type = error messages other that redirection)
– Inform the appropriate source protocol
•
6- return.
Output Module
(responsible for: creating requests, solicitation, error messages requested
by higher level protocols or IP)
•
•
Receive : a demand
1- if (demand = error messages)
– If (demand is from IP)
• If (demand is forbidden i.e. 4 cases where ICMP does not error message)
–
Return
– If (type defines a redirection message)
• If (station is not a router)
– Return
– Create the error message using type, code, and original IP packet
•
2- If (demand = request or solicitation)
– Create a request or solicitation message
•
•
3- send the message
4- return
Ping Program (example)
Gateway
Ping destination
C
Ping -R C
X.Y.Z.B2
X.Y.Z'
.R2
Router
B1
A
SLIP
ping source
.R1
X.Y.Z'.R2
X.Y.Z'.C
X.Y.Z'.Gateway
B
X.Y.Z.R1
B2
X.Y.Z.B1
X.Y.Z
X.Y.Z.A
Traceroute Program (ICMP “Time
Exceeded” revisited)
•
If a router crashes or connection
between two routers is lost
•
•
TRACEROUTE
Create UDP datagram(“with unreachable port#”) to
send to destination
•
UDP datagram has 12bytes of data, (sequence#, TTL,time).
•
•
•
TTL = 1;
Send ‘n’ datagrams to destination
while (!receive (ICMP “port_unreachable”)
• Can take time to re-route
•
•
In this case TTL function is to
avoid routing loops.
If TTL =0/1 must not forward the
datagram.
–
– Router sends ICMP “Exceeded
Time” to sender.
(TTLth Router
•
–
–
–
–
•
}
TTL--; Send ICMP “TimeExceeded”)
Sender knows IP address of TTLth router in ICMP
packet
Print (IP address, 1st RTT, 2nd RTT, .., nth RTT)
TTL++;
Send ‘n’ datagrams to destination
Traceroute Program ( IP Source route
revisited)
dest = D
{#R1,R2,R3}
S
dest = R1
{#R2,R3,D}
R1
dest = R2
{R1,#R3,D}
R2
R3
dest = R3
{R1,R2,#D}
dest = D
{R1,R2,R3#}
• Traceroute can specify a Strict Source routing
– If failed, ICMP error source route unfeasible (type =3, code =5)
• Can also specify loose source routing
– Traceroute [-LooseRoute Destination] Source
– Traceroute Round Trips may be different
• How many source route IP addresses?
D
Traceroute or Ping RTT?
• Traceroute stores original time
in UDP data. (12 bytes).
• Ping stores original time in
ICMP packet, echoed by
receiver.