Hello! I know I haven’t been posting here as often. Well I am going to make up for that!

 

I figured I would start this series of 101’s with communications as I am starting a new endeavor of Cisco certification this year! (yay to me) and my true interest is networking. Don’t be fooled though everything here is not “Cisco related” AT ALL! it applies to all networks no matter what vendor you use.

 

First of all some background.

You do not need any knowledge of computers to understand this. If you have some knowledge your better off forgetting it right now and starting anew as sometimes you may have just enough knowledge to be dangerous! (I’ve learned this the hard way, and crashed many a system and received many phone calls at 1 am usually starting with vulgarities then ending with well get it back up and running NOW! (click))

 

Anyways lets get right into it.

 

If you look in the back of you desktop computer you will most likely find a port that looks similar to a telephone jack only slightly bigger. This port is called a RJ-45 jack or port, aka network port, network card, network connection. ¬†If your computer is connected to the internet and your reading this then more likely than not there is a cable plugged into this port and that cable leads to a device. If you are home that device may be your home router supplied by you internet service provider, if your at work, you may not be able to see where the other end of that cable plugs into however the other end plugs into a “switch”.. your going to just have to trust me on this one ūüėČ

Back to the home user.

 

That device that your Internet service provider gives you is usually referred to as a router, however this is partially true. In actuality that device is many separate devices all rolled into one single box.

What do I mean?

Well there is a difference in what a home users equipment needs and looks like vs what a larger commercial clients equipment needs are and what theirs looks like. (Usually in a large commercial setting the Internet service provider will just leave you with a cable, that’s it.

 

So, lets dissect your home “router” I’m putting it in quotation points and you will see why in a minute.

That device most likely does not route, actually it does something called “NAT” which is different from routing. N.A.T. or¬†Network¬†Address¬†Translation is our next topic and is also very interesting. however NAT is what happens when your computer wants to talk to another computer over the internet. Here we are going to focus on one computer talking to another computer inside your home or inside your office which is where NAT or Routing does not get involved in this process at all but yet still may use your home “router” <– yep still in quotes

because inside your home router there are actually more than one components of equipment that in a larger commercial setting would be divied up into separate physical devices.

These devices are: a “Switch” which operates at something called “Layer 2” in the “OSI Model”

and a NAT gateway (yes not a router) < which operates at something called “Layer 3” in the “OSI Model”

 

Woah! so there are a lot of terms thrown around here. Lets pause and take a look at these big words. (There not big at all and we will simplify them)

 

The ‘OSI model” <– they say a pictures worth a thousand words, I wonder how many a diagram is worth? well here is one anyways:

1-tutorial-osi-7-layer-model

 

So, Here is the OSI Model folks! Is it not Glorious?

yes, im not very impressed either. whats this mean????

It starts at the bottom. You read this from the bottom up.

Layer 1

Is the actual wires and ports and “router” “Nat Gateway” or “switch” you see and the computer port (the RJ-45 jack mentioned above, your not skimming are you?) and the actual cable connecting all these devices.

Then comes:

Layer 2

This is what this post is about layer 2. when two computers communicate on the same network and on the same “Switch” (yes its built in to your home “router”) you can say that these two computers or this computer and mobile device or computer and printer, or scanner or a multitude of devices are communicating at “Layer 2” of this “OSI Model”

So let’s get dirty inside layer 2!

I have seen a lot of confusion when people are first starting out. They believe that computers or any internet connected device communicate with each other using an IP address (Layer 3). This is in fact not true! Devices communicate by something called a MAC ADDRESS. See that port where the cable connects your device? that port is part of a “Network card” and it can be in any device not just a computer. a laptop, printer, scanner, camera, anything that is enabled to communicate using IP addressing has one. ¬†Each of these cards, when they are made at the factory are hard coded with a “MAC Address” a MAC address looks like this “00:50:43:5b:1A:42″¬†

This can be compared to you home address and apartment number if you want to compare it to the postal system. They are all unique (mostly. there are exceptions but those are way out of the scope of this beginners lesson).

Back to the OSI model for a second.

The OSI model works as such: it starts at layer 1 and goes up. Each layer is designed to provide the service for the layer above it. So from what we learned thus far. Layer 1, which consists of the physical wires, the physical boxes called, switches, the routers, the gateways, all the physical devices and the cables that interconnect them provide the medium or the service for which layer 2 runs over. So as we keep going up on the OSI Model we will see that Layer 2 will provide all the foundation for the next layer, layer 3 and layer 3 will provide services for layer 4 and so on.

 

So i said earlier that your home router that your ISP gave you is really an all in one device. To put an image to what devices are in this all in one unit lets take closer look.

Here is the back of a Verizon Fios Router.

actiontec-fios

 

 

We see 4 yellow ports, these ports with the default configuration are set up as a switch, that is one component and really the only component needed for layer 2 communication to take place. The gray port on the right connects to the ISP (Internet Service Provider and the device acts as a gateway to the internet using NAT on this gray port. In addition, the device also features a DHCP server (we will get into this later), a firewall, also normally a standalone device in the commercial world. As well the device has antennas for WiFi which you can think of as just extra invisible (yellow) ports and part of the switch.

 

A standalone switch:

 

layer2switch

Above is a picture of a layer 2 switch alone. If you separated the switch component from your home router this is what it will look like. Of course they come in different models with more or less ports and speeds.

The basic unit of data that a device uses to communicate in a layer 2 switch is called a “frame” this can be easily confused with another type of data called a “packet”.

Now there is a real close knit connection between layer 2 and layer 3. Anytime you deal with layer 2 communications you are dealing in frames and anytime you deal with layer 3 your dealing with packets. Do not get overwhelmed! Lets go through the path data takes from one computer to another and it should come together.

Earlier when I said layer 2 is all you need for devices on the same network to communicate, It is not entirely true. Layer 3 does need to get involved.

By the strict definition of the OSI Model whenever you are dealing with an IP address you are dealing in Layer 3. So while your device already has a MAC address it does also need an IP address.

An IP address can look like this:

192.168.1.2

your device comes with a hard coded MAC address but not with a hard coded IP address. Usually in a home network your home router takes care of this for you, as it is a all in one device it has something in it called a dhcp server. A dhcp server does nothing but detect the presents of a new device on your network and once that device makes itself known, by sending out a signal that it needs an ip address along with its MAC address the dhcp server will detect this and send a signal back to the device telling it that it has been allocated an ip address of lets say “192.168.1.3” but really it can be anything that if configured.

 

However, to simplify things for the moment. lets assume there is no DHCP server. There is only a switch like the one above and that you have already gone into the settings in your computer (We will call this computer PC 1) and you have manually assigned it an ip address of “192.168.1.3”. (This is absolutely possible in almost every device, to manually set your own ip address)

Now your desktop PC 1 is connected to a plain layer 2 switch like the one above by a cat5 also known as network cable to one of the ports, lets say Port 20 (they are all equal and the same)

Lets also assume you have PC number 2 and you went into its settings and you manually set its IP address to be “192.168.1.4” PC 2 is connected to the same switch on port 21.

 

Summary of the information we have:

PC 1’s MAC address is¬†00:08:43:5b:1A:42 ¬†and IP Address 192.168.1.3 connected to switch port number 20

PC 2’s MAC address is¬†00:08:43:5b:1A:43¬†and IP Address 192.168.1.4 connected to switch port number 21

 

PC 1 wants to communicate to PC 2.

First thing to note here is that they are on the same network and the same subnet. A subnet which we will get into more detail later on is a pool of ip addresses that are in the same network so you can see that the ip addresses of the two PC’s in the example are only off by 1 number. The prefix “192.168.1.x” is the same so here in this example again comparing to the postal service they are in the same street and only the house numbers are different. The street being = to “192.168.1.x” and the house number is = to “x” which in the case of PC 1 is 3

and PC 2 x is = to 4

Now lets focus on what the switch does.

The switch is at first oblivious to what devices are connected to it. However it “sees” all the data that flows through it and quickly learns and builds a memory or “Cache” of which port has which MAC address on it. This is called a “Forwarding Table”¬† and it helps speed things up by having the process I am about to describe below only happen once, or whenever the network changes (something is un-plugged or plugged into the switch), also many switches have a countdown timer for this cache which gets flushed once the timer reaches zero.

ARP Stands for Address Resolution Protocol. It is only for MAC addresses.

PC1 or 192.168.1.3 knows that it wants to talk to or initiate some sort of data transfer between itself and PC2 or 192.168.1.4 however it can not find or talk to PC2 because computers communicate via MAC address not IP address. So PC1 needs to find PC2’s MAC address in order to talk to it.

Well how?

It simply asks!

PC1 sends a request on the network called a “Broadcast” the broadcast is simply that, a signal that gets sent to every computer or device plugged into every port on the switch. Multiply this by however many ports the switch has and you will soon appreciate the function of the switches cache.¬† On a network you want to keep broadcasts down to a minimum. Broadcasts flood the entire network and slow it down.¬† We will get back to this in a second.

So PC1 Broadcasts a “who is” ARP which is simply bytes of data that says “Who is 192.168.1.4”

this comes out of the computer from the network card and gets stamped with its MAC address, so on the wire and too the switch the data that the switch floods out to every one of its ports (every port except the one it received the request on) is “00:08:43:5b:1A:42 is asking, who is 192.168.1.4″.

Now every device on the network see’s this request, but only the device that has the IP address in question will answer back. So PC2 sees this broadcast message and knows it is being requested for communication. PC2 responds with a “Unicast” message, or a message that has both the mac address and the ip address to the switch. This message says “192.168.1.4 has MAC address 00:08:43:5b:1A:43

This gets to the switch and being that the switch learned which port PC1 was on when it sent the ARP request, now does not flood it out of every port, but only “Forwards” the data directly back to PC1 on port 20 and in the process it also “cached” that on port 21 exists a device with mac address 00:08:43:5b:1A:43. The next time a computer wants to talk to PC2 the switch will not flood a broadcast message out of every port adding to network traffic but just forward the request out of port 21 instead.

So PC1 now receives the MAC address for the computer it wants to establish a connection to. It can now create the proper communication it wants to send to PC2 and wrap that communication in a virtual box or “frame” the MAC address of PC2 and send it out the network cable (Layer 1) and the switch will forward it directly to PC2.