Data Link Layer: Error Detection & Correction
Data Link Layer: Error Detection & Correction
10.1.2 Redundancy
• To be able to detect or correct errors, we need to send some extra bits with our data.
• These redundant bits are added by the sender and removed by the receiver. Their
presence allows the receiver to detect or correct corrupted bits.
10.1.4 Coding
• The sender adds redundant bits through a process that creates a relationship
between the redundant bits and the actual data bits.
• The receiver checks the relationships between the two sets of bits to detect errors.
• Coding schemes are divided into two broad categories: block coding and convolution
coding.
Example 10.1
Let us assume that k = 2 and n = 3. Table 10.1 shows the list of datawords and codewords.
Assume the sender encodes the dataword 01 as 011 and sends it to the receiver. Consider
the following cases:
1. The receiver receives 011. It is a valid codeword. The receiver extracts the dataword
01 from it.
2. The codeword is corrupted during transmission, and 111 is received This is not a valid
codeword and is discarded.
3. The codeword is corrupted during transmission, and 000 is received,a valid
codeword. The receiver incorrectly extracts the dataword 00. Two corrupted bits
have made the error undetectable.
An error-detecting code can detect only the types of errors for which it is designed; other
types of errors may remain undetected.
Hamming Distance
• The Hamming distance between two words is the number of differences between
the corresponding bits and the Hamming distance between two words x and y is
represented as d(x, y).
• The Hamming distance between the received codeword and the sent codeword is
the number of bits that are corrupted during transmission.
• If the Hamming distance between the sent and the received codeword is not zero,
the codeword has been corrupted during transmission.
• For example, if the codeword 00000 is sent and 01101 is received, 3 bits are in error
and the Hamming distance between the two is d(00000, 01101) = 3.
• If the d is not zero then message is corrupted.
• The Hamming distance can easily be found if we apply the XOR operation (⊕) on the
two words and count the number of 1s in the result.
• For example,the Hamming distance d(10101, 11110) is 3 because (10101 ⊕ 11110) is
01011 (three 1s).
Example 10.3
The minimum Hamming distance for our first code scheme (Table 10.1) is 2. This code
guarantees detection of only a single error. For example, if the third codeword (101) is sent
and one error occurs, the received codeword does not match any valid codeword. If two
errors occur,however, the received codeword may match a valid codeword and the errors
are not detected.
Linear Block Codes
• A linear block code is a code in which the exclusive OR (addition modulo-2) of two
valid codewords creates another valid codeword.
Example 10.5
The code in Table 10.1 is a linear block code because the result of XORing any codeword with
any other codeword is a valid codeword.
Minimum Distance for Linear Block Codes
• The minimum Hamming distance is the number of 1s in the nonzero valid codeword
with the smallest number of 1s.
Example 10.6
In our first code (Table 10.1), the numbers of 1s in the nonzero codewords are 2, 2, and 2. So
the minimum Hamming distance is dmin = 2.
Parity-Check Code
• This code is a linear-block [Link] this code, a k-bit dataword is changed to an n-bit
codeword where n = k + 1. The extra bit, called the parity bit, is selected to make the
total number of 1s in the codeword even.
• Minimum Hamming distance for this category is dmin = 2, which means that the
code is a single-bit error-detecting code. The code in Table 10.2 is also a parity-check
code with k = 4 and n = 5.
A possible structure of an encoder (at the sender) and a decoder(at the receiver).
• The encoder uses a generator that takes a copy of a 4-bit dataword (a0, a1, a2, and
a3) and generates a parity bit r0. The dataword bits and the parity bit create the 5-bit
codeword. The parity bit that is added makes the number of 1s in the codeword
even. In other words,
r0=a3+a2+a1+a0 (modulo-2)
• If the number of 1s is even, the result is 0; if the number of 1s is odd, the result is 1.
• The result, which is called the syndrome, is just 1 bit. The syndrome is 0 when the
number of 1s in the received codeword is even; otherwise, it is 1.
s0 = b3 + b2 + b1 + b0 + q0 (modulo-2)
• If the syndrome is 0, there is no detectable error in the received codeword; the data
portion of the received codeword is accepted as the dataword; if the syndrome is 1,
the data portion of the received codeword is discarded. The dataword is not created.
Example 10.7
Let us look at some transmission scenarios. Assume the sender sends the dataword 1011.
The codeword created from this dataword is 10111, which is sent to the receiver. We
examine five cases:
1. No error occurs; the received codeword is 10111. The syndrome is 0. The dataword
1011 is created.
2. One single-bit error changes a1. The received codeword is 10011. The syndrome is 1.
No dataword is created.
3. One single-bit error changes r0. The received codeword is 10110. The syndrome is 1.
No dataword is created. Note that although none of the dataword bits are corrupted,
no dataword is created because the code is not sophisticated enough to show the
position of the corrupted bit.
4. An error changes r0 and a second error changes a3. The received codeword is 00110.
The syndrome is 0. The dataword 0011 is created at the receiver. Note that here the
dataword is wrongly created due to the syndrome value. The simple parity-check
decoder cannot detect an even number of errors. The errors cancel each other out
and give the syndrome a value of 0.
5. Three bits—a3, a2, and a1—are changed by errors. The received codeword is 01011.
The syndrome is 1. The dataword is not created. This shows that the simple parity
check, guaranteed to detect one single error, can also find any odd number of errors.
A parity-check code can detect an odd number of errors.
• In the encoder, the dataword has k bits (4 here); the codeword has n bits (7 here).
• The size of the dataword is augmented by adding n − k (3 here) 0s to the right-hand
side of the word. The n-bit result is fed into the generator. The generator uses a
divisor of size n − k + 1 (4 here), predefined and agreed upon.
• The generator divides the augmented dataword by the divisor (modulo-2 division).
The quotient of the division is discarded;the remainder (r 2r1r0) is appended to the
dataword to create the codeword.
• The decoder receives the codeword (possibly corrupted in transition). A copy of all n
bits is fed to the checker, which is a replica of the generator.
• The remainder produced by the checker is a syndrome of n − k (3 here) bits, which is
fed to the decision logic analyzer.
• If the syndrome bits are all 0s, the 4 left-most bits of the codeword are accepted as
the dataword (interpreted as no error); otherwise, the 4 bits are discarded (error).
Encoder
• The encoder takes a dataword and augments it with n − k number of 0s. It then
divides the augmented dataword by the divisor. (Explain the fig on your own)
• The 3-bit remainder forms the check bits (r2, r1, and r0). They are appended to the
dataword to create the codeword.
Decoder
• The decoder does the same division process as the [Link] the syndrome is all 0s,
there is no error with a high probability; the dataword is separated from the received
codeword and accepted. Otherwise, everything is discarded. (Explain the fig on your
own)
10.3.2 Polynomials
Degree of a Polynomial
• In this arithmetic, multiplying a term by another term is very simple; we just add the
powers.
Multiplying Two Polynomials
• Multiplying a polynomial by another is done term by term. Each term of the first
polynomial must be multiplied by all terms of the second. The following is an
example:
• We divide the first term of the dividend by the first term of the divisor to get the first
term of the quotient.
• We multiply the term in the quotient by the divisor and subtract the result from the
dividend.
• We repeat the process until the dividend degree is less than the divisor degree.
Shifting
Shifting to the left is accomplished by multiplying each term of the polynomial by x m, where
m is the number of shifted bits; shifting to the right is accomplished by dividing each term of
the polynomial by xm.
In a cyclic code,
1. If s(x) ¦ 0, one or more bits is corrupted.
2. If s(x) = 0, either
a) No bit is corrupted, or
b) Some bits are corrupted, but the decoder failed to detect them.
• We want to find the criteria that must be imposed on the generator, g(x) to detect
the type of error, relationship among the sent codeword, error, received codeword,
and the generator. The received codeword is the sum of the sent codeword and the
error.
Received codeword = c(x) + e(x)
• The receiver divides the received codeword by g(x) to get the syndrome.
• Received codeword / g(x) = c(x) / g(x)+ e(x) / g(x)
Single-Bit Error
• They have very good performance in detecting single-bit errors, double errors, an
odd number of errors, and burst errors.
• They can easily be implemented in hardware and software.
• They are especially fast when implemented in hardware. This has made cyclic codes a
good candidate for many networks.
• There are, however, more powerful polynomials that are based on abstract algebra
involving Galois fields.
10.3.7 Hardware Implementation
• One of the advantages of a cyclic code is that the encoder and decoder can easily and
cheaply be implemented in hardware by using a handful of electronic devices.
• Also, a hardware implementation increases the rate of check bit and syndrome bit
calculation.
Divisor
• Let us first consider the divisor. We need to note the following points:
1. The divisor is repeatedly XORed with part of the dividend.
2. The divisor has n − k + 1 bits which either are predefined or are all 0s. In other words,
the bits do not change from one dataword to another.
3. A close look shows that only n − k bits of the divisor are needed in the XOR
operation. The leftmost bit is not needed because the result of the operation is
always 0,no matter what the value of this bit.
Using these points, we can make a fixed (hardwired) divisor that can be used for a cyclic
code if we know the divisor pattern.
Augmented Dataword
• We show the augmented dataword as fixed in position with the divisor bits shifting to
the right, 1 bit in each step.
• The divisor bits are aligned with the appropriate part of the augmented dataword.
Since our divisor is fixed, we need instead to shift the bits of the augmented
dataword to the left (opposite direction) to align the divisor bits with the appropriate
part.
Remainder
The remainder is 3 bits (n − k bits in general) in length. We can use three registers (single-bit
storage devices) to hold these bits. The following is the step-by-step process that can be
used to simulate the division process in hardware.
1. We assume that the remainder is originally all 0s (000 in our example).
2. At each time click (arrival of 1 bit from an augmented dataword), we repeat the
following two actions:
a) We use the leftmost bit to make a decision about the divisor (011 or 000).
b) The other 2 bits of the remainder and the next bit from the augmented dataword
(total of 3 bits) are XORed with the 3-bit divisor to create the next remainder.
• Steps 1, 2, and 3 push the first 3 bits to the remainder registers; steps 4, 5, 6, and 7
match the paper-and-pencil design. Note that the values in the remainder register in
steps 4 to 7 exactly match the values in the paper-and-pencil design.
• We need, however, to make the registers shift registers. A 1-bit shift register holds a
bit for a duration of one clock time.
• At a time click, the shift register accepts the bit at its input port, stores the new bit,
and displays it on the output port.
• The content and the output remain the same until the next input arrives. When we
connect several 1-bit shift registers together, it looks as if the contents of the register
are shifting.
General Design
10.4 CHECKSUM
• Checksum is an error-detecting technique that can be applied to a message of any
length. In the Internet, the checksum technique is mostly used at the network and
transport layer rather than the data-link layer.
• At the source, the message is first divided into m-bit units. The generator then
creates an extra m-bit unit called the checksum, which is sent with the message.
• At the destination, the checker creates a new checksum from the combination of the
message and sent checksum. If the new checksum is all 0s, the message is accepted;
otherwise,the message is discarded.
10.4.1 Concept
Instead of sending 36 as the sum, we can send 6 as the sum (7, 11, 12, 0, 6, 6).
Checksum
• We can make the job of the receiver easier if we send the complement of the sum,
the checksum. This is the same as subtracting the number from 2m − 1.
• If we add a number with its complement, we get a negative zero (a number with all
bits set to 1). When the receiver adds all five numbers (including the checksum), it
gets a negative zero.
• The receiver can complement the result again to get a positive zero.
Example 10.13
The sender adds all five numbers in one’s complement to get the sum = 6. The sender then
complements the result to get the checksum = 9, which is 15 − 6. Note that 6 = (0110)2 and
9 = (1001)2; they are complements of each other. The sender sends the five data numbers
and the checksum (7, 11, 12, 0, 6, 9). If there is no corruption in transmission, the receiver
receives (7, 11, 12, 0, 6, 9) and adds them in one’s complement to get [Link] sender
complements 15 to get 0. This shows that data have not been corrupted. Figure 10.16 shows
the process.
Internet Checksum
• Traditionally, the Internet has used a 16-bit checksum. The sender and the receiver
follow the steps depicted in Table 10.5. The sender or the receiver uses five steps.
Algorithm
• The traditional checksum uses a small number of bits (16) to detect errors in a
message of any size (sometimes thousands of bits).
• The Fletcher checksum was devised to weight each data item according to its
[Link] has proposed two algorithms: 8-bit and 16-bit.
• 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 check-
sum. The calculation is done modulo 256 (28), 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.
• The 16-bit Fletcher checksum is similar to the 8-bit Fletcher checksum, but it is
calculated over 16-bit data items and creates a 32-bit checksum. The calculation is
done modulo 65,536.
Adler Checksum
• The Adler checksum is a 32-bit checksum. Figure 10.19 shows a simple algorithm in
flowchart form.
• It is similar to the 16-bit Fletcher with three differences. First, calculation is done on
single bytes instead of 2 bytes at a time.
• Second, the modulus is a prime number (65,521) instead of 65,536.
• Third, L is initialized to 1 instead of 0. It has been proved that a prime modulo has a
better detecting capability in some combinations of data.
DLC Services
11.1 DLC SERVICES
• The data link control (DLC) deals with procedures for communication between two
adjacent nodes—node-to-node communication—no matter whether the link is
dedicated or broadcast. Data link control functions include framing and flow and
error control.
11.1.1 Framing
• Data transmission in the physical layer means moving bits in the form of a signal from
the source to the destination.
• The physical layer provides bit synchronization to ensure that the sender and receiver
use the same bit durations and timing.
• The data-link layer, on the other hand, needs to pack bits into frames, so that each
frame is distinguishable from another.
• Framing in the data-link layer separates a message from one source to a destination
by adding a sender address and a destination address.
Frame Size
• In byte stuffing (or character 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 usually called the escape
character (ESC) and has a predefined bit pattern. Whenever the receiver encounters
the ESC character, it removes it from the data section and treats the next character as
data, not as a delimiting flag.
• Byte stuffing by the escape character allows the presence of the flag in the data
section of the frame.
• The receiver removes the escape character, but keeps the next byte, which is
incorrectly interpreted as the end of the frame. If the escape character is part of the
text, an extra one is added to show that the second one is part of the text.
Bit-Oriented Framing
• If the flag pattern appears in the data, we need to somehow inform the receiver that
this is not the end of the frame. We do this by stuffing 1 single bit (instead of 1 byte)
to prevent the pattern from looking like a flag. The strategy is called bit stuffing.
• 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.
11.1.2 Flow and Error Control
One of the responsibilities of the data-link control sublayer is flow and error control at the
data-link layer.
Flow Control
• In communication at the data-link layer, we are dealing with four entities: network
and data-link layers at the sending node and network and data-link layers at the
receiving node.
• Although we can have a complex relationship with more than one producer and
consumer, we ignore the relationships between networks and data-link layers and
concentrate on the relationship between two data-link layers.
Buffers
• Although flow control can be implemented in several ways, we normally use two
buffers; one at the sending data-link layer and the other at the receiving data-link
layer.
• A buffer is a set of memory locations that can hold packets at the sender and
receiver.
• The flow control communication can occur by sending signals from the consumer to
the producer. When the buffer of the receiving data-link layer is full, it informs the
sending data-link layer to stop pushing frames.
Error Control
• The underlying technology at the physical layer is not fully reliable, we need to
implement error control at the data-link layer to prevent the receiving node from
delivering corrupted packets to its network layer.
• Error control at the data-link layer is normally very simple and implemented using
one of the following two methods.
➢ In the first method, if the frame is corrupted, it is silently discarded; if it is not
corrupted, the packet is delivered to the network layer. This method is used mostly in
wired LANs such as Ethernet.
➢ In the second method, if the frame is corrupted, it is silently discarded; if it is not
corrupted, an acknowledgment is sent to the sender.
• In a connectionless protocol, frames are sent from one node to the next without any
relationship between the frames; each frame is independent.
• Note that the term connectionless here does not mean that there is no physical
connection (transmission medium) between the nodes; it means that there is no
connection between frames.
• The frames are not numbered and there is no sense of ordering. Most of the data-
link protocols for LANs are connectionless protocols.
Connection-Oriented Protocol
• The data-link layer at the sender gets a packet from its network layer, makes a frame
out of it, and sends the frame.
• The data-link layer at the receiver receives a frame from the link, extracts the packet
from the frame, and delivers the packet to its network layer.
• The data-link layers of the sender and receiver provide transmission services for their
network layers.
FSMs
• Each FSM has only one state, the ready state. The sending machine remains in the
ready state until a request comes from the process in the network layer.
• When this event occurs, the sending machine encapsulates the message in a frame
and sends it to the receiving machine.
• The receiving machine remains in the ready state until a frame arrives from the
sending machine.
• When this event occurs, the receiving machine decapsulates the message out of the
frame and delivers it to the process at the network layer.
11.2.2 Stop-and-Wait Protocol
• Our second protocol is called the Stop-and-Wait protocol, which uses both flow and
error control.
• The sender sends one frame at a time and waits for an acknowledgment before
sending the next one.
• To detect corrupted frames, we need to add a CRC to each data frame. When a frame
arrives at the receiver site, it is checked. If its CRC is incorrect, the frame is corrupted
and silently discarded.
• Every time the sender sends a frame, it starts a timer. If an acknowledgment arrives
before the timer expires, the timer is stopped and the sender sends the next frame .
• If the timer expires, the sender resends the previous frame, assuming that the frame
was either lost or corrupted.
FSMs
Figure shows the FSMs for our primitive Stop-and-Wait protocol.
Sender States
• The sender is initially in the ready state, but it can move between the ready and
blocking state.
Ready State.
• When the sender is in this state, it is only waiting for a packet from the network layer.
If a packet comes from the network layer, the sender creates a frame, saves a copy of
the frame, starts the only timer and sends the frame. The sender then moves to the
blocking state.
Blocking State.
• The receiver is always in the ready state. Two events may occur:
a) If an error-free frame arrives, the message in the frame is delivered to the network
layer and an ACK is sent.
b) If a corrupted frame arrives, the frame is discarded.
Sequence and Acknowledgment Numbers
11.2.3 Piggybacking
• To make the communication more efficient, 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. Because piggybacking makes communication at the
datalink layer more complicated, it is not a common practice.
11.3 HDLC
High-level Data Link Control (HDLC) is a bit-oriented protocol for communication over point-
to-point and multipoint links. It implements the Stop-and-Wait protocol.
• In ABM, the configuration is balanced. The link is point-to-point, and each station can
function as a primary and a secondary (acting as peers).
11.3.2 Framing
• HDLC defines three types of frames: information frames(I-frames), supervisory
frames (S-frames), and unnumbered frames (U-frames).
• Each type of frame serves as an envelope for the transmission of a different type of
message.
• I-frames are used to data-link user data and control information relating to user data
(piggy-backing).
• S-frames are used only to transport control information.
• U-frames are reserved for system management.
• Each frame in HDLC may contain up to six fields(as shown in fig.11.6): a beginning
flag field, an address field, a control field, an information field, a frame check
sequence (FCS) field, and an ending flag field.
• Flag field. This field contains synchronization pattern 01111110, which identifies both
the beginning and the end of a frame.
• Address field. This field contains the address of the secondary station. If a primary
station created the frame, it contains a to address. If a secondary station creates the
frame, it contains a from address. The address field can be one byte or several bytes
long, depending on the needs of the network.
• Control field. The control field is one or two bytes used for flow and error [Link]
interpretation of bits are discussed later.
• Information field. The information field contains the user’s data from the network
layer or management information. Its length can vary from one network to another.
• FCS field. The frame check sequence (FCS) is the HDLC error detection field. It can
contain either a 2- or 4-byte CRC.
The control field determines the type of frame and defines its functionality.
• I-frames are designed to carry user data from the network layer. The subfields in the
control field are used to define these functions.
• The first bit defines the type. If the first bit of the control field is 0, this means the
frame is an I-frame. The next 3 bits, called N(S), define the sequence number of the
frame.
• The last 3 bits, called N(R), correspond to the acknowledgment number when
piggybacking is used. The single bit between N(S) and N(R) is called the P/F bit,a
single bit with a dual purpose.
• It has meaning only when it is set (bit = 1) and can mean poll or final. It means poll
when the frame is sent by a primary station to a secondary.
• It means final when the frame is sent by a secondary to a primary.
Control Field for S-Frames
• Supervisory frames are used for flow and error control whenever piggybacking is
either impossible or inappropriate.
• If the first 2 bits of the control field are 10, this means the frame is an S-frame. The
last 3 bits, called N(R),correspond to the acknowledgment number (ACK) or negative
acknowledgment number (NAK), depending on the type of S-frame.
• The 2 bits called code are used to define the type of S-frame itself. With 2 bits, we
can have four types of S-frames, as described below:
➢ Receive ready (RR). If the value of the code subfield is 00, it is an RR [Link] kind
of frame acknowledges the receipt of a safe and sound frame or group of frames. In
this case, the value of the N(R) field defines the acknowledgment number.
➢ Receive not ready (RNR). If the value of the code subfield is 10, it is an RNR S-frame.
This kind of frame is an RR frame with additional functions. It acknowledges the
receipt of a frame or group of frames, and it announces that the receiver is busy and
cannot receive more frames. It acts as a kind of congestion-control mechanism by
asking the sender to slow down. The value of N(R) is the acknowledgment number.
➢ Reject (REJ). If the value of the code subfield is 01, it is an REJ S-frame. This is a NAK
frame, but not like the one used for Selective Repeat ARQ. It is a NAK that can be
used in Go-Back-N ARQ to improve the efficiency of the process by informing the
sender, before the sender timer expires, that the last frame is lost or damaged. The
value of N(R) is the negative acknowledgment number.
➢ Selective reject (SREJ). If the value of the code subfield is 11, it is an SREJ S-frame.
This is a NAK frame used in Selective Repeat ARQ. Note that the HDLC Protocol uses
the term selective reject instead of selective repeat. The value of N(R) is the negative
acknowledgment number.
Control Field for U-Frames
11.4.1 Services
The designers of PPP have included several services to make it suitable for a point-to-point
protocol.
Services Provided by PPP
• PPP defines the format of the frame to be exchanged between devices. It also
defines how two devices can negotiate the establishment of the link and the
exchange of data.
• PPP is designed to accept payloads from several network layers (not only IP).
• Multilink PPP, provides connections over multiple links. One interesting feature of
PPP is that it provides network address configuration.
Services Not Provided by PPP
• PPP does not provide flow control. PPP has a very simple mechanism for error
control.
• A CRC field is used to detect errors. If the frame is corrupted, it is silently discarded;
the upper-layer protocol needs to take care of the problem.
• Lack of error control and sequence numbering may cause a packet to be received out
of order. PPP does not provide a sophisticated addressing mechanism to handle
frames in a multipoint configuration.
11.4.2 Framing
PPP uses a character-oriented (or byte-oriented) frame. Figure 11.20 shows the format of a
PPP frame. The description of each field follows:
• Flag. A PPP frame starts and ends with a 1-byte flag with the bit pattern 01111110.
• Address. The address field in this protocol is a constant value and set to 11111111
(broadcast address).
• Control. This field is set to the constant value 00000011 (imitating unnumbered
frames in HDLC). As we will discuss later, PPP does not provide any flow control. Error
control is also limited to error detection.
• Protocol. The protocol field defines what is being carried in the data field: either user
data or other information. This field is by default 2 bytes long, but the two parties
can agree to use only 1 byte.
• Payload field. This field carries either the user data or other information. The data
field is a sequence of bytes with the default of a maximum of 1500 bytes; but this
can be changed during negotiation
• FCS. The frame check sequence (FCS) is simply a 2-byte or 4-byte standard CRC.
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 flaglike 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.
11.4.3 Transition Phases
• A PPP connection goes through phases which can be shown in a transition phase
diagram (see Figure 11.21).
• The transition diagram, which is an FSM, starts with the dead state. In this state,
there is no active carrier (at the physical layer) and the line is quiet.
• When one of the two nodes starts the communication, the connection goes into the
establish state. In this state, options are negotiated between the two parties.
• If the two parties agree that they need authentication, then the system needs to do
authentication; otherwise, the parties can simply start communication.
• Data transfer takes place in the open state. When a connection reaches this state, the
exchange of data packets can be started. The connection remains in this state until
one of the endpoints wants to terminate the connection.
• In this case, the system goes to the terminate state. The system remains in this state
until the carrier (physical-layer signal) is dropped, which moves the system to the
dead state again.
11.4.4 Multiplexing
• Three sets of protocols are defined to make PPP powerful: the Link Control Protocol
(LCP), two Authentication Protocols (APs), and several Network Control Protocols
(NCPs).
• A PPP packet can carry data from one of these protocols in its data field, as shown in
Figure 11.22.
Link Control Protocol
The code field defines the type of LCP packet. There are 11 types of packets, as shown in
Table 11.1.
• There are three categories of packets.
• The first category, comprising the first four packet types, is used for link configuration
during the establish phase.
• The second category, comprising packet types 5 and 6, is used for link termination
during the termination phase.
• The last five packets are used for link monitoring and debugging.
• The ID field holds a value that matches a request with a reply.
• The length field defines the length of the entire LCP packet. The information field
contains information, such as options, needed for some LCP packets.
• The information field is divided into three fields: option type, option length, and
option data. We list some of the most common options in Table 11.2.
Authentication Protocols
• Authentication means validating the identity of a user who needs to access a set of
resources.
• PPP has created two protocols for authentication: Password Authentication Protocol
and Challenge Handshake Authentication Protocol.
PAP
The Password Authentication Protocol (PAP) is a simple authentication procedure with a
two-step process:
a. The user who wants to access a system sends an authentication identification and a
password.
b. The system checks the validity of the identification and password and either accepts or
denies connection.
• When a PPP frame is carrying any PAP packets, the value of the protocol field is
0xC023.
• The three PAP packets are authenticate-request, authenticate-ack, and authenticate-
nak.
• The first packet is used by the user to send the user name and password.
• The second is used by the system to allow access.
• The third is used by the system to deny access.
CHAP
The Challenge Handshake Authentication Protocol (CHAP) is a three-way handshaking
authentication protocol that provides greater security than PAP. In this method, the
password is kept secret; it is never sent online.
a. The system sends the user a challenge packet containing a challenge value, usually a few
bytes.
b. The user applies a predefined function that takes the challenge value and the user’s own
password and creates a result. The user sends the result in the response packet to the
system.
c. The system does the same. It applies the same function to the password of the user and
the challenge value to create a result. If the result created is the same as the result sent in
the response packet, access is granted; otherwise, it is denied.
• CHAP packets are encapsulated in the PPP frame with the protocol value C223 in
hexadecimal.
• There are four CHAP packets: challenge, response, success, and failure. The first
packet is used by the system to send the challenge value. The second is used by the
user to return the result of the calculation. The third is used by the system to allow
access to the system. The fourth is used by the system to deny access to the system.
Network Control Protocols
• PPP has defined a specific Network Control Protocol for each network protocol.
• For example, IPCP (Internet Protocol Control Protocol) configures the link for carrying
IP data packets.
• Note that none of the NCP packets carry network-layer data; they just configure the
link at the network layer for the incoming data.
IPCP
One NCP protocol is the Internet Protocol Control Protocol (IPCP). This protocol configures
the link used to carry IP packets in the Internet.
IPCP defines seven packets, distinguished by their code values, as shown in Table 11.3.
Other Protocols
• After the network-layer configuration is completed by one of the NCP protocols, the
users can exchange data packets from the network layer.
• There are different protocol fields for different network layers. For example, if PPP is
carrying data from the IP network layer, the field value is 0021.
• If PPP is carrying data from the OSI network layer, the value of the protocol field is
0023, and so on. Figure 11.27 shows the frame for IP.
Multilink PPP
• Multilink PPP, a logical PPP frame is divided into several actual PPP frames. A
segment of the logical frame is carried in the payload of an actual PPP frame, as
shown in Figure 11.28.
• To show that the actual PPP frame is carrying a fragment of a logical PPP frame, the
protocol field is set to (003d)16. This new development adds complexity.
• For example, a sequence number needs to be added to the actual PPP frame to show
a fragment’s position in the logical frame.
Example 11.7
Let us go through the phases followed by a network layer packet as it is transmitted through
a PPP connection. Figure 11.29 shows the steps. For simplicity, we assume unidirectional
movement of data from the user site to the system site (such as sending an e-mail through
an ISP).
• The first two frames show link establishment. We have chosen two options (not
shown in the figure): using PAP for authentication and suppressing the address
control fields. Frames 3 and 4 are for authentication. Frames 5 and 6 establish the
network layer connection using IPCP.
• The next several frames show that some IP packets are encapsulated in the PPP
frame. The system (receiver) may have been running several network layer protocols,
but it knows that the incoming data must be delivered to the IP protocol because the
NCP protocol used before the data transfer was IPCP.
• After data transfer, the user then terminates the data-link connection, which is
acknowledged by the system. Of course the user or the system could have chosen to
terminate the network-layer IPCP and keep the data-link layer running if it wanted to
run another NCP protocol.
• The original ALOHA protocol is called pure ALOHA. This is a simple but elegant
protocol.
• The idea is that each station sends a frame whenever it has a frame to send.
However, since there is only one channel to share, there is the possibility of collision
between frames from different stations.
• The pure ALOHA protocol relies on acknowledgments from the receiver. When a
station sends a frame, it expects the receiver to send an acknowledgment. If the
acknowledgment does not arrive after a time-out period, the station assumes that
the frame (or the acknowledgment) has been destroyed and resends the frame
• Pure ALOHA dictates that when the time-out period passes, each station waits a
random amount of time before resending its frame. The randomness will help avoid
more collisions. We call this time the backoff time TB.
• Pure ALOHA has a second method to prevent congesting the channel with
retransmitted frames. After a maximum number of retransmission attempts Kmax, a
station must give up and try later.
• The time-out period is equal to the maximum possible round-trip propagation delay,
which is twice the amount of time required to send a frame between the two most
widely separated stations (2 × Tp).
• The formula for TB depends on the implementation. One common formula is the
binary exponential backoff. In this method, for each retransmission, a multiplier R = 0
to 2K − 1 is randomly chosen and multiplied by Tp or Tfr to find TB. The value of Kmax
is usually chosen as 15.
Vulnerable time
• The vulnerable time, the length of time in which there is a possibility of collision. We
assume that the stations send fixed-length frames with each frame taking Tfr seconds
to send.
• Station B starts to send a frame at time t. Station A has started to send its frame after
t − Tfr. This leads to a collision between the frames from station B and station A.
• On the other hand, suppose that station C starts to send a frame before time t + Tfr.
Here, there is also a collision between frames from station B and station C.
Pure ALOHA vulnerable time=2×Tfr
Example 12.2
A pure ALOHA network transmits 200-bit frames on a shared channel of 200 kbps. What is
the requirement to make this frame collision-free?
Solution
Average frame transmission time Tfr is 200 bits/200 kbps or 1 ms. The vulnerable time is 2 ×
1 ms = 2 ms. This means no station should send later than 1 ms before this station starts
transmission and no station should start sending during the period (1 ms) that this station is
sending.
Throughput
Example 12.3
A pure ALOHA network transmits 200-bit frames on a shared channel of 200 kbps. What is
the throughput if the system (all stations together) produces
a. 1000 frames per second?
b. 500 frames per second?
c. 250 frames per second?
Solution
The frame transmission time is 200/200 kbps or 1 ms.
a. If the system creates 1000 frames per second, or 1 frame per millisecond, then G = 1. In
this case S = G × e−2G = 0.135 (13.5 percent). This means that the throughput is 1000 ×
0.135 = 135 frames. Only 135 frames out of 1000 will probably survive.
b. If the system creates 500 frames per second, or 1/2 frames per millisecond, then G = 1/2.
In this case S = G × e−2G = 0.184 (18.4 percent). This means that the throughput is 500 ×
0.184 = 92 and that only 92 frames out of 500 will probably survive. Note that this is the
maximum throughput case, percentagewise.
c. If the system creates 250 frames per second, or 1/4 frames per millisecond, then G = 1/4.
In this case S = G × e−2G = 0.152 (15.2 percent). This means that the throughput is 250 ×
0.152 = 38. Only 38 frames out of 250 will probably survive.
Slotted ALOHA
• In slotted ALOHA we divide the time into slots of Tfr seconds and force the station to
send only at the beginning of the time slot.
• Because a station is allowed to send only at the beginning of the synchronized time
slot, if a station misses this moment, it must wait until the beginning of the next time
slot.
• The vulnerable time is now reduced to one-half, equal to Tfr.
Slotted ALOHA vulnerable time=Tfr
Throughput
• Carrier sense multiple access (CSMA) requires that each station first listen to the
medium (or check the state of the medium) before sending. In other words, CSMA is
based on the principle “sense before transmit” or “listen before talk.”
• CSMA can reduce the possibility of collision, but it cannot eliminate [Link] are
connected to a shared channel (usually a dedicated medium).
• The possibility of collision still exists because of propagation delay; when a station
sends a frame, it still takes time (although very short) for the first bit to reach every
station and for every station to sense it.
Vulnerable Time
• The vulnerable time for CSMA is the propagation time Tp. This is the time needed for
a signal to propagate from one end of the medium to the other.
Persistence Methods
Three methods have been devised to answer these questions: the 1-persistent method, the
nonpersistent method, and the p-persistent method.
I-Persistent
• The I-persistent method is simple and straightforward. In this method, after the
station finds the line idle, it sends its frame immediately (with probability 1).
• This method has the highest chance of collision because two or more stations may
find the line idle and send their frames immediately.
Nonpersistent
• In the nonpersistent method, a station that has a frame to send senses the line. If the
line is idle, it sends immediately. If the line is not idle, it waits a random amount of
time and then senses the line again.
• This method reduces the efficiency of the network because the medium remains idle
when there may be stations with frames to send.
p-Persistent
• The p-persistent method is used if the channel has time slots with a slot duration
equal to or greater than the maximum propagation time.
• The p-persistent approach combines the advantages of the other two strategies. It
reduces the chance of collision and improves efficiency.
12.1.3 CSMA/CD
• Carrier sense multiple access with collision detection (CSMA/CD) augments the
algorithm to handle the collision.
• In this method, a station monitors the medium after it sends a frame to see if the
transmission was successful. If so, the station is finished. If, however, there is a
collision, the frame is sent again.
• Let us look at the first bits transmitted by the two stations involved in the collision.
• At time t1, station A has executed its persistence procedure and starts sending the
bits of its frame.
• At time t2, station C has not yet sensed the first bit sent by A.
• Station C executes its persistence procedure and starts sending the bits in its frame,
which propagate both to the left and to the right.
•
• The collision occurs sometime after time t2. Station C detects a collision at time t3
when it receives the first bit of A’s frame.
• Station C immediately aborts transmission.
• Station A detects collision at time t4 when it receives the first bit of C’s frame; it also
immediately aborts transmission.
• Looking at the figure, we see that A transmits for the duration t4 − t1; C transmits for
the duration t3 − t2.
• The level of energy in a channel can have three values: zero, normal, and abnormal.
• At the zero level, the channel is idle.
• At the normal level, a station has successfully captured the channel and is sending its
frame.
• At the abnormal level, there is a collision and the level of the energy is twice the
normal level.
Throughput
• The traditional Ethernet was a broadcast LAN that used the 1-persistence method to
control access to the common media.
12.1.4 CSMA/CA
• Carrier sense multiple access with collision avoidance (CSMA/CA) was invented for
wireless networks.
• Collisions are avoided through the use of CSMA/CA’s three strategies: the interframe
space, the contention window, and acknowledgments,
❑ Interframe Space (IFS).
• When an idle channel is found, the station does not send immediately. It waits for a
period of time called the interframe space or IFS.
• Even though the channel may appear idle when it is sensed, a distant station may
have already started transmitting.
• The IFS time allows the front of the transmitted signal by the distant station to reach
this station.
• After waiting an IFS time, if the channel is still idle, the station can send, but it still
needs to wait a time equal to the contention window (described next).
• The IFS variable can also be used to prioritize stations or frame types. For example, a
station that is assigned a shorter IFS has a higher priority.
❑ Contention Window.
• The contention window is an amount of time divided into slots. A station that is
ready to send chooses a random number of slots as its wait time. The number of
slots in the window changes according to the binary exponential backoff strategy.
• The station needs to sense the channel after each time slot. However, if the station
finds the channel busy, it does not restart the process; it just stops the timer and
restarts it when the channel is sensed as idle. This gives priority to the station with
the longest waiting time. See Figure 12.16.
❑ Acknowledgment.
• With all these precautions, there still may be a collision resulting in destroyed data.
In addition, the data may be corrupted during the transmission. The positive
acknowledgment and the time-out timer can help guarantee that the receiver has
received the frame.
Frame Exchange Time Line
1. Before sending a frame, the source station senses the medium by checking the energy
level at the carrier frequency.
a. The channel uses a persistence strategy with backoff until the channel is idle.
b. After the station is found to be idle, the station waits for a period of time called the DCF
interframe space (DIFS); then the station sends a control frame called the request to send
(RTS).
2. After receiving the RTS and waiting a period of time called the short interframe space
(SIFS), the destination station sends a control frame, called the clear to send (CTS), to the
source station. This control frame indicates that the destination station is ready to receive
data.
3. The source station sends data after waiting an amount of time equal to SIFS.
4. The destination station, after waiting an amount of time equal to SIFS, sends an
acknowledgment to show that the frame has been received. Acknowledgment is needed in
this protocol because the station does not have any means to check for the successful arrival
of its data at the destination.
Network Allocation Vector
• When a station sends an RTS frame, it includes the duration of time that it needs to
occupy the channel.
• The stations that are affected by this transmission create a timer called a network
allocation vector (NAV) that shows how much time must pass before these stations
are allowed to check the channel for idleness.
• Each station, before sensing the physical medium to see if it is idle, first checks its
NAV to see if it has expired. Figure 12.17 shows the idea of NAV.
Collision During Handshaking
• Two or more stations may try to send RTS frames at the same time. These control
frames may collide.
• However, because there is no mechanism for collision detection, the sender assumes
there has been a collision if it has not received a CTS frame from the receiver. The
backoff strategy is employed, and the sender tries again.
Hidden-Station Problem
• The solution to the hidden station problem is the use of the handshake frames (RTS
and CTS). Figure 12.17 also shows that the RTS message from B reaches A, but not C.
• However, because both B and C are within the range of A, the CTS message, which
contains the duration of data transmission from B to A, reaches C.
• Station C knows that some hidden station is using the channel and refrains from
transmitting until that duration is over.
CSMA/CA and Wireless Networks
12.2.1 Reservation
• In the reservation method, a station needs to make a reservation before sending
data. Time is divided into intervals. In each interval, a reservation frame precedes the
data frames sent in that interval.
• If there are N stations in the system, there are exactly N reservation minislots in the
reservation frame. Each minislot belongs to a station. When a station needs to send a
data frame, it makes a reservation in its own minislot. The stations that have made
reservations can send their data frames after the reservation frame.
12.2.2 Polling
• Polling works with topologies in which one device is designated as a primary station
and the other devices are secondary stations.
• All data exchanges must be made through the primary device even when the
ultimate destination is a secondary device.
• The primary device controls the link; the secondary devices follow its instructions.
• The primary device, therefore, is always the initiator of a session (see Figure 12.19).
This method uses poll and select functions to prevent collisions.
Select
• The select function is used whenever the primary device has something to send.
• The primary must alert the secondary to the upcoming transmission and wait for an
acknowledgment of the secondary’s ready status.
• Before sending data, the primary creates and transmits a select (SEL) frame, one field
of which includes the address of the intended secondary.
Poll
• The poll function is used by the primary device to solicit transmissions from the
secondary devices. When the primary is ready to receive data, it must ask (poll) each
device in turn if it has anything to send.
• When the first secondary is approached, it responds either with a NAK frame if it has
nothing to send or with data (in the form of a data frame) if it does.
• If the response is negative (a NAK frame), then the primary polls the next secondary
in the same manner until it finds one with data to send. When the response is
positive (a data frame), the primary reads the frame and returns an acknowledgment
(ACK frame), verifying its receipt.
12.2.3 Token Passing
• In the token-passing method, the stations in a network are organized in a logical ring.
• For each station, there is a predecessor and a successor. The predecessor is the
station which is logically before the station in the ring; the successor is the station
which is after the station in the ring.
• The current station is the one that is accessing the channel now.
• A special packet called a token circulates through the ring.
• The possession of the token gives the station the right to access the channel and
send its data. When a station has some data to send, it waits until it receives the
token from its predecessor.
• It then holds the token and sends its data. When the station has no more data to
send, it releases the token, passing it to the next logical station in the ring.
• Token management is needed for this access method. Stations must be limited in the
time they can have possession of the token.
• The token must be monitored to ensure it has not been lost or destroyed.
• And finally, token management is needed to make low-priority stations release the
token to high-priority stations.
Logical Ring
• In the physical ring topology, when a station sends the token to its successor, the
token cannot be seen by other stations; the successor is the next one in line.
• The dual ring topology uses a second (auxiliary) ring which operates in the reverse
direction compared with the main ring. The high-speed Token Ring networks called
FDDI (Fiber Distributed Data Interface) and CDDI (Copper Distributed Data Interface)
use this topology.
• In the bus ring topology, also called a token bus, the stations are connected to a
single cable called a bus. They, however, make a logical ring, because each station
knows the address of its successor (and also predecessor for token management
purposes).
• In a star ring topology, the physical topology is a star. There is a hub, however, that
acts as the connector. The wiring inside the hub makes the ring; the stations are
connected to this ring through the two wire connections.