1

I am new to java and networking, when writing Java socket program I discovered that, IPv4 address can have maximum value of 255.255.255.255

Also, 255 is the maximum value of Byte.

My doubt is why, Integer range is(can be) not used for more(like, 23467.28321.1784.58256) IPv4 address?

codingenious
  • 8,385
  • 12
  • 60
  • 90

2 Answers2

4

IPv4 uses 32-bit (four-byte) addresses, which limits the address space to 4228250626 (232) addresses.

4 bytes mean 32 bits so, each byte can have 8 bits and maximum value of 8 bits number is 255. (11111111 in binary is equal to 255 in decimal). Therefore, 255.255.255.255 is maximum range of IPv4.

And reason for this limitation could be, at that time not much IPv4 addresses were required so, specs were designed this way. :)

codingenious
  • 8,385
  • 12
  • 60
  • 90
  • 2
    the actual, maximum amount of permutations is 4228250625 --> 255^4, 255 permutations per segment, 4 segments in total and IPv4 is not "legacy". Its the worldwide standard - which is BEING replaced by IPv6 in the NEXT DECADES OR SO, it will take a lot of time to replace strictly IPv4 - hardware with never models in data centres – specializt Feb 20 '15 at 14:57
  • 1
    By legacy I meant it was developed when not much addresses were required, may be its conveying wrong meaning. I will remove it. :) – codingenious Feb 20 '15 at 14:59
  • @specializt : It's not 255^4. The amount of available addresses is 256^4 = 4294967296. You must have missed that zero is included. – Tanmay Patil Feb 20 '15 at 15:06
  • 1
    zero is not a valid address - its reserved. You will not find a single IP on this planet which has the value 0 in either the last or first segment - even the two segments in-between are always reserved. Apparently this is even included in the standard : RFC1122 and beyond. – specializt Feb 20 '15 at 15:08
  • I didn't know that. Thanks for the info, but it seems that both of us were wrong :D There are only 3,706,452,992 addresses. http://stackoverflow.com/questions/2437169/what-is-the-total-amount-of-public-ipv4-addresses – Tanmay Patil Feb 20 '15 at 15:10
  • 1
    There are 2^32 = 256^4 = 4294967296 IPv4 addresses. Some of them have special meaning (like 0.0.0.0 and 255.255.255.255), are used for multicast (224.0.0.0/4), are reserved (240.0.0.0/4) etc. Take a look at http://www.iana.org/assignments/ipv4-address-space/. Since we stopped using classful addressing (https://tools.ietf.org/html/rfc4632) `0`s in addresses are nothing special. For example `192.168.0.0/23` contains `192.168.0.0` to `192.168.1.255`. The first one is the network address, the last one is the broadcast address, but e.g. `192.168.1.0` is a perfectly valid address for a node to use. – Sander Steffann Feb 20 '15 at 17:07
3

The dotted notation (abc.def.geh.ijk) is merely a human-readable way of expressing the value of four octets (bytes). All IPv4 addresses are four octets long, as defined in RFC 791:

Addresses are fixed length of four octets (32 bits).

Each group of digits contains the decimal value of a byte, thus limiting the values to 0 - 255. Values larger than 255 cannot be mapped to a byte and are thus are not valid for an IPv4 address.

Community
  • 1
  • 1
Duncan Jones
  • 67,400
  • 29
  • 193
  • 254