ip datagram icmp message format
play

IP Datagram ICMP Message Format 1 byte 1 byte 1 byte 1 byte - 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. Department of Computer Science and Engineering University of South Carolina IP header ICMP Message 20 bytes CSCE515 – Computer Network Programming IP Datagram ICMP Message Format 1 byte 1 byte 1 byte 1 byte VERS HL Service Total Length Datagram ID FLAG Fragment Offset 0 7 8 15 16 31 TTL Protocol Header Checksum type code checksum Source Address payload Destination Address Options (if any) Data CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming ICMP Message Types ICMP Address Mask Request and Reply � intended for a diskless system to obtain its subnet mask. � Echo Request � Id and seq can be any values, and these values are � Echo Response returned in the reply. � Destination Unreachable � Match replies with request � Redirect 0 7 8 15 16 31 � Time Exceeded type(17 or 18) code(0) checksum � there are more ... identifier sequence number subnet mask CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming

  2. ping Program ICMP Echo Request and Reply � Available at /usr/sbin/ping � Test whether another host is reachable � Send ICMP echo_request to a network host � -n option to set number of echo request to send 0 7 8 15 16 31 � -i option to set TTL checksum type(0 or 8) code(0) � -R option to record route (apollon.cse.sc.edu) identifier sequence number � -s option to set timestamp � -w option to set timeout to wait for each reply optional data � Check manual, different ping versions have different options CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming traceroute Program IP Record Route Option � Available at /usr/sbin/traceroute � ping – R : Record route � Every router that handles the datagram adds its IP address to a list in � Display the route that IP datagrams follow from the options field one host to another � The final destination copies the IP addresses into the outgoing ICMP � Compare with ping : echo reply � Doesn’t require an special or optional features at any � All routers on the return path add their IP address to the list intermediate routers � Problems? � Only requires a working UDP module at the destination � uses ICMP and the TTL field in the IP header 39 bytes � -g option to specify intermediate routers to be used with loose source routing (up to 8 times) code len ptr IP addr # 1 IP addr # 2 … IP addr # 9 � -G option to specify intermediate routers to be 1 1 1 4 4 4 used with strict source routing (up to 8 times) CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming traceroute Program UDP port unreachable � TTL + ICMP � ICMP error message � Each router decrement the TTL at least by 1 � IP header � A IP datagram whose TTL is either 0 or 1 will not be forwarded. � An ICMP “time exceeded” message will be sent back to the originating � 8 bytes of the IP datagram that caused the host. error dest = D � WHY? TTL = 2 TTL = 3 39 bytes TTL = 1 S R1 R2 D Ethernet IP ICMP IP header of datagram UDP ICMP TE ICMP TE ICMP TE?? Header header header that generated error header 8 8 14 20 20 UDP “port unreachable” CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming

  3. 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 P M s our packet (one of C c t forward datagram I e r i our IP address or d e r (if forwarding enabled) broadcast addresses)? IP output: routing calculate next hop s table o u router (if necessary) r c e r o u t n i g process IP options IP input queue IP layer network interfaces CSCE515 – Computer Network Programming IP Layer Create Routing Table Entries � Forwarding datagrams generated either on local � Created by default when an interface is configured host or on some other hosts toward their � when the interface’s address is set by the ifconfig ultimate destination Destination Gateway Flags Ref Use Interface 129.252.130.0 129.252.130.106 U 1 68 eri0 � A default router specified in a file, the default is added to � Routing: the routing table on every reboot. � Static routing: when network is small, single � /etc/defaultrouter connection point to other networks, no redundant wyxu@altair % cat /etc/defaultrouter route existent 129.252.130.1 � specified in configuration files � not based on measurement or estimates of current traffic and � Added by route command topology � Dynamic routing: use routing daemon to run routing protocol in order to communicate with other routers � Created by an ICMP redirect CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming 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 CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming

  4. 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 R1 R2 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 CSCE515 – Computer Network Programming 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 checksum � Redirect to some unknown host type(5) code(0-3) 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 CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming 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 CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming

  5. ICMP Router Solicitation ICMP Router Advertisement 0 7 8 15 16 31 checksum type(9) code(0) 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] … CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming Autonomous Systems � Collection of networks with same policy � Single routing protocol Routing protocols � Usually under single administrative control CSCE515 – Computer Network Programming Routing classification Kernel Processing at IP Layer � Interior gateway protocols (IGPs) routing route netstat � RIP (Routing Information Protocol) daemon command command routing table UDP TCP updates from � OSPF (Open Shortest Path First) adjacent routers ICMP P M s our packet (one of C t c forward datagram I e r i our IP address or d e r (if forwarding enabled) broadcast addresses)? � Exterior gateway protocols (EGPs) IP output: routing calculate next hop s table router (if necessary) o u r c e r o u t i n g � BGP: border gateway protocol process IP options � Used between NSFNET backbone and some of the regional networks IP input queue IP layer network interfaces CSCE515 – Computer Network Programming 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