6

I know how IP basically works, and knows that an IP address composed of a network ID portion and a host ID portion, but when I type a IP address, say 8.8.8.8 into the web browser, I didn't supply any subnet mask information.

So, how does the browser know where the dividing line is between the network ID and host ID? Since 8.8.8.8 may mean 8.8.8.8/8, 8.8.8.8/24 etc.

In a nutshell, the IP address I supplied is ambiguous.

1
  • Unless your application (in this case, the browser) is doing routing, it doesn't need to be concerned with subnet masks. A browser will use the system's TCP/IP facility to send traffic, and that facility routes (routing here meaning shipping traffic somewhere based on subnet) on behalf of any/all applications if necessary. Your PC gets its subnet from DHCP.
    – LawrenceC
    Nov 17, 2013 at 15:57

3 Answers 3

6

In the case where the other end is outside your local network, your PC doesn't need to know the subnetting arrangements at the other end it just needs to know enough to deliver the packets to the nearest router. For that it uses two pieces of info.

  • local subnet mask
    it uses this in conjunction with it's own IP address to see if the other IP-address is local or not.
  • default gateway (or explicit routes - see netstat -nr)
    anything non-local gets sent there

The router at the other end (i.e. with an interface in the other LAN) knows about subnet arrangements there. Nothing else needs to.

If you look at netstat -nr you'll see your PC's routing table consists of destination-network, network-mask (the other side of subnet-mask) and gateway (router). Usually PCs have a single default gateway plus some kibble for things you don't use much (loopback, multicast etc).

You can think of the network masks in routing tables as equivalent to a high level summary or aggregation of millions of target subnets.

2

The subnet mask is only used to figure out if an address is local to a particular network, and for routing.

If the address you want to contact (8.8.8.8 in your example) isn't inside any of your local network(s) (say, 172.16.3.0/24 & 127.0.0.1/8 & 192.168.45.88/29), then your machine is unable to contact it directly. In that case, it'll send the traffic to a gateway (say 192.16.3.1), if configured, and hope it gets to its destination.

0

It is not the browser which is finding out the mask, rather the TCP/IP at the lower layer. This also depends on the implementation of the TCP/IP. In most implementations, when an IP is configured without specifying the subnet mask, the default mask for that IP-class will be used. Say, when a class-C IP is configured without mask, then by default mask of 255.25.255.0 can be used.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .