Skip to content

Menu

  • About me
  • Chlebik Reviews

Archives

  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024

Calendar

July 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  
« Jun   Aug »

Categories

  • AWS
  • Back To Basics
  • Blog
  • Book Review
  • Certification
  • Erlang
  • GC Theory
  • Go
  • Java
  • Kubernetes
  • Monthly summary
  • Valuable links
  • Weekly summary

Copyright Michał 'Chlebik' Piotrowski 2025 | Theme by ThemeinProgress | Proudly powered by WordPress

Michał 'Chlebik' Piotrowskiprogrammer, blogger, wizard apprentice
  • About me
  • Chlebik Reviews
Written by Michał Piotrowski2024-07-26

Back to basics #3 – IP

Back To Basics Article

Today we will continue our short review of TCP/IP basics. In the previous article I have just scratched the surface. Today, let’s concentrate on some deeper concepts. All hail IP&CIDR!

Table of Contents

Toggle
  • What are you doing exactly IP?
  • Gimme my IP identifier
  • What is a subnet mask?
  • How does this whole internet still work?
  • CIDR to the rescue
  • What’s next?

What are you doing exactly IP?

To start with – below I am posting again the layered model of the networking stack (thank you Wikipedia).

IP (Internet Protocol for those who don’t remember) has a couple of responsibilities in the TCP/IP stack. It defines the way messages from the application layer are being transformed into datagrams – which later will be translated by lower layers of the stack into frames and later – raw bits. The second responsibility is to define, how hosts within the network see each other. It does that introducing a separate, logical addressing layer, on top of the physical one.

Okay, that sounds complicated. Let’s make things easier. Imagine we got ten machines within our network, with single network interface for each. It could be possible to “remember” all the physical addresses (MACs of the network cards), and route the traffic accordingly. Unfortunately, that solution does not scale for larger networks (especially with the fact, that MAC addresses, are assigned during manufacturing process). Therefore, a simple idea was introduced to separate physical addresses, from the logical ones. It allowed for more flexible network topologies and simplified the whole thing. With the logical addresses, every machine is identified with a single numerical value, e.g. 168.78.2.0

The above identifier is a proud representation of IPv4 – protocol version that forms the backbone of today’s internet. Newer version of it – IPv6 – is still trying to make its way towards wider adoption, but it takes time. Anyway, what is important here, is the fact, that IP address allows for simple division of the IP address into two parts – network identifier and host identifier.

Gimme my IP identifier

The original idea behind IP was created, when the world looked a little bit different than today. Especially when it comes to the amount of network hardware. Everything started with a simple concept of 32bit number, that was design to identify every host in a unique way. For the simplicity of the usage, IPv4 address is usually presented in a form of four octets. Now, depending on the class we can have three “main” classes. They are depicted below.

Depending on the amount of bits designated for network identification part, we can have different amount of unique host IPs. How many? Here you go:

  • Class A – 16 777 216
  • Class B – 65 534
  • Class C – 256

All righty. You may ask here – how do we know, which address class is being used with the IP like 5.189.23.11 ? Well – subnet mask to the rescue.

What is a subnet mask?

Subnet mask is another 4 octets identifier, that divides IPv4 address into network part, and host part. In general the mask specifies how many bits should be used as a network identifier. Therefore, we got lots of possibilities here, depending on the address class. 32 bits are used to identify which octet relates to network address, and which to the host part.

You can find how this “masking” works on the picture below:

 

 

Number of “1” in the bits is deciding, which IP octets are used as a network segment indicator, and which are identifiers for the host machine. Subnet mask is assigned automatically by DNS provider, although it can be also set manually.

How does this whole internet still work?

You can pause for a moment – because there should be something lingering at the back of your skull. Yup, with IPv4 addresses, there’s circa 4 billion possible unique identifiers to be used. So how is it, that almost every person on the planet owns smartphone with internet access? Not to count numerous other smart devices, data centers and stuff. Well, so far we did not fully embrace the benefits of IPv6 (which offers gazillion of unique IPs). The reason why everything still works is NAT – Network Address Translation. I will possibly create a separate blog post about it (including private networks and how that packet sending works). For the time being let’s just stay in the IPv4 for a moment. We got one last thing left to describe – CIDR.

CIDR to the rescue

In 2011 a new way of (re)using IPv4 emerged – CIDR (Classless Inter-Domain Routing). In short, it’s the extension of the concept of subnet mask, but not limited to specific classes. Right now any kind of number of bits can be specified as a network segment identifier. Let’s take an example from the book “TCP/IP in 24 hours”.

ISP has an IP range in their offer, starting from 204.21.128.0 to 204.21.255.255 – I have marked the common part of the address in bold. Those are 17 bits – and therefore, when we apply 17  bit mask to the address (in decimal – 255.255.128.0), we get IP address with the following value – 204.21.128.0/17 – which resulted in the simple fact that right now, for every router in the world, all those IP addresses that are in range between 204.21.128.0 to 204.21.255.255 can be now represented with a single entry in the routing tables.

You can find all the possible CIDR values in the table below. You can find numerous calculators online, that based on the IP address and subnet mask can provide all the necessary information.

What’s next?

If you’re a little bit lost – don’t worry. After reading next pieces in the series it should be easier to get a grasp of things. If you don’t want to wait for me to write the next pieces – here’s a short video that explains some stuff.

Tags: address, cidr, host, ip, mac, networking

Leave a Reply Cancel reply

You must be logged in to post a comment.

Archives

  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024

Calendar

July 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  
« Jun   Aug »

Categories

  • AWS
  • Back To Basics
  • Blog
  • Book Review
  • Certification
  • Erlang
  • GC Theory
  • Go
  • Java
  • Kubernetes
  • Monthly summary
  • Valuable links
  • Weekly summary

All the images (unless stated otherwise) come from Freepik.com

TwitterGithubLinkedinMail

Recent Posts

  • Valuable links #52 – PostgreSQL internals free book
  • Valuable links #51 – Is this post-developer era?
  • Valuable links #50 – Confessions of an Impostor
  • Valuable links #49 – The career craftsman manifesto
  • Garbage collection theory – Generational algorithms

Recent Comments

  1. Monthly summary #1 - June 2024 - Michał 'Chlebik' Piotrowski on About me
  2. Back to basics #3 - IP - Michał 'Chlebik' Piotrowski on Back to basics #2 – TCP/IP 101
  3. Weekly summary #6 - Michał 'Chlebik' Piotrowski on “Mastering API architecture” book review
  4. Weekly summary #5 - Michał 'Chlebik' Piotrowski on Back to basics #1 – Big O notation
  5. Weekly summary #5 - Michał 'Chlebik' Piotrowski on “Designing Data Intensive Applications” by Martin Kleppmann

Archives

  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024

Categories

  • AWS
  • Back To Basics
  • Blog
  • Book Review
  • Certification
  • Erlang
  • GC Theory
  • Go
  • Java
  • Kubernetes
  • Monthly summary
  • Valuable links
  • Weekly summary

Copyright Michał 'Chlebik' Piotrowski 2025 | Theme by ThemeinProgress | Proudly powered by WordPress