A Non-Scary Introduction to Computer Networking (cup of networking - part 1)

Cup of Code
13 min readMar 30, 2020

--

As always, I’ll start with the idea for this article. Two months ago I started a new job that requires knowledge in networking, and even though I took networking course at University — I felt like I don’t remember anything!

So, after I refreshed my memory, I thought it would be a good idea to help others in the same situation — and refresh yours as well :)

Networks!

This article also serves as a good introduction to those who are new to networking. As implied by the title, this publication will have a part two: “Terms in Networking You Hear All The Time — Simply explained”.

This is the table of contents, for easy access:

Table of content

1. The Internet

The Internet is a global network of billions of computers and other electronic devices. You don’t need me to explain to you what it is, because we all use it on a daily basis (here you are, reading my publication online).

This term got the honor to open this introduction because of this quote from an excellent video I saw about the subject, called “How the Internet works in 5 minutes”:

“The Internet is not a bubble cloud, even in the new age of cloud computing. The whole fuzzy cloud picture was created by people more concerned about job security than education. The Internet is a wire, actually buried in the ground.”

The truth about the Internet!

So, the Internet is a wire through which computers can communicate. I’ll mention it for those who don’t know — web pages you visit, pictures you see there — are all files located in a server, that are sent to your computer.

How do web pages get to my computer?

How? We’ll learn more in the next sections!

2. MAC and IP Addresses

The addresses’ goal is to get the message to the right destination.

MAC and IP addresses example [Source: https://www.timeatlas.com/wp-content/uploads/MACAddress.png]

MAC address is a physical address and it’s a globally unique ID for your device. It is called physical because it is hardwired on your device and cannot be changed. A MAC address will look something like this: E3:RA:34:09:21:A3

One of my reviewers for this publication mentioned that although MAC addresses are hard-coded into your device, you can also communicate through a different MAC address, but I think that for our introduction level this is accurate enough.

The IP address indicates where you are, while the MAC address indicates who you are. (https://www.youtube.com/watch?v=oGoWqdlaOMI)

IP addresses are logical (virtual) addresses, and therefore are changeable, so when you connect to the Internet from a coffee shop, you’ll get a different IP address from the one you had at home. An IP address will look something like this: 98.234.23.0

Actually, there are two IP Addresses that we deal with when it comes to Internet-connected devices: Internal IP address and external IP address.

Internal and external IP addresses [Source: https://troypoint.com/internal-external-ip-address/]

An internal IP address is specific to your home network whereas your external IP address is public-facing via your Internet router.

An external IP address is what most Internet users are familiar with. In other words, this is the address of your router interface that is connected to the Internet.

How is this information used?

Curious how is this information used? Wait for the “Layers of networking” section!

3. Subnets and CIDR

CIDR is a method to divide a network into (smaller) networks and create subnets.

Why should we use subnetting? Shortly, to improve network performance and speed, reduce network congestion, boost network security, control network growth and ease administration.
If you want to understand the advantages of subnetting more deeply, click here.

CIDR stands for Classless Inter-Domain Routing and replaces the old system based on classes A, B, and C. Now, this is where I got glimpses of memory from the networking course, so I’ll talk a bit about the classes so we can put it behind us:

Classful network addressing

The problem with this method was the exhaustion of the IP addresses: Class C has ²⁸-2=254 host identifiers, class B has ²¹⁶-1=65,535 and class A has over 16 million host identifiers. That means that an organization that had 250 hosts but now needs 5 more exceeded its class capacity (class C) and has to use class B license and have another ~65,270 IP addresses that will remain unused! IPv4 addresses are finite, so we can’t afford such a waste.

Now that we understood the problem — what is the solution? We have two.

The first one is increasing the address size: Internet Protocol version 6, or IPv6, was first introduced in the late 1990s as a replacement for IPv4. Even then the builders of the Internet realized IPv4’s limitations and the eventual shortage.
IPv6 uses 128-bit addresses, allowing for a theoretical 340 undecillion ( a number with 36 zeros) addresses.

Another solution is having more flexibility regarding the number of bits dedicated to the host: Giving the organization we mentioned before the ability to add only ~250 new host identifiers, which is more realistic to its needs and not as wasteful.

How does it look?

A CIDR IP address looks like a normal IP address except that it ends with a slash followed by a number, called the IP network prefix.

I’ll add here a tiny reminder for conversion between binary and decimal:

[Source: https://www.wikihow.com/Convert-from-Binary-to-Decimal]

So, if we’ll look at our lucky organization, their CIDR will look something like this: 192.0.0.0/23, which means their IP range is 192.0.0.0–192.0.1.255 because 23 bits are for the network and 9 are for the host:

11000000.00000000.00000000.00000000 -- 192.0.0.0
11000000.00000000.00000001.11111111 -- 192.0.1.255

(Here is a link to a CIDR calculation tool that will convert between CIDR and IP range.)

Now, you can easily divide this network into 2 subnets: 192.0.0.0/24 and 192.0.1.0/24

11000000.00000000.00000000.00000000 -- 192.0.0.0
11000000.00000000.00000000.11111111 -- 192.0.0.255
11000000.00000000.00000001.00000000 -- 192.0.1.0
11000000.00000000.00000001.11111111 -- 192.0.1.255

Pop quiz!

How would a division to four subnets look like? What would be the IP network prefix?

The answer: 192.0.0.0/25

11000000.00000000.00000000.00000000 -- 192.0.0.0
11000000.00000000.00000000.01111111 -- 192.0.0.127
11000000.00000000.00000000.10000000 -- 192.0.0.128
11000000.00000000.00000000.11111111 -- 192.0.1.255
11000000.00000000.00000001.00000000 -- 192.0.1.0
11000000.00000000.00000001.01111111 -- 192.0.1.127
11000000.00000000.00000001.10000000 -- 192.0.1.128
11000000.00000000.00000001.11111111 -- 192.0.1.255

But how can you determine whether a host is on the local subnet or on a remote network? With subnet masks.

Subnet Mask:

A subnet mask will “mask” out the host bits, leaving only the Network ID visible.

Subnet masks

For example, 255.255.255.0 is the subnet mask for the prefix 192.168.123.132/24. That is because this subnet has 24 bits for the network, which leaves us with 8 bits for the host.
In binary the subnet mask is: 11111111.11111111.11111111.0000000

Lining up the IP address and the subnet mask together, the network and host portions of the address can be separated:

11000000.10101000.01111011.10000100 -- IP address (192.168.123.132)
11111111.11111111.11111111.00000000 -- Subnet mask (255.255.255.0)

The first 24 bits (the number of ones in the subnet mask) are identified as the network address, with the last 8 bits (the number of remaining zeros in the subnet mask) identified as the host address. This gives you the following:

11000000.10101000.01111011.00000000 -- Network address (192.168.123.0)
00000000.00000000.00000000.10000100 -- Host address (0.0.0.132)
Subnetting meme

4. Layers of Networking

Here is the part where you see this image:

[Source: https://www.guru99.com/layers-of-osi-model.html]

And think to yourself “Damn-it, I used to know that!”

I know, happened to me too, so let me refresh your memory: This is a conceptual model that characterizes the communication functions of a telecommunication or computing system.

Telecommunication is the transmission of signs, signals, messages, words, writings, images and sounds or information of any nature by wire, radio, optical or other electromagnetic systems.

Let’s continue: Some sources will define the TCP/IP conceptual layers as a 4 levels model by merging the two lower layers (data link and physical) to one layer called “network interface”.

Another version of the TCP/IP conceptual layers merges the two lower layers into one called “network interface”

The model partitions a communication system into abstraction layers, which means that it is without regard to its underlying internal structure and technology.

Let’s see an example!

Say you want to go to Facebook’s home page.

A quick reminder:
URLs like “www.facebook.com” are aliases we use and along the process gets translated to IP addresses and are called Domain Name System (DNS).

DNS is The Internet's system for converting alphabetic names into numeric IP addresses. So, when a Web address (URL) is typed into a browser, DNS servers return the IP address of the Web server associated with that name.

As my networking lecturer would say-

It makes much more sense to sing in the radio commercial rather then “For more information, come visit our website at 193.163.4.111

You can read about it more here.

Let’s get back to our example:

Say you want to go to Facebook’s home page

The application layer generates the data and requests connection, which means that it creates a message saying something like “Hey, I want to download a web page from this address: 193.163.4.111” and pass it to the transport layer.

The transport layer establishes connections with the remote host — which means it creates a segment/datagram that contains the original message and adds information about the source and destination: “src port=31, dst port=80” and passes it to the network layer.

Wait — I have a very professional reviewer that insisted that port 31 wouldn’t be available to be a source port, and it’s more accurate to write port number between 1024 to 65535 — but if I did it, we wouldn’t have this story to learn from and remember. So I kept it :)

The network layer transfers packets with virtual (IP) addresses, so it adds information like “src IP addr=186.151.34.129, dst IP addr=193.163.4.111” and passes it to the data link layer.

The data link layer transfer frames with physical addresses, so it adds to the packet the source and destination MAC addresses: “src MAC addr=00:12:F1:1E:E8:93, dst MAC addr=00:04:A3:4D:1C:73”

The physical layer transmits and receives bits.

I like the visualization of the process as a letter and envelopes:

Visualization of the process as a letter and envelopes

When the frames are received at the destination, the layers unwrap in the opposite order. Each layer opens its envelope and uses the information it needs in order to know where to pass it to, who can help this message reach its destination.

If you want to learn more, I’ve talked about it more deeply in my previous publication: For the fullstack developer who is secretly a backend developer — don’t be scared of web communication protocols (HTTP, REST, WS)

This section has been pretty long, we deserve a meme break!

— —

MEME BREAK:

Crazy girlfriend meme

— —

5. Ethernet

Ethernet cable

I thought Ethernet is a physical connection, because it is in the link layer, as you can see in the image below, and because there is an Ethernet cable, but I was wrong, and according to this video I was’t the only one. Ethernet is actually an IEEE protocol.

The Internet is comprised of multiple layers [Source: https://www.youtube.com/watch?v=5u52wbqBgEY]

Why do we need a protocol? Since there is a multitude of devices in our network that may want to send and/or receive data, there have to be some common rules for sending and receiving packets. This is where the protocol comes in.

What is IEEE?
IEEE is The Institute of Electrical and Electronics Engineers (IEEE) and it is a professional association for electronic engineering and electrical engineering, which basically means a bunch of people making sure Internet things go smoothly, partly by creating Internet protocols.
IEEE 802 is a family of IEEE standards dealing with local area networks and metropolitan area networks, and the most widely used standards are for the Ethernet family.

You can learn more about it here.

As a software engineer I didn’t find much interest in the structure of the ethernet cable and the types that exist, but if you do — you can find more information here.

What does the Ethernet cable connect to?

Wait… What does the Ethernet cable connect to?

6. Hub, Switch and Router

A Hub connects all the network devices together on an internal network. It’s a device that has multiple ports that accepts ethernet connections from network devices. It is considered to not be intelligent because it doesn’t filter any data or hold any information to where the data should be sent. The only thing a hub knows is when a device is connected to one of its ports.

So when computer 1 wants to talk to computer 4, a data packet arrives at computer 1’s port it is sent to all the others (computers 2,3 and 4), and then computers 2 and 3 throw the package because it is not destined for them.

It’s kind of like an office conversation in an open space office— when you talk to your colleague, and all her/his neighbors can hear you as well, but the content is not relevant for them — so they just drop it. The problem is — both in hubs and in office gossips — is that sometimes you have information you don’t want everyone to hear.

When you go talk with a colleague — all her neighbors can hear you as well

A Switch is a smart hub. Besides detecting that a device is physically connected to it, it also keeps a record of the MAC addresses of those devices, which means it can pass frames to a specific destination. That way you reduce unnecessary traffic on the network and keep it a little bit more secure.

Hubs and Switches are used to exchange data within a LAN. To exchange data outside the LAN, a device needs to be able to read IP addresses. That’s where the router comes in.

A Router is a device that is capable of sending and receiving data packets from one network to another based on their IP address. The router is the gateway of the network.

pop quiz!
The router is transferring packets — so on which level does it operate?

Notice that the Switch is working with MAC addresses, which means it operates at the data link layer (and works with frames), and the Router is working at the network layer (because it works with IP addresses).

How does the router know how to navigate a received package? it has a routing table!

What’s a routing table?

What’s a routing table? we are about to find out!

7. Routing Tables:

A routing table contains the information necessary to forward a packet along the best path toward its destination, meaning it maps between the destination IP and the next hop or outgoing interface where the packet should exit. As we know, each packet contains information about its origin and destination. Routing Table provides the device with instructions for sending the packet to the next hop on its route across the network.

Here is a simple example of routing tables:

Routing table example

Root got a package to transfer to A4. It’s routing table says that A::1 would get it there. A::1 passes it to A::3 that passes it to A::4.

Now that we talked about routing tables, we can mention that another advantage of CIDR addresses is reducing routing tables sizes: because the network is divided into subnets, it is possible to represent a block of IP addresses in a single address, with the <IP address/prefix P> address format. For example, saving 200.71.0.0/16 in my routing table instead of saving ²⁸ addresses: 200.71.0.0, 200.71.1.0, …, 200.71.255.0.

So, Hubs and Switches are used to create LANs, and Routers are used to connect networks.

Haha, I scared you, didn’t I?

You didn’t think I’d leave you hanging and not explain what LAN is, right?

8. LAN

LAN stands for local area network, and it is a connection of devices within a specific area, usually one or several buildings. LANs typically have a high bandwidth rate and low latency.

Bandwidth is the amount of data that can be transmitted in a fixed amount of time, usually measured in bits per second (bps).

Latency is a time interval between the stimulation and response.

There are also MAN (Metropolitan Area Network), which covers towns, and WAN (Wide Area Network) that covers big areas such as countries.

Let’s ignore that fuzzy cloud

Before we finish.. I want to give a shoutout to PowerCert Animated Videos YouTube channel, because of their fun and interesting videos!

To conclude:

We all connect to The Internet on a daily basis so it’s nice to know how it works.

Now we are familiar with everything in this diagram: The Internet (still not a cloud!), WAN, LAN, Router, Switch, Ethernet… That’s nice!

Here is a list of all the terms we learned here:
Internet, MAC address, IP address (internal & external), layers of networking, DNS, telecommunication, subnets, CIDR, subnet mask, IPv4, IPv6, classful network addressing, routing tables, router, hub, switch, LAN, MAN, WAN, ethernet, IEEE.

Wow! We learned a lot!
Are there any terms you think should’ve been on the list? I can add them to part 2!

I hope you enjoyed reading this article and found it useful. I would love to hear your thoughts, here in the comments or in a private message:
LinkedIn: www.linkedin.com/in/ifat-neumann
Facebook: https://www.facebook.com/cupofcodebyifat/
Email: cupofcodebyifat@gmail.com

Resources:
https://www.youtube.com/watch?v=7_LPdttKXPc
https://www.geeksforgeeks.org/routing-tables-in-computer-network/
https://en.wikipedia.org/wiki/OSI_model
https://en.wikipedia.org/wiki/Modem
https://www.youtube.com/watch?v=oGoWqdlaOMI
https://pc.net/helpcenter/answers/difference_between_switch_and_router
https://www.keycdn.com/support/what-is-cidr
https://www.scienceabc.com/innovation/what-is-a-modem-what-does-it-do-router-working.html
https://www.cs.rutgers.edu/~badri/352dir/Spring04/notes/week6-four.pdf
https://support.microsoft.com/en-us/help/164015/understanding-tcp-ip-addressing-and-subnetting-basics
https://www.youtube.com/watch?v=1z0ULvg_pW8
https://www.youtube.com/watch?v=_NX99ad2FUA
https://troypoint.com/internal-external-ip-address/

--

--

Cup of Code

I write about things that interest me as a software engineer, and I find interest in various subjects :) || Come visit at www.cupofcode.blog