[Python-Dev] PEP 3144 review. (original) (raw)

Andrew McNamara andrewm at object-craft.com.au
Thu Sep 17 02:41:37 CEST 2009


Some people have claimed that the gateway address of a network isn't necessarily the zero address in that network.

It almost never is - conventions vary, but it is often the network address plus one, or the broadcast address minus one.

I'll go further: I don't think it's even legal for the gateway address to be the zero address of the network (and I used to program the embedded software in routers for a living :) ).

I don't think the RFCs forbid the zero address being used, and "enlightened" network stacks allow it (typically routers) to achieve better utilisation of the limited IPv4 address space (for a /24 or larger, wasting one address out of 255 isn't too bad, but it is now typical to use much smaller nets - right down to /30).

If that's true, then you can't calculate the network address from a host address and a netmask -- there isn't enough information.

You can always calculate the network address from the IP address plus mask - the network address is simply the bits that are not masked.

In the olden days, the mask was spelled out in octets (eg 255.255.255.0). But we've moved to a more compact and logical notation where the number of leading significant bits is specified (eg /24).

-- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/



More information about the Python-Dev mailing list