Module 2
Module 2
3.1 INTRODUCTION
3.1.1 Types of Errors
• When bits flow from 1 point to another, they are subject to unpredictable-changes „.‟ of interference.
• The interference can change the shape of the signal.
• wo types of errors: 1) Single-bit error 2) Burst-error.
1) Single-Bit Error
Only 1 bit of a given data is changed →
from 1 to 0 or
→ from 0 to 1 (Figure 10.1a).
2) Burst Error
Two or more bits in the data have changed →
from 1 to 0 or
→ from 0 to 1 (Figure 10.1b).
A burst-error occurs more than a single-bit error.
This is because:
Normally, the duration of noise is longer than the duration of 1-bit. When
noise affects data, the noise also affects the bits.
The no. of corrupted-bits depends on → data-
rate and → duration of noise.
3.1.2 Redundancy
• The central concept in detecting/correcting errors is redundancy.
• Some extra-bits along with the data have to be sent to detect/correct errors. These extra bits are called
redundant-bits.
• The redundant-bits are
→ added by the sender and
→ removed by the receiver.
• The presence of redundant-bits allows the receiver to detect/correct errors.
3.1.3 Error Detection vs. Error Correction
• Error-correction is more difficult than error-detection.
1) Error Detection
Here, we are checking whether any error has occurred or not. The answer is a simple
YES or NO.
We are not interested in the number of corrupted-bits.
2) Error Correction
Here, we need to know
3
Computer Networks notes
→ exact number of corrupted-bits and
→ location of bits in the message.
Two important factors to be considered: 1) Number of errors and 2)
Message-size.
3.1.4 Coding
• Redundancy is achieved through various coding-schemes.
1) Sender adds redundant-bits to the data-bits. This process creates a relationship between →
redundant-bits and
→ data-bits.
2) Receiver checks the relationship between redundant-bits & data-bits to detect/correct errors.
• Two important factors to be considered:
1) Ratio of redundant-bits to the data-bits and 2) Robustness of the process.
• Two broad categories of coding schemes: 1) Block-coding and 2) Convolution coding.
3.2 Block Coding
• The message is divided into k-bit blocks. These blocks are called data-words.
• Here, r-redundant-bits are added to each block to make the length n=k+r.
• The resulting n-bit blocks are called code-words.
• Since n>k, the number of possible code-words is larger than the number of possible data-words.
• Block-coding process is 1-to-1; the same data-word is always encoded as the same code-word.
n k
• Thus, we have 2 -2 code-words that are not used. These code-words are invalid or illegal.
3.2.1 Error Detection
• If the following 2 conditions are met, the receiver can detect a change in the original code-word:
1) The receiver has a list of valid code-words.
2) The original code-word has changed to an invalid code-words.
4
Computer Networks notes
ii) However, if the code-word is corrupted but the received code-word still matches a
valid codeword, the error remains undetected.
• An error-detecting code can detect only the types of errors for which it is designed; other types of errors may
remain undetected.
Example 3.1
5
Computer Networks notes
¤ Let us assume that the sent code-word x is at the center of a circle with radius s. ¤ All received
code-words that are created by 0 to s errors are points inside the circle or on the perimeter of the
circle.
¤ All other valid code-words must be outside the circle
• For example: A code scheme has a Hamming distance dmin = 4.
This code guarantees the detection of upto 3 errors (d = s + 1 or s = 3).
[Link] Linear Block Codes
• Almost all block codes belong to a subset of block codes called linear block codes.
• A linear block code is a code in which the XOR of 2 valid code-words creates another valid code-word.
(XOR Addition modulo-2)
• The code in Table 10.1 is a linear block code because the result of XORing any code-word with any other
code-word is a valid code-word.
For example, the XORing of the 2nd and 3rd code-words creates the 4th one.
[Link].1 Minimum Distance for Linear Block Codes
• Minimum Hamming distance is no. of 1s in the nonzero valid code-word with the smallest no. of 1s.
• In Table 10.1,
The numbers of 1s in the nonzero code-words are 2, 2, and 2. So the
minimum Hamming distance is dmin = 2.
[Link] Parity Check Code
• This code is a linear block code. This code can detect an odd number of errors.
• A k-bit data-word is changed to an n-bit code-word where n=k+1.
• One extra bit is called the parity-bit.
• The parity-bit is selected to make the total number of 1s in the code-word even.
• Minimum hamming distance dmin = 2. This means the code is a single-bit error-detecting code.
6
Computer Networks notes
• Here is how it works (Figure 10.4): 1) At Sender
The encoder uses a generator that takes a copy of a 4-bit data-word (a0, a1, a2, and a3) and generates
a parity-bit r0.
The encoder
→ accepts a copy of a 4-bit data-word (a0, a1, a2, and a3) and → generates a
parity-bit r0 using a generator
→ generates a 5-bit code-word
The parity-bit & 4-bit data-word are added to make the number of 1s in the code-word even. The
addition is done by using the following:
The checker performs the same operation as the generator with one exception: The addition is done
over all 5 bits. The result is called the syndrome bit
(so).
Syndrome bit = 0 when the no. of 1s in the received code-word is even; otherwise, it is 1. The
syndrome is passed to the decision logic analyzer.
1) If s0=0, there is no error in the received code-word. The data portion of the received
code-word is accepted as the data-word.
2) If s0=1, there is error in the received code-word. The data portion of the received code-
word is discarded. The data-word is not created.
Example 3.2
7
Computer Networks notes
3.3 Cyclic Codes
• Cyclic codes are special linear block codes with one extra property:
If a code-word is cyclically shifted (rotated), the result is another code-word.
For ex: if code-word = 1011000 and we cyclically left-shift, then another code-word = 0110001.
• Let First-word = a0 to a6 and Second-word = b0 to b6, we can shift the bits by using the following:
8
Computer Networks notes
The decision-logic-analyzer performs following functions:
i) For No Error
¤ If all syndrome-bits are 0s, the received code-word is accepted. ¤ Data-
word is extracted from received code-word (Figure 10.7a).
ii) For Error
¤ If all syndrome-bits are not 0s, the received code-word is discarded (Figure 10.7b).
9
Computer Networks notes
Example 3.3
3.3.2 Polynomials
• A pattern of 0s and 1s can be represented as a polynomial with coefficients of 0 and 1 (Figure 10.8).
• The power of each term shows the position of the bit; the coefficient shows the value of the bit.
Standard Polynomials
12
Computer Networks notes
Algorithm
13
Computer Networks notes
3.4.2 Other Approaches to the Checksum
• If two 16-bit items are transposed in transmission, the checksum cannot catch this error.
• The reason is that the traditional checksum is not weighted: it treats each data item equally.
• In other words, the order of data items is immaterial to the calculation.
• Two approaches have been used to prevent this problem: 1)Fletcher and 2)Adler
[Link] Fletcher Checksum
• The Fletcher checksum was devised to weight each data item according to its position.
• Fletcher has proposed two algorithms: 8-bit and 16-bit (Figure 10.18).
• The first, 8-bit Fletcher, calculates on 8-bit data items and creates a 16-bit checksum.
The second, 16-bit Fletcher, calculates on 16-bit data items and creates a 32-bit checksum.
• The 8-bit Fletcher is calculated over data octets (bytes) and creates a 16-bit checksum.
8
• The calculation is done modulo 256 (2 ), which means the intermediate results are divided by 256 and the
remainder is kept.
• The algorithm uses two accumulators, L and R.
• The first simply adds data items together; The second adds a weight to the calculation.
14
Computer Networks notes
• The data link control (DLC) deals with procedures for communication between two adjacent nodes i.e.
node-to-node communication.
• Data link control functions include 1) Framing and 2) Flow control and 3) Error control.
3.5.1 Framing
• A frame is a group of bits.
• Framing means organizing the bits into a frame that are carried by the physical layer.
• The data-link-layer needs to form frames, so that each frame is distinguishable from another.
• Framing separates a message from other messages by adding sender-address & destination-address.
15
Computer Networks notes
• The destination-address defines where the packet is to go.
The sender-address helps the recipient acknowledge the receipt.
• Q: Why the whole message is not packed in one frame?
Ans: Large frame makes flow and error-control very inefficient.
Even a single-bit error requires the re-transmission of the whole message.
When a message is divided into smaller frames, a single-bit error affects only that small frame. (Our postal
system practices a type of framing. The simple act of inserting a letter into an envelope separates one piece of
information from another; the envelope serves as the delimiter. In addition, each envelope defines the sender
and receiver addresses since the postal system is a many-to-many carrier facility).
[Link] Frame Size • Two types
of frames: 1) Fixed Size
Framing
There is no need for defining boundaries of frames; the size itself can be used as a delimiter. For
example: ATM WAN uses frames of fixed size called cells.
2) Variable Size Framing
We need to define the end of the frame and the beginning of the next frame. Two
approaches are used: 1) Character-oriented approach 2) Bit-oriented approach.
[Link] Character Oriented Framing
• Data to be carried are 8-bit characters from a coding system such as ASCII (Figure 11.1).
• The header and the trailer are also multiples of 8 bits.
1) Header carries the source and destination-addresses and other control information. 2) Trailer
carries error-detection or error-correction redundant bits.
• To separate one frame from the next frame, an 8- bit (I-byte) flag is added at the beginning and the end of a
frame.
• The flag is composed of protocol-dependent special characters.
• The flag signals the start or end of a frame.
• Problem:
Character-oriented framing is suitable when only text is exchanged by the data-link-layers.
However, if we send other type of information (say audio/video), then any pattern used for the flag
can also be part of the information.
If the flag-pattern appears in the data-section, the receiver might think that it has reached the end of
the frame.
Solution: A byte-stuffing is used.
(Byte stuffing character stuffing)
• In byte stuffing, a special byte is added to the data-section of the frame when there is a character with the
same pattern as the flag.
• The data-section is stuffed with an extra byte. This byte is called the escape character (ESC), which has a
predefined bit pattern.
• When a receiver encounters the ESC character, the receiver → removes ESC character from the data-section
and → treats the next character as data, not a delimiting flag.
16
Computer Networks notes
• Problem:
What happens if the text contains one or more escape characters followed by a flag?
The receiver removes the escape character, but keeps the flag, which is incorrectly interpreted as the end
of the frame. Solution:
Escape characters part of the text must also be marked by another escape character (Fig 11.2).
• In short, byte stuffing is the process of adding one extra byte whenever there is a flag or escape character in
the text.
[Link] Bit Oriented Framing
• The data-section of a frame is a sequence of bits to be interpreted by the upper layer as text, audio, video,
and so on.
• However, in addition to headers and trailers, we need a delimiter to separate one frame from theother.
• Most protocols use a special 8-bit pattern flag 01111110 as the delimiter to define the beginning and the end
of the frame (Figure 11.3).
• Problem:
If the flag-pattern appears in the data-section, the receiver might think that it has reached the end of
the frame.
Solution: A bit-stuffing is used.
• In bit stuffing, if a 0 and five consecutive 1 bits are encountered, an extra 0 is added. This extra stuffed bit
is eventually removed from the data by the receiver. (Figure 11.4).
• This guarantees that the flag field sequence does not inadvertently appear in the frame.
17
Computer Networks notes
• In short, bit stuffing is the process of adding one extra 0 whenever five consecutive 1s follow a 0 in the data,
so that the receiver does not mistake the pattern 0111110 for a flag.
3.5.2 Flow Control and Error Control
• One of the responsibilities of the DLC sublayer is flow and error control at the data-link layer.
• At the sending node, the data-link layer tries to push frames toward the data-link layer at the receiving node
(Figure 11.5).
• If the receiving node cannot process and deliver the packet to its network at the same rate that theframes
arrive, it becomes overwhelmed with frames.
• Here, flow control can be feedback from the receiving node to the sending node to stop or slow down pushing
frames.
[Link].1 Buffers
• Flow control can be implemented by using buffer.
• A buffer is a set of memory locations that can hold packets at the sender and receiver.
• Normally, two buffers can be used. 1) First buffer at the sender.
2) Second buffer at the receiver.
• The flow control communication can occur by sending signals from the consumer to the producer.
• When the buffer of the receiver is full, it informs the sender to stop pushing frames.
18
Computer Networks notes
2) Second method: If the frame is corrupted, it is discarded;
If the frame is not corrupted, an acknowledgment is sent to the sender.
Acknowledgment is used for the purpose of both flow and error control.
[Link].1 Combination of Flow and Error Control
• Flow and error control can be combined.
• The acknowledgment that is sent for flow control can also be used for error control to tell the sender the
packet has arrived uncorrupted.
• The lack of acknowledgment means that there is a problem in the sent frame.
• A frame that carries an acknowledgment is normally called an ACK to distinguish it from the dataframe.
19
Computer Networks notes
3.6 DATA LINK LAYER PROTOCOLS
• Traditionally 2 protocols have been defined for the data-link layer to deal with flow and error control: 1)
Simple Protocol and 2) Stop-and-Wait Protocol.
• The behavior of a data-link-layer protocol can be better shown as a finite state machine (FSM).
• An FSM is a machine with a finite number of states (Figure 11.6).
• The machine is always in one of the states until an event occurs.
• Each event is associated with 2 reactions:
1) Defining the list (possibly empty) of actions to be performed.
2) Determining the next state (which can be the same as the current state).
• One of the states must be defined as the initial state, the state in which the machine starts when it turns on.
[Link] Design
• Here is how it works (Figure 11.7):
1) At Sender
¤ The data-link-layer
→ gets data from its network-layer →
makes a frame out of the data and →
sends the frame.
20
Computer Networks notes
2) At Receiver
¤ The data-link-layer
→ receives a frame from its physical layer →
extracts data from the frame and
→ delivers the data to its network-layer.
Data-link-layers of sender & receiver provide transmission services for their network-layers.
Data-link-layers use the services provided by their physical layers for the physical transmission
of bits.
[Link] FSMs
• Two main requirements:
1) The sender-site cannot send a frame until its network-layer has a data packet to send.
2) The receiver-site cannot deliver a data packet to its network-layer until a frame arrives.
• These 2 requirements are shown using two FSMs.
• Each FSM has only one state, the ready state.
21
Computer Networks notes
Example 3.6
22
Computer Networks notes
[Link] FSMs
23
Computer Networks notes
Example 3.7
24
Computer Networks notes
The acknowledgment-numbers always announce the sequence-number of the next frame expected
by the receiver.
For example,
If frame-0 has arrived safely, the receiver sends an ACK-frame with acknowledgment-1
(meaning frame-1 is expected next).
Example 3.8
3.6.3 Piggybacking
• A technique called piggybacking is used to improve the efficiency of the bidirectional protocols.
• The data in one direction is piggybacked with the acknowledgment in the other direction.
• In other words, when node A is sending data to node B, Node A also acknowledges the data received from
node B.
3.7 High-Level Data Link Control (HDLC)
• HDLC is a bit-oriented protocol for communication over point-to-point and multipoint links.
• HDLC implements the ARQ mechanisms.
3.7.1 Configurations and Transfer Modes
• HDLC provides 2 common transfer modes that can be used in different configurations: 1) Normal response
mode (NRM)
2) Asynchronous balanced mode (ABM). NRM
• The station configuration is unbalanced (Figure 11.14).
• We have one primary station and multiple secondary stations.
• A primary station can send commands, a secondary station can only respond.
• The NRM is used for both point-to-point and multiple-point links.
25
Computer Networks notes
ABM
• The configuration is balanced (Figure 11.15).
• Link is point-to-point, and each station can function as a primary and a secondary (acting as peers).
• This is the common mode today.
3.7.2 Framing
• To provide the flexibility necessary to support all the options possible in the modes andconfigurations,
HDLC defines three types of frames:
1) Information frames (I-frames): are used to transport user data and control information relating to user
data (piggybacking).
2) Supervisory frames (S-frames): are used only to transport control information.
3) Unnumbered frames (U-frames): are reserved for system management.
Information carried by U-frames is intended for managing the link itself.
• Each type of frame serves as an envelope for the transmission of a different type of message.
[Link] Frame Format
26
Computer Networks notes
This field can be 1 byte or several bytes long, depending on the needs of the network.
3) Control Field
This field is one or two bytes used for flow and error control.
4) Information Field
This field contains the user's data from the network-layer or management information. Its
length can vary from one network to another.
5) FCS Field
This field is the error-detection field. (FCS Frame Check Sequence) This
field can contain either a 2- or 4-byte standard CRC.
[Link].1 Control Fields of HDLC Frames
• The control field determines the type of frame and defines its functionality (Figure 11.17).
27
Computer Networks notes
1) Receive Ready (RR) = 00
¤ This acknowledges the receipt of frame or group of frames. ¤
The value of N(R) is the acknowledgment-number. 2) Receive
Not Ready (RNR) = 10
¤ This is an RR frame with 1 additional function:
i) It announces that the receiver is busy and cannot receive more frames. ¤ It
acts as congestion control mechanism by asking the sender to slow down. ¤ The value
of N(R) is the acknowledgment-number.
3) ReJect (REJ) = 01
¤ It is a NAK frame used in Go-Back-N ARQ to improve the efficiency of the process. ¤ It
informs the sender, before the sender time expires, that the last frame is lost or damaged.
¤ The value of N(R) is the negative acknowledgment-number.
4) Selective REJect (SREJ) = 11
¤ This is a NAK frame used in Selective Repeat ARQ.
¤ The value of N(R) is the negative acknowledgment-number.
3) Control Field for U-Frames
• Unnumbered frames are used to exchange session management and control information betweenconnected
devices.
• U-frames contain an information field used for system management information, but not user data.
• Much of the information carried by U-frames is contained in codes included in the control field.
• U-frame codes are divided into 2 sections:
i) A 2-bit prefix before the P/F bit ii)
A 3-bit suffix after the P/F bit.
• Together, these two segments (5 bits) can be used to create up to 32 different types of U-frames.
Example 3.9
28
Computer Networks notes
29
Computer Networks notes
This field is byte-stuffed if the flag-byte pattern appears in this field. Padding is needed if the
payload-size is less than the maximum size. 6) FCS
This field is the PPP error-detection field.
This field can contain either a 2- or 4-byte standard CRC.
[Link] Byte Stuffing
• Since PPP is a byte-oriented protocol, the flag in PPP is a byte that needs to be escaped whenever it appears
in the data section of the frame.
• The escape byte is 01111101, which means that every time the flag like pattern appears in the data, this extra
byte is stuffed to tell the receiver that the next byte is not a flag.
• Obviously, the escape byte itself should be stuffed with another escape byte.
3.8.2 Transition Phases
• The transition diagram starts with the dead state (Figure 11.21). 1) Dead
State
In dead state, there is no active carrier and the line is quiet.
2) Establish State
When 1 of the 2 nodes starts communication, the connection goes into the establish state. In
establish state, options are negotiated between the two parties.
3) Authenticate State
If the 2 parties agree that they need authentication,
Then the system needs to do authentication;
Otherwise, the parties can simply start communication.
4) Open State
Data transfer takes place in the open state.
5) Terminate State
When 1 of the endpoints wants to terminate connection, the system goes to terminate state.
30
Computer Networks notes
4.1 Introduction
• When nodes use shared-medium, we need multiple-access protocol to coordinate access to medium.
• Analogy:
We need to ensure
→ Each people has right to speak.
→ Two people do not speak at the same time
→ Two people do not interrupt each other (i.e. Collision Avoidance)
• Many protocols have been designed to handle access to a shared-link (Figure 12.1).
• These protocols belong to a sublayer in the data-link layer called Media Access Control (MAC).
1) Four random-access protocols (or Contention Methods):
i) ALOHA ii) CSMA iii) CSMA/CD iv)
CSMA/CA These protocols are mostly used in LANs and WANs.
2) Three controlled-access protocols:
i) Reservation ii) Polling iii) Token-passing
Some of these protocols are used in LANs.
3) Three channelization protocols:
i) FDMA ii) TDMA iii) CDMA
These protocols are used in cellular telephony.
1)ALOHA
2)CSMA (Carrier Sense Multiple Access)
3)CSMA/CD (Carrier Sense Multiple Access with Collision-detection)
4)CSMA/CA (Carrier Sense Multiple Access with Collision Avoidance)
4.2.1 ALOHA
• ALOHA was designed for a wireless LAN, but it can be used on any shared medium.
• Since the medium is shared between the stations, there is possibility of collisions.
When 2 or more stations send the data simultaneously, there is possibility of collision & data loss
[Link] Pure ALOHA
32
Computer Networks notes
In fig 12.4 ,
If station B sends a frame between t-Tfr and t, this leads to a collision between the frames from station A
and station B.
[Link].2 Throughput
• The average number of successful transmissions is given by
33
Computer Networks notes
• If a station misses the time-slot, the station must wait until the beginning of the next time-slot.
• If 2 stations try to resend at beginning of the same time-slot, the frames will collide again (Fig 12.6).
[Link].1 Throughput
• The average number of successful transmissions is given by
4.2.2 CSMA
• CSMA was developed to minimize the chance of collision and, therefore, increase the performance.
• CSMA is based on the principle “sense before transmit” or “listen before talk.”
• Here is how it works:
1) Each station checks the state of the medium: idle or busy.
2) i) If the medium is idle, the station sends the data.
i) If the medium is busy, the station defers sending.
• CSMA can reduce the possibility of collision, but it cannot eliminate it.
34
Computer Networks notes
35
Computer Networks notes
1) 1-Persistent
• Before sending a frame, a station senses the line (Figure 12.10a).
i) If the line is idle, the station sends immediately (with probability = 1). ii) If
the line is busy, the station continues sensing the line.
• This method has the highest chance of collision because 2 or more stations:
→ may find the line idle and
→ send the frames immediately.
2) Non-Persistent
• Before sending a frame, a station senses the line (Figure 12.10b).
i) If the line is idle, the station sends immediately.
ii) If the line is busy, the station waits a random amount of time and then senses the line again.
• This method reduces the chance of collision because 2 or more stations:
→ will not wait for the same amount of time and
→ will not retry to send simultaneously.
3) P-Persistent
• This method is used if the channel has time-slots with a slot-duration equal to or greater than the maximum
propagation time (Figure 12.10c).
• Advantages:
i) It combines the advantages of the other 2 methods.
ii) It reduces the chance of collision and improves efficiency.
• After the station finds the line idle, it follows these steps:
1) With probability p, the station sends the frame.
2) With probability q=1-p, the station waits for the beginning of the next time-slot and checks the line
again.
i) If line is idle, it goes to step 1.
ii) If line is busy, it assumes that collision has occurred and uses the back off procedure.
4.2.3 CSMA/CD
• Disadvantage of CSMA: CSMA does not specify the procedure after a collision has occurred.
Solution: CSMA/CD enhances the CSMA to handle the collision.
• Here is how it works (Figure 12.12):
1) A station
→ sends the frame &
→ then monitors the medium to see if the transmission was successful or not.
If the transmission was unsuccessful (i.e. there is a collision), the frame is sent again.
36
Computer Networks notes
[Link] Procedure
• CSMA/CD is similar to ALOHA with 2 differences (Figure 12.13):
1) Addition of the persistence process.
¤ We need to sense the channel before sending the frame by using non-persistent, 1- persistent or
p-persistent.
2) Frame transmission.
i) In ALOHA, first the entire frame is transmitted and then acknowledgment is waited for. ii)
In CSMA/CD, transmission and collision-detection is a continuous process.
37
Computer Networks notes
[Link] Throughput
• The throughput of CSMA/CD is greater than pure or slotted ALOHA.
• The maximum throughput is based on
→ different value of G
→ persistence method used (non-persistent, 1-persistent, or p-persistent) and →
„p‟ value in the p-persistent method.
• For 1-persistent method, the maximum throughput is 50% when G =1.
• For non-persistent method, the maximum throughput is 90% when G is between 3 and 8.
4.2.4 CSMA/CA
• Here is how it works (Figure 12.15):
1) A station needs to be able to receive while transmitting to detect a collision.
i) When there is no collision, the station receives one signal: its own signal. ii)
When there is a collision, the station receives 2 signals:
a) Its own signal and
b) Signal transmitted by a second station.
2) To distinguish b/w these 2 cases, the received signals in these 2 cases must be different.
38
Computer Networks notes
3) Acknowledgment
• There may be a collision resulting in destroyed-data.
• In addition, the data may be corrupted during the transmission.
• To help guarantee that the receiver has received the frame, we can use
39
Computer Networks notes
4.3.1 Reservation
• Before sending data, each station needs to make a reservation of the medium.
• Time is divided into intervals.
• In each interval, a reservation-frame precedes the data-frames.
function.
→ alerts the secondary about upcoming transmission by sending select frame (SEL) →
then waits for an acknowledgment (ACK) from secondary
→ then sends the data frame and
→ finally waits for an acknowledgment (ACK) from the secondary.
2) Poll
if they have anything to send; this is
called poll function.
its predecessor.
42
Computer Networks notes
43
Computer Networks notes
MODULE-WISE QUESTIONS
44