From a2b53102ee5ff169472ce3a03a7037fe25969919 Mon Sep 17 00:00:00 2001 From: lomna-dev Date: Sun, 20 Aug 2023 15:10:10 +0530 Subject: [PATCH] Starting Data link layer --- datalink.org | 1 + main.html | 599 +++++++++++++++++++++++++++++++++++++++------------ main.org | 95 +++++++- 3 files changed, 553 insertions(+), 142 deletions(-) create mode 100644 datalink.org diff --git a/datalink.org b/datalink.org new file mode 100644 index 0000000..df5ac1a --- /dev/null +++ b/datalink.org @@ -0,0 +1 @@ +* Data Link Layer diff --git a/main.html b/main.html index fa94f9a..2299f0d 100644 --- a/main.html +++ b/main.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Computer Networks @@ -223,88 +223,100 @@

Table of Contents


-
-

1. Introduction

+
+

1. Introduction

A computer network is collection of two or more computers that can communicate with each other. @@ -322,8 +334,8 @@ Computer networks are made of protocols which allow us to send data through link


-
-

1.1. Some basic terminologies

+
+

1.1. Some basic terminologies

Here, we will look at basic terminologies used in computer networks. Most of these will be expanded on further. @@ -356,8 +368,8 @@ Computer networks can fall under two broad categories

-
-

1.2. OSI Model

+
+

1.2. OSI Model

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 @@ -377,31 +389,31 @@ We don't use the OSI Model and mostly use it as a referencial model. The TCP/IP

-
-

1.3. Unique Identifiers of Computer Network

+
+

1.3. Unique Identifiers of Computer Network

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.

-
-

1.3.1. Hostname

+
+

1.3.1. Hostname

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.

-
-

1.3.2. IP Address

+
+

1.3.2. IP Address

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.

-
-

1.3.3. MAC Address

+
+

1.3.3. MAC Address

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. @@ -410,8 +422,8 @@ Stands for Media Access Control Address. It is also known as the physical addres

-
-

1.4. Ports

+
+

1.4. Ports

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 socket, example 192.168.0.1:8000 @@ -469,8 +481,8 @@ The ports are divided into three categories.

-
-

2. Network Models

+
+

2. Network Models

A network model defines a way to organize a system's functions and features. It also defines it's structure and protocols. @@ -499,8 +511,8 @@ There have been many network models, many of them are no longer used. IBM's SNA


-
-

2.1. OSI Model

+
+

2.1. OSI Model

TODO : Add OSI model image @@ -518,8 +530,8 @@ The OSI model has 7 layers. Each layer has different functionality. The principl

  • 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
  • -
    -

    2.1.1. Physical Layer

    +
    +

    2.1.1. Physical Layer

    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. @@ -540,8 +552,8 @@ Hub, repeater, moden and cables are physical layer devices

    -
    -

    2.1.2. Data Link Layer (DLL)

    +
    +

    2.1.2. Data Link Layer (DLL)

    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. @@ -576,8 +588,8 @@ Switch and bridges are example of DLL devices.

    -
    -

    2.1.3. Network Layer

    +
    +

    2.1.3. Network Layer

    The network layer controls operations of the subnet. @@ -605,8 +617,8 @@ The implementation of network layer is in devices such as routers and switches.

    -
    -

    2.1.4. Transport Layer

    +
    +

    2.1.4. Transport Layer

    The data in transport layer is referred to as segments. This layer is responsible for end to end delivery of messages. It also acknowledges successful transmission and re-transmits data if error is found. @@ -645,8 +657,8 @@ Transport layer is operated by the OS. This layer is called the heart of OSI

    -
    -

    2.1.5. Session Layer

    +
    +

    2.1.5. Session Layer

    This layer is responsible for establishing connection, maintanance of communication sessions and authentication. It ensures the security in connection. @@ -662,8 +674,8 @@ The services provided by session layer are

    -
    -

    2.1.6. Presentation Layer

    +
    +

    2.1.6. Presentation Layer

    Also called the translation layer. This layer translates files and data from local formats to standard, transmittable formats. @@ -681,8 +693,8 @@ The services provided by presentation layer are

    -
    -

    2.1.7. Application Layer

    +
    +

    2.1.7. Application Layer

    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. @@ -695,8 +707,8 @@ This layer has protocols such as HTTP, FTP, SMTP, DNS and provides the functiona

    -
    -

    2.2. TCP/IP Model

    +
    +

    2.2. TCP/IP Model

    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. @@ -711,8 +723,8 @@ The TCP/IP model had 4 layers, but sometimes physical layer is also included in

    -
    -

    2.2.1. Link layer

    +
    +

    2.2.1. Link layer

    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. @@ -720,8 +732,8 @@ The requirnment for a robust network led to the choice of packet-switching netwo

    -
    -

    2.2.2. Internet layer

    +
    +

    2.2.2. Internet layer

    This layer roughly corresponds to the OSI network layer. Its job is to permit hosts to inject packets into any network and have them travel independently to the destination. 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. @@ -744,16 +756,16 @@ The job of internet layer is to deliver IP packets where they are supposed to go

    -
    -

    2.2.3. Transport layer

    +
    +

    2.2.3. Transport layer

    TODO : Here

    -
    -

    2.2.4. Application layer

    +
    +

    2.2.4. Application layer

    TODO : Here @@ -763,16 +775,16 @@ TODO : Here

    -
    -

    3. Physical Layer

    +
    +

    3. Physical Layer

    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.


    -
    -

    3.1. Network Topology

    +
    +

    3.1. Network Topology

    The arrangement of nodes and links in a computer network is called network topology. There are various types of topologies @@ -782,24 +794,24 @@ The arrangement of nodes and links in a computer network is called network topol TODO : Add images of network topology

    -
    -

    3.1.1. Point-to-Point

    +
    +

    3.1.1. Point-to-Point

    It is the simplest connection with two nodes and a single link between them.

    -
    -

    3.1.2. Daisy chaining

    +
    +

    3.1.2. Daisy chaining

    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.

    -
    -

    3.1.3. Mesh topology

    +
    +

    3.1.3. Mesh topology

    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). @@ -843,8 +855,8 @@ Mesh topology is of two types

    -
    -

    3.1.4. Star topology

    +
    +

    3.1.4. Star topology

    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. @@ -874,8 +886,8 @@ Drawback of star topology are

    -
    -

    3.1.5. Bus topology

    +
    +

    3.1.5. Bus topology

    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. @@ -905,8 +917,8 @@ Drawbacks

    -
    -

    3.1.6. Ring topology

    +
    +

    3.1.6. Ring topology

    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 token is a frame which is circulated around the network. The token is passed from one node to another till it reaches its destination. @@ -931,8 +943,8 @@ Disadvantages

    -
    -

    3.1.7. Tree topology

    +
    +

    3.1.7. Tree topology

    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. @@ -962,8 +974,8 @@ Drawbacks

    -
    -

    3.1.8. Hybrid topology

    +
    +

    3.1.8. Hybrid topology

    A hybrid topology is when a network combines two or more topologies in a way that does not resemble standard topologies. @@ -990,24 +1002,37 @@ Disadvantages

    -
    -

    3.2. Digital Modulation

    +
    +

    3.2. Digital Modulation

    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.

    -
    -

    3.2.1. Bandwidth and maximum data rate

    +
    +

    3.2.1. Bandwidth and maximum data rate

    -Bandwidth is the measure of carrying capacity of a medium. It is measured in Hertz (Hz). -
    -Note : in many places, maximum data rate is also refered to as the bandwidth. +Bandwidth is the measure of carrying capacity of a medium. There are two ways to define bandwidth. +

    +
      +
    • When working on the physical layer, bandwidth can be seen as the maximum frequency of the signals that can travel in the medium. It is measured in Hertz (Hz)
    • +
    • In every other context, bandwidth is the maximum possible data transfer rate of the medium. It is measured in bits per second (bps).
    • +
    +

    +These two ways to define bandwidth are linked and are not actually different ideas. +

    + +

    +The reason for this difference of Hz and bps measurements is that the maximum frequency of medium is something that only the physical layer is concerned with. In every other layer, we only care about how much data can be transferred. +

    + +

    +Therefore, unless we are working on physical layer, bandwidth is the maximum data transfer rate of the medium.

    -
    -
    3.2.1.1. Maximum data rate for noiseless wires
    +
    +
    3.2.1.1. Maximum data transfer rate for noiseless wires

    Suppose our analog signal has \(V\) different levels. Then for a noiseless wire with bandwidth of \(B\), the maximum data rate is @@ -1018,8 +1043,8 @@ Example, a noiseless 3-kHz channel cannot transmit binary signal (two levels) at

    -
    -
    3.2.1.2. Maximum data rate for noisy wires
    +
    +
    3.2.1.2. Maximum data transfer rate for noisy wires

    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 SNR (Signal-to-Noise Ratio). \(S\) denotes signal power and \(N\) denotes noise power. The ratio is expressed on a log scale as @@ -1038,8 +1063,8 @@ Using SNR, the maximum data rate in a noisy medium is

    -
    -

    3.2.2. Non-Return to Zero (NRZ)

    +
    +

    3.2.2. Non-Return to Zero (NRZ)

    TODO : Add image @@ -1056,8 +1081,8 @@ The NRZ is simple, but is seldom used by itself in practice. We use more complex

    -
    -

    3.2.3. Increasing bandwidth efficiency by symbols

    +
    +

    3.2.3. Increasing bandwidth efficiency by symbols

    Bandwidth is a limited resource, therefore we must use it efficiently. @@ -1080,8 +1105,8 @@ Note: the number of levels does not need to be a power of 2.

    -
    -

    3.2.4. Clock recovery

    +
    +

    3.2.4. Clock recovery

    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. @@ -1091,8 +1116,8 @@ Clocks on both sender and reciever side are used to decode the incoming signal i 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.

    -
    -
    3.2.4.1. Manchester encoding
    +
    +
    3.2.4.1. Manchester encoding

    TODO : Add image @@ -1108,8 +1133,8 @@ Therefore, the downside of manchester encoding is that it requires twice as m

    -
    -
    3.2.4.2. Non-Return-to-Zero Inverted (NRZI)
    +
    +
    3.2.4.2. Non-Return-to-Zero Inverted (NRZI)

    TODO : Add image @@ -1128,8 +1153,8 @@ In NRZI, rather than using levels to represent bits, we use transitions to re

    -
    -
    3.2.4.3. 4B/5B
    +
    +
    3.2.4.3. 4B/5B

    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. @@ -1247,8 +1272,8 @@ Since there are 32 different 5 bit patterns and all of them are not used. We can

    -
    -
    3.2.4.4. Scrambling
    +
    +
    3.2.4.4. Scrambling

    Another approach is scrambling the bits to reduce chances of long runs of 0's. @@ -1268,8 +1293,8 @@ However, since scrambling is pseudorandom there is no guarentee that long run

    -
    -

    3.2.5. Balanced signals

    +
    +

    3.2.5. Balanced signals

    Signals that have almost as many positive voltages as negative voltages are called balanced signals. Balanced signals average to zero, which means they have no DC electrical component. @@ -1285,7 +1310,299 @@ We need balanced signals because

  • Balanced signals have easier clock recovery since there is a mix of positive and negative voltages.
  • It helps in calibration of receivers as they can check average of signals to decode symbols. In unbalanced signals, the average drifts causing errors.
  • +
    +
    +
    3.2.5.1. Alternate Mark Inversion (AMI)
    +
    +

    +TODO : Add image +

    + +

    +AMI encoding adds another voltage level to achieve the balance. It is a bipolar encoding, i.e it uses positive and negative voltages to represent 1 bit and no voltage to represent 0 bit. +

    + +

    +Therefore, there are 3 levels in the signal +, - and 0. The 1 bit will cycle between positive and negative values, to make signal balanced. The pair of voltages chosen cancel each other (example, + is +5V and - is -5V). +

    + +

    +0 bits are all represented by 0V +

    + +

    +The first 1 bit in sequence is + +
    +The second 1 bit in sequence is - +
    +The third 1 bit in sequence is + +
    +and so on. +

    + +

    +Suppose + is +5V and - is -5V. The encoding will be as follows +

    + + + +++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Bits10100111001
    Signal+0-00+-+00-
    Voltage (V)+50-500+5-5+500-5
    +

    +In old terminology, 1 is called a "mark" and 0 is called a "space". +

    +
    +
    +
    +
    3.2.5.2. 8B/10B
    +
    +

    +If we don't want to add another level to achieve balance, we can use mapping similar to 4B/5B. +A balanced code is 8B/10B. It will map 8 bits to 10 bits, therefore it is 80% efficient. +

    + +

    +The 8B/10B coding will first take the first 5 bits from 8 bit input and map it to 6 bits (using a 5B/6B). Then it will take the remaining 3 bits and map them to 4 bits (using a 3B/4B). Finally the 6 bits and 4 bits are concatenated to get 10 bits. +

    + +

    +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. +

    + +

    +Both 3B/4B and 5B/6B can map an input into one of two outputs, 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 encoder will remember the disparity between the two produced codes. Then it will choose one of the two possible outputs such that disparity is reduced. +

    + +
      +
    • 8B/10B guarentees that disparity is at most 2. So signal will never be far from balanced.
    • +
    • 8B/10B will never have more than 5 cosecutive 1's or 0's, therefore it can be used for clock recovery.
    • +
    +

    +


    +

    +
    +
    +
    +
    +
    +

    3.3. Switching

    +
    +

    +Two different switching techniques are used by networks. +

    +
      +
    • Circuit switching : the switching used in traditional telephone systems
    • +
    • Packet switching : the switching used in IP technology
    • +
    +

    +This section will only provide brief introduction with relation to physical layer. Switching is later discussed in network layer. +

    +
    +
    +

    3.3.1. Circuit switching

    +
    +

    +When a telephone call is placed, the switching equipment looks for a single path from sender to receiver and maintains it for the duration of the communication. This technique of having a direct physical connection is called circuit switching. +

    + +

    +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. +

    + +

    +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. +

    + +

    +The main property of circuit switching is that there is a single path for the whole duration of communication. 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. +

    + +

    +Since there is a reserved path, once setup is complete the only dealy for data is propogation time for signals. Also once path is reserved, there is no danger of congestion. Of course the conjestion can be felt before connection is established, as it may take a while due to switching or trunk capacity. +

    +
    +
    +
    +

    3.3.2. Packet switching

    +
    +

    +In contrast to circuit switching, there is 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. +

    +

    +Each packet will travel independently of others and can choose any path to reach destination in the network. It is up to routers 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. +

    + +

    +Packet-switching networks place tight upper limit on the packet sizes. This ensures that no single user can monopolize any transmission line for long, 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. +

    + +

    +Since bandwidth is not reserved, packets may have to wait to be forwarded, this introduces queuing delay 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. +

    + +

    +Packet switching does not waster bandwidth which is limited resource. Packet switching is also more fault tolerant, in fact that was why packet switching was chosen for internet. If some switches go down, packets can travel around them. +

    + +

    +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. +

    + +

    +The difference between circuit and packet switching is +

    + + + +++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ItemCircuit switchedPacket switched
    Call SetupRequiredNot needed
    Dedicated Physical PathYesNo
    Whole data follows same pathYesNo
    Data arrives in orderYesNo
    Is a switch crash fatalYesNo
    Bandwidth availableFixedDynamic
    Time of possible congestionAt setupOn every packet
    Potentially wasted bandwidthYesNo
    Store-and-forward transmissionNoYes
    BillingPer minutePer Byte


    @@ -1293,10 +1610,18 @@ We need balanced signals because
    +
    +

    4. Data Link Layer

    +
    +

    +


    +

    +
    +

    Author: Anmol Nawani

    -

    Created: 2023-08-13 Sun 18:07

    +

    Created: 2023-08-16 Wed 21:42

    Validate

    diff --git a/main.org b/main.org index ba12ffe..b2a843a 100644 --- a/main.org +++ b/main.org @@ -304,16 +304,19 @@ Disadvantages ** Digital Modulation 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. *** Bandwidth and maximum data rate -Bandwidth is the measure of carrying capacity of a medium. It is measured in Hertz (Hz). -\\ -Note : in many places, maximum data rate is also refered to as the bandwidth. -**** Maximum data rate for noiseless wires +*Bandwidth is the measure of carrying capacity of a medium*. There are two ways to define bandwidth. ++ When working on the physical layer, *bandwidth can be seen as the maximum frequency of the signals* that can travel in the medium. It is measured in Hertz (Hz) ++ In every other context, bandwidth is the *maximum possible data transfer rate of the medium*. It is measured in bits per second (bps). +These two ways to define bandwidth are linked and are not actually different ideas. + +The reason for this difference of Hz and bps measurements is that the *maximum frequency of medium is something that only the physical layer is concerned with.* In every other layer, we only care about how much data can be transferred. Therefore, *unless we are working on physical layer, bandwidth is the maximum data transfer rate of the medium.* +**** Maximum data transfer rate for noiseless wires 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. -**** Maximum data rate for noisy wires +**** Maximum data transfer rate for noisy wires 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 *SNR (Signal-to-Noise Ratio)*. $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 *decibals (dB)* @@ -407,5 +410,87 @@ We need balanced signals because + If signal is not balanced, we waste energy because DC component is filtered out. + Balanced signals have *easier clock recovery* since there is a mix of positive and negative voltages. + It helps in *calibration of receivers* as they can check average of signals to decode symbols. In *unbalanced signals, the average drifts causing errors.* +**** Alternate Mark Inversion (AMI) +TODO : Add image + +AMI encoding adds another voltage level to achieve the balance. It is a bipolar encoding, i.e it uses *positive and negative voltages to represent 1 bit and no voltage to represent 0 bit*. + +Therefore, *there are 3 levels in the signal +, - and 0.* The 1 bit will cycle between positive and negative values, to make signal balanced. The *pair of voltages chosen cancel each other* (example, + is +5V and - is -5V). + +*0 bits are all represented by 0V* + +The *first 1* bit in sequence is *+* +\\ +The *second 1* bit in sequence is *-* +\\ +The *third 1* bit in sequence is *+* +\\ +*and so on.* + +Suppose + is +5V and - is -5V. The encoding will be as follows +#+ATTR_HTML: :rules all +| Bits | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | +|-------------+----+---+----+---+---+----+----+----+---+---+----| +| Signal | + | 0 | - | 0 | 0 | + | - | + | 0 | 0 | - | +|-------------+----+---+----+---+---+----+----+----+---+---+----| +| Voltage (V) | +5 | 0 | -5 | 0 | 0 | +5 | -5 | +5 | 0 | 0 | -5 | +In old terminology, 1 is called a "mark" and 0 is called a "space". +**** 8B/10B +If we don't want to add another level to achieve balance, we can use mapping similar to 4B/5B. +*A balanced code is 8B/10B.* It will map 8 bits to 10 bits, therefore it is *80%* efficient. + +The 8B/10B coding will first take the *first 5 bits from 8 bit input and map it to 6 bits* (using a 5B/6B). Then it will take the *remaining 3 bits and map them to 4 bits* (using a 3B/4B). Finally the 6 bits and 4 bits are concatenated to get 10 bits. + +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. +*Both 3B/4B and 5B/6B can map an input into one of two outputs*, 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 *encoder will remember the disparity* between the two produced codes. Then it will choose one of the two possible outputs such that disparity is reduced. + ++ 8B/10B guarentees that *disparity is at most 2*. So signal will never be far from balanced. ++ 8B/10B will *never have more than 5 cosecutive 1's or 0's*, therefore it can be used for *clock recovery*. +@@html:
    @@ +** Switching +Two different switching techniques are used by networks. ++ *Circuit switching* : the switching used in traditional telephone systems ++ *Packet switching* : the switching used in IP technology +This section will only provide brief introduction with relation to physical layer. Switching is later discussed in network layer. +*** Circuit switching +When a telephone call is placed, the switching equipment looks for a *single path* from sender to receiver and maintains it for the duration of the communication. This technique of having a direct physical connection is called *circuit switching*. + +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. + +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. + +The main property of circuit switching is that *there is a single path for the whole duration of communication.* 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. + +Since there is a reserved path, *once setup is complete the only dealy for data is propogation time for signals*. Also once path is reserved, there is no danger of congestion. Of course the *conjestion can be felt before connection is established, as it may take a while due to switching or trunk capacity.* +*** Packet switching +In contrast to circuit switching, there is *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*. + +Each packet will travel independently of others and can choose any path to reach destination in the network. It is *up to routers* 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. + +Packet-switching networks place *tight upper limit on the packet sizes*. This ensures that *no single user can monopolize any transmission line for long*, 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. + +Since bandwidth is not reserved, packets may have to wait to be forwarded, this introduces *queuing delay* 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. + +Packet switching does not waster bandwidth which is limited resource. *Packet switching is also more fault tolerant*, in fact that was why packet switching was chosen for internet. If some switches go down, packets can travel around them. + +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. + +The *difference between circuit and packet switching* is +|--------------------------------+------------------+-----------------| +| Item | Circuit switched | Packet switched | +|--------------------------------+------------------+-----------------| +| Call Setup | Required | Not needed | +| Dedicated Physical Path | Yes | No | +| Whole data follows same path | Yes | No | +| Data arrives in order | Yes | No | +| Is a switch crash fatal | Yes | No | +| Bandwidth available | Fixed | Dynamic | +| Time of possible congestion | At setup | On every packet | +| Potentially wasted bandwidth | Yes | No | +| Store-and-forward transmission | No | Yes | +| Billing | Per minute | Per Byte | +|--------------------------------+------------------+-----------------| +@@html:
    @@ +#+INCLUDE: "./datalink.org" :minlevel 1 @@html:
    @@