Computer Networking

Abdul Rafay
15 min readMar 16, 2022

In this Blog, You will Learn

  • Network & Internet
  • Client-Server Architecture
  • Protocol
  • IP Addresses
  • How Data is Transferred?
  • Port Number
  • How is the Internet connected between countries and continents?
  • Types of area networks — LAN, MAN and WAN
  • Computer Network Topologies
  • OSI Model (Open System Interconnection Model)
  • TCP/IP Model
  • HTTP Protocol
  • How does email work?
  • DNS (Domain Name System)
  • UDP (User Datagram Protocol)
  • TCP (Transmission Control Protocol)
  • IP (Internet Protocol)

Network

Computers are connected; it is a network.

Internet

Internet is the collection of these networks.

How did it all start?

The ARPANET, one of the earliest computer networks, was introduced by Leonard Kleinrock in his 1961 article entitled “The Flow of Information in the Large Communication Network.”

To describe the data sent between computers on a network, Donald Davis coined the term “packet” in 1965.

Client-Server Architecture

Client-server architecture is a computer network architecture in which many clients request and receive service from a centralized server.

Client-Server Architecture

In the client-server architecture, when the client computer sends the data request to the server, it accepts the request, processes it, and returns the requested data packet to the client.

Peer-to-Peer Architecture

Peer-to-peer architecture, or P2P, is a network where members connect directly without a mediator. It is a commonly used computer networking architecture in which each workstation or node has the same capabilities and responsibilities.

Protocol

A protocol is a set of rules defined by the Internet Society for formatting and processing data.

IP address

An IP address is a unique address that identifies a device on the Internet or a local network. IP stands for “Internet Protocol,” a set of rules that govern the format of data transmitted over the Internet or local network.

All the connected devices that talk to each other have an IP address.

Sockets

Sockets are just like some connection between two applications. It is a gateway between application and network.

Cookies

Cookies are a unique string stored in the client’s browser. When a client first views a site, they set a cookie. After that, when the client makes a new request, the cookie will also be sent.

How is Data Transferred?

  • The Internet Service Provider (ISP) gives you a modem/router with a global/public IP address.
  • For everyone globally, all devices connected to a modem/router have the same IP address (global/public IP address).
  • The modem/router assigns IP addresses (local/private IP addresses) to their connected devices.
  • Local IP addresses are assigned using the DHCP protocol.
  • DHCP (Dynamic Host Configuration Protocol) is a protocol that provides fast, automated and centralized management of IP address distribution across networks.
  • If a connected device requests a Google webpage, it is from a public IP address for Google’s server.
  • The modem/router uses NAT (Network Address Translation) to determine who has requested.
  • The IP address determines the device that sends the data, and the Port Number is used to determine the application that sends the data on that device.

Ports

The IP address indicates which device we are working with, and the port indicates which application we are working with.

Port Number

The port is a 16-bit number. Therefore, the total number of possible ports is ²¹⁶.

How is the Internet connected between countries and continents?

Today, 99% of international Internet traffic is delivered not by satellites but by a complex network of hundreds of thousands of miles of underwater cables laid on the ocean floor. Today, there are dozens of these cables connecting countries and continents worldwide, and modern cables can transfer data at speeds of over 160 terabits per second.

Click to see the complete Submarine Cables Map.

Types of area networks — LAN, MAN, and WAN

Local Area Network (LAN)

Local Area Network (LAN)

A local area network (LAN) is a collection of devices connected in one physical location, such as a building, office, or home.

Metropolitan Area Network (MAN)

A metropolitan area network (MAN) is a computer network that connects computers in a metropolitan area. A metropolitan area is any large area with a single city, multiple cities, towns, or buildings. MAN is more significant than a local area network (LAN) but smaller than a Wide Area Network (WAN).

Wide Area Network (WAN)

A Wide Area Network (WAN) is a computer network covering a wide geographic area, including regions, countries, continents, and even the entire world. The WAN includes technology for transmitting data, image, audio, and video information over long distances and across various LANs and MANs.

What is Modem?

A modem is a device used to convert a digital signal to an analog signal and vice versa.

Computer Network Topologies

Point-to-Point

A point-to-point network includes two hosts, such as computers, switches, routers, and back-to-back servers connected using a single cable.

Point-to-Point

Bus Topology

All devices share a single communication line or cable in a bus topology. Bus topology problems can occur when multiple hosts are sending data simultaneously. If the shared communication line fails, all other devices can fail.

Bus Topology

Ring Topology

Each host machine connects precisely to the other two machines in a ring topology, creating a circular network structure. If one host attempts to communicate or send a message to a non-adjacent host, the data will pass through all intermediate hosts.

Ring Topology

Failure of any host results in failure of the whole ring.

Star Topology

All hosts in the Star topology use point-to-point connections to connect to a central device called a hub device. There is a point-to-point connection between the host and the hub.

Star Topology

If the hub fails, the connectivity of all hosts to all other hosts fails.

Tree Topology

It is also known as a hierarchical topology, and it is the most common form of network topology currently in use. This topology is mimicked as an extended star topology and inherits the properties of the bus topology.

Tree Topology

Mesh Topology

In this type of topology, hosts are connected to one or more hosts. This topology has hosts that have point-to-point connections with all other hosts. Alternatively, you may have a host that has a point-to-point connection with only a few hosts.

Mesh Topology

It is expensive and has scalability issues.

OSI Model (Open System Interconnection Model)

There are seven layers in OSI model.

OSI Model

Application Layer

The application layer is implemented in software. The user interacts with the software on this layer. Data is moved to the presentation layer.

The main protocols used in the application layer are:

HTTP stands for Hypertext Transfer Protocol. This protocol allows us to access data on the World Wide Web. It transfers data in the form of plain text, audio, video. It is known as a hypertext transfer protocol because it can be used in a hypertext environment where it can jump from one document to another.

SNMP stands for Simple Network Management Protocol. It is a framework used to manage devices on the Internet using the TCP / IP protocol suite.

SMTP stands for Simple Mail Transfer Protocol. The TCP / IP protocol that supports email is a simple mail transfer protocol. This protocol is used to send data to another email address.

DNS stands for Domain Name System. An IP address is used to identify a host’s connection to the Internet. However, people prefer to use names instead of addresses. Therefore, the system that maps the name to the address is called the domain name system.

TELNET is an acronym for Terminal Network. It connects the local computer to the remote computer in such a way that the terminal is known in the local terminal remote system.

FTP stands for File Transfer Protocol. FTP is a standard Internet protocol that transfers files from one computer to another.

Presentation Layer

The presentation layer converts the raw data to machine representable binary form (ASCII to EBCDIC conversion). Then the data is sent to the session layer. Before the data is transmitted further, it goes under encoding and encryption (ensure that data is only readable to the end-user). Data is also compressed, so it is easy to transport extensive data. The SSL protocol is used for encryption and decryption.

Session Layer

Session Layer helps set up and manage the connections and enables sending and receiving data. Before a session is established, it will do authentication and authorization.

Transport Layer

Segmentation:

The data received from the session layer is divided into smaller data units called segments. Each segment will have a source and destination port number and a sequence number. The sequence number helps to reassemble the segments in the correct order.

Flow Control:

The transport layer controls the amount of data that has been transported.

Error Control:

It also controls data loss or corrupted data. It also adds checksum to each data segment to determine if the data received by the end-user was good.

Network Layer

The network layer transfers received data segments from one computer to another located in a different network. The router resides on the network layer. IP addressing is a function of the network layer. It assigns sender and recipient IP addresses to each segment and creates an IP packet.

Data Link Layer

The data link layer allows communication with the hosts. The physical addressing (MAC addressing) is done at the Data Link Layer. MAC address is a 12 digit alphanumeric number of a computer’s Network Interface. MAC addresses of sender and receiver are assigned to the data packets to form a frame.

Physical Layer

The physical layer is the bottom layer in the OSI model, which is the physical and electrical representation of the system. It consists of various network components such as power plugs, connectors, receivers, cable types, etc.

TCP/IP Model

HTTP Protocol

It is an application layer protocol for distributed, collaborative, hypermedia information systems that allow users to communicate data on the World Wide Web.

HTTP allows users to interact with web resources such as HTML files passing hypertext messages between clients and servers. HTTP clients typically use Transmission Control Protocol (TCP) connections to communicate with servers.

HTTP Methods

GET means you are requesting some data.

POST: Client giving some data to the server.

PUT data at a specific location.

DELETE data from the server.

Response Status Codes

1XX → (informational)

The request was received continuing process.

2XX → (successful)

The request was successfully received, understood, and accepted.

3XX → (redirection)

Further action needs to be taken in order to complete the request.

4XX → (client error)

The request contains the wrong syntax or cannot be fulfilled.

5XX → (server error)

The server failed to fulfill a valid request.

Client request

GET / HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

Server response

HTTP/1.1 200 OK
Date: Mon, 23 May 2005 22:38:34 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 155
Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)
ETag: "3f80f-1b6-3e1cb03b"
Accept-Ranges: bytes
Connection: close

<html>
<head>
<title>An Example Page</title>
</head>
<body>
<p>Hello World, this is a very simple HTML document.</p>
</body>
</html>

How does email work?

  • Application layer protocols for sending emails are SMTP (Simple Mail Transfer Protocol) and Pop3.
  • Email use TCP (Transmission Control Protocol) as Transport Layer protocol.
Email Sending
  • The sender sends its mail to its SMTP server.
  • Sender’s SMTP server makes a connection with the receiver’s SMTP server.
Emails Recieving

POP (Post Office Protocol)

All sent messages are stored on the POP server until the user logs in using the email and pulls the message to their computer. After the message is downloaded by the user, it is deleted from the server.

As we know that SMTP is used to transfer email messages from server to server, POP is used to collect the email with an email client from the server, and it does not include sending messages.

IMAP

IMAP stands for Internet Message Access Protocol, and it is an open standard that describes access to email messages. While IMAP is an integral part of receiving email, it is not the easiest to use (or understand)

POP vs. IMAP

POP3 pulls email from one server to another computer, then deletes the email from the server.

On the other hand, IMAP stores the messages on the server and synchronizes the messages across multiple devices.

DNS (Domain Name System)

When you type any URL (https://www.google.com/) and press enter, it will use DNS to find the server’s IP address (Google’s Server).

Functions of DNS

  • Map URL is to IP addresses and vice versa
  • Load distribution

Why DNS?

The IP address of each webpage is difficult to remember.

DNS port number 53.

Local DNS stores the URL — IP mapping of the recently visited webpage in your local cache.

DNS Hierarchy

  • Root DNS has addresses of TLD DNS Servers.
  • TLD DNS — Top Level Domain
  • Authoritative DNS is the final holder of the IP of the domain you are looking for.

When the user searches any website, it first checks the local cache. If the URL — IP mapping is not in the cache, it goes to the Local DNS (Internet Service Provider). If the local DNS does not have the URL — IP mapping record, it will proceed to Root DNS. Root DNS provides the addresses of TLD DNS servers. It goes to the address of that TLD DNS server. TLD gets the IP address of the requested website from the Authenticative Server of the website.

Tansport Layer

Multiplexing /Demultiplexing to Transport Layer

The transport layer gets data from different devices. To ensure that the order of data is the same from sender to recipient and from which application the data is sent, MUX the data from different applications and DEMUX at the receiver’s end.

Data from different applications is first sent to the sockets. Sockets have port numbers. The transport layer will attach the socket port number with the data packet to know from where the data is coming and to which application we have to send the data.

  • The transport layer also takes care of congestion control.
  • Congestion Control algorithms built-in TCP.
  • Checksum is an error detection method that is used to detect corrupt data packets.

Transport Layer Protocols

  • UDP
  • TCP

UDP (User Datagram Protocol)

It is used to transport data from Transport Layer to Network Layer and vice versa.

  • It is a connectionless protocol. No connection will be established between the two systems before communication.
  • Data may or may not be delivered in UDP.
  • Data may change.
  • Data may not be in order.

Use cases of UDP

  • It is faster than TCP.
  • Apply in video conferences.
  • DNS uses UDP.
  • Gaming …

UDP Header

TCP (Transmission Control Protocol)

  • Application Layer sends raw data.
  • TCP segments this data (divide into chunks) and add headers.
  • TCP takes care of
  • — when data does not arrive
  • — maintains the order of the data using the sequence number.

Sequence Number

Each byte of data in TCP is identified by a sequence number. To rebuild data in order, the sequence number identifies the order of the bytes sent from each computer, even if the data is delivered out of order.

Features

  • Connection-oriented
  • Error Control
  • Provide Congestion Control
  • Full Duplex (Both the connected system can send and receive data)

Three-Way Handshake

TCP uses a three-way handshake to establish reliable connections. The connection is full-duplex, and both sides synchronize (SYN) and acknowledge (ACK) each other. These four flags are exchanged in three stages — SYN, SYN-ACK, and ACK — as shown in Figure Bellow.

Three Way Handshake

Step 1 (SYN): In the first step, the client wants to set up a connection with the server, so it sends a segment with the SYN(Synchronize Sequence Number) that informs the server that the client is likely to start communication with which order number it starts segments.

Step 2 (SYN + ACK): The server responds with SYN-ACK signal bits set to the client request. Acknowledgment (ACK) shows the response to the segment it received, and SYN indicates which order number it is likely to start segments with.

Step 3 (ACK): In the last part, the client acknowledges the server’s response, and they both set up a reliable connection with which they will start transferring the actual data.

TCP Header

Network Layer

Here we work with routers.

If user A wants to send a message to user B, many routers will be connected between them. Every single router has its Network Address. Every router has a forwarding table. A router forwards a packet by analyzing the value of a field in the arriving packet’s header and then using this header value to index into the router’s forwarding table. The value stored in the forwarding table entry for that header indicates the router’s outgoing link interface to which the packet is to be forwarded.

Internet Protocol (IP)

The Internet Protocol (IP) is a protocol, or set of rules, for routing and addressing packets of data so that they can travel across networks and arrive at the correct destination.

Subnet

A subnet, or subnetwork, is a network inside a network. Subnets make networks more efficient. Network traffic can travel a shorter distance through subnetting without passing through unnecessary routers to reach its destination.

IPv4 addresses are presented in the form of four decimal numbers separated by periods, like 203.0.113.112. (IPv6 addresses are longer and use letters as well as numbers.)

Every IP address has two parts.

  • The first part indicates which network the address belongs to.
  • The second part specifies the device within that network.

However, the length of the “first part” changes depending on the network’s class.

Networks are categorized into different classes, labelled A through E. Class A networks can connect millions of devices. (Class D and Class E networks are not commonly used.) Class B networks and Class C networks are progressively smaller in size.

Classes of IP addresses and their ranges

  • Class A → 0.0.0.0–127.255.255.255
  • Class B → 128.0.0.–191.255.255.255
  • Class C → 192.0.0.0–223.255.255.255
  • Class D→ 224.0.0.0–239.255.255.255
  • Class E → 240.0.0.0–255.255.255.255

Subnet Mask

A subnet mask is a 32 bits address used to distinguish between a network address and a host address. A subnet mask identifies which part of an IP address is the network and host addresses. They are not shown inside the data packets traversing the Internet. They carry the destination IP address, which a router will match with a subnet.

Methods of Subnet Masking

We can subnet the masking process in two ways: Straight or Short-cut.

1) Straight

You should use the binary notation method for both the address and the mask and then apply the AND operation to get the block address.

2) Short-Cut Method

  • If the byte in the mask is 255, you need to copy the byte to the destination address.
  • When the byte in the mask is 0, you need to replace the byte in the address with 0.
  • When the byte in the mask is neither 255 nor 0, you should write the mask and address in binary and use the AND operation.
  • In case the extracted network address matches the local network ID, and the destination is located on the local network. However, if they do not match, the message must be routed outside the local network.

What is IPv4?

IPv4 (Internet Protocol version 4) is the standard address format that lets all machines on the internet communicate with one another. IPv4 is written as a 32-bit string of digits, and an IPv4 address is composed of four numbers, each between 0 and 255, separated by periods.

192.168.1.1

What is IPv6?

IPv6 (Internet Protocol version 6) is an updated standard for identifying computers on the internet. Like IPv4, it gives every device a unique identifier, but one adjusted to accommodate the increasing number of computers connected to the internet today.

IPv6 increases the number of possible IP addresses from IPv4’s 4 billion up to 340 trillion trillion trillion. IPv6 is written as a 128-bit hexadecimal string of digits, and a specific IPv6 address looks something like this:

2001:0ab8:85a2:0000:0000:8a3e:0370:7334

Middlebox

A middlebox is a computer networking device that transforms, inspects, filters, and manipulates traffic for purposes other than packet forwarding. Examples of middleboxes include firewalls, network address translators (NATs), load balancers, and deep packet inspection (DPI) boxes.

Summary

I hope you learn something today, you can share your learning on Your Social Media Platform, and it’s my pleasure that I helped you with something. If you still have any questions, you can connect with me and I am happy to assist you with them.

Abdul Rafay — | LinkedIn

www.linkedin.com

If this post was helpful, please click the 👏 Button below to show your support for the author.

--

--