Networking In Real World

Networking In Real World

Hop into world of computer networks

ยท

10 min read

One of the most significant technological advancements of the 21st century that promote communication, Information Transfer, Business growth, Entertainment, and connectivity. Yes, I am talking about the Internet, a network of networks. It is a worldwide system of computer networks.

Now the question is what is this computer network?

In Simple words, it is the collection of connected devices to share resources or exchange information.

Now there might be multiple questions poping how can we connect with other devices (computers/ systems/ servers)? how can we share information with them? , are there any standards associated to send information ?๐Ÿค”

Let's see ๐Ÿ”ญ

Consider this analogy someone wants to send a parcel/ letter to a person named Sheldon at his workplace/ office. For this, they need to know Sheldon's workplace address now the parcel can reach Sheldon but there is a challenge there might be multiple departments present at the office. So the sender also needs to mention the department where Sheldon works.

This whole situation is very similar to how a network packet travels from a senders machine to a receivers machine. Every machine/ device over a network can be identified with a unique identifying number assigned its called the IP Address. The sender machine needs to mention the IP address of the receiver's machine to send the network packet to them.

Now think again the packet that is sent, is been sent just to the receiver's machine but which program in the receiver machine the packet should be delivered to is the challenge and to solve this we have the port numbers. Programs in the machine have a number associated with them this is called a Port Number so the sender will be sending the network packet with the receiver machine IP and port number.


We came across multiple important terms in this discussion so far Let's understand them in detail and explore more such terms ...


Computer Network and Its Types

A computer network is a group of interconnected devices like computers, servers, switches, routers, hubs, etc. They are connected with the moto to share resources or exchange information via network packets.

There are several types of computer networks:

  1. Local Area Network (LAN): It connects devices over a small geographic region like homes, offices, campuses, or buildings and is usually of private ownership.

  2. Metropolitan Area Network (MAN): It connects and operates in large areas such as a city.

  3. Wide Area Network (WAN): It connects devices across different geographic locations like cities or countries.

Network Protocols

In a Computer network, the network packets are used to exchange information, Here we need to note the network packets and ways to communicate are been governed by a set of rules and standards these are known as Network Protocols.

There are multiple different types of network protocols each meant for its own purpose. eg. HTTP, TCP/IP, SMTP, etc.

These play a crucial part in the network they ensure that the devices can communicate with each other effectively and efficiently.

IP Address

An IP address stands for Internet Protocol address it is a unique identification number assigned to a device over the network.

Types of IP address:

  • IPV4

    • Internet Protocol version 4 (IPV4) is 32-bit in size. computers understand binary but this doesn't work for humans so we split the 32 bits into 4 octets each of 8 bits and in decimal, we can represent them as a number ranging from 0 to 255. with IPV4 we can assign 4,294,967,296 IP's to different devices.

    • IP Address classification and Structure:

      • Public IP address:

        To connect to the public world (internet) we are assigned a public IP address by our Internet service providers (ISP) these can be dynamic IP's or static IPs. Dynamic IPs are those IPs assigned to the user by the ISP from a pool of public IP addresses while static IPs are those assigned to the user by the ISP which don't change i.e fixed in nature.

        Without a public IP, we can't connect to the internet or the outside world.

      • Private IP address:

        Private IP addresses are the ones that allow organizations to create their own private network with their help of it. we can't connect to the outside world on private IP.

      • Previously for better management, depending on the numerical order they are also classified as IP classes: class A, B, C, and so on.

      • Structure of IP Address:

        • An IP address has a structure in a similar way that a postal address has a structure. A postal address is a multi-level route to the destination eg. Popular Road, Newtown London UK

        • An IP address has 2 level address. The first level consists of the network address and the second level consists of the host address.

        • The network address is the common address for all the devices in that particular network.

๐Ÿฅ‘Fun Fact:

Is 172.217.41156 a valid IP address?

Answer is Yes, the only condition it must satisfy is it should be of 32-bits, by the way this one of the IP of google I got connected with

Just converted the last 2 octets into binary and then instead of forming again 2 octets converted it to a single decimal number

160.196 => 10100000 11000100

now 1010000011000100 in decimal is 41156.

Try doing the same activity :)

  • IPV6

    • In today's world where we have n number of devices around us the number of IP addresses provided by IPV4 becomes limited and to solve this challenge we introduced the IPV6 a 128-bit IP address. In human-friendly form, IPv6 is written as a group of 8 hexadecimal numbers separated with colons(:)

Netmask and Subnets

In the above discussion we saw the structure of an IP address consisting of the network address and the host address but who will be deciding how and from which point to divide this 32-bit number i.e IP into these 2 parts? This task is done with the help of Netmask.

Netmasks are also 32-bit numbers. which we divide into 4 octets each of 8-bit (eg. 255.255.0.0) here each bit present represents either the network or host address. if the bit is set to 1 it represents the network address while if set to 0 it represents the host address.

Netmask helps us to find the number of hosts in the network. Consider an example If netmask = 255.255.255.0 and we have to find the number of hosts in the network.

At the most, we get all the decimal numbers converted to binary further we count for the number of zeros, and then we have 8 zeros so in total we can have 2^8 i.e 256 hosts in this network range.

Consider we are given an IP of a device 192.168.2.56 also we are provided with the netmask i.e 255.255.0.0 here we can easily say as the initial 16 bits are filled with bits set to 1 so the network range is 192.168.0.0/16.

But when we are provided with some uncommon kind of netmask say 255.255.252.0 how can we find the network range? There are some standard ways we can follow to get the network range if the netmask and IP address are provided

  • Convert the netmask into binary form.

    255.255.252.0 => 11111111 11111111 11111100 00000000

  • Convert the IP into binary form

    192.168.2.56 => 11000000 10101000 00000010 00111000

  • Perform AND operation between the netmask and IP which we converted into binary form

  • Convert the result into decimals considering to form 4 octets each of 8-bit.

    11000000 10101000 00000000 00000000 => 192.168.0.0

  • The result obtained is our network range. => 192.168.0.0

Subnet i.e subnetwork is a smaller network that is created by partitioning a larger network into smaller and manageable segments. these smaller networks have their own unique IP address range and netmask.

Classless Inter-Domain Routing

Classless Inter-Domain Routing (CIDR) is one of the methods for assigning and distributing IP addresses. It replaces the older system of allocating the IP addresses based on classes (A, B, and C) which eventually become inefficient due to the rapid growth of devices and bigger networks establishing

In CIDR we use a notation called "slash notation" to specify the number of bits used in the network portion of the IP address. eg. consider the IP 192.168.34.47 with the CIDR of /24 this means that the first 24 bits of the IP address are used to identify the network and the remaining 8 bits are used to identify the host. we write it as 192.168.34.47/24.

Network Devices

Network devices like switches, routers, hubs, etc are very much important in order to establish a network we can buy these hardware devices and set up the network or we can also use software-defined networking (SDN) which allows us to use software that provides same functionalities as these network devices.

Let's understand some of the network devices:

  1. Switches

    • Switches operate over layer 2 or a data link layer of the OSI model

    • Connects devices over the same network

  2. Router

    • The router operates on the network layer of the OSI model

    • Routers can connect different networks and they can also connect devices over different networks

  3. Network Interface Card (NIC)

    • NIC is a component in the device without which a device cannot be connected over a network it is also called a network interface controller, network adapter, or LAN adapter.

So far we discussed multiple things regarding the networking and network pack.

Quick Question! ๐Ÿ’ก

Can we send a network packet to host machines outside our network ?

Answer is Yes, observer the diagram below

here we have 2 different networks each network having switch to keep connectivity among there devices in there networks and those switches are again attached to a common router to establish connectivity between the two networks.

NOTE: wheather a network packet can travel to outside network depends on the connectivity with outside network but along with this it also depends on the routing rules set in the routing table.

Routing Table

Wheneven the network packet arrive at the router. Router checks its destination address and accordingly takes the routing decisions like which network interface (NIC) to use, is it possible to send the network packet. In all these decisions router takes help of Routing table.

Routing table is a set of rules present in tabular format. they provides information about topology of network immediate around it.

lets understand more on this with a fun practical:

  1. In linux to find the IP of our machine we can use the command # ifconfig <network_card_name> and to check the routing table use the command # route -n

    Note: if you don't find this command in your machine try installing net-tools software

  1. Now routing table consist of 3 main sections destination, genmask and Iface. destination indicates the destination network or destination host, genmask indicates the netmask and Iface indicates the network card.

  2. In the first rule of the routing table we can see destination is 0.0.0.0 and netmask is 0.0.0.0 this means with this rule we can access the internet. although behind the seen the network packet will also go to my ISP further which will provide me with public IP.

  3. Because of this rule we can ping to google, facebook, twitter, etc. here we can see while pinging to google or twitter we get connected to one of there servers and gets there host IP.

  4. Now lets delete the rule from the routing table where destination network is 0.0.0.0 command: # route del -net 0.0.0.0 . After this when we try again to ping to google and twitter with there host IP it is not pingable (Network is unreachable).

  5. Now lets try to create a scenario where we will be able to ping or connect to twitter but not to google. for this we will be creating a rule in routing table

    command: # route add -net 104.244.42.0/24 gw 192.168.1.1 enp0s3 here enp0s3 is my network card name, 192.168.1.1 is my gateway and 104.244.42.0/24 is the destination network we wanted to add.

    after this we can see we could ping to twitter but can't ping to google

    Amazing !๐Ÿ˜ we have created a setup where one can connect to Twitter but can't connect to google. we did this just by few changes in routing table

Additional Learning Resources:

  1. https://curryncode.com/2020/08/31/privatepublic-ess-classes/

  2. https://www.geeksforgeeks.org/what-is-an-ip-address/

  3. Wikipedia

  4. https://www.techtarget.com/searchnetworking/definition/CIDR

That's all for this blog ๐Ÿ™Œ

Thank you For Reading :) #HappyLearning

Any query and suggestion are always welcome- Gaurav Pagare

ย