Compare commits

...

4 Commits

144
1.txt
View File

@@ -41,7 +41,8 @@ With all of that being said, let's jump straight in!
PART 1
Here we are, the physical layer! It's dark, dirty and grimy, and there's a distinct smell of solder in the air. It doesn't seem like much, but this, my friends, is where it all begins.
Here we are, the physical layer! It's dark, dirty and grimy, and there's a distinct smell of solder in the air (I don't think they get many visitors).
It doesn't seem like much, but this, my friends, is where it all begins.
The physical layer is honestly the least 'networking-esque' of the layers. Think of it as the foundation for our OSI layer: data can't be transferred through networks, and indeed,
networks wouldn't exist, if we didn't have the hardware to create them. The physical layer encompasses the actual cables and wires through which information flows. This is also where
@@ -89,8 +90,8 @@ means, is that the NIC only receives data wirelessly. But, all the same, every n
through a NIC.
But how does the data reach your NIC? Every NIC is identifiable by a certain address. This address is 'burned in' during the manufacturing process, and is globally unique (your NIC
is the only one in the world with that address). This address is known as a MAC address (not to be confused with the more well-known IP address). A MAC address is a physical address,
which means that it a) never changes, and b) refers to a specific device.
is the only one in the world with that address). This address is known as a MAC, or Media Access Control address (not to be confused with the more well-known IP address). A MAC address
is a physical address, which means that it a) never changes, and b) refers to a specific device.
A MAC consists of 48 bits, although it is often written in hexadecimal. This results in 12 hexadecimal digits. The address is separated into six groups of two (separated by colons),
with the first three groups identifying the manufacturer of the NIC, and the next six groups identifying the device itself.
@@ -106,5 +107,140 @@ Every manufacturer has an OUI assigned to them by the IEEE (Institute of Electri
A simple Google search will provide you with this information.
Now, let's tie this back into encapsulation. With every step in the encapsulation process (ie. with every layer that the data goes down), the layer adds relevant information to the data,
Now, let's tie this back into encapsulation. With every step in the encapsulation process (ie. with every layer that the data goes down), that layer adds relevant information to the data,
that will help the data be sent to the correct destination.
So, when the data link layer (the second layer) receives data, in the form of a 'packet', from the third layer (we count the layers starting from the bottom), it adds certain information
to it as well. Specifically, it adds a header (which is inserted before the packet) and a trailer (which is inserted after the packet).
INSERT IMAGE HERE
The header consists of four fields:
Frame Start - This field indicates the start of a frame (a frame is really just a grouping of bits).
Addresses - This field contains the source and destination MAC addresses.
Type - This identifies the layer 3 protocol that the data uses (more on this later).
Control - This field contains information that's used for flow control, essentially determining the priority of the packet.
The trailer consists of two fields:
Error detection - This field contains a checksum (a mathematical hash) of the data in the frame. This can be used to ensure that the data wasn't corrupted on the way.
Frame stop - This field indicates the end of the frame.
The purpose of a MAC address is simple: at the very basic level, devices need to send data to each other. However, they don't know each other's IP addresses, because all they know is
which <i>physical</i> devices are connected to them. Therefore, the IP address needs to be converted into a physical (i.e. MAC) address, so that the data can actually be sent to
the correct device. This IP-to-MAC conversion is done using a protocol called ARP (Address Resolution Protocol). More on that later.
Now, let's focus on an important question, one that you're probably wondering about: it's all fine and dandy that devices can use MAC addresses to communicate, but what if there are more
than two devices on a network? I can't connect a single device to multiple devices, can I?
As it turns out, you can. Certain devices, called network switches, or just 'switches' for short, are built for this exact purpose. They have rows of ethernet ports (sometimes upwards of
30), and are used as a central 'hub' for the devices on a network. They can receive incoming connections from one port, and forward them to another, based on the destination MAC
address. A switch maintains a list of ports, and the MAC addresses of the devices connected to those ports. This is called a CAM, or Content Addressable Memory, Table. This table is
the backbone of the switch, and is used to direct data to the correct device.
This way, a single switch can essentially connect a network together, providing internal communication.
INSERT IMAGE HERE
Now, let's journey further upward - I can already hear the noise and commotion...
LAYER 3:
So, here we are, the network layer! This is where the magic happens, for the most part. It's also the busiest layer of the OSI model. Tons of packets flying around in all directions,
heading, unceasingly, to their destination.
This is probably the layer that most people are familiar with. If you've ever heard the term 'IP address', you have at least some idea of the work that this layer does.
So, communication using MAC addresses works pretty well, for short distances. If you're connected to a single other device, you just send the data to them, and if you're part of a larger
network, you send the data to the switch, which looks up the port in its CAM table, and then directs the data to the right device.
But, what if I want to change my device's MAC address? Remember that MAC address are 'burned-in'at the manufacturing process. More importantly, what if there are multiple networks
connected to each other, like an inter-connected network? Maybe even, an 'internet'?
In such cases, and many more, IP (Internet Protocol) addresses are extremely useful. They are 'logical' addresses, as opposed to the 'physical' addresses that MAC addresses
represent. What this means is that they don't represent a physical object (like a NIC), and can therefore be modified. Essentially, I don't need to know the MAC address of
a device, in order to send data to it.
One of the key uses of IP addresses is in connecting multiple networks together. In comparison with switches, which connect devices together, <b>routers</b> connect multiple networks
together. They use IP addresses to relay, or 'route', data between these networks, which is useful because they can route entire chunks of IP addresses, which isn't feasible with MAC
addresses.
Before getting into the technical details of IP addresses, let me provide a simple example that illustrates the benefit of them, and shows a key difference between IP and MAC addresses.
Let's suppose we have the following topology, which is just a fancy word for the layout of devices in a network:
___ ___ ___
|PC1| <-----------------> |S1 | <-------------------> |PC2|
|___| |___| |___|
AA:BB:CC:DD:EE:FF 11:22:33:44:55:66 FF:EE:DD:CC:BB:AA
A
|
|
|
|
|
V
___
|PC3|
|___|
99:99:99:99:99:99
This topology represents a single network, with two devices connected via a switch. PC1 and PC2 are just PC's, while S1 is a switch. The MAC address for each device is given below it. The
terms 'data' and 'frame' are used interchangably, although this is isn't completely accurate.
Let's suppose PC1 wants to send some data to PC2. It isn't directly connected to PC2, but it <i>is</i> connected to a switch. So it decides to send the data to the switch. The frame for
this data contains PC1's MAC address as the source address, and PC2's MAC address as the destination address.
S1 receives the frame. As it receives the data, it examines the frame for the <i>source</i> MAC address. If you're keeping track, that's the MAC address of PC1 (AA:BB:CC:DD:EE:FF).
So S1 takes the MAC address, and the port number on which it received the frame, and creates an entry in its CAM table.
The next step for S1 is to send the data to PC2. However, it doesn't know PC2's MAC address yet. So, it 'floods' the data, sending it out through all ports, except for the one from which
it received the frame. This means that both PC2 and PC3 will receive the frame. PC3, however, sees that the data wasn't meant for it, by examining the destination MAC address. Remember
that the destination address is still that of PC2. Therefore, PC2 receives the frame, recognizes that the data was meant for it, and generates a response.
The response, once again, goes to the switch. The switch creates another entry in its CAM table, this time for PC2. However, it doesn't have to flood the data this time, because it
already has an entry for PC1 in its MAC table. It just sends the data through the right port, and PC1 receives the response.
This is an important characteristic of switches: their ability to 'learn' MAC addresses over a period of time. Eventually, your switch would have learned the MAC address of every device
on its network, and doesn't need to flood the data anymore.
Now, let's examine another network, or rather a network of two networks:
INSERT ASCII DIAGRAM