• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: icmp traceroute
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: icmp traceroute


  • Subject: Re: icmp traceroute
  • From: Dalton Hamilton <email@hidden>
  • Date: Mon, 28 Aug 2006 09:52:28 +0200


However, I found an application called MTR.    I downloaded the code  
and looked at it.  Here is what it does and it acts as the EXPIRED  
response includes the original ICMP header immediately after the  
returned IP Header.




To get this to work, I had to define two structures as MTR did.  The two I defined are:

struct ICMPHeader {
uint8_t type;
uint8_t code;
uint16_t checksum;
uint16_t id;
uint16_t sequence;
};


/*  Structure of an IP header.  */
struct IPHeader {
uint8_t version;
uint8_t tos;
uint16_t len;
uint16_t id;
uint16_t frag;
uint8_t ttl;
uint8_t protocol;
uint16_t check;
uint saddr;
uint daddr;
};




I then used these structures to move forward in the packet (as MTR) does.  

if(packetInterpretedAsICMPPacket->icmp_type == ICMP_TTL_EXPIRE)
{  
packetInterpretedAsIPPacket = (struct ip *)&(packetInterpretedAsICMPPacket->icmp_ip);

header = (struct ICMPHeader *)(pingReplyBuffer + sizeof (struct IPHeader) +
  sizeof (struct ICMPHeader) +
  sizeof (struct IPHeader));
printf("Actual Seq# = %d        icmp packet icmp_seq = %d\n",sequenceNumber,header->sequence);

if(header->sequence != sequenceNumber)
continue;



However, what baffles me is why I can't just do this:

header = (struct ICMPHeader *)(pingReplyBuffer + sizeof (struct ip) +
  sizeof (struct icmp) +
  sizeof (struct ip));

Or do this:

int ipHeaderLength = packetInterpretedAsIPPacket->ip_hl << 2;
ipHeaderPtr = (struct ip *)(pingReplyBuffer + ipHeaderLength + sizeof(struct icmp))
int ipHeaderLength2 = ipHeaderPtr->ip_hl << 2;
header = (struct ICMPHeader *)(pingReplyBuffer + ipHeaderLength +
  sizeof (struct icmp) +
   ipHeaderLength2);

But none of these worked for me.  I tried many different (logical) methods to move forward in the packet to the returned ICMP Header but none gave me the correct results.  I finally decided to try the exact method MTR uses -- i.e. to define their IPHeader struct and ICMPHeader struct and then move forward in the pingReplyBuffer by increments computed by the sizeof their structures.  Why doesn't our /usr/include/netinet/ip.h and ip_icmp.h structures for struct ip and struct icmp work??????  This seems like a kludge to me.  What am I missing here??


Many thanks for all your help.  I couldn't have gotten this working without the help from this working group - in this case, specifically from Josh and Peter.  This type of community effort and support is so appreciated by people like me.  

THANKS!!!!

The code is working now but I'm just a bit un-happy with the way I got it to work.

Thanks
Dalton Hamilton

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: icmp traceroute
      • From: "Peter Sichel" <email@hidden>
References: 
 >icmp traceroute (From: Dalton Hamilton <email@hidden>)
 >Re: icmp traceroute (From: "Peter Sichel" <email@hidden>)
 >Re: icmp traceroute (From: Dalton Hamilton <email@hidden>)
 >Re: icmp traceroute (From: "Peter Sichel" <email@hidden>)

  • Prev by Date: Re: icmp traceroute
  • Next by Date: Re: send() on socket when network is disconnected
  • Previous by thread: Re: icmp traceroute
  • Next by thread: Re: icmp traceroute
  • Index(es):
    • Date
    • Thread