I have broadband internet at home. The WAN port on my router has a public address, and all the hosts on my LAN have private addresses. The router performs NAT so that we can all access the internet (well over TCP and UDP anyway).
Anyway, my router has a built-in HTTP daemon which provides a web page for configuring the router. When I go into "LAN statistics", it tells me what hosts are on my LAN. It tells me their IP address, their MAC address, and their host name.
First thing I'm curious about is how the router knows what's sitting on the LAN. My first thought was that maybe it just looks at the DHCP leases it has given out, but then I tried configuring one host's IP address manually and it still came up in the host list.
Another thought I had was that maybe it just pings all the addresses in the network address range. Only problem here though is that my address range is 10.0.0.0/8, so it would have to ping about 16 million hosts, and I doubt that that's what it's doing.
Another thought I had was that maybe it looks at the MAC address table in its internal switch?
Does anyone know a home broadband internet router typically determines what hosts are on the LAN?
My second question pertains to how a computer knows whether there's an ethernet cable plugged into the NIC (i.e. how it knows that it's on a LAN). For instance, in Windows, I have a little icon in the bottom right corner; the icon is two little machines, and it represents my NIC network connection. When there's no ethernet cable plugged in, there's an X through the icon. When I plug a cable in (e.g. a cross-over between two laptops), then all of a sudden the X disappears and it instantly knows it's on a LAN. How is this? Also, after a second or two, it pops up a little balloon box saying whether it's 10 or 100 Mbps. Again, how does it know this?
Last thing I want to ask about is the host name. How does it get the hostname (e.g. "family-pc" or "laptop-james")? Is there some sort of layer 2 or layer 3 protocol for getting a host's name? Does anyone know a way of intercepting the hostname request in Windows?