Search code examples
javaipv4

Why IPv4 address is in bytes and can not be in integer range?


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?


Solution

  • 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. :)