In this lesson, we're going to learn some networking theory.In the early days of networking, there was a big problem considering standards. There were none. That’s why Apple computers talked to Apple computers, IBM machines to IBM machines, but there was no universally accepted standard that could define the communication.The problem was solved though, with the Open Systems Interconnection Model
developed by ISO. Looking at the model, vendors could manufacture their products in such a way that they'd be able to communicate with systems from other OEMs.OSI model has 7 layers that help us “break down” the communication and see what happens to our data at various points in time. The seven layers are:
- Application layer – Layer 7
- Presentation layer – Layer 6
- Session layer – Layer 5
- Transport layer – Layer 4
- Network layer – Layer 3
- Data-link layer – Layer 2
- Physical layer – Layer 1
These seven layers originally represented OSI Protocol stack (which was rejected by the community because of complex hexadecimal addressing). Today, OSI model describes TCP/IP protocol stack (community favored TCP/IP for easy 32-bit decimal addressing).Let us examine what the 7 layers are using the following example:Imagine you're sending a message to your friend. You message is “Hello”. In computer world, the actual data being transmitted is called a payload
. So “Hello” is your payload. You type your message in your browser and your browser interacts with certain protocols, which reside on the Application layer to start sending the payload. Some Application layer protocols are HTTP, FTP, Telnet, etc.
After receiving your payload, application layer hands it down to presentation layer. Layer 6 formats your payload. In our case, “Hello” gets formatted according to UTF-8 or ASCII (character encoding). If encryption is needed, the Presentation layer handles the encryption.
On the Session layer, nothing happens to your payload. The Session layer just manages sessions between two remote hosts.The Transport layer plays a very big role. It determines the best method to transfer your data. TCP (Transmission Control Protocol)
and UDP (User Datagram Protocol)
are the most common and widely used protocols that reside on Transport layer.TCP is used for reliable communication (i.e. if some of your data is lost during transmission, TCP makes sure it is resent and arrived in order). UDP, on the other hand, is used for unreliable communication (for example for Voice over IP; you don’t need some part of your conversation being resent if it’s dropped.)Also, TCP and UDP handle port numbering. A port number is a value ranging from 1 to 65,535 that's assigned statically or dynamically to a software program, which wants to connect to a remote host. The addressee would then know which port to send the response to. Thanks to port numbers, we can make use of network resources using multiple programs simultaneously.When your data gets to Transport layer, TCP or UDP adds some overhead to the payload:
This is a TCP segment
. It contains destination port (which program the data is intended to), source port (which program addressee should respond to), sequence number (data is resent if needed based on sequence numbers), checksum (error checking), Flags (Control bits), ACK (acknowledgement; i.e. “I got your previous query and I am expecting next sequence number”) and the actual data.
on the other hand, has less overhead added to the data. Length field represents length of the data + overhead.The Network layer has everything that has to do with logical addressing. An IP packet
is created on this layer.
Data-link layer deals with physical addressing. A physical address or MAC address
(Media Access Control address) is a 48-bit hexadecimal number that's unique to every Network Interface Card (NIC)
in the world.Here’s the example for a MAC address: 0A:0C:BB:FF:43:1A. MAC addresses are used to talk to devices within one subnet. For example, if you use a switch to connect 3 PCs, those PCs will communicate using MAC addresses.On Data-link, layer a frame
Type defines a method by which the frame was created. We most commonly use Ethernet frames today. FCS is short for Frame Check Sequence. It's used for error-checking and data integrity.This whole process of putting payload into segments, segments into packets, packets into frames is called encapsulation
.The Physical layer has nothing to do with logic behind networking. Cabling, medium types, etc. reside on this layer.When your “Hello” reaches the other computer, this process is reversed (which is why it’s called decapsulation
). The addressee first interprets the frame, then unwraps the packet, then reads the datagram, encodes/decodes using appropriate technology and presents it to the application. Thanks and next up is lesson 3.