You have probably found yourself in this position before: you search up something on Google, click on a link, and it takes you to a web page. Everyone who uses the internet (or is it the World Wide Web?) has done this before; odds are, that's how you got to this very web page. Have you ever wondered what goes on in this process? How is it that, upon clicking a link, you are automatically transported to the right web page? How does Google fetch the results in the first place? These questions, and many more, shall be answered in this beginner's guide to computer networking. The only thing that I ask of you, is that you are familiar with number systems, specifically, binary and hexadecimal. These are essential components of the networking world, and are used heavily. A quick glance through the wikipedia articles should help familiarize you with them, as well as how to convert between binary, hexadecimal and decimal (the ordinary number system). Before we begin, I would like to show the model that I will be using to teach this: a model so perfect, so beautiful in its elegance, that it puts any other model to shame. I am talking, of course, about the OSI model. This will be my 'guiding document', so to speak. The OSI model is a 7-layer model, where every upper layer is an abstraction of a lower one. The layers of the OSI model build on each other, and none of the layers can exist without the help of all those below it. I will start at the very bottom, the Physical layer, and leave you at the top, the Application level. Don't worry if some of the terms don't make sense to you, they didn't make sense to me either, when I first started learning networking. I hope you're familiar with the concept of binary: the system of 1's and 0's, the only language that a computer really understands. Every application you open, every video you watch, every image you see, every web page you view, is ultimately, to the computer, just a bunch of 1's and 0's. This is similar to how networks work as well: no matter what type of information you are sending across a network, it has to be converted into binary to be sent 'across the wire', that is, across networks. As an example: if you wanted to view this web page (hopefully, that's why you're here!), you have to fetch the actual document that contains the web page from me, here in Texas. Let's suppose you were living in New York. The document (which is stored on my computer), has to be converted into a stream of bits (1's and 0's), transported across the country to you, and then 'reassembled' into an actual web page. And all of that, at the drop of a hat! Isn't it amazing? In my example, I covered two very important processes, fundamental to computer networks: encapsulation is the process by which data is converted into bits, while de-encapsulation is the opposite: it is the conversion of bits, back into data. In the context of the OSI layer, encapsulation goes down the layers, while de-encapsulation goes up the layers. Insert image here Got it? If not, here's another example: when you requested this web page, your web browser encapsulated the request and sent the bits to my computer. My computer de-encapsulated those bits, in order to decipher the original request. It fetches the web page (which is really just a file), and encapsulates it into bits. Those bits are sent to your web browser, which de-encapsulates them in order to retrieve the original web page. This is, obviously, an oversimplification and as we will soon see, there are many 'middle-men' to help faciliate both processes. I want you to keep these two terms in mind, because they are crucial to understanding the OSI model, and networking as a whole. 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 (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 the actual bits are transferred: once the data has been completely encapsulated (ie. once we have gone down the OSI layer), all we are left with is bits - these bits, through electrical pulses, are transferred through wires. A '1' represents a high voltage, and a '0' represents a low voltage. The maximum rate at which data can flow through a wire is called its 'bandwidth'. If you have a gigabit connection at home, all that really means is that 1 gigabit (a billion bits) can be transferred into and out of your network every second. It is not the speed at which the bits travel (that is determined by physics) but rather the rate at which the bits are transmitted. Bandwidth depends on a number of things, including the actual material used to create the cable. Copper is the most common one, but most ISP's (Internet Service Providers, think AT&T and Verizon), are now switching to glass: this is the fiber-optic conection that some of you may have. The key point to note is that bandwidth is the maximum capacity of your connection: don't expect anything more, but you can sure expect something less! The actual rate of data transfer through a wire, is called it's 'throughput'. This can never be greater than the bandwidth, but it is often less than the bandwidth. This can occur due to a number of reasons, including the amount of traffic that is flowing through a network. The best way to visualize this is to imagine a highway. Bandwidth is the theoretical maximum rate at which cars can go through a highway, if everyone drove perfectly. It is determined by factors such as the number of lanes and the condition of the road. However, as you probably know, most people are terrible drivers. This results in congestion and backed-up traffic. At this point, the rate at which cars go through the highway, is the throughput. This is influenced by such factors as the number of cars and the types of cars that are going through the highway. Notice the difference: bandwidth is independent of the actual data, while throughput is heavily influenced by it. Another important term (that you may have heard before) is latency. This the amount of time, including any delays, that it takes for data to travel from one part of a network to another. If you ever have a slow connection, that means you have a high latency. Latency can be caused by any number of factors, including congestion of traffic on the network. If you're browsing this web page on your phone, you may notice that there are no wires that extend from your phone, and receive the web page. So how does the data get to your device? This is where Wi-Fi comes in. Wi-Fi, or Wireless Fidelity, is a technology that allows information to be encoded in radio waves, and sent over the air. There are two standard bands for Wi-Fi signals, 2.4 Gigahertz or 2,4G, and 5 Gigahertz, or 5G. So that's the physical layer - it may be boring, but it is the foundation of the internet as we know it. Now, let's go upwards - onto the next floor, where we see the data link layer. PART 2 Ah, finally! Daylight! We're now in the Data Link layer, on the second step of our journey. There's a lot that happens here, and this is where we begin to notice some semblance to actual networking. The Data Link layer is how we address devices physically. You see, every device that communicates using a network needs to have a certain device, without which, network communication cannot take place. This device is commonly known as a network card, but the technical term for it is a NIC (Network Interface Card). INSERT IMAGE HERE A NIC receives information through an ethernet port. You may have seen one of these on your PC, but most laptops, especially recent ones, have decided to forego this port. What this means, is that the NIC only receives data wirelessly. But, all the same, every network-capable device must have a NIC, and at a fundamental level, all information must enter or leave 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, 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. Keeping up so far? Here's an example of a MAC address. AA:BB:CC:11:22:33 Notice the six groups of two. The first three groups (AA:BB:CC) are called the OUI (Organizationally Unique Identifier), and identify the manufacturer. The last three groups (11:22:33) is an identifier that is unique to that specific NIC. Every manufacturer has an OUI assigned to them by the IEEE (Institute of Electrical and Electronics Engineers), a global regulatory body. For example, one of Apple's OUIs is 6C:E5:C9. 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), 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 physical 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, routers 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 is 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 source 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