Networking in Computers ?
Published: 2021-01-19 07:54:44

<!-- wp:paragraph -->
<p><strong><em>Some basic key definitions:</em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li><strong>Bandwidth</strong>: Data transferred per unit time. So 10 Mbps is equal to transfer of 10 million bits every second.</li><li><strong>Throughput</strong>: Total data transmission for a specified time range.</li><li><strong>Latency</strong>:  Transfer delay of  of data packets</li><li><strong>Router</strong>: It helps you connect multiple devices to the Internet, and connect the devices to each other. <ol><li>A router acts as a dispatcher, choosing the best route for your information to travel.</li></ol></li><li><strong>Internet Protocol (IP)</strong>:  Is the address system of the Internet and has the core function of delivering packets of information from a source device to a target device.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","width":684,"height":448,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fd2slcw3kip6qmk.cloudfront.net%2Fmarketing%2Fpages%2Fchart%2Fexamples%2Fcomputernetworkdiagram.png&amp;f=1&amp;nofb=1" alt="" width="684" height="448"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong><em>Q.Is there any difference between URL, URN and URI?</em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Uniform Resource Identifier: A string of characters used to identify a name or a resource on the Internet. A URI has two specializations known as URL and URN.</li><li>Uniform Resource Locator:  Specifies where an identified resource is available and the mechanism for retrieving it. A URL defines how the resource can be obtained.</li><li>Uniform Resource Name:  Uses the URN scheme, and does not imply availability of the identified resource</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Both URNs (names) and URLs (locators) are URIs, and a particular URI may be both a name and a locator at the same time.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://i.stack.imgur.com/2iD7U.jpg" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"textAlign":"center"} -->
<h2 class="has-text-align-center"><em>Application Architecture</em></h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":4} -->
<h4><em><strong>1.Client Server Model:</strong></em></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The client computer sends a request for data to the server through the internet, the server accepts the requested, process it and deliver the data packets requested back to the client. One special feature is that the server computer has the potential to manage numerous clients at the same time. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>A single client can connect to numerous servers at a single timestamp, where each server provides a different set of services to that specific client. <strong>It creates a centralized network.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>An example, would be my computer and the WordPress server. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse1.mm.bing.net%2Fth%3Fid%3DOIP.kZkqt3iyhweRzzQLIyvq8wHaDw%26pid%3DApi&amp;f=1" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4><strong><em>2.Peer to Peer  Model:</em></strong></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>All the computers and devices that are part of them are referred to as peers, and they share and exchange workloads. Each peer in a peer-to-peer network is equal to the other peers. There are no privileged peers, and there is no primary administrator device in the center of the network.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The primary goal of peer-to-peer networks is to share resources and help computers and devices work collaboratively, provide specific services, or execute specific tasks. <strong>It creates a decentralized network.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>An example would be torrent sites, as transfer of data happens from peer to peer.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse2.mm.bing.net%2Fth%3Fid%3DOIP.5n1JaA3f-jDPWjjMHqt-7gHaFH%26pid%3DApi&amp;f=1" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4><strong><em>3.Open System Interconnection model(OSI Model)</em></strong>:</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The OSI model can be seen as a universal language for computer networking. It’s based on the concept of splitting up a communication system into seven abstract layers, each one stacked upon the last.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":560,"height":355,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fexploitbyte.com%2Fwp-content%2Fuploads%2F2019%2F11%2FOSi-fre-min.png&amp;f=1&amp;nofb=1" alt="" width="560" height="355"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong><em>1.Application Layer:</em></strong> </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Acts as an interface between users and software  applications. Data is packed from this interaction to transmit. <strong>Application layer is responsible for the protocols and data manipulation that the software relies on to present meaningful data to the user.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong><em>2.Presentation Layer: </em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Preparing data by converting it into binary code, so that it can be used by the application layer. <strong>The presentation layer is responsible for translation, encryption, and compression of data.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong><em>3.Session Layer: </em></strong> </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The time between when the communication is opened and closed is known as the session. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>The session layer ensures that the session stays open long enough to authenticate, authorize and  transfer all the data being exchanged, </strong>and then promptly closes the session in order to avoid wasting resources. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong><em>4.Transport Layer: </em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Responsible for end-to-end communication between the two devices. This includes <strong>taking data from the session layer and breaking it up into chunks called segments</strong> before sending it.  <strong>The transport layer on the receiving device is responsible for reassembling the segments into data the session layer can consume</strong>. The transport layer is also responsible for flow control and error control. </p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Flow control determines an optimal speed of transmission to ensure that a sender with a fast connection doesn’t overwhelm a receiver with a slow connection. </li><li>Performs error control on the receiving end by ensuring that the data received is complete, and requesting a re-transmission if it isn’t.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong><em>5.Network layer:  </em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Responsible for facilitating data transfer between two different networks. If the two devices communicating are on the same network, then the network layer is unnecessary. <strong>The network layer breaks up segments from the transport layer into smaller units, called packets, on the sender’s device, and reassembling these packets on the receiving device. </strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong><em>6.Data Link layer: </em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Facilitates data transfer between two devices on the same network. <strong>The data link layer takes packets from the network layer and breaks them into smaller pieces called frames.</strong> </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Like the network layer, the data link layer is also responsible for flow control and error control in intra-network communication . The transport layer only does flow control and error control for inter-network communications.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong><em>7.Physical layer: </em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>This layer includes the physical equipment involved in the data transfer, such as the cables and switches. <strong>This is also the layer where the data gets converted into a bit stream, which is a string of 1s and 0s. </strong>The physical layer of both devices must also agree on a signal convention so that the 1s can be distinguished from the 0s on both devices.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":484,"height":482,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="http://programmerprodigycode.files.wordpress.com/2021/01/72b87-picture1.png" alt="" width="484" height="482"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5><strong><em>For more information on OSI model,</em></strong></h5>
<!-- /wp:heading -->

<!-- wp:list {"ordered":true} -->
<ol><li><a rel="noreferrer noopener" href="https://www.youtube.com/watch?v=-6Uoku-M6oY" target="_blank">https://www.youtube.com/watch?v=-6Uoku-M6oY</a></li><li><a href="https://www.freecodecamp.org/news/osi-model-networking-layers-explained-in-plain-english/" target="_blank" rel="noreferrer noopener">https://www.freecodecamp.org/news/osi-model-networking-layers-explained-in-plain-english/</a></li></ol>
<!-- /wp:list -->

<!-- wp:heading {"textAlign":"left","level":4} -->
<h4 class="has-text-align-left"><strong><em>4.Transmission Control Protocol/Internet Protocol (TCP/IP) Model:</em></strong></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Transmission Control Protocol/Internet Protocol (TCP/IP) network provides a framework for transmitting this data, and it requires some basic information from us to move this data.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>There was redundancy and repetition of  functionalities in  different layers in OSI Model, <strong>So we combined Application, Presentation and Session Layer into one layer called Application layer.</strong> This layer was responsible for all the functionalities of three layers.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="http://programmerprodigycode.files.wordpress.com/2021/01/a2edb-tcpip_5_layer_overview.png" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong><em>1.Application Layer: </em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li> Responsible for the protocols and data manipulation that the software relies on to present meaningful data to the user.</li><li>Responsible for converting data into binary code, encrypting data and compressing data, before beginning the session.</li><li>Responsible for ensuring that the session stays open long enough to authenticate, authorize and transfer all the data being exchanged, and then promptly closes the session in order to avoid wasting resources.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong><em>2.Transport Layer: </em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Establishes the connection between applications running on different hosts. It keeps track of the processes running in the applications above it by assigning port numbers to them and uses the Network layer to access the TCP/IP network.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong><em>3.Network Layer: </em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Responsible for creating the packets that move across the network. It uses IP addresses to identify the packet’s source and destination.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong><em>4.Data Link Layer: </em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Responsible for creating the frames that move across the network. These frames encapsulate the packets and use MAC addresses to identify the source and destination.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong><em>5.Physical Layer:</em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The Physical layer encodes and decodes the bits found in a frame and includes the transceiver that drives and receives the signals on the network.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":566,"height":325,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://dtechsmag.com/wp-content/uploads/2020/02/csg25-03-tcp-ip-encapsulation.png" alt="" width="566" height="325"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5><strong><em>For more information on tcp/IP model,</em></strong></h5>
<!-- /wp:heading -->

<!-- wp:list {"ordered":true} -->
<ol><li><a href="https://www.youtube.com/watch?v=3b_TAYtzuho" target="_blank" rel="noreferrer noopener">https://www.youtube.com/watch?v=3b_TAYtzuho</a></li></ol>
<!-- /wp:list -->

<!-- wp:heading {"textAlign":"center","level":4} -->
<h4 class="has-text-align-center"><strong><em>Network Performance:</em></strong></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>We have to minimize the Delay and Packet Loss, and maximize Throughput.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":3410,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2021/01/image.png?w=1024" alt="" class="wp-image-3410"/></figure>
<!-- /wp:image -->

<!-- wp:list {"ordered":true} -->
<ol><li><em><strong>D(proc):</strong> </em>Between the time the packet is correctly received at the head node of the incoming link and the time the packet is assigned to an outgoing link queue for transmission.</li><li><strong><em>D(queue): </em></strong>Between the time the packet is assigned to a queue for transmission and the time it starts being transmitted. During this time, the packet waits while other packets in the transmission queue are transmitted.</li><li><strong><em>D(trans):</em></strong> Between the times that the first and last bits of the packet are transmitted.</li><li><strong><em>D(prop):</em></strong> Between the time the last bit is transmitted at the head node of the link queue and the time the last bit is received at the next router. This is proportional to the physical distance between transmitter and receiver.</li></ol>
<!-- /wp:list -->

<!-- wp:preformatted -->
<pre class="wp-block-preformatted"><strong><em>Total Delay= D(proc)+ D(delay) + D(trans) + D(prop)</em></strong></pre>
<!-- /wp:preformatted -->

<!-- wp:nextpage -->
<!--nextpage-->
<!-- /wp:nextpage -->

<!-- wp:heading {"textAlign":"center","level":3} -->
<h3 class="has-text-align-center"><strong><em>Application Layer</em></strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Protocols Used in Application Layer are:</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong><em>1. Hyper Text Transfer Protocol(HTTP):</em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>This is a basis for data communication in the internet. The data communication starts with a request sent from a client and ends with the response received from a web server.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fultimatepeter.com%2Fwp-content%2Fuploads%2F2013%2F11%2FHTTP-request-response.png&amp;f=1&amp;nofb=1" alt=""/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong><em>Various Methods used are:</em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li><strong>GET Method</strong>: Requests a representation of the specified resource. Requests using <code>GET</code> should only retrieve data.</li><li><strong>HEAD Method</strong>: Asks for a response identical to that of a <code>GET</code> request, but without the response body.</li><li><strong>POST Method</strong>: Used to submit an entity to the specified resource, often causing a change in state or side effects on the server.</li><li><strong>PUT Method:</strong> Replaces all current representations of the target resource with the request payload.</li></ol>
<!-- /wp:list -->

<!-- wp:heading {"textAlign":"center","level":3} -->
<h3 class="has-text-align-center">HTTP Request:</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A simple request message from a client computer consists of the following components:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>A request line to get a required resource. It contains Method, Path and HTTP version.</li><li>Headers. They contain name value pairs.</li><li>An empty line.</li><li>A message body which is optional. Contains extra information to be delivered to the server.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.imperva.com%2Fblog%2Fwp-content%2Fuploads%2Fsites%2F9%2F2017%2F10%2Fparts-of-a-HTTP-request-1.png&amp;f=1&amp;nofb=1" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"textAlign":"center","level":3} -->
<h3 class="has-text-align-center">HTTP Response:</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A simple response from the server contains the following components:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>HTTP Status Code. It contains HTTP version, Status code and Response</li><li>Headers. They contain name value pairs.</li><li>An empty line.</li><li>A message body which is optional. Contains extra information to be delivered to the host.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://www3.ntu.edu.sg/home/ehchua/programming/webprogramming/images/HTTP_ResponseMessageExample.png" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong><em>Types of Status Code:</em></strong> For example 404 or 502 error code,</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>1XX: Information regarding message</li><li>2XX: Information regarding success</li><li>3XX: Information regarding Re directional</li><li>4XX: Information regarding Client</li><li>5XX: Information regarding Server</li></ol>
<!-- /wp:list -->

<!-- wp:heading {"textAlign":"center","level":3} -->
<h3 class="has-text-align-center">HTTPS OVER HTTP ?</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><em>HTTPS is the secured HTTP protocol required to send and receive information securely over internet. Nowadays it is mandatory for all websites to have HTTPS protocol to have secured internet. </em></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Besides the security and encryption, the communication structure of HTTPS protocol remains same as HTTP protocol as explained above.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fwebecreator.com%2Fblog%2Fwp-content%2Fuploads%2F2018%2F06%2F17-sucuri-a-ssl-http-vs-https-chart%402.png&amp;f=1&amp;nofb=1" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"textAlign":"left","level":3} -->
<h3 class="has-text-align-left">2.Domain Name System(DNS):</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>It’s like a global phone book of the internet which contains numeric addresses instead of alphabetic addresses. DNS is a protocol used for exchanging information on the internet, using domain names as the upper layer to match to IP address as the layer beneath it.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>End users access information using domain names, not IP addresses, for example, you are searching for my blog, now instead of remembering the site’s IP address number, you just have to remember the site’s name to connect and access information from it.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":405,"height":312,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.kasperskydaily.com%2Fwp-content%2Fuploads%2Fsites%2F92%2F2016%2F12%2F06015704%2Fdns-normal-en-1024x791.png&amp;f=1&amp;nofb=1" alt="" width="405" height="312"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong><em>There are 4 DNS servers involved in loading a webpage:</em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li><strong><em>DNS re<strong>cursor</strong> </em>- </strong>A server designed to receive queries from client machines through applications such as web browsers and resolve these queries.<strong> Caching is a data persistence process that helps short-circuit the necessary requests by serving the requested resource record earlier in the DNS lookup. </strong><ol><li>The recursor can be thought of as a librarian who is asked to go find a particular book somewhere in a library.</li></ol></li><li><strong>Root nameserver</strong> - The root server is the first step in translating  human readable host names into IP addresses. <ol><li>It can be thought of like an index in a library that points to different racks of books - typically it serves as a reference to other more specific locations.</li></ol></li><li><strong>TLD nameserver</strong> - The top level domain server (TLD) is the next step in the search for a specific IP address, and it hosts the last portion of a host name, for example .in or .com.<ol><li>It can be thought of as a specific rack of books in a library.</li></ol></li><li><strong>Authoritative nameserver</strong> - The authoritative nameserver is the last stop in the nameserver query. If the authoritative name server has access to the requested record, it will return the IP address for the requested host name back to the DNS Recursor that made the initial request.<ol><li>It can be thought of as a dictionary on a rack of books, in which a specific name can be translated into its definition. </li></ol></li></ol>
<!-- /wp:list -->

<!-- wp:heading {"level":4} -->
<h4><strong><em>What is a DNS resolver?</em></strong></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The DNS resolver is the first stop in the DNS lookup, and it is responsible for dealing with the client that made the initial request. The resolver starts the sequence of queries that ultimately leads to a URL being translated into the necessary IP address.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":463,"height":308,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fblog.cloudflare.com%2Fcontent%2Fimages%2F2018%2F04%2Fdns-lookup-diagram.png&amp;f=1&amp;nofb=1" alt="" width="463" height="308"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"textAlign":"center"} -->
<h2 class="has-text-align-center">DNS Query and Response:</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The DNS messages are sent over UDP( smaller than 512 bytes for common requests and responses) or TCP.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://i.imgur.com/68escU5.png" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:list {"ordered":true} -->
<ol><li><strong>Question Section:</strong>This is a section consisting of one or more question records. It is present on both query and response messages.</li><li><strong>Answer Section:</strong> This is a section consisting of one or more resource records. It is present only on response messages. This section includes the answer from the server to the client (resolver).</li><li><strong>Authoritative Section:</strong> This is a section consisting of one or more resource records. It is present only on response messages. This section gives information (domain name) about one or more authoritative servers for the query.</li><li><strong>Additional Information Section:</strong> This is a section consisting of one or more resource records. It is present only on response messages. This section provides additional information that may help the resolver.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><em>Information about flags in header:</em></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li><strong>QR (query/response):</strong> This is a 1-bit subfield that defines the type of message. If it is 0, the message is a query. If it is 1, the message is a response.</li><li><strong>OpCode:</strong> This is a 4-bit subfield that defines the type of query or response (0 if standard, 1 if inverse, and 2 if a server status request).</li><li><strong>AA (authoritative answer):</strong> This is a 1-bit subfield. When it is set (value of 1)it means that the name server is an authoritative server. It is used only in a response message.</li><li><strong>TC (truncated):</strong> This is a 1-bit subfield. When it is set (value of 1), it means that the response was more than 512 bytes and truncated to 512. </li><li><strong>RD (recursion desired):</strong> This is a 1-bit subfield. When it is set (value of 1) it means the client desires a recursive answer. </li><li><strong>RA (recursion available):</strong> This is a 1-bit subfield. When it is set in the response, it means that a recursive response is available. </li><li><strong>Reserved:</strong> This is a 3-bit subfield set to 000.</li><li><strong>RCode:</strong> This is a 4-bit field that shows the status of the error in the response.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://www.oreilly.com/library/view/understanding-tcpip/9781904811718/graphics/1718_11_04.jpg" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"textAlign":"left","level":3} -->
<h3 class="has-text-align-left">3.<em><strong>Email Protocols:</strong></em></h3>
<!-- /wp:heading -->

<!-- wp:image {"align":"center","width":573,"height":300,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fwww.afternerd.com%2Fblog%2Fwp-content%2Fuploads%2F2017%2F11%2Fsmtp-message-flow.png&amp;f=1&amp;nofb=1" alt="" width="573" height="300"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>When ever we are sending mail from Bob to Alice, the protocol followed will be,</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Bob will send the email to his mail server using SMTP.</li><li>Bob's server is going to check if Alice also has the same mail server. <ol><li>If they have same mail server then mail server will allow Alice to pull mail directly from it. An example for Inter organization mail communication.</li><li>If they have different Mail server then, Bob's mail server will send the mail to Alice's mail server and then Alice will be able to pull her mail from her mail server.   </li></ol></li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","width":509,"height":286,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Ftechwelkin.com%2Fwp-content%2Fuploads%2F2016%2F10%2Fpop-vs-imap.jpg&amp;f=1&amp;nofb=1" alt="" width="509" height="286"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3>Q.<em>What do you mean by a Port and a Socket?</em></h3>
<!-- /wp:heading -->

<!-- wp:list {"ordered":true} -->
<ol><li>Port: Just as the IP address identifies the computer, The network<strong> </strong>port identifies the application or service running on the computer. <ol><li>A port number uses 16 bits and so can therefore have a value from<strong> 0</strong> to <strong>65535</strong> decimal</li></ol></li><li>Socket: A connection between two computers uses a socket<strong>.</strong> It is a tuple of IP address and Port.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://qph.fs.quoracdn.net/main-qimg-c152067b268cb84901742c9594bafd14" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:list {"ordered":true} -->
<ol><li>Host A has an application running on port 7, It creates a socket or an endpoint to send /receive information.</li><li>Host B also has an application running on port 81, It creates a socket or an endpoint to send/ receive information.</li><li>Host A and B can communicate over internet/network using their respective sockets.</li></ol>
<!-- /wp:list -->

<!-- wp:heading {"level":5} -->
<h5>For more information on Sockets and ports,</h5>
<!-- /wp:heading -->

<!-- wp:list {"ordered":true} -->
<ol><li><a rel="noreferrer noopener" href="http://www.steves-internet-guide.com/tcpip-ports-sockets/" target="_blank">http://www.steves-internet-guide.com/tcpip-ports-sockets/</a></li><li><a href="https://github.com/kakabisht/CN_Lab/tree/master/socket_programmin" target="_blank" rel="noreferrer noopener">For code on Socket programming in java and python </a></li></ol>
<!-- /wp:list -->

<!-- wp:nextpage -->
<!--nextpage-->
<!-- /wp:nextpage -->

<!-- wp:heading {"textAlign":"center"} -->
<h2 class="has-text-align-center">Transport Layers:</h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":4} -->
<h4><em><strong>1.Transmission Control Protocol (TCP):</strong></em></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The computer sending the data connects directly to the computer it is sending the data it to, and stays connected for the duration of the transfer. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>A real life comparison to this method would be to pick up the phone and call a friend.  Your friend picks up the phone and responds with a hello or a an acknowledgment that he his free to talk right now. When he gives you an acknowledgement, then you start speaking. You have a conversation and when it is over, you both hang up, releasing the connection. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":712,"height":356,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.keycdn.com%2Fimg%2Fsupport%2Ftcp-fast-open.png&amp;f=1&amp;nofb=1" alt="" width="712" height="356"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>This proves the point that TCP connections are:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>A three way setup, connection request -&gt; Acknowledgment -&gt; Start sending data,</li><li>Connection Oriented </li><li>Reliable</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>TCP is a connection-oriented Layer. It moves data in a continuous, unstructured byte stream. Sequence numbers identify bytes within that stream. </strong></p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":461,"height":324,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.ahirlabs.com%2Fwp-content%2Fuploads%2F2018%2F07%2FTCP-HEADER.png&amp;f=1&amp;nofb=1" alt="" width="461" height="324"/></figure></div>
<!-- /wp:image -->

<!-- wp:list {"ordered":true} -->
<ol><li><strong>Source Port</strong> and <strong>Destination Port fields</strong> (16 bits each) identify the end points of the connection.</li><li><strong>Sequence Number field</strong> (32 bits) specifies the number assigned to the first byte of data in the current message. Under certain circumstances, it can also be used to identify an initial sequence number to be used in the upcoming transmission.</li><li><strong>Acknowledgement Number field</strong> (32 bits) contains the value of the next sequence number that the sender of the segment is expecting to receive, if the ACK control bit is set.</li><li><strong>Data Offset(a.k.a. Header Length) field</strong> (variable length) tells how many 32-bit words are contained in the TCP header. This information is needed because the Options field has variable length, so the header length is variable too.</li><li><strong>Reserved field</strong> (6 bits) must be zero. </li><li><strong>Flags field</strong> (6 bits) contains the various flags:<ol><li>URG—Indicates that some urgent data has been placed.</li><li>ACK—Indicates that acknowledgement number is valid.</li><li>PSH—Indicates that data should be passed to the application as soon as possible.</li><li>RST—Resets the connection.</li><li>SYN—Synchronizes sequence numbers to initiate a connection.</li><li>FIN—Means that the sender of the flag has finished sending data.</li></ol></li><li><strong>Window field</strong> (16 bits) specifies the size of the sender's receive window .</li><li><strong>Checksum field</strong> (16 bits) indicates whether the header was damaged in transit.</li><li><strong>Urgent pointer field</strong> (16 bits) points to the first urgent data byte in the packet.</li><li><strong>Options field</strong> (variable length) specifies various TCP options.</li><li><strong>Data field</strong> (variable length) contains upper-layer information.</li></ol>
<!-- /wp:list -->

<!-- wp:heading {"level":5} -->
<h5><strong><em>Applications where TCP is used are:</em></strong></h5>
<!-- /wp:heading -->

<!-- wp:list {"ordered":true} -->
<ol><li>Emails</li><li>Online Transactions </li><li>Socket Programming</li></ol>
<!-- /wp:list -->

<!-- wp:heading {"level":4} -->
<h4><em><strong>2.User Datagram Protocol (UDP):</strong></em></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>UDP does not connect directly to the receiving computer like TCP does, but rather sends the data out and relies on the devices in between the sending computer and the receiving computer to get the data where it is supposed to go properly. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>A real life comparison to this method would be to be send a letter to friend via postal service. You put the letter in the postbox, and then you hope it reaches the destination. Sometimes it does not reach the destination. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="http://classes.dma.ucla.edu/Fall05/161A/projects/Joshua/Project1/images/udp.gif" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>This proves the point that UDP connections are:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>No acknowledgements are involved.</li><li>Fast but no reliable.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>UDP is a connection-less Layer. It has Checksum value for basic detection of faulty data packets.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://www.csestack.org/wp-content/uploads/2017/02/UDP-header-format.png" alt=""/></figure>
<!-- /wp:image -->

<!-- wp:list {"ordered":true} -->
<ol><li><strong>Source Port</strong> and <strong>Destination Port fields</strong> (16 bits each) identify the end points of the connection.</li><li><strong>Length field</strong> (16 bits) specifies the length of the header and data.</li><li><strong>Checksum field</strong> (16 bits) allows packet integrity checking  or error detection in the packet.</li></ol>
<!-- /wp:list -->

<!-- wp:heading {"level":5} -->
<h5><strong><em>Applications where UDP is used are:</em></strong></h5>
<!-- /wp:heading -->

<!-- wp:list {"ordered":true} -->
<ol><li>YouTube</li><li>Online Images </li></ol>
<!-- /wp:list -->

<!-- wp:nextpage -->
<!--nextpage-->
<!-- /wp:nextpage -->

<!-- wp:heading {"textAlign":"center","level":3} -->
<h3 class="has-text-align-center">Sliding Window Protocol:</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A window is a space that holds or can hold multiple bytes. For example, if there is a window of 1000 bytes and the size of the individual message or frame is 100 bytes long. There could be a maximum of 10 messages at any time in the window.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The sliding window is a technique for sending multiple frames at a time. In this technique, each frame has sent from the sequence number. The sequence numbers are used to find the missing data in the receiver end. The purpose of the sliding window technique is to avoid duplicate data, so it uses the sequence number.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":5} -->
<h5><em><strong>1.Go-Back-N Automatic Repeat Request</strong>(<strong>Go back N ARQ):</strong></em></h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>It is a data link layer protocol that uses a sliding window method. In this, if any frame is corrupted or lost, all subsequent frames have to be sent again.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If the receiver receives a corrupted frame, it cancels it. The receiver does not accept a corrupted frame. When the timer expires, the sender sends the correct frame again. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":377,"height":273,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Ftechdifferences.com%2Fwp-content%2Fuploads%2F2016%2F05%2FGo-Back-N.jpg&amp;f=1&amp;nofb=1" alt="" width="377" height="273"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5><em><strong>2.Selective Repeat Automatic Repeat Request(Selective Repeat ARQ):</strong></em></h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The Go-back-N ARQ protocol works well if it has fewer errors. But if there is a lot of error in the frame, lots of bandwidth loss in sending the frames again. So, we use the Selective Repeat ARQ protocol. In this protocol, the size of the sender window is always equal to the size of the receiver window. The size of the sliding window is always greater than 1.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If the receiver receives a corrupt frame, it does not directly discard it. It sends a negative acknowledgment to the sender. The sender sends that frame again as soon as on the receiving negative acknowledgment. There is no waiting for any time-out to send that frame.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Ftechdifferences.com%2Fwp-content%2Fuploads%2F2016%2F05%2FSelective-repeat.jpg&amp;f=1&amp;nofb=1" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>When we have network issue, then we reduce the window size by half to debug the issue. When the window size reaches 1, it is called as Silly window.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"textAlign":"center","level":3} -->
<h3 class="has-text-align-center">Flow Control:</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Flow control methods are techniques that determine the data flow between sender and receiver. <strong>It determines how much data should be send by the sender before receiving acknowledgement. </strong>It makes sender to wait for some sort of an acknowledgement before continuing to send some more data. </p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Avoids the sender from overwhelming the receiver</li><li>Sender transmits the data slowly to the receiver</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","width":492,"height":369,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimage1.slideserve.com%2F1803683%2Ftcp-flow-control-l.jpg&amp;f=1&amp;nofb=1" alt="" width="492" height="369"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Algorithms Used for Flow control are <a rel="noreferrer noopener" href="http://pages.cs.wisc.edu/~suman/courses/640/s18/tcp-part2.pdf" target="_blank">Nagle, Karn and Patridge, and Jacobson.</a></p>
<!-- /wp:paragraph -->

<!-- wp:heading {"textAlign":"center","level":3} -->
<h3 class="has-text-align-center"><strong><em>Congestion Control:</em></strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Congestion is a situation in Communication Networks in which too many packets are present in a part of the subnet, performance degrades. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Congestion in a network may occur when the load on the network is greater than the capacity of the network. </strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Avoid senders from overwhelming the network</li><li>Transmits the data to the network slowly</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Network congestion occurs in case of traffic overloading. We have two Algorithms to help to regulate rate of data transmission and reduces congestion,</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>1.Leaky Bucket:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Suppose we have a bucket with a hole at the bottom of it, now we may input water into the bucket at any rate but the water will pour at a constant rate from the bottom.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://i.pinimg.com/originals/43/d3/ac/43d3ace723f01193afc7043382b967b8.png" alt=""/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><a href="https://github.com/kakabisht/CN_Lab/tree/master/flow_control" target="_blank" rel="noreferrer noopener">Java code for leaky bucket algorithm</a></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>2.Token Bucket:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>To over come the problem of water overflowing in the leaky bucket. We use Token bucket, it has a finite set of tokens. Each packet is given a token, if token are finished then the packet has to wait in a queue, until token becomes available.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":454,"height":449,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.researchgate.net%2Fprofile%2FFurat_Nidhal%2Fpublication%2F325608278%2Ffigure%2Ffig8%2FAS%3A634661147521024%401528326417356%2FFigure-35-The-token-bucket-algorithm-a-Before-b-After-1.png&amp;f=1&amp;nofb=1" alt="" width="454" height="449"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><a rel="noreferrer noopener" href="https://github.com/kakabisht/CN_Lab/tree/master/flow_control" target="_blank">Java code for token bucket algorithm</a></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center"><strong>It's recommended to first put a token bucket and then a leaky bucket in the network.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->
<h4>Q.How to reduce packet drops?</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><strong><em>1.Additive Increase Multiplicative Decrease(AIMD): </em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>It checks the traffic in the network and </p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>If there is less traffic in the network, then increase the window size by 1.</li><li>If there is more traffic in the network, then decrease the window size by half.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong><em>2.Random Early Detection(RED): </em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>It calculates the probability of a packet to be dropped, If the probability is high it will drop it otherwise will enqueue it.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":509,"height":588,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2Ff%2Ffd%2FRandom_Early_Detection_algorithm_en.svg%2F1200px-Random_Early_Detection_algorithm_en.svg.png&amp;f=1&amp;nofb=1" alt="" width="509" height="588"/></figure></div>
<!-- /wp:image -->

<!-- wp:list {"ordered":true} -->
<ol><li><a href="http://www.eecs.umich.edu/courses/eecs489/w07/LectureSlides/lec8_tcp.pdf">http://www.eecs.umich.edu/courses/eecs489/w07/LectureSlides/lec8_tcp.pdf</a></li><li><a href="https://web.cs.wpi.edu/~rek/Undergrad_Nets/C02/TCP_SlidingWindows.pdf" target="_blank" rel="noreferrer noopener">https://web.cs.wpi.edu/~rek/Undergrad_Nets/C02/TCP_SlidingWindows.pdf</a></li></ol>
<!-- /wp:list -->

<!-- wp:heading {"level":5} -->
<h5>For more Information on flow and congestion control:</h5>
<!-- /wp:heading -->

<!-- wp:nextpage -->
<!--nextpage-->
<!-- /wp:nextpage -->

<!-- wp:heading {"textAlign":"center","level":3} -->
<h3 class="has-text-align-center">Network Layer:</h3>
<!-- /wp:heading -->

<!-- wp:heading {"textAlign":"center","level":3} -->
<h3 class="has-text-align-center">Bandwidth and Queue of the Router:</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>How to decide which source will be allowed to first input data packets in Queue router,  to solve this we have three strategies </p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":508,"height":284,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://book.systemsapproach.org/_images/f06-01-9780123850591.png" alt="" width="508" height="284"/></figure></div>
<!-- /wp:image -->

<!-- wp:list {"ordered":true} -->
<ol><li>First in First out: Which ever data packet is first received by the Queue router will be sent on the output link. This approach does not work as different data packages have different sizes.</li><li>Priority Queue: Which ever data packet has more priority than the other will be sent on the output link.</li><li>Fair Queuing: Each source receives a time slice to send it's packet, for example source 1 and source 2 both have a time slice of a min.  </li></ol>
<!-- /wp:list -->

<!-- wp:heading {"level":4} -->
<h4>IP Header:</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>IP header is the peace of information that is inserted by the IP layer while sending the network packet to the remote peer. </p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>For a received message from the peer, the IP layer removes the header.&nbsp; The header information works as a piece of control information for the user data. </li><li>Mainly the IP header does end to end routing and ensures the quality of service.&nbsp; </li></ol>
<!-- /wp:list -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.ictshore.com%2Fwp-content%2Fuploads%2F2016%2F11%2F1013-07-IP_Packet.png&amp;f=1&amp;nofb=1" alt=""/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>The IP packet format consists of these fields:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li><strong>Version field</strong> (4 bits) indicates the version of IP currently used.</li><li><strong>IP Header Length (IHL) field</strong> (4 bits) indicates how many 32-bit words are in the IP header.</li><li><strong>Type-of-service field</strong> (8 bits) specifies how a particular upper-layer protocol would like the current datagram to be handled. Datagrams can be assigned various levels of importance through this field.</li><li><strong>Total Length field</strong> (16 bits) specifies the length of the entire IP packet, including data and header, in bytes.</li><li><strong>Identification field</strong> (16 bits) contains an integer that identifies the current datagram. This field is used to help reconstruct datagram fragments.</li><li><strong>Flags field</strong> (4 bits; one is not used) controls whether routers are allowed to fragment a packet and indicates the parts of a packet to the receiver.</li><li><strong>Time-to-live field</strong> (8 bits) maintains a counter that gradually decrements to zero, at which point the datagram is discarded. This keeps packets from looping endlessly.</li><li><strong>Protocol field</strong> (8 bits) indicates which upper-layer protocol receives incoming packets after IP processing is complete.</li><li><strong>Header Checksum field</strong> (16 bits) helps ensure IP header integrity.</li><li><strong>Source Address field</strong> (32 bits) specifies the sending node.</li><li><strong>Destination Address field</strong>(32 bits) <em>s</em>pecifies the receiving node.</li><li><strong>Options field</strong> (32 bits) allows IP to support various options, such as security.</li><li><strong>Data field</strong> (32 bits) contains upper-layer information.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>Fragmentation</strong>: To distinguish between the ending of a data packet and starting of the another one.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":429,"height":242,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fnotes.shichao.io%2Ftcpv1%2Ffigure_10-9.png&amp;f=1&amp;nofb=1" alt="" width="429" height="242"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong><em>1.IPv4 addresses</em></strong>:</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>An IPv4 address is 32 bit address that uniquely and universally defines the connection of a device.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Address Space</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>An address space is the total number of addresses used by IPv4 protocol. If <strong>N bit</strong> address is used, the total addresses in the address space will be <strong>2<sup>N</sup>.</strong> IPv4 uses <strong>32 bit</strong> addresses then the total number of addresses in the address space is</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>2<sup>32</sup> = 42, 94,967,296</strong></p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":482,"height":281,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.bluecatnetworks.com%2Fwp-content%2Fuploads%2F2019%2F11%2Fipv4-1.png&amp;f=1&amp;nofb=1" alt="" width="482" height="281"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong><em>2.IPv6 addresses</em></strong>:</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>An IPv6 address is 64 bit address that uniquely and universally defines the connection of a device.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Address Space</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>An address space is the total number of addresses used by IPv6  protocol. If <strong>N bit</strong> address is used, the total addresses in the address space will be <strong>2<sup>N</sup>.</strong> IPv6 uses <strong>64 bit</strong> addresses then the total number of addresses in the address space is</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>2<sup>64</sup> = 18,446,744,073,709,552,000</strong></p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2F7%2F70%2FIpv6_address_leading_zeros.svg%2F300px-Ipv6_address_leading_zeros.svg.png&amp;f=1&amp;nofb=1" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>For more information on Logical addressing,</h5>
<!-- /wp:heading -->

<!-- wp:list {"ordered":true} -->
<ol><li><a rel="noreferrer noopener" href="https://notesformsc.org/logical-addressing/" target="_blank">https://notesformsc.org/logical-addressing/</a></li><li><a href="https://www.cpe.ku.ac.th/~plw/dccn/presentation/ch19.pdf" target="_blank" rel="noreferrer noopener">https://www.cpe.ku.ac.th/~plw/dccn/presentation/ch19.pdf</a></li></ol>
<!-- /wp:list -->

<!-- wp:heading {"level":3} -->
<h3>Routing:</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Finding the least expensive way from source to destination for a data packet.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":577,"height":432,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://image.slidesharecdn.com/internet-rtg-protocol-fundamentalsdrvishalsharma1998-11-20-120508075224-phpapp02/95/internet-routing-protocols-fundamental-concepts-of-distancevector-and-linkstate-routing-17-728.jpg?cb=1336464223" alt="" width="577" height="432"/></figure></div>
<!-- /wp:image -->

<!-- wp:list {"ordered":true} -->
<ol><li><strong>Static</strong>: A predefined route has been set from data packet A to B. </li><li><strong>Dynamic</strong>: It dynamically  finds the cheapest route from A to B at each node, the algorithm used here is Bellman ford algorithm.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Algorithm for Bellman Ford,</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Initialize the distance from the source node S to all other nodes as infinite (999999999) and to itself as 0.</li><li>For every node in the graph do</li><li>For every edge E in the EdgeList do</li><li>Node_u = E.first, Node_v = E.second</li><li>Weight_u_v = EdgeWeight ( Node_u, Node_v )</li><li>If ( Distance [v] &gt; Distance [u] + Weight_u_v )</li><li>Distance [v] = Distance [u] + Weight_u_v</li></ol>
<!-- /wp:list -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fpeople.inf.elte.hu%2Fhytruongson%2FBellman-Ford%2F10-bellmanford.jpg&amp;f=1&amp;nofb=1" alt=""/></figure>
<!-- /wp:image -->

<!-- wp:nextpage -->
<!--nextpage-->
<!-- /wp:nextpage -->

<!-- wp:heading {"textAlign":"center"} -->
<h2 class="has-text-align-center">Data Link Layer</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Data-link layer uses some error control mechanism to ensure that frames are transmitted with certain level of accuracy. But to understand how errors is controlled, it is essential to know what types of errors may occur.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>1.Error detection:</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>1.<strong>Parity check</strong>: It counts the number of 1s either they are even or odd.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":338,"height":253,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fwww.liberaldictionary.com%2Fwp-content%2Fuploads%2F2018%2F12%2Fparity-check.jpg&amp;f=1&amp;nofb=1" alt="" width="338" height="253"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>2.<strong>Checksum</strong>: It calculates the hash value of the data packet, if the hash value is equal at both sides then data was error free.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>3.<strong>Cyclic redundancy check(CRC)</strong>: This technique involves binary division of the data bits being sent. The divisor is generated using polynomials. The sender performs a division operation on the bits being sent and calculates the remainder. Before sending the actual bits, the sender adds the remainder at the end of the actual bits. Actual data bits plus the remainder is called a codeword. The sender transmits data bits as codewords.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":527,"height":396,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimage.slidesharecdn.com%2Fcrclinkdin-170901152210%2F95%2Fcyclic-redundancy-check-6-638.jpg%3Fcb%3D1504279544&amp;f=1&amp;nofb=1" alt="" width="527" height="396"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3>Error Correction:</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><strong>1.Hamming code</strong>:</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>They are used to detect errors that helps in recovering the original binary word. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The basic concept of Hamming Code is to add Parity bits to the data stream to verify that the data received is correct or matches with the input. These bits are transmitted in such a way that they identify where the error has occurred in the data stream and rectifies it.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":569,"height":426,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimage3.slideserve.com%2F5545001%2Fhamming-code-layout1-l.jpg&amp;f=1&amp;nofb=1" alt="" width="569" height="426"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In order to detect ’d’ errors, it needs a code with (d + 1) bits and similarly to correct d errors it needs a code with (2d + 1) bits .These Codes uses extra Parity bits to identify the error.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":5} -->
<h5>For more information,</h5>
<!-- /wp:heading -->

<!-- wp:list {"ordered":true} -->
<ol><li><a href="https://users.cis.fiu.edu/~downeyt/cop3402/hamming.html" target="_blank" rel="noreferrer noopener">https://users.cis.fiu.edu/~downeyt/cop3402/hamming.html</a></li></ol>
<!-- /wp:list -->

<!-- wp:heading {"level":3} -->
<h3>Media Access Control:</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A media access control is a network data transfer policy that determines how data is transmitted between two computer terminals through a network cable.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The essence of the MAC protocol is to ensure non-collision and eases the transfer of data packets between two computer terminals. A collision takes place when two or more terminals transmit data/information simultaneously. </p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":5} -->
<h5>1.Carrier Sense Multiple Access with Collision Avoidance (CSMA/CA)</h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Regulates how data packets are transmitted between two computer nodes. This method avoids collision by configuring each computer terminal to make a signal before transmission. The signal is carried out by the transmitting computer to avoid a collision.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Multiple access implies that many computers are attempting to transmit data. Collision avoidance means that when a computer node transmitting data states its intention, the other waits at a specific length of time before resending the data.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>CSMA/CA is data traffic regulation is slow and adds cost in having each computer node signal its intention before transmitting data. It used only on Apple networks.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimage.slidesharecdn.com%2Fcsmamohammedabuibaid-160701034304%2F95%2Fcarrier-sense-multiple-access-csma-15-638.jpg%3Fcb%3D1467345036&amp;f=1&amp;nofb=1" alt=""/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>2.Carrier Sense Multiple Access with Collision Detection (CSMA/CD)</h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Carrier sense multiple access with collision detection (CSMA/CD) is the opposite of CSMA/CA. Instead of detecting data to transmit signal intention to prevent a collision, it observes the cable to detect the signal before transmitting.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Collision detection means that when a collision is detected by the media access control policy, transmitting by the network stations stops at a random length of time before transmitting starts again.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>It is faster than CSMA/CA as it functions in a network station that involves fewer data frames being transmitted. CSMA/CD is not as efficient as CSMA/CA in preventing network collisions. This is because it only detects huge data traffic in the network cable. Huge data traffic increases the possibility of a collision taking place. It is used on the Ethernet network.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimage.slidesharecdn.com%2Fcsmamohammedabuibaid-160701034304%2F95%2Fcarrier-sense-multiple-access-csma-13-638.jpg%3Fcb%3D1467345036&amp;f=1&amp;nofb=14" alt=""/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>3.Demand Priority:</h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The demand priority is an improved version of the Carrier sense multiple access with collision detection (CSMA/CD). This data control policy uses an ‘active hub’ in regulating how a network is accessed. Demand priority requires that the network terminals obtain authorization from the active hub before data can be transmitted.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Another distinct feature of this MAC control policy is that data can be transmitted between the two network terminals at the same time without collision. In the Ethernet media, demand priority directs that data is transmitted directly to the receiving network terminal.<strong>‍</strong></p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":329,"height":277,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fnetworkencyclopedia.com%2Fwp-content%2Fuploads%2F2019%2F08%2Fdemand-priority.jpg&amp;f=1&amp;nofb=1" alt="" width="329" height="277"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>4.Token Passing:</h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>This media access control method uses free token passing to prevent a collision. Only a computer that possesses a free token, which is a small data frame, is authorized to transmit. Transmission occurs from a network terminal that has a higher priority that one with a low priority.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Token passing flourishes in an environment where a large number of short data frames are transmitted. This media access control policy is highly efficient in avoiding a collision. Possession of the free token is the only key to transmitting data by a network node. Each terminal holds this free token for a specific amount of time if the network with the high priority does not have data to transmit, the token is passed to the adjoining station in the network.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse3.mm.bing.net%2Fth%3Fid%3DOIP.IBAaZjkvED_KRlaBUlapvQHaFx%26pid%3DApi&amp;f=1" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center"><strong><em>Code is present at <a rel="noreferrer noopener" href="https://github.com/kakabisht/CN_Lab" target="_blank">https://github.com/kakabisht/CN_Lab</a></em></strong></p>
<!-- /wp:paragraph -->