Tracing Connections, Multiplayer Debugging

BlitzMax Forums/BlitzMax Programming/Tracing Connections, Multiplayer Debugging

You want some technique like Tracert?

This method works by sending repeated ping packets to the host. Each packet has its Time To Live (TTL) field starting at 1 and increasing till the destination host responds.

I will try and draw an ASCII diagram :)

L---->N1---->N2---->D

L - Local Host (Your Computer)
N1/2 - Nodes (Routers)
D - Destination

L sends a ping packet with destination IP (and MAC) address set to that of D. The TTL field of the ping packet is set to 1. When N1 recives the packet it decrements the TTL field by 1 (This happens for any network interface that recives a packet). When it looks at the packet a check is made to the TTL field, seeing that it has a value of 0 it discards the packet and sends a ICMP (Internet Command Protocol?) message back to the original sender (TTL field will be some operating system default like 64 or something large). (I cant remember the type of ICMP packet that is sent back but it basicly says that the packet timed out).

Your app would at this point check for that recived ICMP packet and you can then extract the IP, MAC address, etc from it and that would be N1 in the diagram.

If you set the TTL field to 2 then it will become 0 by the time N2 recives it and you will get an ICMP packet eminating from that host and you can extract the IP, etc once again. After a third time you get a packet (ICMP echo?) that you can see is from the desination host.

So in answer to your question, I dont think you can do this from within BlitzMax without using a new network library. BlitzMax networking library cant generate ICMP packets (especialy with changed fields).

You would need to use RAW sockets or LIBnet. The only drawback of LIBnet is that you would have to import all the functions and im sure that its object orientated. LIBnet is also cross platform compatable :)
http://libnet.sourceforge.net/#download

Raw sockets have also been Excluded/ScaledDown from windows with the introduction of Service Pack 2.

WindowsXP machines also by default will not send out ICMP packets in response to recived ones (windows Firewall). If you did tracert then you see like:

***.***.***.***

Under that nodes heading.

So it should be quite a large problem to solve in terms of effort.

If you get anywhere then I would love to know.