You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1629 lines
66 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2023-08-16 Wed 21:42 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Computer Networks</title>
<meta name="author" content="Anmol Nawani" />
<meta name="generator" content="Org Mode" />
<style>
#content { max-width: 60em; margin: auto; }
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #e6e6e6;
border-radius: 3px;
background-color: #f2f2f2;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: auto;
}
pre.src:before {
display: none;
position: absolute;
top: -8px;
right: 12px;
padding: 3px;
color: #555;
background-color: #f2f2f299;
}
pre.src:hover:before { display: inline; margin-top: 14px;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-authinfo::before { content: 'Authinfo'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { }
</style>
<link rel="stylesheet" href="src/org.css">
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
displayAlign: "center",
displayIndent: "0em",
"HTML-CSS": { scale: 100,
linebreaks: { automatic: "false" },
webFont: "TeX"
},
SVG: {scale: 100,
linebreaks: { automatic: "false" },
font: "TeX"},
NativeMML: {scale: 100},
TeX: { equationNumbers: {autoNumber: "AMS"},
MultLineWidth: "85%",
TagSide: "right",
TagIndent: ".8em"
}
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body>
<div id="content" class="content">
<h1 class="title">Computer Networks</h1>
<div id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#org9cd6467">1. Introduction</a>
<ul>
<li><a href="#org99c8429">1.1. Some basic terminologies</a></li>
<li><a href="#orgbdddc58">1.2. OSI Model</a></li>
<li><a href="#orgb773ee3">1.3. Unique Identifiers of Computer Network</a>
<ul>
<li><a href="#orga76425d">1.3.1. Hostname</a></li>
<li><a href="#org98ea7f8">1.3.2. IP Address</a></li>
<li><a href="#org466e87f">1.3.3. MAC Address</a></li>
</ul>
</li>
<li><a href="#org514db7d">1.4. Ports</a></li>
</ul>
</li>
<li><a href="#org0164d60">2. Network Models</a>
<ul>
<li><a href="#orga1167d7">2.1. OSI Model</a>
<ul>
<li><a href="#org819ca22">2.1.1. Physical Layer</a></li>
<li><a href="#orga69c543">2.1.2. Data Link Layer (DLL)</a></li>
<li><a href="#org8b391d0">2.1.3. Network Layer</a></li>
<li><a href="#orgcf1456f">2.1.4. Transport Layer</a></li>
<li><a href="#orgf2393f7">2.1.5. Session Layer</a></li>
<li><a href="#org1b35043">2.1.6. Presentation Layer</a></li>
<li><a href="#org1c6166f">2.1.7. Application Layer</a></li>
</ul>
</li>
<li><a href="#orge2048ce">2.2. TCP/IP Model</a>
<ul>
<li><a href="#org3bd3f00">2.2.1. Link layer</a></li>
<li><a href="#org282a19f">2.2.2. Internet layer</a></li>
<li><a href="#org77e944a">2.2.3. Transport layer</a></li>
<li><a href="#orga2a23d3">2.2.4. Application layer</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#org51c9d06">3. Physical Layer</a>
<ul>
<li><a href="#org24f4493">3.1. Network Topology</a>
<ul>
<li><a href="#org1fd355c">3.1.1. Point-to-Point</a></li>
<li><a href="#org73d1586">3.1.2. Daisy chaining</a></li>
<li><a href="#orgf3edb1f">3.1.3. Mesh topology</a></li>
<li><a href="#org2a440e7">3.1.4. Star topology</a></li>
<li><a href="#org6bdd66c">3.1.5. Bus topology</a></li>
<li><a href="#org994566e">3.1.6. Ring topology</a></li>
<li><a href="#org2951587">3.1.7. Tree topology</a></li>
<li><a href="#org3009196">3.1.8. Hybrid topology</a></li>
</ul>
</li>
<li><a href="#orga8b833b">3.2. Digital Modulation</a>
<ul>
<li><a href="#orga6decfd">3.2.1. Bandwidth and maximum data rate</a>
<ul>
<li><a href="#orge836a41">3.2.1.1. Maximum data transfer rate for noiseless wires</a></li>
<li><a href="#org74f8800">3.2.1.2. Maximum data transfer rate for noisy wires</a></li>
</ul>
</li>
<li><a href="#org709c85f">3.2.2. Non-Return to Zero (NRZ)</a></li>
<li><a href="#orgba47841">3.2.3. Increasing bandwidth efficiency by symbols</a></li>
<li><a href="#org2e0dad5">3.2.4. Clock recovery</a>
<ul>
<li><a href="#org83e35b9">3.2.4.1. Manchester encoding</a></li>
<li><a href="#orgfc45c3c">3.2.4.2. Non-Return-to-Zero Inverted (NRZI)</a></li>
<li><a href="#org0dcf6ae">3.2.4.3. 4B/5B</a></li>
<li><a href="#orge986a37">3.2.4.4. Scrambling</a></li>
</ul>
</li>
<li><a href="#orgcb6a702">3.2.5. Balanced signals</a>
<ul>
<li><a href="#orgb52d16a">3.2.5.1. Alternate Mark Inversion (AMI)</a></li>
<li><a href="#org3509b66">3.2.5.2. 8B/10B</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#orgba83308">3.3. Switching</a>
<ul>
<li><a href="#org08c9017">3.3.1. Circuit switching</a></li>
<li><a href="#org8ace8aa">3.3.2. Packet switching</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#org571cce0">4. Data Link Layer</a></li>
</ul>
</div>
</div>
<p>
<hr />
</p>
<div id="outline-container-org9cd6467" class="outline-2">
<h2 id="org9cd6467"><span class="section-number-2">1.</span> Introduction</h2>
<div class="outline-text-2" id="text-1">
<p>
A computer network is collection of two or more computers that can communicate with each other.
</p>
<p>
Computer networks have two basic building blocks
</p>
<ol class="org-ol">
<li><b>Nodes</b> : these are devices that are connected to the network. They can either be network redistribution points or communication endpoints. Example of nodes are computers, routers, switches and other devices on the network.</li>
<li><b>Links</b> : these are the connections between nodes. It includes the type of connectivity (wired or wireless) and the protocols that are used for communication between the nodes.</li>
</ol>
<p>
Computer networks are made of protocols which allow us to send data through links between nodes.
<hr />
</p>
</div>
<div id="outline-container-org99c8429" class="outline-3">
<h3 id="org99c8429"><span class="section-number-3">1.1.</span> Some basic terminologies</h3>
<div class="outline-text-3" id="text-1-1">
<p>
Here, we will look at basic terminologies used in computer networks. Most of these will be expanded on further.
</p>
<ul class="org-ul">
<li><b>Protocol</b> : a set of rules and standards that govern how data is transmitted between nodes in the network.</li>
<li><b>Topology</b> : refers to the arrangement of links and nodes in a computer network. There are eight basic network topologies: point-to-point, ring or circular, mesh, tree, star, bus, daisy chain and hybrid</li>
<li><b>IP Address</b> : it is a unique numerical identifier that is assigned to each node in the network. It's purpose is to identify devices in network allowing us to send and recieve data from them. IP Address stands for Internet Protocol Address.</li>
<li><b>DNS</b> : stands for Domain Name System. It is naming system and a protocol which translates human redable domains (such as <a href="https://git.lomna.xyz/">git.lomna.xyz</a>) and translates it into an IP address of the node from which we need to get data.</li>
<li><b>Firewall</b> : it is a security device which can either be hardware-based or software-based. It controls and monitors incoming and outgoing network traffic and protects from unauthorized access and security threats.</li>
</ul>
<p>
A system which complies with all the protocols can be connected to a network
</p>
<ol class="org-ol">
<li><b>Open System</b> : a system which complies to all network protocols and can be used for communication in network.</li>
<li><b>Closed Sytem</b> : if a system does not comply to all network protocols and thus is not connected to network, unable to communicate.</li>
</ol>
<p>
Computer networks can fall under two broad categories
</p>
<ol class="org-ol">
<li><b>Client-Server Architecture</b> : in this architecture a communicating node can either be a server or a client. The client sends requests to the server, the server fulfills that request and sends a response. There are multiple clients connected to the same server.</li>
<li><b>Peer-to-Peer</b> : in this architecture there is no central server, tasks are divided amongst the nodes. Each node has the same set of capabilities and responsibilities.</li>
</ol>
<p>
<hr />
</p>
</div>
</div>
<div id="outline-container-orgbdddc58" class="outline-3">
<h3 id="orgbdddc58"><span class="section-number-3">1.2.</span> OSI Model</h3>
<div class="outline-text-3" id="text-1-2">
<p>
OSI stands for Open Systems Interconnection. It is a reference model which specifies standards and communication protocols for computer network. It is a 7 layer architecture. Each layer has different functions and protocols. The seven layers are
</p>
<ol class="org-ol">
<li>Physical Layer</li>
<li>Data Link Layer</li>
<li>Network Layer</li>
<li>Transport Layer</li>
<li>Session Layer</li>
<li>Presentation Layer</li>
<li>Application Layer</li>
</ol>
<p>
We don't use the OSI Model and mostly use it as a referencial model. The TCP/IP model is more widely used.
<hr />
</p>
</div>
</div>
<div id="outline-container-orgb773ee3" class="outline-3">
<h3 id="orgb773ee3"><span class="section-number-3">1.3.</span> Unique Identifiers of Computer Network</h3>
<div class="outline-text-3" id="text-1-3">
<p>
In order to establish communication between two nodes, we need to identify the nodes. This is done by using unique identifiers given to devices on a network.
</p>
</div>
<div id="outline-container-orga76425d" class="outline-4">
<h4 id="orga76425d"><span class="section-number-4">1.3.1.</span> Hostname</h4>
<div class="outline-text-4" id="text-1-3-1">
<p>
A hostname is a human readable label that is assigned to a device on the network. On the internet, a hostname is a domain name which has been assigned to a host computer. It is useful to identify devices on a local network.
</p>
</div>
</div>
<div id="outline-container-org98ea7f8" class="outline-4">
<h4 id="org98ea7f8"><span class="section-number-4">1.3.2.</span> IP Address</h4>
<div class="outline-text-4" id="text-1-3-2">
<p>
Also known as the logical address, every device to which a direct communication can be established will have a unique IP address. Interned Assigned Numbers Authority (IANA) assigns and manages ip addresses globally. Previously, ipv4 (version 4) was used and was an address of 32 bits, hence there are \(2^{32}\) unique ipv4 addresses. Because there are limited number of ipv4 addresses, we are running out of them. A new version of ip addresses ipv6 is now implemented. It has addresses of size 128 bits.
</p>
</div>
</div>
<div id="outline-container-org466e87f" class="outline-4">
<h4 id="org466e87f"><span class="section-number-4">1.3.3.</span> MAC Address</h4>
<div class="outline-text-4" id="text-1-3-3">
<p>
Stands for Media Access Control Address. It is also known as the physical address. Every Network Interface Card (NIC) is assigned a unique identifier. These are assigned by the manufacturer and cannot be changed. The length of a MAC address is 48 bits.
<hr />
</p>
</div>
</div>
</div>
<div id="outline-container-org514db7d" class="outline-3">
<h3 id="org514db7d"><span class="section-number-3">1.4.</span> Ports</h3>
<div class="outline-text-3" id="text-1-4">
<p>
A single system has multiple connections and network applications running. A port is a logical channel through which data can be sent or recieved. A port number is always associated with a network address such as an IP address so that we can identify the device whose port was referenced. The unique combination of ip address and port number together is called a <b>socket</b>, example 192.168.0.1:8000
<br />
The ip address and port number are seperated by a colon (:)
</p>
<p>
The ports are divided into three categories.
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="all" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Port Type</th>
<th scope="col" class="org-left">Range</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">Well known ports</td>
<td class="org-left">0 - 1023</td>
</tr>
<tr>
<td class="org-left">Registered ports</td>
<td class="org-left">1024 - 49151</td>
</tr>
<tr>
<td class="org-left">Dynamic ports</td>
<td class="org-left">49152 - 65535</td>
</tr>
</tbody>
</table>
<ul class="org-ul">
<li>The ports from 0 through 1023 are called well-known ports or system ports. They are used by system processes to provide widely used network services. Example, port 20 is for FTP and 80 is for HTTP.</li>
<li>Ports in the range from 1024 to 49151 are user or registered ports. These ports can be freely used by the user. Unlike system ports, most OS will allow applications to use these ports without superuser privelages.</li>
<li>Ports in range 49152 to 65535 are dynamic ports or private ports. They are also called ephemeral ports, because they are used for very short period of time. The TCP, UDP and SCTP typically use ephemeral port for client end of communication. The allocation of ephemeral port is temporary and only valid for short duration of communication session.</li>
</ul>
<p>
<hr />
</p>
</div>
</div>
</div>
<div id="outline-container-org0164d60" class="outline-2">
<h2 id="org0164d60"><span class="section-number-2">2.</span> Network Models</h2>
<div class="outline-text-2" id="text-2">
<p>
A network model defines a way to organize a system's functions and features. It also defines it's structure and protocols.
</p>
<p>
In order to assign functionality to different parts of a network, these models are organized into layered structure. Each layer has a set of functions to perform. Protocols are created to handle functions in each layer. So each layer will have it's own collection of protocols which is called a <i>protocol suite</i>.
</p>
<p>
There are a few guiding principles for creating layers in a network model, such as
</p>
<ul class="org-ul">
<li>Not creating too many layers, as it may lead to unneccessary complexity.</li>
<li>Reduce the number of interactions between the layers</li>
<li>Collect similar functions and seperating fundamentally different functions in different layers</li>
<li>Indentify whether the function of layer is based on hardware or software.</li>
</ul>
<p>
Lower layers are linked with hardware whereas, the upper layers are linked with software.
</p>
<p>
There have been many network models, many of them are no longer used. IBM's SNA model, Apple's AppleTalk and IPX/SPX model are all no longer in use. They were phased out by the popular and most commonly used model today, the TCP/IP model.
<hr />
</p>
</div>
<div id="outline-container-orga1167d7" class="outline-3">
<h3 id="orga1167d7"><span class="section-number-3">2.1.</span> OSI Model</h3>
<div class="outline-text-3" id="text-2-1">
<p>
TODO : Add OSI model image
The OSI model is used as a reference model. This means that it is used to provide building blocks for other network models and compare other network models to improve connectivity and consistency.
</p>
<p>
The OSI model has 7 layers. Each layer has different functionality. The principles applied for the 7 layers are
</p>
<ol class="org-ol">
<li>A layer should be created where a different abstraction is needed</li>
<li>Each layer should should perform a well-defined function</li>
<li>The function for each layer should be chosen with eye toward defining an internationally standardized protocols</li>
<li>Minimize the information flow across layer boundries</li>
<li>The number of layers should be large enough that distinct functions need not be in same layer, but small enough that architecture is not unwieldy</li>
</ol>
</div>
<div id="outline-container-org819ca22" class="outline-4">
<h4 id="org819ca22"><span class="section-number-4">2.1.1.</span> Physical Layer</h4>
<div class="outline-text-4" id="text-2-1-1">
<p>
The lowest layer of the OSI model. Responsible for physical connections between the devices. The physical layer handles data in form of bits and is responsible for transmitting bits without loss from one node to another.
</p>
<p>
Functions of physical layer are
</p>
<ul class="org-ul">
<li><b>Bit Synchronization</b> : the physical layer provides a clok to synchronize sending and recieving of data between nodes</li>
<li><b>Bit rate control</b> : the physical layer also controls the the number of bits sent per second.</li>
<li><b>Physical topologies</b> : topology defines how the nodes and links are arranged in the network</li>
<li><b>Transmission mode</b> : the physical layer defines how data will flow from one node to another. Some transmissions modes are simplex, half-duplex and full-duplex</li>
</ul>
<p>
Hub, repeater, moden and cables are physical layer devices
</p>
</div>
</div>
<div id="outline-container-orga69c543" class="outline-4">
<h4 id="orga69c543"><span class="section-number-4">2.1.2.</span> Data Link Layer (DLL)</h4>
<div class="outline-text-4" id="text-2-1-2">
<p>
This layer is responsible for node-to-mode delivery of the message. It makes sure that data transfer is error-free from one node to another, over the physical layer. When packet enters a network, it is the responsibility of DLL to transmit it to the host using MAC address.
</p>
<p>
The DLL has two sublayers:
</p>
<ol class="org-ol">
<li>Logical Link Control (LLC)</li>
<li>Media Access Control (MAC)</li>
</ol>
<p>
The packet recieved from <b>network layer</b> is divided into frames, depending on the frame size of NIC. The reciever's MAC address is obtained by placing an Address Resolution Protocol (ARP) request, asking for MAC address for given IP address. The destination host replies to the ARP request with it's MAC address.
</p>
<p>
The functions of DLL are
</p>
<ul class="org-ul">
<li><b>Framing</b> : since physical layer only accepts and transmits stream of bits without meaning or structure, the DLL breaks message into recognizable frame with boundries. This is done by attaching special bit patterns at beginning and end of a frame. Breaking message into frames is called framing.</li>
<li><b>Physical addressing</b> : after creating frames, the DLL will add MAC address of the sender and reciever in the header of each frame.</li>
<li><b>Error control</b> : DLL will detect and retransmit damaged or lost frames.</li>
<li><b>Flow control</b> : the data rate must be constant on both sides to not cause corruption in data. Flow control is coordinated by the DLL to avoid this.</li>
<li><b>Access contrl</b> : when a single communication channel is shared by multiple devices, the MAC sub-layer of DLL determines which device has control over the channel at a given time.</li>
</ul>
<p>
DLL is handled by the NIC and device drivers of host machines.
Switch and bridges are example of DLL devices.
</p>
</div>
</div>
<div id="outline-container-org8b391d0" class="outline-4">
<h4 id="org8b391d0"><span class="section-number-4">2.1.3.</span> Network Layer</h4>
<div class="outline-text-4" id="text-2-1-3">
<p>
The network layer controls operations of the subnet.
It is responsible for transmission of data from one host to other located on different subnets. It is also responsible for packet routing i.e, the selection of the shortest path for the packets. The sender and reciever IP addresses are place in the header by the network layer.
</p>
<p>
Routes can be based on static table that rarely changed, or are updated automatically at the start of conversation. Routes can also be highly dynamic to reflect the current network load.
</p>
<p>
Too many packets present in subnet can cause bottlenecks. <b>Handling congestion is also the responsibility of network layer</b>. The <b>quality of service</b> (delay, transit time, jitter, etc.) are also a network layer issue.
</p>
<p>
Functions of network layer are
</p>
<ul class="org-ul">
<li><b>Routing</b> : the network layer determines which route will be used to send packet from sender to reciever.</li>
<li><b>Logical addressing</b> : the network layer identifies the IP addresses of sender and reciever in the network an places them in the header.</li>
</ul>
<p>
The implementation of network layer is in devices such as routers and switches.
</p>
</div>
</div>
<div id="outline-container-orgcf1456f" class="outline-4">
<h4 id="orgcf1456f"><span class="section-number-4">2.1.4.</span> Transport Layer</h4>
<div class="outline-text-4" id="text-2-1-4">
<p>
The data in transport layer is referred to as <b>segments</b>. This layer is responsible for end to end delivery of messages. It also acknowledges successful transmission and re-transmits data if error is found.
</p>
<p>
At sender's side, this layer recieves data from upper layers, performs <b>segmentation</b> and also implements <b>flow and error control</b>. It also adds source and destination port numbers in headers and forwards the segmented data to network layer. The destination port number is configured either by default or manually. example, when requesting web server, we use destination port 80 for the request because it is default port used for HTTP requests.
</p>
<p>
At reciever's side, it performs sequencing and reassembling of segmented data. Then port number is read from the header and data is forwarded to the respective application.
</p>
<p>
Transport layer is an <b>end-to-end layer</b>. It carries data all the way from source to destination. That is, a program on source machine carries on a conversation with similar program on destination machine using headers and control messages. The lower layers, have protocols which communicate between machine and immediate neighbours, not the source and destination. <i><b>Layers 1 to 3 are chained, i.e. communicate with neighbours while layers 4 to 7 are end-to-end.</b></i>
</p>
<p>
Funtions of transport layer are
</p>
<ul class="org-ul">
<li><b>Segmentation and Reassembly</b> : at sender the message from session layer is broken into smaller units called segments, at receiver the segements are reassembled into message.</li>
<li><b>Service Point Addressing</b> : the transport layer determines what type of service is provided to the session layer and ultimately, to the user. The type of service is determined when connection is established via port address.</li>
</ul>
<p>
The service of transport layer is of two types
</p>
<ol class="org-ol">
<li><b>Connection Oriented Service</b> : it is a three phase service that has connection establishment, data transfer and then termination. The receiving node will send and acknowledgment and asks for re-transmission if there is error. This type of transmission is reliable and secure. example, TCP</li>
<li><b>Connectionless service</b> : in this type of transmission, there is no need to establish a connection before data transfer and the receiver does not send an acknowledgement. This approach allows faster communication but is less reliable. example, UDP</li>
</ol>
<p>
Transport layer is operated by the OS. This layer is called the <b>heart of OSI model</b>.
</p>
</div>
</div>
<div id="outline-container-orgf2393f7" class="outline-4">
<h4 id="orgf2393f7"><span class="section-number-4">2.1.5.</span> Session Layer</h4>
<div class="outline-text-4" id="text-2-1-5">
<p>
This layer is responsible for establishing connection, maintanance of communication sessions and authentication. It ensures the security in connection.
</p>
<p>
The services provided by session layer are
</p>
<ul class="org-ul">
<li><b>Connection establishmen and release</b> : The session layer open a connection between two nodes, this connection is called a <b>session</b>. In OSI, transport layer does not terminate the connection, the session layer is responsible for that. In TCP/IP model, this is done by the transport layer.</li>
<li><b>Dialogue control</b> : in a session, there can be three different types of dialogue - two way simultaneous (full-duplex), two way alternate (half-duplex) and one way (simplex). It controls which side has the turn during communication.</li>
<li><b>Synchronization points and resynchronization</b> : this layer allows the two sides to insert synchronization points between dialogue and allow them to resynchronize to a previous synchronization point, aborting the current transmission. This can be used for real-time audio/video.</li>
</ul>
</div>
</div>
<div id="outline-container-org1b35043" class="outline-4">
<h4 id="org1b35043"><span class="section-number-4">2.1.6.</span> Presentation Layer</h4>
<div class="outline-text-4" id="text-2-1-6">
<p>
Also called the translation layer. This layer translates files and data from local formats to standard, transmittable formats.
</p>
<p>
The services provided by presentation layer are
</p>
<ul class="org-ul">
<li><b>Data conversion</b> : example, converting file formats such as bmp to webp which are easier to transmit in a network.</li>
<li><b>Character code translation</b> : changing strings to bits that can be transmitted.</li>
<li><b>Compression</b> : compressing and decompressing data in order to reduce the amount of data has to be sent.</li>
<li><b>Encryption and Decryption</b> : encrypting and decryting of messages for security</li>
<li><b>Serialization</b> : converting complex data structures into flat structures using mechanisms like JSON and XML.</li>
</ul>
</div>
</div>
<div id="outline-container-org1c6166f" class="outline-4">
<h4 id="org1c6166f"><span class="section-number-4">2.1.7.</span> Application Layer</h4>
<div class="outline-text-4" id="text-2-1-7">
<p>
Also called the Desktop Layer. This layer acts as the window for applications to access the network. This layer produces the data which will be transferred over network and displays the information to user. This layer also contains the protocols for interfaces to different functionalities of the web.
</p>
<p>
This layer has protocols such as HTTP, FTP, SMTP, DNS and provides the functionality to use services associated with these protocols.
<hr />
</p>
</div>
</div>
</div>
<div id="outline-container-orge2048ce" class="outline-3">
<h3 id="orge2048ce"><span class="section-number-3">2.2.</span> TCP/IP Model</h3>
<div class="outline-text-3" id="text-2-2">
<p>
TCP/IP was used in ARPANET and now the worldwide Internet. The ARPANET started as a network of hundreds of universities and government installations. When satellite and radio networks were added, they caused problems with existing protocols. This need for a model that can connect multiple networks in a seamless way was the major goal of the TCP/IP model.
</p>
<p>
Another requirment was that connections remain intact as long as the source and destination machines were working, even if some machines or transmission lines were out of operation. So a flexible and robust network was needed.
</p>
<p>
The TCP/IP model had 4 layers, but sometimes physical layer is also included in the model.
</p>
</div>
<div id="outline-container-org3bd3f00" class="outline-4">
<h4 id="org3bd3f00"><span class="section-number-4">2.2.1.</span> Link layer</h4>
<div class="outline-text-4" id="text-2-2-1">
<p>
The requirnment for a robust network led to the choice of packet-switching network based on a connectionless layer that runs across different networks. The link layer describes what links like serial lines and classic ethernet must do to meet needs of this connectionless internet layer. It is not a layer in normal sense, but rather an interface between different hosts and transmission links.
</p>
</div>
</div>
<div id="outline-container-org282a19f" class="outline-4">
<h4 id="org282a19f"><span class="section-number-4">2.2.2.</span> Internet layer</h4>
<div class="outline-text-4" id="text-2-2-2">
<p>
This layer roughly corresponds to the OSI network layer. Its job is to permit hosts to <b>inject packets into any network and have them travel independently to the destination</b>. That is, it will allow packets from go to one network to another while they are going to destination. This property that packets can travel through any network makes the whole network more robust, by allowing communication even if a few networks in some path are down.
</p>
<p>
The packets may even arrive in a completely different order than in which they were sent. If in-order delivery was needed, then it's the responsibility of higher layers to rearrange them.
</p>
<p>
It is similar to the <b>old mail system</b>. When a sequence of international letters are dropped in a mailbox from one country, most mails will be delivered to the correct address in destination country. The mails may not go in the same sequence they we entered in the mailbox. Furthermore, each country (network for our analogy) has it's own stamps, envelope size, and other rules and protocols.
</p>
<p>
The internet layer defines an official packet format and protocol called <b>Internet Protocol</b> (IP), with a companion protocol <b>Internet Control Message Protocol</b> (ICMP) that helps its function.
</p>
<p>
The job of internet layer is to deliver IP packets where they are supposed to go. Packet routing is the major obstacle for this layer. (IP has proven not effective to avoid congestion)
</p>
</div>
</div>
<div id="outline-container-org77e944a" class="outline-4">
<h4 id="org77e944a"><span class="section-number-4">2.2.3.</span> Transport layer</h4>
<div class="outline-text-4" id="text-2-2-3">
<p>
TODO : Here
</p>
</div>
</div>
<div id="outline-container-orga2a23d3" class="outline-4">
<h4 id="orga2a23d3"><span class="section-number-4">2.2.4.</span> Application layer</h4>
<div class="outline-text-4" id="text-2-2-4">
<p>
TODO : Here
<hr />
</p>
</div>
</div>
</div>
</div>
<div id="outline-container-org51c9d06" class="outline-2">
<h2 id="org51c9d06"><span class="section-number-2">3.</span> Physical Layer</h2>
<div class="outline-text-2" id="text-3">
<p>
The lowest layer of the TCP/IP model. It describes the standard for the physical connections between nodes. It only views the data as a stream of bits and is concerned with transmission of bits without error.
<hr />
</p>
</div>
<div id="outline-container-org24f4493" class="outline-3">
<h3 id="org24f4493"><span class="section-number-3">3.1.</span> Network Topology</h3>
<div class="outline-text-3" id="text-3-1">
<p>
The arrangement of nodes and links in a computer network is called network topology. There are various types of topologies
</p>
<p>
TODO : Add images of network topology
</p>
</div>
<div id="outline-container-org1fd355c" class="outline-4">
<h4 id="org1fd355c"><span class="section-number-4">3.1.1.</span> Point-to-Point</h4>
<div class="outline-text-4" id="text-3-1-1">
<p>
It is the simplest connection with two nodes and a single link between them.
</p>
</div>
</div>
<div id="outline-container-org73d1586" class="outline-4">
<h4 id="org73d1586"><span class="section-number-4">3.1.2.</span> Daisy chaining</h4>
<div class="outline-text-4" id="text-3-1-2">
<p>
Also called linear topology, the nodes are connected in a series. Message will follows the whole chain till it reaches the destination. If a link fails in this topology, it is hard to find it, therefore it is not good for large networks.
</p>
</div>
</div>
<div id="outline-container-orgf3edb1f" class="outline-4">
<h4 id="orgf3edb1f"><span class="section-number-4">3.1.3.</span> Mesh topology</h4>
<div class="outline-text-4" id="text-3-1-3">
<p>
Every node is connected to another node through a direct link. In mesh topology, we use AHCP (Ad Hoc Configuration Protocol) and DHCP (Dynamic Host Configuration Protocol).
</p>
<p>
So every node is connected to every other node directly connected through a link. So if there are \(N\) nodes, then the each node has \((N - 1)\) links.
</p>
<p>
If there are \(N\) nodes, then in a mesh topology, the total number of links will be
\[ \text{number of links in mesh topology : } \frac{N(N - 1)}{2} \]
\[ \text{where } N \text{ is the number of nodes} \]
</p>
<p>
Advantages of mesh topology are
</p>
<ul class="org-ul">
<li>communication is fast between any pair of nodes</li>
<li>data transfer is reliable since there are dedicated links between all nodes</li>
<li>since every pair of node has dedicated link, this provides security and privacy</li>
<li>the network is more robust single a failure of single device won't break the network</li>
</ul>
<p>
Drawbacks of mesh topology are
</p>
<ul class="org-ul">
<li>installation is hard, since each link needs to be configured</li>
<li>excessive amount of cables and channels are required to connect all nodes</li>
<li>the cost of maintanance is very high</li>
</ul>
<p>
Mesh topology is of two types
</p>
<ol class="org-ol">
<li><b>Full mesh topology</b> : it is the traditional mesh topology, where every node is connected with other node thus every node has \((N - 1)\) connections.</li>
<li><b>Partial mesh topology</b> : a more practical implementation where it is not necessary to connect all nodes to one another. Only channels with high amount of traffic are connected. This is not the traditional way to implement mesh topology.</li>
</ol>
</div>
</div>
<div id="outline-container-org2a440e7" class="outline-4">
<h4 id="org2a440e7"><span class="section-number-4">3.1.4.</span> Star topology</h4>
<div class="outline-text-4" id="text-3-1-4">
<p>
All nodes are connected to a central node (called the hub) through links. Hubs are not communication endpoints, their function is to forward packets across all ports. The hubs can either be passive in nature or active.
</p>
<p>
Active hubs repeat and strengthen incoming transmissions, while passive hubs simply serve as a point of connectivity. Active hubs are also referred to as <b>repeaters</b>.
</p>
<p>
Advantages of star topology are
</p>
<ul class="org-ul">
<li>only \(N\) links are required to connect \(N\) nodes to a network</li>
<li>each device will need only one port</li>
<li>if one link fails, it won't affect other links</li>
<li>cost effictive</li>
</ul>
<p>
Drawback of star topology are
</p>
<ul class="org-ul">
<li>if the hub fails, then whole network is down</li>
<li>performace is dependant on the hubs</li>
</ul>
</div>
</div>
<div id="outline-container-org6bdd66c" class="outline-4">
<h4 id="org6bdd66c"><span class="section-number-4">3.1.5.</span> Bus topology</h4>
<div class="outline-text-4" id="text-3-1-5">
<p>
In bus topology, all the nodes are connected to a single backbone line. This backbone is bi-directional, there are lines from node to backbone called droplines. This topology is not robust, since if backbone is damaged, the whole network is down.
</p>
<p>
In this topology, various MAC protocols are followed like TDMA, Pure Aloha, CDMA, etc.
</p>
<p>
Advantages of Bus topology
</p>
<ul class="org-ul">
<li>there is only a single link and \(N\) drop lines required</li>
<li>reduces the cost for installation</li>
<li>CSMA is the most common method for this topology</li>
</ul>
<p>
Drawbacks
</p>
<ul class="org-ul">
<li>if backbone fails, then whole network is down</li>
<li>this topology can't handle heavy traffic</li>
<li>adding new nodes slows the network</li>
<li>security is very lower</li>
</ul>
</div>
</div>
<div id="outline-container-org994566e" class="outline-4">
<h4 id="org994566e"><span class="section-number-4">3.1.6.</span> Ring topology</h4>
<div class="outline-text-4" id="text-3-1-6">
<p>
A daisy chain in a closed circular loop is called a ring topology. The most common method for communication in this topology is token passing. A <b>token</b> is a frame which is circulated around the network. The token is passed from one node to another till it reaches its destination.
</p>
<p>
Advantages
</p>
<ul class="org-ul">
<li>better for traffic than bus topology</li>
<li>cheap to install and expand</li>
</ul>
<p>
Disadvantages
</p>
<ul class="org-ul">
<li>single node failure can cause entire network to fail</li>
<li>troubleshooting is difficult</li>
<li>the topology is not secure</li>
</ul>
</div>
</div>
<div id="outline-container-org2951587" class="outline-4">
<h4 id="org2951587"><span class="section-number-4">3.1.7.</span> Tree topology</h4>
<div class="outline-text-4" id="text-3-1-7">
<p>
Also called a star-bus topology. It can be seen as multiple star topologies connected via a backbone like in bus topology. Tree topology is hierarchical and there are parent and child star networks. It uses protocols like DHCP and SAC. The backbone is like the truck of the tree and various star networks branch out from it.
</p>
<p>
The hubs connected directly to main backbone are central hubs. The hubs connected to other hubs are child hubs. This makes this topology very flexible.
</p>
<p>
Advantages
</p>
<ul class="org-ul">
<li>allows networks to prioritize different computers</li>
<li>new nodes are easy to add</li>
<li>error detection and error correction is easy</li>
</ul>
<p>
Drawbacks
</p>
<ul class="org-ul">
<li>if backbone fails the entire network is down. If a parent hub fails, then all the connected child network is down</li>
<li>cost of maintanance is high</li>
<li>reconfiguration is hard</li>
</ul>
</div>
</div>
<div id="outline-container-org3009196" class="outline-4">
<h4 id="org3009196"><span class="section-number-4">3.1.8.</span> Hybrid topology</h4>
<div class="outline-text-4" id="text-3-1-8">
<p>
A hybrid topology is when a network combines two or more topologies in a way that does not resemble standard topologies.
</p>
<p>
Advantages
</p>
<ul class="org-ul">
<li>this is very flexible</li>
<li>size of network can be easily expanded</li>
</ul>
<p>
Disadvantages
</p>
<ul class="org-ul">
<li>it is challenging to design and maintain</li>
<li>the infrastructure needs specialization to maintain</li>
</ul>
<p>
<hr />
</p>
</div>
</div>
</div>
<div id="outline-container-orga8b833b" class="outline-3">
<h3 id="orga8b833b"><span class="section-number-3">3.2.</span> Digital Modulation</h3>
<div class="outline-text-3" id="text-3-2">
<p>
Wires carry analog signals in form of continuously varying voltage. To send digital information, we need to devise analog signals to represent bits. This process of converting bits to analog signals is called digital modulation.
</p>
</div>
<div id="outline-container-orga6decfd" class="outline-4">
<h4 id="orga6decfd"><span class="section-number-4">3.2.1.</span> Bandwidth and maximum data rate</h4>
<div class="outline-text-4" id="text-3-2-1">
<p>
<b>Bandwidth is the measure of carrying capacity of a medium</b>. There are two ways to define bandwidth.
</p>
<ul class="org-ul">
<li>When working on the physical layer, <b>bandwidth can be seen as the maximum frequency of the signals</b> that can travel in the medium. It is measured in Hertz (Hz)</li>
<li>In every other context, bandwidth is the <b>maximum possible data transfer rate of the medium</b>. It is measured in bits per second (bps).</li>
</ul>
<p>
These two ways to define bandwidth are linked and are not actually different ideas.
</p>
<p>
The reason for this difference of Hz and bps measurements is that the <b>maximum frequency of medium is something that only the physical layer is concerned with.</b> In every other layer, we only care about how much data can be transferred.
</p>
<p>
Therefore, <b>unless we are working on physical layer, bandwidth is the maximum data transfer rate of the medium.</b>
</p>
</div>
<div id="outline-container-orge836a41" class="outline-5">
<h5 id="orge836a41"><span class="section-number-5">3.2.1.1.</span> Maximum data transfer rate for noiseless wires</h5>
<div class="outline-text-5" id="text-3-2-1-1">
<p>
Suppose our analog signal has \(V\) different levels. Then for a noiseless wire with bandwidth of \(B\), the maximum data rate is
\[ \text{maximum data rate} = 2\ B\ log_2V \text{ bits/sec} \]
When converting bits, if we are only using two levels, one for 0 bit and one for 1 bit. So, we can in most cases simplify the formula to
\[ \text{maximum data rate} = 2\ B \text{ bits/sec} \]
Example, a noiseless 3-kHz channel cannot transmit binary signal (two levels) at rate exceeding 6000 bps.
</p>
</div>
</div>
<div id="outline-container-org74f8800" class="outline-5">
<h5 id="org74f8800"><span class="section-number-5">3.2.1.2.</span> Maximum data transfer rate for noisy wires</h5>
<div class="outline-text-5" id="text-3-2-1-2">
<p>
But the noiseless wire is an ideal case, which is not possible in real wires. Amount of noise is measured using ratio of signal power to noise power called <b>SNR (Signal-to-Noise Ratio)</b>. \(S\) denotes signal power and \(N\) denotes noise power. The ratio is expressed on a log scale as
\[ SNR = 10\ log_{10} (S/N) \text{ dB} \]
The unit of SNR is <b>decibals (dB)</b>
</p>
<p>
Using SNR, the maximum data rate in a noisy medium is
\[ \text{maximum data rate} = B\ log_2(1 + S/N) \text{ bits/sec} \]
<b>Example</b>, suppose SNR is of 40 dB and bandwidth is 1MHz. Then, using formula for SNR, \(S/N\) is \(10^4\). Therefore, the maximum data rate is
\[ \text{maximum data rate} = 1\ log_2 (10^4) \text{ Mbps}\]
\[ \text{maximum data rate} = 13.288 \text{ Mbps} \]
</p>
</div>
</div>
</div>
<div id="outline-container-org709c85f" class="outline-4">
<h4 id="org709c85f"><span class="section-number-4">3.2.2.</span> Non-Return to Zero (NRZ)</h4>
<div class="outline-text-4" id="text-3-2-2">
<p>
TODO : Add image
The most straightforward form of digital modulation is to use positive voltage for 1 bit and negative voltage to represent 0 bit. This scheme is called NRZ (Non-Return-to-Zero)
</p>
<p>
The NRZ signal propogates down the wire. At the other end, the reciever converts in into bits by sampling the signal at regular intervals of time. This signal won't look the same as one that was sent. It will be distorted by noise. To decode bits receiver will map signal samples to closest symbols.
</p>
<p>
The NRZ is simple, but is seldom used by itself in practice. We use more complex schemes to convert bits to signals. These schemes are called <b>line codes</b>.
</p>
</div>
</div>
<div id="outline-container-orgba47841" class="outline-4">
<h4 id="orgba47841"><span class="section-number-4">3.2.3.</span> Increasing bandwidth efficiency by symbols</h4>
<div class="outline-text-4" id="text-3-2-3">
<p>
Bandwidth is a limited resource, therefore we must use it efficiently.
</p>
<p>
With NRZ, the signal may cycle between positive and negative level every 2 bits (in case of alternating 1s and 0s). Therefore, atleast a bandwidth of B/2 Hz is needed when bit rate is B bits/sec.
</p>
<p>
One strategy for using the limited bandwidth is to <b>increase the signaling levels</b>. For example, by using four voltages, we can send 2 bits at once as a single <b>symbol</b>. When the number of levels is 4, the maximum data rate increases.
\[ \text{maximum data rate} = 4\ B \text{ bits/sec} \]
So, by increasing the number of levels, we can send <b>symbols</b> rather than bits to increase performance.
</p>
<p>
We call rate at which symbol changes the <b>symbol rate</b> to distinguish it from bit rate. An older name for symbol rate is <b>baud rate</b>.
\[ \text{bit rate} = \text{symbol rate } \times \text{ bits in a symbol} \]
Note: the number of levels does not need to be a power of 2.
</p>
</div>
</div>
<div id="outline-container-org2e0dad5" class="outline-4">
<h4 id="org2e0dad5"><span class="section-number-4">3.2.4.</span> Clock recovery</h4>
<div class="outline-text-4" id="text-3-2-4">
<p>
Clocks on both sender and reciever side are used to decode the incoming signal into bits. Suppose we are sending a signal with 20 consecutive zero's. In this case it will become hard to tell bits apart, 20 zero's will look very similar to 19 or 21 zero's.
</p>
<p>
We could use accurate clocks for this problem. But when bit rate is in multiple Mbps, the clock would need to be accurate down to less than a fraction of microsecond. Therefore, accurate clocks are not a general solution.
</p>
</div>
<div id="outline-container-org83e35b9" class="outline-5">
<h5 id="org83e35b9"><span class="section-number-5">3.2.4.1.</span> Manchester encoding</h5>
<div class="outline-text-5" id="text-3-2-4-1">
<p>
TODO : Add image
A clever trick is to <b>mix a clock signal with the data signal</b> by XORing them together. This scheme is called <b>Manchester Encoding</b>.
</p>
<p>
The clock should make a complete cycle for every bit that needs to be transmitted. Therefore, clock frequency needs to be twice of bit rate. In other words, if the bit rate is \(B\) bits/sec, then the clock frequency will be \(B\) Hz.
</p>
<p>
Therefore, the downside of manchester encoding is that it requires <b>twice as much bandwidth as NRZ</b>.
</p>
</div>
</div>
<div id="outline-container-orgfc45c3c" class="outline-5">
<h5 id="orgfc45c3c"><span class="section-number-5">3.2.4.2.</span> Non-Return-to-Zero Inverted (NRZI)</h5>
<div class="outline-text-5" id="text-3-2-4-2">
<p>
TODO : Add image
</p>
<p>
Clock recovery problems occur when there are long runs of 1's or 0's. NRZ-I encoding produces signals that are easy to translate with clock.
</p>
<p>
In NRZI, rather than using levels to represent bits, <b>we use transitions to represent bits</b>. Example, 1 bit will be a transition and 0 bit will be no transition. A transition is going from one level to another.
</p>
<p>
<b>USB uses NRZI</b> encoding to send bits. Long runs of 0 will still cause problems in NRZI.
</p>
</div>
</div>
<div id="outline-container-org0dcf6ae" class="outline-5">
<h5 id="org0dcf6ae"><span class="section-number-5">3.2.4.3.</span> 4B/5B</h5>
<div class="outline-text-5" id="text-3-2-4-3">
<p>
To truly fix the issue, we can break long runs of 0's by mapping group of bits to longer patterns that do not have consecutive 0's.
</p>
<p>
A well known code of this type is 4B/5B. Every <b>4 bits are mapped to 5 bit patterns</b> which are then sent as analog signals. The translation table is fixed.
</p>
<p>
The 5 bit patterns are designed in a way that <b>there are never more than three consecutive 0's</b>. This encoding will <b>add 25% overhead which is better than 100% overhead of manchester</b>.
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-right" />
<col class="org-right" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-right">Data (4B)</th>
<th scope="col" class="org-right">Codeword (5B)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-right">0000</td>
<td class="org-right">11110</td>
</tr>
<tr>
<td class="org-right">0001</td>
<td class="org-right">01001</td>
</tr>
<tr>
<td class="org-right">0010</td>
<td class="org-right">10100</td>
</tr>
<tr>
<td class="org-right">0011</td>
<td class="org-right">10101</td>
</tr>
<tr>
<td class="org-right">0100</td>
<td class="org-right">01010</td>
</tr>
<tr>
<td class="org-right">0101</td>
<td class="org-right">01011</td>
</tr>
<tr>
<td class="org-right">0110</td>
<td class="org-right">01110</td>
</tr>
<tr>
<td class="org-right">0111</td>
<td class="org-right">01111</td>
</tr>
<tr>
<td class="org-right">1000</td>
<td class="org-right">10010</td>
</tr>
<tr>
<td class="org-right">1001</td>
<td class="org-right">10011</td>
</tr>
<tr>
<td class="org-right">1010</td>
<td class="org-right">10110</td>
</tr>
<tr>
<td class="org-right">1011</td>
<td class="org-right">10111</td>
</tr>
<tr>
<td class="org-right">1100</td>
<td class="org-right">11010</td>
</tr>
<tr>
<td class="org-right">1101</td>
<td class="org-right">11011</td>
</tr>
<tr>
<td class="org-right">1110</td>
<td class="org-right">11100</td>
</tr>
<tr>
<td class="org-right">1111</td>
<td class="org-right">11101</td>
</tr>
</tbody>
</table>
<p>
Since there are 32 different 5 bit patterns and all of them are not used. We can have remaining patterns which don't have many successive 0's as control signals.
</p>
<p>
4B/5B is usually used in conjunction to NRZI.
</p>
</div>
</div>
<div id="outline-container-orge986a37" class="outline-5">
<h5 id="orge986a37"><span class="section-number-5">3.2.4.4.</span> Scrambling</h5>
<div class="outline-text-5" id="text-3-2-4-4">
<p>
Another approach is scrambling the bits to reduce chances of long runs of 0's.
</p>
<p>
A <b>scrambler</b> will XOR the data with a psuedorandom sequence before it is transmitted. This mixing will make data pseudorandom (assuming the sequence was chosen independent of data). The receiver can XOR the incoming bits with same sequence to recover the real data. Therefore, the pseudorandom sequence must be easy to create. It is usually given as seed to a simple random number generator.
</p>
<p>
<b>Scrambling will add no overhead.</b> Also, repetitive data patterns can cause electromagnetic interference. Pseudorandom data is usually "white", i.e. has more uniform spread across signals <b>reducing interference.</b>
</p>
<p>
However, since scrambling is pseudorandom there is <b>no guarentee that long runs won't occur.</b> With predictable data patterns, it is <b>easy for malicious users to send data that can cause long runs of 0's</b>, causing link to fail. Earlier standards had this defect, it was possible to send certain <b>"killer packets"</b> that caused problems.
</p>
</div>
</div>
</div>
<div id="outline-container-orgcb6a702" class="outline-4">
<h4 id="orgcb6a702"><span class="section-number-4">3.2.5.</span> Balanced signals</h4>
<div class="outline-text-4" id="text-3-2-5">
<p>
Signals that have almost as many positive voltages as negative voltages are called <b>balanced signals.</b> Balanced signals <b>average to zero</b>, which means they have no DC electrical component.
</p>
<p>
We need balanced signals because
</p>
<ul class="org-ul">
<li><b>Many mediums</b> such as coaxial cables or lines with transformers <b>strongly reduce the DC component of signals.</b></li>
<li>A method of connecting receiver called <b>capacitive coupling</b> can only pass AC signals.</li>
<li>If signal is not balanced, we waste energy because DC component is filtered out.</li>
<li>Balanced signals have <b>easier clock recovery</b> since there is a mix of positive and negative voltages.</li>
<li>It helps in <b>calibration of receivers</b> as they can check average of signals to decode symbols. In <b>unbalanced signals, the average drifts causing errors.</b></li>
</ul>
</div>
<div id="outline-container-orgb52d16a" class="outline-5">
<h5 id="orgb52d16a"><span class="section-number-5">3.2.5.1.</span> Alternate Mark Inversion (AMI)</h5>
<div class="outline-text-5" id="text-3-2-5-1">
<p>
TODO : Add image
</p>
<p>
AMI encoding adds another voltage level to achieve the balance. It is a bipolar encoding, i.e it uses <b>positive and negative voltages to represent 1 bit and no voltage to represent 0 bit</b>.
</p>
<p>
Therefore, <b>there are 3 levels in the signal +, - and 0.</b> The 1 bit will cycle between positive and negative values, to make signal balanced. The <b>pair of voltages chosen cancel each other</b> (example, + is +5V and - is -5V).
</p>
<p>
<b>0 bits are all represented by 0V</b>
</p>
<p>
The <b>first 1</b> bit in sequence is <b>+</b>
<br />
The <b>second 1</b> bit in sequence is <b>-</b>
<br />
The <b>third 1</b> bit in sequence is <b>+</b>
<br />
<b>and so on.</b>
</p>
<p>
Suppose + is +5V and - is -5V. The encoding will be as follows
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="all" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-right" />
<col class="org-right" />
<col class="org-right" />
<col class="org-right" />
<col class="org-right" />
<col class="org-right" />
<col class="org-right" />
<col class="org-right" />
<col class="org-right" />
<col class="org-right" />
<col class="org-right" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Bits</th>
<th scope="col" class="org-right">1</th>
<th scope="col" class="org-right">0</th>
<th scope="col" class="org-right">1</th>
<th scope="col" class="org-right">0</th>
<th scope="col" class="org-right">0</th>
<th scope="col" class="org-right">1</th>
<th scope="col" class="org-right">1</th>
<th scope="col" class="org-right">1</th>
<th scope="col" class="org-right">0</th>
<th scope="col" class="org-right">0</th>
<th scope="col" class="org-right">1</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">Signal</td>
<td class="org-right">+</td>
<td class="org-right">0</td>
<td class="org-right">-</td>
<td class="org-right">0</td>
<td class="org-right">0</td>
<td class="org-right">+</td>
<td class="org-right">-</td>
<td class="org-right">+</td>
<td class="org-right">0</td>
<td class="org-right">0</td>
<td class="org-right">-</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="org-left">Voltage (V)</td>
<td class="org-right">+5</td>
<td class="org-right">0</td>
<td class="org-right">-5</td>
<td class="org-right">0</td>
<td class="org-right">0</td>
<td class="org-right">+5</td>
<td class="org-right">-5</td>
<td class="org-right">+5</td>
<td class="org-right">0</td>
<td class="org-right">0</td>
<td class="org-right">-5</td>
</tr>
</tbody>
</table>
<p>
In old terminology, 1 is called a "mark" and 0 is called a "space".
</p>
</div>
</div>
<div id="outline-container-org3509b66" class="outline-5">
<h5 id="org3509b66"><span class="section-number-5">3.2.5.2.</span> 8B/10B</h5>
<div class="outline-text-5" id="text-3-2-5-2">
<p>
If we don't want to add another level to achieve balance, we can use mapping similar to 4B/5B.
<b>A balanced code is 8B/10B.</b> It will map 8 bits to 10 bits, therefore it is <b>80%</b> efficient.
</p>
<p>
The 8B/10B coding will first take the <b>first 5 bits from 8 bit input and map it to 6 bits</b> (using a 5B/6B). Then it will take the <b>remaining 3 bits and map them to 4 bits</b> (using a 3B/4B). Finally the 6 bits and 4 bits are concatenated to get 10 bits.
</p>
<p>
The 3B/4B and 5B/6B will try to produce codes that are balanced. For example, "001" will be mapped to "1001" by 3B/4B. But producing all codes balanced is not possible in this way.
</p>
<p>
<b>Both 3B/4B and 5B/6B can map an input into one of two outputs</b>, one with an extra 1 and other with extra 0. This pair of outputs are usually complement of each other. As these two codes map bits, the <b>encoder will remember the disparity</b> between the two produced codes. Then it will choose one of the two possible outputs such that disparity is reduced.
</p>
<ul class="org-ul">
<li>8B/10B guarentees that <b>disparity is at most 2</b>. So signal will never be far from balanced.</li>
<li>8B/10B will <b>never have more than 5 cosecutive 1's or 0's</b>, therefore it can be used for <b>clock recovery</b>.</li>
</ul>
<p>
<hr />
</p>
</div>
</div>
</div>
</div>
<div id="outline-container-orgba83308" class="outline-3">
<h3 id="orgba83308"><span class="section-number-3">3.3.</span> Switching</h3>
<div class="outline-text-3" id="text-3-3">
<p>
Two different switching techniques are used by networks.
</p>
<ul class="org-ul">
<li><b>Circuit switching</b> : the switching used in traditional telephone systems</li>
<li><b>Packet switching</b> : the switching used in IP technology</li>
</ul>
<p>
This section will only provide brief introduction with relation to physical layer. Switching is later discussed in network layer.
</p>
</div>
<div id="outline-container-org08c9017" class="outline-4">
<h4 id="org08c9017"><span class="section-number-4">3.3.1.</span> Circuit switching</h4>
<div class="outline-text-4" id="text-3-3-1">
<p>
When a telephone call is placed, the switching equipment looks for a <b>single path</b> from sender to receiver and maintains it for the duration of the communication. This technique of having a direct physical connection is called <b>circuit switching</b>.
</p>
<p>
In early days of telephone, connection was made by operator by plugging jumper cables into input and output sockets. Automatic circuit switching was invented by Almon B. Strowger. For nearly a 100 years, the automatic circuit switching equipment used worldwide was known as Strowger gear.
</p>
<p>
The parts of path between telephone may in fact be microwave or fibre or any other type of medium. There are thousand of calls multiplexed on parts of links.
</p>
<p>
The main property of circuit switching is that <b>there is a single path for the whole duration of communication.</b> Therefore, it needs to set up and end-to-end path before any data can be sent. The bandwidth required for communication is also reserved before data is sent.
</p>
<p>
Since there is a reserved path, <b>once setup is complete the only dealy for data is propogation time for signals</b>. Also once path is reserved, there is no danger of congestion. Of course the <b>conjestion can be felt before connection is established, as it may take a while due to switching or trunk capacity.</b>
</p>
</div>
</div>
<div id="outline-container-org8ace8aa" class="outline-4">
<h4 id="org8ace8aa"><span class="section-number-4">3.3.2.</span> Packet switching</h4>
<div class="outline-text-4" id="text-3-3-2">
<p>
In contrast to circuit switching, there is <b>no need to set up dedicated path in advance. Packet switching is analogous to sending data in form of series of letters using postal system</b>.
</p>
<p>
Each packet will travel independently of others and can choose any path to reach destination in the network. It is <b>up to routers</b> to use store-and-forward transmission to send each packet on its way towards the destination. Since every packet travels independently, they may arrive out of order.
</p>
<p>
Packet-switching networks place <b>tight upper limit on the packet sizes</b>. This ensures that <b>no single user can monopolize any transmission line for long</b>, so that network can handle interactive traffic. It also reduces delay since first packet of a long message can be forwarded before second is fully formed. However, there is more delay than circuit switching. In ciruit switching, bits can flow continuously without anything ever being stored and forwarded later.
</p>
<p>
Since bandwidth is not reserved, packets may have to wait to be forwarded, this introduces <b>queuing delay</b> and congestion. On the other hand, we don't have to wait to establish a connection. Therefore, in circuit switching (during setup) and packet switching (packets are travelling) congestion occurs at different times.
</p>
<p>
Packet switching does not waster bandwidth which is limited resource. <b>Packet switching is also more fault tolerant</b>, in fact that was why packet switching was chosen for internet. If some switches go down, packets can travel around them.
</p>
<p>
These differences in the types of switching also leads to the difference in which billing is usually done for both networks. With circuit switching main load factors are distance and time of communication, therefore billing is done for how long connection is established (talktime on phone calles). Whereas in packet switching main load factor is how much traffic is added to network by a user, therefore billing is done based on how much data is transferred by user.
</p>
<p>
The <b>difference between circuit and packet switching</b> is
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Item</th>
<th scope="col" class="org-left">Circuit switched</th>
<th scope="col" class="org-left">Packet switched</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">Call Setup</td>
<td class="org-left">Required</td>
<td class="org-left">Not needed</td>
</tr>
<tr>
<td class="org-left">Dedicated Physical Path</td>
<td class="org-left">Yes</td>
<td class="org-left">No</td>
</tr>
<tr>
<td class="org-left">Whole data follows same path</td>
<td class="org-left">Yes</td>
<td class="org-left">No</td>
</tr>
<tr>
<td class="org-left">Data arrives in order</td>
<td class="org-left">Yes</td>
<td class="org-left">No</td>
</tr>
<tr>
<td class="org-left">Is a switch crash fatal</td>
<td class="org-left">Yes</td>
<td class="org-left">No</td>
</tr>
<tr>
<td class="org-left">Bandwidth available</td>
<td class="org-left">Fixed</td>
<td class="org-left">Dynamic</td>
</tr>
<tr>
<td class="org-left">Time of possible congestion</td>
<td class="org-left">At setup</td>
<td class="org-left">On every packet</td>
</tr>
<tr>
<td class="org-left">Potentially wasted bandwidth</td>
<td class="org-left">Yes</td>
<td class="org-left">No</td>
</tr>
<tr>
<td class="org-left">Store-and-forward transmission</td>
<td class="org-left">No</td>
<td class="org-left">Yes</td>
</tr>
<tr>
<td class="org-left">Billing</td>
<td class="org-left">Per minute</td>
<td class="org-left">Per Byte</td>
</tr>
</tbody>
</table>
<p>
<hr />
</p>
</div>
</div>
</div>
</div>
<div id="outline-container-org571cce0" class="outline-2">
<h2 id="org571cce0"><span class="section-number-2">4.</span> Data Link Layer</h2>
<div class="outline-text-2" id="text-4">
<p>
<hr />
</p>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: Anmol Nawani</p>
<p class="date">Created: 2023-08-16 Wed 21:42</p>
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>