How do you calculate what the subnet mask is from just an I.P. address?
I think Jan Fritsch & Bruce Epper has summed it up pretty effectively. :) Good explanations.
Also the link given by Alan Wade is so very educative. All the above are great advice and resource.
For unicast addressing:
Class A networks which can have up to 128 networks of 16.7 million hosts each will normally have a netmask of 255.0.0.0 and an IP range of 0.0.0.0 - 127.255.255.255
Class B networks which can have up to 16,384 networks with up to 65,534 hosts each generally will have a netmask of 255.255.0.0 and an IP range of 22.214.171.124 - 126.96.36.199.
Class C networks can have up to a bit more than 2 million networks of 254 hosts each with a netmask of 255.255.255.0 and and IP range of 192.0.0.0 - 188.8.131.52
As far as "calculating" a mask from an IP address, in general, it can't be done. The IP address and subnet mask are two halves of a whole which is used to determine what part of the IP address is the network address and what part is the host address. This is done by design by the network engineers/architects in order to optimize resources (number of networks required and number of expected hosts per network) for each particular situation and will be a predetermined pairing, not a calculated value.
If a network is set up as a general class A, B, or C network, in most cases you can assume that the default subnet masks listed above were used. For example, most home networks will be using the private address range of the class C network (192.168.x.x) and will thus have the default subnet mask of 255.255.255.0.
You can't calculate the subnet mask from a single IP-Address. You get the default subnet mask via the class.
Class A (0 - 184.108.40.206) = 255.0.0.0
Class B (128 - 220.127.116.11) = 255.255.0.0
Class C (192 - 18.104.22.168) = 255.255.255.0
For subnets you'd need more data like the network id, broadcast address or CIDR in addition to determine the subnet mask
This pretty much answer your question but maybe in reverse: http://www.pointz.com/spudpage/subnets.html