Computer networks
Tags: computerscience, beginners, localhackday, majorleaguehacking
Published: 2021-01-15 10:21:44

This seems similar to social network but what is this? As in social network people communicate with each other and share their experience or post some cool stuff, computer networks are group of computer sharing resources. 

But how does computer share information with each other does it opens a mobile phone and chat with another computer? No, computer connects with one another either via wire or wirelessly. Well, mobile is also a kind of computer though.

There are many types of computer network and even it could be divided on the basis of many things. Like on the basis of **architecture the network** follows we could have **Client Server Architecture** or **peer to peer architecture**. 



## What is Client Server Architecture?
Imagine working in a company where a team is working on one part of the project and other team is working on some other part of the project. But at some point of time they have to communicate with project lead about their project so that project lead manages both team’s progress. Now your server is just like project lead and client is like the individual teams. Hence a server manages one or more clients so that information could be transferred between client to client via server.



## What is peer to peer architecture?
In a peer-to-peer network, tasks are allocated to every device on the network. Furthermore, there is no real hierarchy in this network, all computers are considered equal and all have the same abilities to use the resources available on this network. Instead of having a central server which would act as the shared drive, each computer that’s connected to this network would act as the server for the files stored on it.

On the basis of **geographic area covered**, network could be divided into three major types such as local area network, metropolitan area network and wide area network. 



Today there are many computers communicating together through **Internet**, which is a global system of interconnected computers that uses some set of rules called **protocols** to communicate and share resources with each other.

We send information from one computer to other in small packets. But how will a packet know which computer to go into? For this we define unique address for every computer on the internet known as the **IP address** (Internet Protocol). Many companies (or Internet service provider) provide broadband or LAN service to users. They provide our computer a unique IP address, through which we could ask and send data.



## How to identify a Computer System on the Internet?
Mostly the computer is identified using IP address in the internet but we need to go into the details of transferring the data between computers. If we want to send a “Hello world” to the computer in other part of the world through internet then first we type the words into the computer, computer identifies it, converts into electrical signal, and transmit over the internet then the computer at other part of the world will translate back into words and display it.

The data before sending from the computer is broken into packets. Each packet contains port number (Port number is the location of the application in the computer requesting the data or sending the data). The destination IP address is also attached to the packet. At last the packet contains Destination MAC address, source MAC address, Destination IP, Source IP, Data, Port number.
The ISP routers examines the destination address in each packet and determines where to send it. 




## What is Network Implementations and Simulations?
Network simulation is the theoretical and entirely virtual model of network made mathematically. It is the implementation of all the features of the network virtually inside a computer system. This is made to test all features in a network and make sure it is ready for implementation. Some network simulating software used are NS2, NS3, qualnet, OPNET etc. Network implementation is actually using the network in real world to test how it works in real world. It is done for quality assurance, proof of concept and for trouble shooting.

We know that the data is being transferred from a computer to one or many computers. These categorizes as unicast, multicast and broadcast. Unicast is when there is participation of single sender and single recipient. Broadcast is when one sender and all recipient. Multicast is between unicast and broadcast where there is one sender and many recipients. 


**IP Address** : Internet Protocol address is a dot separated numeric label assigned to every computer there in the network. Internet Protocol version 4 (IPv4) defines an IP address as a 32-bit number. However, because of the growth of the Internet and the depletion of available IPv4 addresses, a new version of IP (IPv6), using 128 bits for the IP address, was standardized in 1998. This is mostly given by ISP of the internet.
It looks something like 255.255.255.0


**MAC Address** : Media Access Control address are unique 48 bits’ number representing our Hardware, embedded into network card (Network Interface Card) during the time of manufacturing. It is a 12-digit hexadecimal number (6-Byte binary number), which is mostly represented by Colon-Hexadecimal notation.


## Difference between IP and MAC: 
Media access control address is a 6-byte hexadecimal number. It is retrieved using ARP protocol. It is provided by the chip manufacturer. It is static.
Internet Protocol Address can be either 4 byte or 16 bytes. It is retrieved using RARP protocol. It is provided by the internet service provider. It is dynamic.


**Port Number** :  Ports can be thought of as separate channels on each computer. For example, we can browse the internet while reading emails, because these two applications are using different ports. 


Port number is the part of the addressing information used to identify the senders and receivers of messages in computer networking. Different port numbers are used to determine what protocol incoming traffic should be directed to. Port number identifies a specific process to which an Internet or other network message is to be forwarded when it arrives at a server. Ports are identified for each protocol and It is considered as a communication endpoint.


Port is represented by 16 bit numbers. 0 to 1023 are restricted port numbers, used by well-known protocols services. 1024 to 49151 are registered port numbers which can be registered to specific protocols by software corporations and last 49152 to 65536 are used as private ports means they can be used by anybody.



**Network Protocols** : A network protocol is an established set of rules that determine how data is transmitted between different devices in the same network. It allows connected devices to communicate with each other, regardless of any differences in their internal processes, structure or design. There are many protocols but the following are the well-known ones: 

**IP**: Internet protocol delivers packets from the source host to the destination host solely based on the IP addresses in the packet headers. 

**TCP**: Transmission Control Protocol is a set of rules that defines how to establish and maintain a network conversation through which application programs can exchange data. It is responsible for routing application protocols to the correct application on the destination computer. 

**UDP**: User Datagram Protocol is a communications protocol that is primarily used for establishing low-latency and loss-tolerating connections between applications on the internet. It speeds up transmissions by enabling the transfer of data before an agreement is provided by the receiving party. 

Both UDP and TCP run on top of IP and are sometimes referred to as UDP/IP or TCP/IP. TCP sends individual packets and is considered a reliable transport medium. UDP sends messages called datagrams but the service does not provide any guarantees that the data will be delivered or offer special features to retransmit lost or corrupted messages.

**HTTP**:  Hypertext transfer protocol is a TCP/IP based communication protocol, that is used to deliver data (HTML files, image files, query results, etc.) on the World Wide Web. The default port is TCP 80, but other ports can be used as well. It provides a standardized way for computers to communicate with each other. HTTP specification specifies how clients' request data will be constructed and sent to the server, and how the servers respond to these requests.

**FTP**: File transfer protocol is a standard internet protocol provided by TCP/IP used for transmitting the files from one host to another. It is mainly used for transferring the web page files from their creator to the computer that acts as a server for other computers on the internet. 

**RPC**: Remote procedural call is the mechanisms which enable a client to invoke the procedure or method from the server through establishing communication between client and server. It consists ordinary data structures.

**RMI**:  Remote Method Invocation is a similar to RPC but it supports object-oriented programming, a java platform. In RMI, objects are passed as a parameter rather than ordinary data.


All of this happens due to Protocol Stack. The Protocol stack used in the internet is called TCP/IP stack. 


## How does Computer communicate by protocols?
Computer sends and receives data with set of rules called TCP/IP. The rules tell computer how it should send data and in what form to store data so that there is synchronization between the data received and the data send by the computer.  

Computer connects to internet through router or Wi-Fi in your home. The router assigns an IP address for the connection with your computer. When accessing a local computer in our network, our router sends our TCP/IP packets between the local IP addresses. And when we communicate over internet our computer uses the IP address of the ISP not the router.  

When searching a URL in internet let’s say www.google.com our data packet contains our IP address and URL with MAC address of the PC. **DNS (Domain name service)** converts the URL to IP address of the destination server. Once DNS has converted URL into IP address then it is easy for the routers on the internet to know where to route the TCP/IP packet. By heading to different routers, it finally reaches the server or the destination computer.



## One-way and two-way communication in network
One-way communication is direct communication from sender to the receiver. While two-way communication includes a feedback from the receiver to the sender and lets the sender know that the message has been received accurately. Both sender and receiver listen to each other and gather information.



**Network Socket**: A socket is an endpoint of a two-way communication link between two programs running on a network. The socket mechanism provides a means of inter-process communication (IPC) by establishing named contact points between which the communication take place. 

Socket is like a string phone attached to both ends so that the communication between the endpoints could be possible.

Server creates the socket and attaches to a network port addresses and then waits for the client to contact it. The client creates a socket and connects to the server socket. When the connection is established then the transfer of data takes place. 

There are two types of sockets Datagram, which has connection less point for sending and receiving packets and Stream socket, which provides connection oriented flow of data.



## Connection-oriented and connectionless protocols
In connection oriented service we have to establish a connection before starting the communication. When connection is established, we send the message or the information and then we release the connection.

In connectionless the data is transferred in one direction from source to destination without checking that destination is still there or not or if it prepared to accept the message. Authentication is not needed in this.
Connection oriented protocol makes a connection and checks whether message is received or not and sends again if an error occurs, while connectionless service protocol does not guarantee a message delivery.



## URL Parsing
URL parsing is a function of traffic management and load-balancing products that scan URLs to determine how to forward traffic across different links or into different servers.

This was my lab assignment for computer networks this week. And would going to share with you all.

Participating in LHD-build.