ges are usually acted on by either the IP layer or the higher layer protocol (TCP or UDP). Some ICMP messages cause errors to be returned to user processes.
There are 15 different values for the type field, which identify the particular ICMP message. Some types of ICMP messages then use different values of the code field to further specify the condition.
Chapter 7: Ping Program
Ping tests whether another host is reachable. It sends an ICMP echo request message to a host, expecting an ICMP echo reply to be returned. Ping also measures the round-trip time to host.
The server echoes the identifier and sequence number fields, and any additional data sent by the client and of interest.
On some systems (bsd/386 version 0.9.4 for example) time may be listed as 0 ms because the available timer only provides 10 ms accuracy.
-r sets the IP record route (RR) in the outgoing IP datagram which contains the ICMP echo request message. this option records the route the datagram takes to its destination.
This functionality can also be obtained used
Chapter 8: Traceroute Program
Traceroute lets us see the route that IP datagrams follow from one host to another. Traceroute also lets us use the IP source route option.
The program sends UDP datagrams starting with TTL 1, increasing the TTL by 1 to locate each router in the path. An ICMP time exceeded is returned by each router when it discards the UDP datagram, and an ICMP port unreachable is generated by the final destination.
-g implement loose and strict source routing, to specify a forced route.
Chapter 9: IP Routing
Datagrams to be routed can be generated on the local host or on some other host (must be configured to act as a router otherwise datagrams received are dropped).
The routing table can be updated by
route command or when ICMP redirect messages are received. The information contained in the routing table drives all decisions made by IP. The kernal maintains the routing table.
The steps IP performs when searching its routing table:
- search for a matching host address
- search for a matching network address
- search for a default entry (usually specifed as a network entry with a network ID of 0)
IP performs the routing mechanisism (searching the routing table to decide which interface to send a packet out) while routing policy is set by a routing daemon.
netstat -rn // -r displays the routing table, -n prints IP addresses in numeric format not names.
u the route is up.
g the route is a gateway(route). if not set, the destination is directly connected.
h the route is to a host - the destination is a complete host. If not set, the destination is to a network and the destination is a network address.
d the route was created by ICMP redirect.
m the route was modified by ICMP redirect.
Use displays the number of packets sent through that route.
lo0 is the loopback interface.
Whenever an interface is initialised a direct route is automatically created for that interface. Routes to hosts or networks must be entered into the routing table. The
route command may be executed from initialisation files at system boot.
route add <destination> <gateway/router> 1 // final argument is routing metric: if 0 set without g flag, if greater than 0 set with g flag.
Routing tables are also initialised by running routing daemon or via routing discovery protocol.
The ICMP "host unreachable" error message is sent by a router when it receives an IP datagram that it cannot deliver or forward.
Hosts are not supposed to forward IP datagrams unless they have been specifically configured as a router. On unix systems this is via the
ipforwarding kernal variable.
ICMP redirect errors allow a host with minimal routing knowledge to build up a better routing table over time.
Chapter 10: Dynamic Routing Protocols
There are two basic types of routing protocols: Interior Gateway Protocols (IGPs), for routers within an autonomous system, and Exterior Gateway Protocols (EGPs), for routers to communicate with routers in other autonomous systems.
Dynamic Routing Protocols are used by routers to communicate with each othe