Computer Networking

Vibhanshu SinghVibhanshu Singh
12 min read

C - commonly
O - oriented
M - machine
P - particularly
U - used for
T - training
E - educational
R - research

  • Network - computers connected together.

  • Internet - a collection of these computer networks.

How did it start?

ARPA - Advance Research Project Agency

  1. MIT

  2. Stanford

  3. University of Utah

  4. VC, LA

Tim Berner invented WWW (World Wide Web).

The first website is:

World's First Website

and there was no search engine, which means you can’t search anything.

  • The Internet Society sets the protocols and controls the Internet. The protocoling system is done by RFC (Request for Comments).

  • Yahoo, I believe, is the first search engine.

Why do we need these protocols/rules?

to communicate smoothly with each other without having conflicts.

What is a server and a client?

client sends a request to the server and the server sends back a response. Our computer can also be a server when working on a local host.

Protocols?

Protocols are just the rules defined by The Internet Society that how data is being transferred.

  • TCP (Transmission Control Protocol): It will ensure that the data will reach its destination and will not be corrupted on the way.

  • UDP (User Datagram Protocol): Example: Video Conferencing

  • HTTP (Hyper Text Transfer Protocol): used by web browsers, the World Wide Web. It defines the format of the data that how data is being transferred between the client and the server.

IP Addresses:

Format: [x.x.x.x]
where each ‘x’ ranges between 0 to 255
Command to check your own IP Address: “$ curl ifconfig.me -s”

ISP (Internet Service Provider)

For example, AirTel in my case, gives us a modem/router. This modem will have the global IP address. Devices connected to this modem/router will have the same IP address for everyone around the world.

Suppose Device 01 (D01), Device 02 (D02), and Device 03 (D03) are connected to the router/modem. So, the modem/router will give IP addresses to these as well like IP 01 for D01, IP 02 for D02, and IP 03 for D03. These are known as the local IP address. They assign these IP addresses using DHCP (Dynamic Host Configuration Protocol)

Note: When we search google.com from any one of the devices. Google will see only the global IP address, which means Google will recognize that only one device is making the request.
The modem will also decide who was the one who was making the request. Was it device 01, device 02, or device 03?
The modem does that using NAT (Network Address Translation).

Q: We got that which device made the request but now tell me which application made that request.
A: It is determined by the PORT Numbers.
IP will determine where these computers are located and the port number will determine which application made that request.
Example: Online Gaming.
Ports are basically the 16-bit numbers. It means that it has 16 cells and each cell will contain 0’s and 1’s.
The total possible port numbers are 2^16 (= 65,536)

We know that web pages use HTTP. All the HTTP stuff we do happens on Port 80. Like MongoDB has a port number 27017 (correct me if I am wrong), SQL has 1433.

Port numbers from 0 to 1023 are called Reserved Ports. Port numbers from 1024 to 49152 are also registered by some sort of applications. We can use the remaining ones.

Q: What is 1 mbps?
A: 1 mbps = 10^6 bits per second
1 gbps = 10^9 bits per second
1 kbps = 10³ bits per second

There are two ways by which communication between the computers happens.
01: Guided Way: A path is already defined.
02: Unguided Way

Open This.

Q: Why not satellites but cables?
A: Because it is faster

- LAN (Local Area Network): Small houses/offices (Basically limited to an area).
- MAN (Metropolitan Area Network): across a city.
- WAN (Wide Area Network): across countries.
The Internet is actually the collection of all these three layers.

- SONET (Synchronous Optical Networks): carries the data using optical fiber cables hence covering larger distances.
- Frame Relay - a way to connect your LAN to WAN.

-Modem: a device used to convert digital signals to analog signals and vice versa.
- Routers: a device that routes the data packets to the IP Addresses.

Topologies:

A network topology is the physical and logical arrangement of nodes and connections in a network.

Types:

  1. Bus Topology: if the link gets broken then it spoils the internet.

  2. Ring Topology:
    Limitations:

    1. If the cable gets breaks then we can’t send the data.

    2. Unnecessary calls are made, if making a call from A to F, then it makes call from B to C also.

  3. Star Topology:
    Limitation: If the control system fails then the network will go down.

  4. Tree Topology (Bus + Star)

  5. Mesh Topology: expansive and scalability issues.

Structure of the Network

Order | Amazon | Delivery Company [US] | Transport
Transport [India] | Delivery Company | Amazon | Received

  • Order and the Received are the Application Layer.

  • The rest is the internet.

OSI Model (Open Systems Interconnected Model)

  1. Application Layer

  2. Presentation Layer

  3. Session Layer

  4. Transport Layer

  5. Network Layer

  6. Data Link Layer

  7. Physical Layer

  • 1, 2, 3, 4 have their own network

  • The router lies somewhere between 4, 5

  • While taking about 5, 6, and 7 they have their own another network

Application Layer: It’s implemented in software where the folks interact with the application. We used to send our data from the application layer to the presentation layer.
Q: What is the idea of the presentation layer?
A: It converts the user data into machine-representable binary format. Encoding and encryption also occur in between. It also provides abstraction.

Then the data is sent to the session layer is helps in managing and setting up the connections and it enables receiving and sending data followed by the terminated sessions.

Then comes the transport layer, responsible for sending the data to the folks easily.

Data received from the session layer is now being segmented into small data units called segments.

And every segment will contain the source, the destination’s port number, and the sequence number (Sequence Number: is basically used to reassemble the segment in the correct order).

The next thing is flow control.

Network Layer: works for the transmission of received data segments from one computer to another that is located on a different network.
Function: Logical Addressing.

Data Link Layer basically allows you to directly communicate with the computer and the hosts (also known as physical addressing [MAC Address = it is 12 digit alpha-numeric number of the network]). It also adds a MAC address.

Next is physical, here we deal with cables and stuff.

Another Model (TCP/IP Model)

  • developed by ARPA

  • similar to the OSI Model but instead of 7 layers, it has only five layers.

  1. Application

  2. Transport

  3. Network

  4. Data Link Physical

  • Application Layer: users interact with this.
    Example: Browsers, WhatsApp, etc.
    Q: Where does it lie?
    A: On your devices.
    Has the same protocols (client-server architecture)

    If we have to create our own server then we should have a reliable IP address that can be reached via clients.
    The collection of servers in a big company is known as the data center. It may have static IP addresses (addresses that do not change), a good internet connection, and a high upload speed.

  • Peer-to-peer architecture (p2p architecture): various applications/devices running on various devices. Here is no one dedicated computer. You can scale it rapidly.
    Example: Torrent.

Protocols

Web Protocols:

  • TCP/IP

  • HTTP - how data is being transferred

  • DHCP - allocates IP address to the people and devices connected to your network.

  • FTP - how files are transferred

  • SMTP - It is used to send the mails

  • POP3/IMAC - Receive mails

  • SSH - how to access the computer’s terminal remotely

  • VNC - it is used for graphical control

  • TELNET - it enables users to connect to a remote host or a device using the TELNET client

  • UDP - stateless connection

Sockets: when we have to send the message from one system to another then we use sockets.

  • Ports (Ephemeral Ports): can exist on the client side but on the server side, you have to know the port number.

HTTP (in detail):

It is a client-server protocol. It is an application layer protocol. So, these application layer protocols also require some transport layer protocol. HTTP uses TCP inside it (it’ll make sure all the data is sent and received) (HTTP = Application Layer and TCP = Transport Layer) (HTTP is also a stateless protocol = Which means the server will not store any data of the client by default).

Note: In links after the “?” are all the arguments.

HTTP Method: is basically telling the server what to do.

  • GET - requesting the data

  • POST - I am a client and want to send something to the server.

  • PUT - Puts data at a specific location.

  • DELETE - want to del. the data from the server

Status Words

  • 1xx - informational

  • 2xx - success

  • 3xx - redirecting

  • 4xx - client error

  • 5xx - server error

Cookies: It is a unique string. It is stored on the client’s browser. It has an expiry date.

Third-Party Cookies: these are the cookies that are set for the websites you don’t visit.

Q: Where are all these IP addresses stored and how do they find that server?
A: Here, comes the picture of DNS (Domain Name System). Basically, domain names are mapped to IP Addresses.

Example: mail.google.com
here, mail = sub-domain, google = second-level domain, and com = top-level domain.
Top-level domains are also known as root-DNS servers. This is the first point of contact for your query.

  • .com - commercial

  • .edu - for educational institute

  • .org - for the non-profit organization

  • .us, .uk, .in - country-specific

These are managed by ICANN.org

Note: Whenever we visit a site for the first time, our computer will store its IP address in the local machine in the form of a cache.
Local DNS Server = the first point of contact

Your ISP has all the information on the sites you visit. No matter its in incognito and if something bad happens they are liable to tell the govt. or the police.

You can’t buy a domain name, you can only rent a domain name.

Transport Layer

Transportation of message from one computer to another is done by the network layer. But within that computer, the transportation of the data from the network to the application is done by the transportation layer.

Box (you) | CC01 (Courier Company of your country) //done by transport layer
// done by network layer
CC02 (Courier Company of your friend’s country) | Box (friend) //done by transport layer
Note: Application Layer also allows you to take care of the congestion control.

Checksums: to check whether the data is corrupted or not. It is like a number. It is used to set the orders.

UDP (User Datagram Protocol)

  • Data may or may not be delivered.

  • Data may change.

  • Data may not be in order.

  • Connectionless Protocol.

UDP Packet:

  1. Source Port Number

  2. Destination Port Number

  3. Length of data gram

  4. Checksum

  5. Data

1, 2, 3, and 4 are known as the header and have a size of 8 bytes, 2 bytes each).
Total size = 2^16
Size of data = 2^16 - 8

Use cases:

  • it’s very fast

  • video call apps

  • DNS (UDP)

  • gaming

TCP (Transmission Control Protocol)

  • transport layer protocol

  • application layer sends a lot of row data (TCP segments). This data is being divided into chunks and add a header. It may also called the data network layer.

  • congestion control

takes care of when data does not arrive and maintains the order of data using sequence numbers.

Features:

  • Connection-oriented

  • Error control

  • Congestion control

  • Bi-directional/Full duplex

one TCP connection is established between two computers only.

3 Way Handshake

Network Layer:

here we work with routers.

  • Transport - segments

  • Network - packets

  • Data Link Layer - frames

    1. Hop-by-hop routing

      1. Forwarding routing

      2. Routing table

192.168.2.30: (192.168.2 = Network Address/Subnet ID || 30 = Device Address/Host ID)
Q: Who creates these routing tables?
A: Control Plane.
- Every router is a node.
- Links between routes are the edges.

Two types of routing

  1. Static: adding address manually

  2. Dynamic: when there is a change in the network they are updated automatically.

Internet Protocol (IP)

The protocol that lies in the networking layer.
IPV4: 32 bits number, 4 words
IPV6: This Is the future. 128 bits number, 8 words
Hoping basically occurs to the ISP’s router (main).
Internet society created classes for this subnet and host ID and whatever.

Class of IP Addresses

  1. Class A: [0.0.0.0 to 127.255.255.255]

  2. Class B: [128.0.0.0 to 191.255.255.255]

  3. Class C: [192.0.0.0 to 223.255.255.255]

  4. Class D: [224.0.0.0 to 239.255.255.255]

  5. Class E: [240.0.0.0 to 255.255.255.255]

Subnet Masking: basically means that the subnet mask is going to mask the network part of the IP address and it will leave us to the host part.

Variable Length Subnet: we can set the length of our subnet network.

In the initial days, the first come first serve has been declared. So, MIT, Stanford and etc etc took the class A IP addresses.

ITEF (Internet Engineering Task Force)

It assigns the IP addresses based on the region so that hopping can be minimized.
Some of the IPV4 addresses are reserved. Example: localhost = 127.0.0.1. These are known as loopback addresses.

IPV4 vs IPV6

IPV4 = 2 ^ 32 = 4.3 billion

IPV6 = 2 ^ 128 = 3.4 × 10 ^ 38

Cons of IPV6:

  1. not backward compatible

  2. ISPs would have to shift to a lot of hardware ware

Representation: There are 8 numbers, each is a hexadecimal digit which represents 16-bit part of the addresses.
Format: a.a.a.a.a.a.a.a (each is a hexadecimal number of 16-bit)

Middle Boxes: an extra device that also interacts with the IP packets.

Data Link Layer is responsible to transfer the received packets over the physical link.
DHCP servers have a pool of IP addresses.
But at the end of the data link layer they communicate with each other using link-layer address/MAC address [not of the device but of the component].

Note:

This blog is not a professional blog. It’s just for my revision. You can also prefer it if you want to. Thanks for reading. :)

0
Subscribe to my newsletter

Read articles from Vibhanshu Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vibhanshu Singh
Vibhanshu Singh