Sign Up|Login Courses & Workshops
Overview
Pricing
BLOG HOME

An introduction to networking

A computer network (also referred to as a "data network" or simply a "network") consists of a set of devices connected together in order to exchange data between themselves. These devices create a network using their respective network interfaces. Some devices may use a single network interface; others may connect via multiple interfaces.

The type of interface(s) a device uses to connect to a network depends on the physical medium. A wireless interface connects to a network over the air using a standard such as IEEE 802.11 (known colloquially as WiFi). Various types of wired mediums are in use today, the most common of which follows the IEEE 802.3 standard (Ethernet). Most devices with a wired network interface will have at least one Ethernet interface.

Types of devices in a network (based on their function)

A device connected to a computer network is typically called a node. Based on the function of a node within the network, we can classify it as one of 2 types of devices:

  • Hosts are devices that either store data to serve to other hosts or request data from other hosts when necessary—for example, a laptop or a web server.
  • Network devices facilitate the transfer of data between hosts—for example, a network switch or a router.

Host can be further classified based on their primary function:

  • Clients primarily request data from other hosts to perform a specific function. For example, a laptop or a desktop.
  • Servers are devices that primarily store, process and send data to a client device when requested. For example, a web server or an email server.
  • Peripherals are devices that perform a specific function in a network. For example, a printer.
  • Peer-to-peer devices devices act as a client and a server to other hosts on the network. A device such as a laptop may be a client device for some applications (like a web browser) and a peer-to-peer device for other applications (such as BitTorrent).

The mechanics of data transfer in a computer network

As stated earlier, the primary purpose of creating a computer network is to allow devices to exchange data. How exactly does this data exchange happen? Let us look at the mechanics of data transfer in a computer network.

Network Headers, Layers and Encapsulation

When a host needs to send data to another host over a computer network, the data is "encapsulated" in several layers of "headers." Each layer contains specific information about the source of the data and its intended destination.

Let us use an example to illustrate how this would work.

Consider the following scenario. Five computers and a server are connected via a switch to form a network. The server (Device F) has a web-server application running on it.

10.0.0.91
A
10.0.0.94
D
10.0.0.92
B
0/1
0/2
0/3
SWITCH
0/4
0/5
0/6
10.0.0.95
E
C
10.0.0.93
F
10.0.0.100

The user on Device A (a computer) opens a new tab in a browser window and requests a web page stored on web-server F.

Device A creates a request to send to Device F. The request must include enough information to:

  • identify the source device (Device A)
  • identify the source application (web-browser)
  • identify the destination device (Device F)
  • identify the destination application (web-server)

The request to download the home page of the web server application running on Device F would follow a format specified in the HTTP protocol and look like the following:

GET / HTTP/1.1

There may be many applications (or processes) running on a server. When this request arrives at Device F, there must be some method to identify its target application (or process). In order to identify the target application on Device F, Device A must encapsulate the request in a Transport Layer (Layer 4) header.

The most common Transport Layer protocols in use today are Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). The HTTP protocol (and consequently, web servers and client browser applications) use TCP as the transport layer protocol to transfer traffic. For the HTTP request from Device A to be directed to the correct application running on Device F, the request must be encapsulated in a TCP header.

Transport Layer protocol (both TCP and UDP) headers include a field known as the Destination Port. The destination port in a TCP or UDP header is not a physical port or interface on a device. It is simply a field in the header and is a number between 0 and 65535. A web server application, by default, listens for incoming requests on a "well-known" TCP port number 80 (or 443 for secure HTTP).

The HTTP request above must therefore be encapsulated in a TCP Header where the Destination port is set to 80. The request now looks like this:

 80
GET / HTTP/1.1

So far, we have created an HTTP request and identified the application that must process the request on the receiving device. We next need to uniquely identify the receiving device out of all the devices on the network. We do this by encapsulating the entire request (which currently consists of an HTTP request encapsulated in a TCP header) in a network layer (Layer 3) header. The most common network layer protocol used today is Internet Protocol (IP). (IP version 4, to be exact.)

The request is next encapsulated in an IP header. One of the fields in an IP Header is the Destination IP Address. The destination IP Address must be set to the IP Address assigned to Device F (10.0.0.10 - as seen in the diagram above). The request now looks like this:

 10.0.0.10
 80
GET / HTTP/1.1

We now have a request that is encapsulated in a TCP (Transport Layer) header, and an IP (Network Layer) header. The Destination IP Address in the IP Header identifies the intended recipient via its Network Layer Address. However, this is not yet sufficient to ensure that the request arrives at the correct destination device.

The devices in this example are connected via their respective Ethernet interfaces to an Ethernet switch. Ethernet is a Data Link Layer (Layer 2) protocol. In order for the HTTP request to make it to Device F, we now need to add a Data Link (or Layer 2) header. In this case, it would be an Ethernet Header.

The Ethernet Header contains a field for the Destination MAC Address. This would be the MAC Address of the Ethernet interface on Device F. The MAC Address is a hardware address. Every Ethernet interface is assigned a unique MAC Address by the manufacturer of the interface. The Destination MAC Address in the Ethernet Header is set to the MAC Address of the Ethernet interface on Device F (we will suppose this to be the address EC:70:2C:5D:AF:F2).

 EC:70:2C:5D:AF:F2
 10.0.0.10
 80
GET / HTTP/1.1

We now have an HTTP Request encapsulated in Layer 4, Layer 3 and Layer 2 headers. The Layer 4 (TCP) header identifies which application on the destination device should handle the request. The Layer 3 (IP) header identifies which device the request is being sent to. The Layer 2 header identifies the physical Ethernet MAC address of the interface of the device that the request is being sent to.

When this request arrives at Device F, it will be forwarded to the application that is "listening" on TCP port 80. The web server application (which is listening on TCP port 80) processes the request and creates a response to be sent back to the originator of the request.

How does Device F (and the web server application running on it) know who to send the response back to? In order to send the response back to the correct device on the network, Device F will inspect other fields in the headers encapsulating the HTTP request.

In order to allow for full two-way communication in a network, there exists a corresponding "Source" field for every "Destination" field in the Transport, Network and Data-link layer headers. The Ethernet header will include the MAC Address of Device A's Ethernet interface (we will assume this to be 70:F4.7D:A5.BC:4F):

70:F4.7D:A5.BC:4FEC:70:2C:5D:AF:F2
 10.0.0.10
 80
GET / HTTP/1.1

The IP header will include Device A's IP Address in the "Source Address" field (10.0.0.91 - as seen in the diagram above):

70:F4.7D:A5.BC:4FEC:70:2C:5D:AF:F2
10.0.0.9110.0.0.10
 80
GET / HTTP/1.1

The TCP header will also include a "Source Port" field. When a tab in a browser window makes an HTTP request, the Operating System dynamically generates a TCP Source Port and assigns it to the specific tab in the browser window. Each tab in each browser window in a computer will be assigned a different (unique) TCP Source Port. Generally, the TCP source port assigned to browser tabs is a high number (10000 and greater). In our case let's assume that the OS assigns port number 10801 to this particular browser tab. This will be indicated as the Soure Port in the TCP header.

The HTTP request encapsulated in headers with all of the Source and Destination fields completed will look like this:

Data Link (MAC)70:F4.7D:A5.BC:4FEC:70:2C:5D:AF:F2Layer 2
Network (IP)10.0.0.9110.0.0.10Layer 3
Transport (TCP)1080180Layer 4
 GET / HTTP/1.1 

When this request arrives at Device F, it is forwarded to the web server application that is listening on TCP port 80. The web server creates a response that would look something like this (the ... represents the actual HTML markup generated by the webserver):

Because all of the necessary Source information was included in the Transport, Network and Data Link layer headers, Device F is able to create all the required headers to send this response back to Device A. The response, encapsulated in headers will look like this:

Data Link (MAC)EC:70:2C:5D:AF:F270:F4.7D:A5.BC:4FLayer 2
Network (IP)10.0.0.1010.0.0.91Layer 3
Transport (TCP)8010801Layer 4
  

If you compare the headers encapsulating the HTTP request against the headers encapsulating the HTTP response, you will notice that the Source and Destination fields are reversed depending on the direction the data is traveling (Device A → Device F vs Device A ← Device F).

The IP and Data-Link layer headers ensure that the HTTP response is correctly directed to Device A. When the response arrives at Device A, the response data is forwarded to the browser tab was assigned TCP port 10801. (This will be the same browser tab that had created the HTTP request.)

This concludes a synopsis of how data is transferred between 2 devices in a computer network. It leaves open 2 questions:

  • Layer 1: We have discussed Layers 2 to 4 in our discussion, but we have not mentioned Layer 1. Does it exist in the model being used, and if so where does it fit in?
  • Network devices: Switches, routers firewalls etc. Where do network devices fit in this process of data transfer. How do they affect the transfer of data from one device to another?

Layer 1

There does exist a Layer 1 in the OSI Model. Layer 1 standards and protocols define the details of how data is represented and signalled over the physical medium being used by a network interface. This layer is known as the physical layer. The physical layer may be a wired layer or a wireless layer. The IEEE 802.11 standard includes different options for signalling at the physical layer using a wireless medium. Multiple standards exist at the physical layer for signalling over a wired medium. Some of these include Ethernet physical layer standards such as 10BASE-T, 100BASE-T, 100BASE-FX etc.

The details of signalling at the physical layer falls somewhat outside the scope of the networking field per se, it falls more within the field of electrical or computer engineering. However, it is important to understand one of the features included in Ethernet (and other) standards at the physical layer. This feature is called Carrier Sense Multiple Access / Collision Detection (CSMA/CD). CSMA/CD will be discussed in a separate post.

The role of switches, routers and firewalls in a network

We have discussed how data is encapsulated in multiple headers in order to be transferred from an application (such as a web browser) on one device to another application (such as a web server) on a different device in a network. We have not described the role of network devices such as switches, routers and firewalls in ensuring that the data arrives at the correct destination device. The next blog post discusses this: The role of switches, routers and firewalls in a network.

Want to test your networking skills with hands-on configuration and troubleshooting questions? Try out the Workshops section of this website here: Workshops (Login required).

Read how to use the device simulators on this website here: Workshops - General Instructions

Share this
Have a comment, question or feedback? Join the discussion below.
Yonathan3 years ago
Networking in a nutshell!!!
Daimon3 years ago
It's jargon language hoping i will learn fast
Richard3 years ago
it been interesting reading
Connected Dots Online3 years ago
Thank you for the feedback.
Karan4 years ago
its...good and very helpful ...
Connected Dots Online4 years ago
Thanks for the feedack!
srinidhi4 years ago
amazing content. Earlier I read these concepts n seemed to understand everything .but this content really connected the dots.
thanks for sharing these valuable content for free. you have a big heart n kudo's to the team.
Connected Dots Online4 years ago
Hi Srinidhi,
Thanks for the feedback! Great to hear that the content helped to really connect the dots! ;)
Dawit4 years ago
How did the computers new the destination mac address,while even the switch didn't know where to send to?
Connected Dots Online4 years ago
Hi Dawit,

Check out the first 2 lessons in this course (Routing Baiscs):
https://www.connecteddots.online/courses/routing-basics--connected-routes-and-an-introduction-to-cisco-router-cli

The lessons "Review Network Headers" and "Address Resolution Protocol" cover this exact question!
Dawit4 years ago
Okay, thanks.
Pardon4 years ago
MORE MATERIAL, THISS IS EXCITING
Connected Dots Online4 years ago
More material (including additional interactive content) will be uploaded over the next few months. Keep checking back for updates.
Seyfettin5 years ago
Geliştiri