ping program icmp message format
play

ping Program ICMP Message Format Available at /usr/sbin/ping Test - PDF document

ICMP Internet Control Message Protocol ICMP is a protocol used for exchanging control messages. CSCE 515: Two main categories Query message Computer Network Error message Programming Usage of an ICMP message is determined by


  1. ICMP Internet Control Message Protocol � ICMP is a protocol used for exchanging control messages. CSCE 515: � Two main categories � Query message Computer Network � Error message Programming � Usage of an ICMP message is determined by type and code fields ------ IP, Ping, Traceroute � ICMP uses IP to deliver messages. � ICMP messages are usually generated and processed by Wenyuan Xu the IP software, not the user process. http://www.cse.sc.edu/~wyxu/csce515f07.html Department of Computer Science and Engineering University of South Carolina IP header ICMP Message 20 bytes 2007 CSCE515 – Computer Network Programming ping Program ICMP Message Format � Available at /usr/sbin/ping � Test whether another host is reachable � -n option to set number of echo request to send � -i option to set TTL 0 7 8 15 16 31 � -r option to record route type code checksum � -s option to set timestamp payload � -w option to set timeout to wait for each reply 2007 CSCE515 – Computer Network Programming 2007 CSCE515 – Computer Network Programming ICMP Echo Request and Reply IP Record Route Option � ping – R : Record route � Every router that handles the datagram adds its IP address to a list in the options field � The final destination copies the IP addresses into the outgoing ICMP echo reply � All routers on the return path add their IP address to the list 0 7 8 15 16 31 � Problems? type(0 or 8) code(0) checksum identifier sequence number optional data 39 bytes code len ptr IP addr # 1 IP addr # 2 … IP addr # 9 1 1 1 4 4 4 2007 CSCE515 – Computer Network Programming 2007 CSCE515 – Computer Network Programming

  2. traceroute Program traceroute Program � Available at /usr/sbin/traceroute � TTL + ICMP � Display the route that IP datagrams follow from � Each router decrement the TTL at least by 1 � A IP datagram whose TTL is either 0 or 1 will not be forwarded. one host to another � An ICMP “time exceeded” message will be sent back to the originating � Compare with ping : host. � Doesn’t require an special or optional features at any intermediate routers � Only requires a working UDP module at the dest = D destination � uses ICMP and the TTL field in the IP header TTL = 2 TTL = 3 � -g option to specify intermediate routers to be TTL = 1 used with loose source routing (up to 8 times) S R1 R2 D ICMP TE ICMP TE ICMP TE?? � -G option to specify intermediate routers to be used with strict source routing (up to 8 times) UDP “port unreachable” 2007 CSCE515 – Computer Network Programming 2007 CSCE515 – Computer Network Programming Kernel Processing at IP Layer If the host disabled the forwarding, does the host still need routing table? routing route netstat daemon command command routing table Creating Routing UDP TCP updates from adjacent routers ICMP Entries ICMP redirects our packet (one of forward datagram our IP address or (if forwarding enabled) broadcast addresses)? IP output: routing calculate next hop s o table router (if necessary) u r c e r o u t n i g process IP options IP input queue IP layer network interfaces 2007 CSCE515 – Computer Network Programming Create Routing Table Entries IP Routing — Static Routing � Forward datagrams generated either on local � Created by default when an interface is host or on some other hosts toward their configured ultimate destination � when the interface’s address is set by the ifconfig � A default router specified in a file, the default is � Routing: added to the routing table on every reboot. � Static routing: when network is small, single � /etc/defaultrouter connection point to other networks, no redundant route existent � Added by route command � specified in configuration files � Dynamic routing: use routing daemon to run routing protocol in order to communicate with other routers � Created by an ICMP redirect � ICMP router advertisement � Solicitation message 2007 CSCE515 – Computer Network Programming 2007 CSCE515 – Computer Network Programming

  3. route Command ICMP Redirect Error � Explicitly add or remove routing table entry � Sent by a router to sender of an IP from configuration files at bootstrap time datagram when the datagram should have been sent to a different router � route add default sun 1 � route add slip bsdi 1 � Used only when the host has a choice of routers to send its datagram to 2007 CSCE515 – Computer Network Programming 2007 CSCE515 – Computer Network Programming Example of ICMP Redirect Example of ICMP Redirect Destination Gateway Destination Gateway -------------------- -------------------- ----- -------------------- -------------------- ----- default 129.252.130.1 129.252.1.0 129.252.1.1 127.0.0.1 127.0.0.1 default 129.252.130.1 127.0.0.1 127.0.0.1 host host 129.252.1.180 129.252.1.180 (1) IP datagram (1) IP datagram (3) ICMP redirect (3) ICMP redirect (2) IP datagram (2) IP datagram redirect from 129.252.130.1 to redirect from 129.252.130.1 to R1 R2 R1 R2 129.252.1.180 129.252.1.180 129.252.130.1 129.252.130.1 129.252.1.1 129.252.1.1 Destination Gateway Destination Gateway Final destination Final destination -------------------- -------------------- ----- -------------------- -------------------- ----- default 129.252.1.1 default 129.252.1.1 127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1 2007 CSCE515 – Computer Network Programming 2007 CSCE515 – Computer Network Programming ICMP Redirect Security concern � What can you do to take advantage of the ICMP redirect? � Screw-up the routing table 0 7 8 15 16 31 � Redirect to some unknown host type(5) code(0-3) checksum router IP address that should be used � Redirect to the host itself � Sniffing packet IP header + first 8 bytes of original datagram data � Redirect to my own address? � Greedy router, � I don’t want to route the packet 2007 CSCE515 – Computer Network Programming 2007 CSCE515 – Computer Network Programming

  4. Security concern- Partial solutions ICMP Router Discovery Messages � The new router must be on a directly � After bootstrapping connected network � broadcasts / multicasts a router solicitation message � The redirect must be from the current � other routers respond with a router router for that destination advertisement message � The redirect cannot tell the host to use itself as a router � Periodically advertisement � The route that’s being modified must be an � broadcasts / multicasts a router solicitation indirect route message 2007 CSCE515 – Computer Network Programming 2007 CSCE515 – Computer Network Programming ICMP Router Solicitation ICMP Router Advertisement 0 7 8 15 16 31 type(9) code(0) checksum number of address 0 7 8 15 16 31 lifetime addresses entry size(2) checksum type(10) code(0) router address [1] unused (sent as 0) preference level [1] router address [2] preference level [2] … 2007 CSCE515 – Computer Network Programming 2007 CSCE515 – Computer Network Programming Kernel Processing at IP Layer routing route netstat daemon command command routing table UDP TCP updates from adjacent routers Routing protocols ICMP ICMP redirects our packet (one of forward datagram our IP address or (if forwarding enabled) broadcast addresses)? IP output: routing calculate next hop s table router (if necessary) o u r c e r o u t i n g process IP options IP input queue IP layer network interfaces 2007 CSCE515 – Computer Network Programming

  5. Routing Protocols Distance-vector Protocols � Executed by routing daemon to � Maintain a vector of distances communicate routing information with � Each router updates its other routers routing table based on vector of distances received from neighbors � Two types of routing protocols � Example: RIP � Distance-vector protocols � most widely used routing protocol � Link-state protocols � the metrics used: hop count 2007 CSCE515 – Computer Network Programming 2007 CSCE515 – Computer Network Programming Problem: Count-to-infinity Count-to-infinity � With distance vector routing, good news travels fast, but bad news travels slowly � When a router goes down, it takes can take a really long time before all the other routers become aware of it 2007 CSCE515 – Computer Network Programming 2007 CSCE515 – Computer Network Programming Improvements Routing Information Protocol (RIP) � Split Horizon � Most widely used routing protocol � Carried in UDP datagrams � Don’t tell neighbor about routes obtained from it � Routing daemon: � routed � gated � Triggered updates as opposed to periodic updates UDP IP header RIP Message � Path vectors, Store vectors or complete header path as opposed to just next hop 8 bytes 20 bytes 2007 CSCE515 – Computer Network Programming 2007 CSCE515 – Computer Network Programming

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend