OSI Model: Part One

Melissa Brown
11 min readSep 29, 2018

--

Recently, I had to fix a wifi network that was down and it had me thinking about mental problem-solving models for fixing network problems. When we have an error in our code we normally have a nice clear error message of the problem. But if our home or office wifi is down where is the problem coming from? The device? The cables? The network? Where do we start?

The Open Systems Interconnection model (OSI model) is a useful logical mental model for how network systems are supposed to communicate with each other. It breaks down the components of network communication and slots them into layers. There are seven logical layers.

OSI Model

First Layer

The first layer deals with sending bits from one computer to another. It is not concerned with the details of the bits but rather the physical set up (Wiring, cables) etc.

Second Layer

Is the data link layer. This is the layer transfers data frames (messages) between nodes(paths) over a network. These frames include information such as source ids and destination addresses.

Third Layer

The third layer is the network layer. This is the layer that routers operate on. IP addresses are important at this layer. It is the layer where a computer decides how it will find the other computer that it wants to send the information to.

Fourth Layer

Transport layer. Once it has found the computer that it wants to send the information to it makes more decisions that deal with t the transport of data back and forth.

Fifth Layer

The session layer. This layer deals with the communication required in creating a session between two computers. For example, when your computer wants to visit a website a session is created. Once you close down that webpage the session is terminated.

Sixth Layer

The sixth layer is the presentation layer. This is the layer that the operating system is on.

Seventh Layer

The seventh layer is the layer closest to the end user. This is the application layer. It is the application that the user is working with, for example, Firefox or Chrome.

Let us look at how some of these layers work. Starting with the Data Layer.

Data Layer

Switches

One of the most import parts of the data layer is switches. Different devices plug into a switch so they can talk to each other. When things are going wrong at the data layer we need to look at the switch. Every computer has a unique MAC address “Media Access Control Address. A MAC address is a hardware identification number that uniquely identifies each device on a network. The switches job is to learn the MAC addresses of the devices on its port and deliver the ‘messages’ to the correct device. Let us say we have computer 1 and computer 4. Computer 1 wants to send a message to computer 4. When computer 1 first sends a message the switch does not have anything in its MAC address table for that device. When the switch receives the message, it records the computers MAC address and the port from which it came from. If the switch does not know the destination mac address ( computer 4’s address) it will send out the message through all ports on the switch. When the destination computer receives the message it will generate a response message. It sends this response message will send back to the switch. The switch then records this information. The switch then builds a roadmap of the MAC addresses and ports. It keeps this information in a table at a MAC table. The next time computer 1 wants to talk to computer 4. The switch recognizes the addresses and it doesn’t have to send out the message to all devices but instead, it sends it directly to computer 4.

VLANS

A LAN is a local area network is a computer network that generally covers a small area for example single room, building or group of buildings.

You may want devices that are connected together on the same physical LAN but that are not allowed to communicate directly. For example, if you want to separate guest computers with admin computers or phones lines from computers. With VLANs, you can isolate traffic.

vLAN virtually separates broadcast domains within a single LAN. A single VLAN has a single broadcast domain and is its own network. A separate vlan = separate networks = separate broadcasts.

Note: You can have multiple VLANs on the same switch. One device can also be on a different switch and yet on the same VLAN as another device.

What is a Trunk Port and trunking?

A trunk port is a port that carries traffic for all the VLANs it can handle multiple signals simultaneously. This whole process is known as trunking

Trunk ports mark the ‘messages’ with unique identifying tags as they move between switches. Let us say computer 1 wants to send a ‘message’ to computer 8. Computer 8 is on a different switch. If a switch cannot find the mac address of computer 8 on its switch out through the trunk port. Before the trunk port sends it along the trunk link to the next switch it tags it with extra information called a VLAN id. When switch 2 receives the ‘message’ it looks at the VLAN id and sends the ‘message’ to the computer on the same VLAN matching that id.

What if I want to send a message to a computer on a different VLAN?

The Network Level: Level 3

When we are discussing multiple VLANs that need to communicate with each other we are moving into level 3. Multiple VLANs need to communicate through routers. The router is the gateway to the other network. Each computer has an IP address and a unique mac address. A Router has multiple IP addresses and each IP address will have multiple mac addresses associated with it.

All computers and other devices connected to a network, such as smartphones, tablets, and fax machines, have a unique IP address. No two computers on the network may have the same IP address. Without the IP address, computers and mobile devices would not be able to communicate with each other.

Computer 1 wants to send data to computer 10 which is on a different network. To do this it has to send some information or a ‘packet.’ The IP packet is going to have the destination address, its own IP address and the IP address of the source.

The ‘message’

However, it only knows the mac addresses of the computers on the same network so how does it send the data to the correct computer? Computer 1, however, does know the mac address of its default gateway router. The computer sends the information out to the switch the switch opens the header and sees the gateway(router) as the destination mac address. The switch then sends the packet to the router. It arrives at the router. The router sees the realises the information belongs to it. It then looks at the destination IP. The router knows the mac address of the computer that is associated with the IP. It then sends the message to its correct destination.

The Transport Level 4: Layer 4

Level 4 is all about the transmission of data and our TCP Transmission Control Protocol. The TCP is the connection-oriented protocol that sets out the rules for providing the reliable transportation of streams of data. If some of the data is dropped or lost the protocol detects this and resends it. This method of segment control between the sender and the receiver is called windowing. Let us have a look at how it works.

Windowing

Windowing allows the sender to adjust the amount of data sent in each transmission. When computer 1 is trying to send information to computer 2 the information they are trying to send is broken down into packets(smaller pieces). It starts sending packets in groups and those groups get progressively bigger. When computer 2 receives packet one and it will tell computer 1 it has received the packet. Once computer 1 knows computer 2 has received the first packet it will keep sending it twice as much information to computer 2. If something happens with the packets on the way or the packet order is messed up it will start sending the information again. Not from the first packet but from the last packet that computer 2 received in order.

Buffering

Devices such as routers and switches have memory to store segments of data. If will store the segments of data in its memory if the bandwidth needed to transmit the data isn’t available at the time of sending. Let us say you have a router that can transfer 100 megabits per second but the devices that are sending data are sending it at 1000 megabits per second. If this happens the buffer will start to fill up with these extra bits. Then it has time to transfer all the data. However, sometimes the buffers can overflow and drop segments. You can increase the buffer by increasing memory to the router or increasing the speed of the connection.

Domain Name Server (DNS)

The domain name server is the equivalent of an address book. They map domain names to IP addresses. When you enter a URL into your web browser the URL is translated into an IP address. Without the DNS we would all have to memorize random numbers to access the websites we wanted to visit.

Today there are way too many devices for each to have their own IP address this is which Dynamic Host Configuration Protocol (DHCP) comes in.

Dynamic Host Configuration Protocol (DHCP)

Dynamic Host Configuration Protocol (DHCP) is a network protocol that enables a server to automatically assign an IP address to a computer from a scope configured for a given network.

Each computer will run a DHCP client and it will call out to the DHCP server and ask for an IP address. The servers can be run on a router or a server. In your home internet, your DHCP server will be built in on a router whereas in an office environment they are likely to have their own server.

Step 1: DHCP Discovers

Your computer sends a message out to everyone saying it needs a DHCP server other devices that are not the server will ignore the message.

Step 2: DHCP Offer

The DHCP server will send a suggested IP address to the requesting caller.

Step 3: DHCP Request

The calling device accepts the IP address and requests to lease it for a period of time.

Step 4: DHCP Pack

The DHCP server then acknowledges the request and sends the device a pack that contains the IP address along with other information such as the DNS server and default gateway. The DHCP keeps a record of all these packs as well as a lease time.

Subnets and Subnet Masks

As the number of computers on a network grows, network traffic will grow this can cause performance issues. To fix this you would divide your network into different subnetworks and minimize the traffic across the different subnetworks. We create these different networks by a logical subdivision of an IP. This logical division is called a subnetwork or subnet. Like VLANs devices on a different subnetwork cannot talk to each other. To understand subnets we need to look at IP addresses in detail.

Our IP address has two components to it. There is a part that tells you the network identifier and a second part that tells you the device identifier. Another important term here is a subnet mask. A subnet mask is a number that defines a range of IP addresses that can be used in a network.

1. Subnet — division of a network into subnetworks

<network1><network2><network3>

2. A Subnet Mask — separates the IP address into the network and host addresses

<network><host>

3. Subnetting — further divides the host part of an IP address into a subnet and host address

<network><subnet><host>

How is this division done?

Lets first look at how an IP address is determined.

192.168.1.1

Each number in each section of this IP address corresponds to a binary number that is determined by a series of 8 numbers (octets).

Each octet is a series of bits and can either be 1 or 0 for example.

10110101

To determine the number that corresponds to the bits we start from the right side and move up in powers of 2.

The total number of one octet is 255. If you wanted to get an IP address of 128 you would put a 1 over the 128 and a zero over everything else.

If I wanted the IP address of 192.168.1.1 you would do the following.

We add up the numbers that are marked with a 1 for each octet for example. 192 + 64 =192

128+32+8 = 168

and the process continues.

Subnet Masks aka Network Masks

Let us look at the three most common classes of IP addresses.

A network mask helps you know which portion of the address identifies the network and which portion of the address identifies the node. If we look at the bit structure of the classes they look like this.

·       Class A: 255.0.0.0·       Class B: 255.255.0.0·       Class C: 255.255.255.0

There is an easy way to determine the Class if the IP address by the 1st octet.

· Class A: The first octet in the address is between 0 and 127, inclusive

· Class B: The first octet in the address is between 128 and 191, inclusive

· Class C: The first octet in the address is between 192 and 223, inclusive

An IP address of 192.168.1.0 would be class C. and has a network mask of 24This is because every IP address is a 32-bit binary number. Out of the first 24 bits (8 x 3) have already gone for the network address.

Subnetting

Now that we have our network mask how many subnets can we have and how many hosts can we have? There is an equation to work this out.

subnets = 2n (N represents the number of bits).

Valid hosts = Total host = 2n-2

https://www.youtube.com/watch?v=8IS13vnRuTQ

Our IP address is a 32-bit binary number. As we saw before out of the 32 bits the first 24 bits (8 x 3) have already gone for the network address. The remaining 1s in the last octet are our subnets.

Next up Level 5,6 and 7.

--

--