Re: ICMP Router Discovery
Re: ICMP Router Discovery
- Subject: Re: ICMP Router Discovery
- From: Peter Bierman <email@hidden>
- Date: Tue, 28 Jun 2005 16:47:15 -0700
At 6:02 PM -0500 6/28/05, Chase wrote:
if this turns out to be consistently predictable (pinging the
broadcast address of the subnet yields **ONLY** results from oneself
and the router on that subnet), then i can just look thru the ping
source, pull out the relevant parts, and simply filter out responses
from the local address. that should always give me the router
address, right?
I think you're going down the wrong track.
Routers may or may not have certain behaviors that you can use to
identify them, but those behaviors might be different and change over
time.
Instead, you need to think about what it means to have a router at all.
You have a given machine connected to any number of networks. There
are other devices connected to those networks. Some of those devices
might not be final destinations, but instead will forward traffic.
When the given machine needs to talk to other machines, it uses an address.
First, it checks to see if that address lives on a network already
connected to itself. If it is, then it picks the interface holding
that network, and sends the data directly there. No router is used.
If the destination address is NOT on a directly connected network, it
starts looking for a 'gateway'. Gateways are machines on a directly
connected network that will accept traffic for networks beyond. AKA,
routers.
There might be gateways that are only valid for a range of IPs. And
there will almost always be one gateway that's valid for any IP;
that's the default route/gateway. They're checked from most-specific
to least specific.
netstat knows a list of the valid gateways. It has to, since your
machine can't use routers it doesn't know about!
So you can get the information you want without asking the network anything.
Take a long look at:
'man 4 route'
-pmb
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden