Why is IPv4 written in decimal? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why is IPv4 written in decimal?

Does anybody know why IPv4 addresses are written in decimal? I mean since it's a collection of four bytes, wouldn't it be more natural to write it in hexadecimal like IPv6?

8th Oct 2018, 8:27 PM
Jens-Emil Sønderup Müller
Jens-Emil Sønderup Müller - avatar
4 Answers
+ 4
Unless someone has a better answer (like grouping, or base 10): It looks like it just kindof happened. The first suggested format was the full 32-bit number (try it, it works) while the hexadecimal form is nonstandard. https://en.m.wikipedia.org/wiki/Dot-decimal_notation "No formal specification of this textual IP address representation exists. [First mentioned in] RFC 780 (1981): IP address ... to be enclosed in brackets [or] a 32bit decimal integer prefixed by a pound sign. RFC 1123 (Requirements for Internet Hosts – Application and Support) [mentions] 'IP address in dotted-decimal ("#.#.#.#") form' " [with caveats]. The page indicates a draft for standardizing it expired. So...it may very well be that "we use it because that's what we use" (a few system used it, it was good enough, more systems used it, etc)
8th Oct 2018, 9:36 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
Hex does make working with CIDR notation easier: 192.168.0.1 /24 is easy, if you know each octet is 8 bits (so the first three octets are masked off, the last octet is for hosts) ...but hex really helps here: 172.16.79.0/21 vs AC.10.4F.00 /21 ...the second one it's easier to see that the 4F may be a typo, because the last three bits of the 'F' are actually in the host portion. ( 21 bits for network, 11 bits for hosts ) Most routers I think prioritize the /21 so chopped off 'properly', the network is: AC.10.48.00 /21 (or the range 172.16.72.0 - 172.16.79.255) But realistically, would we use a tool? ~SoloLearn nice-subnet-calc link removed, code's been set private since I last saw it :(
9th Oct 2018, 4:54 PM
Kirk Schafer
Kirk Schafer - avatar
0
「HAPPY TO HELP」 That was my thought as well, however is it really easier? Hex is more compact and therefore easier to remember an address and less characters to type wrong. Furthermore anybody working with ips should already know hex, especially in 1981 when IPv4 was conceived
8th Oct 2018, 9:36 PM
Jens-Emil Sønderup Müller
Jens-Emil Sønderup Müller - avatar
0
Kirk Schafer Fair enough. I guess it doesn't matter that much anyway, it just struck me as odd 😅
8th Oct 2018, 9:44 PM
Jens-Emil Sønderup Müller
Jens-Emil Sønderup Müller - avatar