Micron Document
Networking
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Essential Hardware

Router

The router is the most important part of networking. One thing to understand is that the Internet is one big decentralized network. There are wires connecting everywhere to everywhere! Mainly through undersea cables to cross continents on a global scale but more locally, your ISP (Internet Service Provider) is hosting a whole network of devices, like your router, which other ISPs can access. It can become a mess. You could theoretically create your own Internet by not connecting to the main Internet we use but physically connecting routers together with ethernet cables, although if you do want to do this there are much better modern ways to create your own network, for example Reticulum.

We use routers to find different networks based on their IP addresses and route traffic between them. After a route has been found, data is sent to the destination address using Ethernet, going through multiple hops on the way to the destination.

Switches

A switch forwards traffic to computers in a local network based on their MAC addresses. They are typically included in home routers nowadays, with the 4 ports built in the back. However for a proper network you'll need more than that to connect all your devices which make switches invaluable to a large organization (and networking enthusiasts).

Because a switch has no need to find a route since all devices are assumed to be plugged into the physical Ethernet port, it doesn't need to know the IP address. It uses MAC addresses instead, which unlike IP addresses never change. This is because they are assigned by the manufacturer at production in the network card. (Although you can assign your own MAC address and making sure there are not any conflicts).

It maintains its own table of MAC addresses that it receives when computers broadcast their MAC address to the whole network. It then learns which physical Ethernet port the frame (unit of data for ethernet) came from and maps the MAC address to the Ethernet port.

Server

A server is more of a role than a specific device. Any computer can be a server, a laptop, a 3DS maybe even a Commodore 64 if you really tried. What it does is host services, like a web server, and sends back data to a computer. The big server rack you see in the image above are what a large organization would have since they require multiple servers. Most organizations nowadays would just use a VPS (Virtual Private Servers). They are VMs that are hosted on one big server, which can scale efficiently due to being virtual. This means you can save tons of money using a VPS instead of building your own servers.

They will be assigned static IPs (Internet Protocol Addresses) so that there won't be any downtime from the IPs constantly changing and then having to constantly find a route to it.

Topologies

The green dots represents devices on the network and the line represents connections between them so that they can send frames (divided pieces of data). The most common topologies are Star (households and corporations) and Mesh (nomads). At the start of the devlopment of Ethernet, the bus topology was quite common.

Ethernet

Ethernet is a wired networking technology used to physically connect computers together. It was standardized in the 80s as IEEE 802.3. It relies on computers having NICs (Network Interface Card) to actually provide the port to connect to. Each NIC is uniquely identified with a MAC address normally assigned by the device manufacturer but you can use a locally administered address to set your own MAC address. It is the final layer before bits (the unit of physical data going through the wires) is actually sent using electrical signals or light pulses.

A MAC address is a 48-bit identifier made up of 6 octets normally represented in hexadecimal. That means each octet is 8 bits and they can be seperated by either colons or dashes depending on your operating system. On Unix/Linux it uses the colon notation.

For example, it could look like this:

00:1A:2B:3C:4D:5E

Which in binary is:

00000000 00011010 00101011 00111100 01001101 01011110

The first three octets identify the OUI (Organizationally Unique Identifier) of the manufacturer. The last three can be assigned in any way. If you want to change your mac address from being universally administered to being locally administered by the manufacturer you have to set the second least-significant bit to 1. This bit is also called the U/L bit.

00:1A:2B:3C:4D:5E
00000000 00011010 00101011 00111100 01001101 01011110

would become

02:1A:2B:3C:4D:5E
00000010 00011010 00101011 00111100 01001101 01011110

IP (Internet Protocol)

The Internet Protocol provides addressing for the Internet with IP addresses. Each device has a unique address so that they can locate each other inside a network.

IPv4

IPv4 (Internet Protocol version 4) addresses are 32-bit IP addresses, seperated into 4 8-bit octets by periods.

25.172.34.56

The IP address is split into the network portion, which identifies your network and the device portion, which identifies your specific device. Where it splits is determined by the subnet mask, through a process called binary anding.

To find the network portion of the address 25.172.34.56 with a subnet mask of 255.255.255.0, you must convert both into binary and add them with the rule 1 + 1 = 1 and all other combinations equals 0.

Subnet Mask: 11111111.11111111.11111111.00000000

IP Address: 00011001.10101100.00100010.00111000

Network: 00011001.10101100.00100010.00000000

Converting both the IP address and network address back into decimal numbers shows that the IP and network addresses are the same up to a point, which is where the ones in the subnet mask end and where the zeroes start to begin.

IP Address: 25.172.34.56

Network: 25.172.34.0

From this, we can conclude that 25.172.34 is the network portion and 56 is the device portion. We can also add a /24 at the end, since there are 24 bits (ones) in the subnet mask.

25.172.34.56/24

IPv6

IPv6 (Internet Protocol version 6) addresses are 128-bit IP addresses represented in hexadecimal (base 16) format, seperated into 8 16-bit 4-digit hextets by colons.

2001:042d:80a2:d900:0000:0000:cd23:0009

The main reason for using IPv6 is that IPv4 addresses are running out. Since IPv4 is 32-bit, there are only 4,294,967,295 addresses available. When you consider how fast the human population is rising and accessing the internet, you can see that we're starting to approach the limit. In contrast, with IPv6 being 128-bit, there are around 3.4`*10^38 addresses available.

There are two ways of writing IPv6 addresses. One way is the preferred format, which is just the IPv6 address without any simplification.

2001:042d:80a2:d900:0000:0000:cd23:0009

Then there is the readable format which simplifies the IPv6 address to make it shorter and more readable.

2001:42d:80a2:d900::cd23:9

There are rules to simplifying an IPv6 address:

1. remove any trailing 0s
2. if there are mutiple hextets together that only contain the 0 digit, you can leave both sections blank by putting :: after the previous non-blank hextet and before the next non-blank hextet.
- you can only do this once
- you have to the pick spot where there is the most amount of hextets containing only 0s together
- e.g. 2001:0000:0000:452::e09

How IP & Ethernet Work Together

Some may ask "Why can't we just use IP/MAC addresses?" and this comes from a misunderstanding of how both work. IP addresses are used to find the final destination of where data should go if it needs to travel to a different network. MAC addresses are used to identify which machines data should go to in order to get to the final destination. Routers deal with IP to find the final destination, switches deal with Ethernet to actually forward data to machines.

If you're not required to connect to the Internet and just need a LAN (Local Area Network) you can technically just use a switch since it'll automatically forward frames to the Ethernet port that the destination is connected to on the switch using the MAC address. Other protocols that you'll be using on the computer are built on top of IP so you'll still be using that, but you technically wouldn't need it if protocols were built on Ethernet instead.

NAT (Network Address Translation)

NAT is an extension for IPv4 to allow devices to use the router IP address instead of each device having their own address. Basically, networks are now split into a private/local networks, which typically have the IP address 192.168.0.0 (the 0 at the end just means the whole network) with a subnet mask of 255.255.255.0 making it a Class C network. And devices in this private network use the 192.168.0.0 network to send packets to each other. When you want to send packets to a different network (outside the router) that's when your router kicks in and changes the source address from the device to its own public address (otherwise the destination won't understand which device for example 192.168.0.123 belongs to!). Then it sends the packet to the destination. The public address will be assigned by your ISP. But the private address you assign by yourself either automatically through the router with DHCP or manually setting up static IPs on each device.

NAT is very important in making sure that the address space on IPv4 does not become full. It also improved security by not exposing devices to the wider Internet, unless ports were opened on the router. Kind of like a firewall, it blocks inbound traffic by default.

ARP (Address Resolution Protocol)

Address Resolution Protocol helps with mapping IP addresses to MAC addresses in a computer's ARP cache in a local network. If a computer needs to send a packet to another computer with an IP address of let's say 192.168.0.54 but doesn't know its MAC address it will send a broadcast to address 192.168.0.255 asking every computer in the network "Are you 192.168.0.54, and if you are please can you give me your MAC address?". (...255 is reserved for broadcast, that's why we say that there's 254 usable addresses, 253 if you count your router and assign it an IP.) If a computer on the network does indeed have the address 192.168.0.54 it will respond to the original computer where the broadcast was sent "Yes! I'm here. My MAC address is 6C:7A:9F:8A:FF:09". (Spoofing is possible here)

Network Stack Models (TCP/IP, OSI)

TCP/IP is the model that is practically used in networking, however network engineers still refer to the OSI (Open System Interconnection) model colloquially. For example the application layer, which is Layer 4 in TCP/IP, would be referred to Layer 7 as that is the layer number for the application layer in the OSI model.

The key differences are that:
1. Link layer in TCP/IP is split into two layers on the OSI model - Physical and Data link.
2. Application layer in TCP/IP combines the Application, Presentation and Session layer in the OSI model.

TCP/IP

| No. | Layer | Description | Protocols | Unit |
|-----|-------|-------------|-----------|------|
| 4 | Application | Communication between end-user applications | HTTP, IRC, BitTorrent | Message |
| 3 | Transport | Provides reliable data transfer (ordering, error checking etc.)| TCP, UDP, QUIC | Segment |
| 2 | Internet | Routing and addressing of data from different networks | IP, ARP, ICMP | Packet |
| 1 | Link | Physical Addressing and physical transmission of data | Ethernet, Wi-Fi, Bluetooth | Frame |

OSI Model
| No. | Layer | Description | Protocols | Unit |
|-----|-------|-------------|-----------|------|
| 7 | Application | Communication between end-user applications | HTTP, IRC, BitTorrent | Message |
| 6 | Presentation | Formatting, encrypting and converting computer code to network formatted code | OpenPGP, TLS, MIME | Message |
| 5 | Session | Handles communication sessions between applications on different networks | Socket | |
| 4 | Transport | Provides reliable data transfer (ordering, error checking etc.)| TCP, UDP, QUIC | Segment |
| 3 | Network | Routing and addressing of data from different networks | IP, ARP, ICMP | Packet |
| 2 | Data Link | Physical Addressing between nodes | Ethernet, Wi-Fi, Bluetooth | Frame |
| 1 | Physical| Physical transmission of data | Twisted Copper Wires, Fibre Optic Cables | Raw Bits |
Resources