Monday, December 10, 2018

Networking Part III: Networking 101

This is part 3 of a series of networking posts:
If you know nothing or very little about networking, here are the basics! I am coming from a developer background and needed to learn this, so wanted to share from my perspective a 101 level breakdown of networking.

What is a computer network?
A computer network is 2 or more computers that communicate with each other via some medium-- this medium can be anything (radio waves, wires, infrared, optical fibers, or others!).

A network interface card (NIC) allows you to connect to a computer network.

What is a Network Interface Card (NIC)?

A NIC is a piece of hardware that connects to a motherboard, and will connect the computer to a network.  The CPU will hand it data.  The NIC takes the data from the computer, translates the CPU's parallel data into a linear form that can be sent via cables, and vice versa from data coming from the cables into the CPU.  A NICs can connect to several different networks at the same time and manage which data goes to which network.

Network Interface Cards have a lot of other names, but they are are describing the same piece of hardware:

  • Network Interface Controller (NIC)
  • Network Card
  • Network Adapter
  • Network Adapter Card (NAC)
  • LAN Card
  • LAN Adapter
  • Physical Network Interface
Each Network Interface Card (NIC) gets an IP addressed assigned to it, which is the identifier of that device.

What is an IP Address (IPv4)?
4 numbers (each between 0-255), separated by periods. The lowest IP address is 0.0.0.0 and the highest is 255.255.255.255.

What does binary have to do with IP addresses (IPv4)?
Each of these decimal numbers is called an octet (127, 16, 254, and 1 as shown below). There are 4 octets in an IP address.  Each octet contains 8 bits and can be represented in binary. Take note that there are 32 bits, as we will talk about this more in subnetting.


There is a network portion and a host portion of an IP address. There are different options for how much of a network/host ratio that you would like which depends on how many IP addresses you need to have available, we will talk more on this later.

The network portion identifies a group of devices.  The host portion is the individual device on that specific network.

  • You can have a zipcode 11111 and address 345 Cave Stone Road, you have identified one specific house.  If you go to another zip code 22222, there may be another yet different specific house at 345 Cave Stone Road.  The zip code is the network portion of an IP address.  The actual house's address is the host portion of an IP address.
The amount of the IP address that is network or host portion depends on the subnet mask...

What is a subnet mask (netmask)?
The subnet mask separates the network and host portions of an IP address an determines how many total addresses we have internally to use (# of host addresses).

Subnet mask (netmask) shorthand:

  1. We have an IP address of 201.0.10.10 (or any other IP address, the value of this is irrelevant and just used as an example)
  2. Let's say our subnet mask is 255.255.255.0
  3. In binary, this would be converted to 11111111 11111111 11111111 00000000
  4. In all IP addresses, we have 32 bits that could be changed, because there are 4 sets of 8 bits, as seen above. 
  5. Wherever there is a 1 in our subnet mask in binary, this is our network portion.
  6. This means that the network portion is the first 24 bits
  7. Using CIDR (Classless Inter-Domain Routing), we could say this is a /24 length of the network prefix. 
  8. We can now write this IP address and subnet mask as 201.0.10.10/24
If we were to look at the photo below where the IP address is 16.1.1.1, let's solve for the CIDR subnet value. Remember that in 255 in decimal is 11111111 in binary and 0 is 0.  If we have 255.0.0.0 as our subnet, this converts to 11111111 00000000 00000000 00000000.  The network portion is 8 bits.  So it would be /8.  What are the other two IP addresses CIDR values? See below the photo for the solution. 
  • For the IP address 16.1.1.1, our subnet is /8
  • For the IP address 132.147.1.1, our subnet is /16
  • For the IP address 221.138.62.1, our subnet is /24
How does this relate to how many IP addresses I get?
Let's go through a scenario where my network is 210.10.10.0/24

  1. If my subnet is /24, then I have 24 bits as my network portion and 8 bits that are my host portion. 
  2. 8 bits can hold 2^8 values. 
  3. There are 256 total addresses in my network. 
  4. To get the total usable addresses you subtract 2 because there are 2 "special" addresses that cannot be used.  To be specific in this example: 210.10.10.0 cannot be used because it is the zero address and 210.10.10.255 cannot be used because it is the broadcast address. 
    1. The zero address cannot be used because it is used to specify a network without specifying a host.  The broadcast address is to s used to broadcast a message to every host on a network.
  5. For a subnet of /24, the total usable addresses now becomes 254.
Let's go through a scenario where my network is 210.10.10.0/8
  1. If my subnet is /8, then I have 8 bits as my network portion and 24 bits that are my host portion. 
  2. 24 bits can hold 2^24 values. 
  3. There are 16,777,216 total addresses in my network. 
  4. To get the total usable addresses you subtract 2 because there are 2 "special" addresses that cannot be used.  To be specific in this example: 210.0.0.0 cannot be used because it is the zero address and 210.255.255.255 cannot be used because it is the broadcast address. 
    1. The zero address cannot be used because it is used to specify a network without specifying a host.  The broadcast address is to s used to broadcast a message to every host on a network.
  5. For a subnet of /8, the total usable addresses now becomes 16,777,214.
The higher the number for your subnet, the less IP addresses you get.  A /24 will have much less IP addresses than a /8, as seen above.

What if the subnet isn't a nice number like 255 or 0?
If you network IP address is: 210.10.10.0/23. 

We have 23 bits in the network and 9 bits in the host.  
/23 in binary is (twenty-three 1's):
11111111 11111111 11111110 00000000

/23 in decimal is:
255.255.254.0

  1. If my subnet is /23, then I have 23 bits as my network portion and 9 bits that are my host portion. 
  2. 9 bits can hold 2^9 values. 
  3. There are 512 total addresses in my network, minus the 2 "special" addresses you get 510 as the total usable addresses. 
  4. To get the values of the usable addresses, see below:
    • 210.10.10.0 converted to binary is below.  The first 23 digits (due to /23 subnet) are the network and the last 9 are the network:
      ‭11010010‬ 00001010 00001010 00000000
      network portion                   host portion
      "The unusable zero address is where the host portion (yellow highlight) is all 0's.  The unusable broadcast address is where the host portion (yellow highlight) is all 1's."

      11010010‬ 00001010 00001010 00000000 = host address = 210.10.10.0
      ‭11010010‬ 00001010 00001011 11111111 =broadcast address =  210.10.11.255
    • To be specific in this example: 210.10.10.0 cannot be used because it is the zero address and 210.10.11.255 cannot be used because it is the broadcast address. 

Here are some more subnets and examples:

Big Picture: What is IPv4 vs. IPv6?
IPv4 stands for Internet Protocol version 4 and what we have been talking about above in this article (everything above related to IPv4 only).  IPv4 uses 32 bits for its Internet addresses (which we mentioned), and can allow for 2^32 IP addresses total (4.29 billion).  However, all of these 4.29 billion are assigned and we have run out.  IPv6 is the sixth revision to the Internet Protocol and the successor to IPv4, and it is 128-bit addresses so 2^128 addresses (a lot more than 4.29 billion).  IPv6 is based on the hexadecimal system.

Why don't we all just go do IPv6 now?
Only a small fraction of the web has switched over to the new protocol, Azure and other cloud providers are still mostly utilizing IPv4.  Also, exchanging data between IPv4 and IPv6 requires special gateways which makes it hard to support only partially moving over to the new protocol, and most companies have legacy systems, software, and networking-- so it could be awhile.

Checkout these news articles to see the progress so far:


What is a reserved IP address?
There are some IP addresses that you cannot use because they are not allowed to be used by the Internet Engineering Task Force (IETF) and the Internet Assigned Numbers Authority (IANA).  See a list of reserved IP addresses and what they are each set is reserved for on Wikipedia here.

Recommended Networking PluralSight Course:
If you do happen to own a PluralSight subscription about 6 hours, this course is very in depth and well made: