CN - Module 2 Full
CN - Module 2 Full
• The data link layer is responsible for moving frames from one node to the
next one.
• Framing & Synchronization
• It receives the “Packet” from the Network layer and adds a Header and a
Trailer to form a “Frame”
• The receiving device should be in perfect sync with the sending device.
• This means it should know the start of a bit duration and the exact
duration of a bit.
• This will lead to bit-gain or bit-loss and even complete loss of the
message.
• Special bit patterns, called Flags, are used to indicate the beginning and the
end of each frame.
• The popular HDLC (High-level Data Link Control) protocol used the same
pattern of 01111110 as the Start and End flags.
• One problem here is that the Flag pattern may occur in the data since it is a
bit-oriented protocol (non-text data like picture, audio, video, etc)
• This problem can be overcome by “bit-stuffing”.
• Sender scans the data and inserts an extra ‘0’ after 5 consecutive 1’s.
• Receiver removes the 0 after 5 consecutive 1’s.
• Framing also involves computing the checksum (parity) bits and putting
them in the frame, to enable the receiver node to check for transmission
errors.
• It also includes the Physical (MAC) addresses of the sending node and the
receiving node.
• The MAC address of a network device is a permanent address that is
hardwired during its manufacture.
• A MAC address comprises of six groups of two hexadecimal digits (48
bits), separated by hyphens or colons.
• Example - 00:0A:89:5B:F0:11
• The IP address is used by routers to bring the packet to the right network
while the MAC address is used to deliver the frame to the device within the
network.
Computer Networks - Prof Ashok Herur 11
Error detection and correction codes
• When error detection codes are used, the receiver can only find out that
something is wrong but will not be able to say which bit(s) are incorrect.
• The only way out, is to ask the transmitter to retransmit the frame.
• Example codes: Character Parity, CRC
• When error correction codes are used, the receiver can pin-point the
erroneous bits and hence correct them.
• However, the amount of redundancy (overhead) here is much more than
in error detection codes.
• Example codes: Hamming code, Convolutional code.
• Error correction codes are also called Forward Error Correction (FEC) codes.
• When the error rate is very low (optical fibre), error detection codes are
better since the number of retransmissions will be very few.
• The receiver divides the received bit sting by the same GP string used by the
transmitter.
• If the remainder is Zero, it means that there are no errors. Else, it means
that the frame has some errors.
• Note that this method can detect the presence of up to N errors.
• Example:
1. Compute the Checksum for the message, 10010, using a Generator
Polynomial, x3 + x + 1
2. Show how the receiver verifies the Checksum when there is no error.
3. Show how the receiver detects the presence of a 2-bit error.
• Hamming code is an error correction code, that can detect and correct
single-bit errors.
• Hamming code uses a block parity mechanism; The data is divided into
blocks, and parity is added to the block.
• The number of parity bits added to Hamming code is given by the formula
2p ≥ d + p + 1, where p is the number of parity bits and d is the number of
data bits.
• For example, if you wanted to transmit 8 data bits, the formula would be 24
≥ 8 + 4 + 1. So 4 parity bits are required, for a total of 12 bits.
• This code is called Hamming (12, 8)
• These parity bits occupy the 2N bit positions, and are calculated by using
standard equations. The other bit places are filled by the bits representing
the character.
• Its transmission efficiency (code rate = k/n) goes up as the block size
increases.
• In Hamming(12, 8), the code rate (data bits / total) is only 0.67, while
Hamming(255, 247) is 0.969.
• However, as the block size increases, the chance of multiple errors in
the block also increases, and hence it will not be effective.
• It has a larger overhead compared to Character parity method.
• It needs 4 parity bits for each character (50% overhead) while Character
parity method required just one parity bit (12.5% overhead).
Computer Networks - Prof Ashok Herur 22
Example: Hamming (11, 7)
Solution:
• Since the message is 7 bits long, we need 4 parity bits, as per the formula:
2p ≥ d + p + 1.
• These parity bits will occupy the 1st, 2nd, 4th and 8th bit positions.
• P1 + D3 + D5 + D7 + D9 + D11 =0
• P2 + D3 + D6 + D7 + D10 + D11 =1
• P4 + D5 + D6 + D7 =0
• P8 + D9 + D10 + D11 =1
• So, the number 1010 2 = 10 (decimal) indicates that bit number 10 is
incorrect. Hence, it is flipped from the received value of ‘1’ to ‘0’.
• Convolutional code is an error correction code, that can detect and correct
multiple bit errors in a synchronous transmission frame.
• The computed parity bits depend not only on the current block but on the
past few blocks as well.
• It is quite complex and requires a lot of computation.
• It is also called as Viterbi coding.
• Sender’s window and the Receiver’s window are of the same size = N
• The sender can send N frames without waiting for the acknowledgement,
while the receiver can receive up to N frames.
• Whenever a frame is faulty, only the faulty frame has to be retransmitted.
• The receiver buffers the correct frames, while waiting for the retransmission
of the faulty frame.
• It then puts the frames in the correct sequence before passing them on to
the Network layer.
• In dynamic channel allocation scheme, users get to use the channels as and
when they are needed.
• The allocation protocols consider a number of parameters to minimize the
transmission interference from other users.
• This allocation scheme optimises bandwidth usage and results in faster
transmissions.
• Dynamic channel allocation is further divided into centralised (cell-phone
networks) and distributed allocation (LAN).
• The ALOHA protocol was developed at the University of Hawaii in the early
1970s for packet radio networks.
• However, it can be used in any situation where multiple devices share a
common communication channel.
• This protocol allows devices to transmit data at any time, without a set
schedule. There is no coordination between devices.
• When multiple devices attempt to transmit data at around the same time, it
can result in a collision. A collision is assumed when no ACK is received.
• In this case, each device will simply wait a random amount of time before
attempting to transmit again.
• Here, the channel time is divided into time slots, and stations are only
authorized to transmit at the beginning of a time-slot.
• The duration of a time slot is exactly equal to the packet transmission
time.
• As a result, wasted time due to collisions can be reduced to one packet time
or the susceptible period can be half of that in Pure ALOHA.
• If the frame is received successfully, the receiver sends an acknowledgment.
• If the acknowledgment is not received within a time-out period, the
sender assumes that the frame was not received and retransmits the
frame in the next time slot.
G = the offered load (or the number of packets being transmitted in one packet
time i.e. in one time-slot). In other words, it is a measure of the number of
nodes attempting to transmit in the time of a given time slot.
Computer Networks - Prof Ashok Herur 45
Carrier Sense Multiple Access (CSMA) protocols
• When the station is ready to send the frames, it will sense the channel.
• If the channel found to be busy, the station will wait for it to be idle.
• If the channel is found to be idle, the station transmits the frame
immediately.
• It is called “persistent” because it continuously tracks a busy channel till it
becomes idle.
• It is called “1-persistent” because after finding a channel to be idle, it surely
transmits it’s frame immediately (with a probability of 1, i.e. 100%)
• The problem with this method is that there is a high chance of collisions:
• When two or more stations find the channel in an idle state and they
transmit their frames at the same time.
• When the frames of a station are being transferred, then all the other
stations will sense that and won’t transmit the data; But the moment
they sense that the transmission has ended, they will all send their
frames at the same time.
• Another drawback is that when a collision occurs, the concerned stations
have to wait for a random time for the channel to be idle, and start all over
again.
• As in 1-persistent CSMA, the station that has frames to send will sense for
the channel.
• If the channel is found to be idle, the station transmits the frame
immediately.
• However, if the channel found to be busy, the station will wait for a
random time before sensing it again.
• In this method, the station does not continuously sense for the channel to
get idle.
• This reduces the chances of collision, but also reduces the efficiency of the
network when the load is light.
• p-persistent CSMA is used when a channel has time-slots and the duration of a
time-slot is equal to or greater than the maximum propagation delay time for that
channel.
• When the station is ready to send the frames, it will sense the channel.
• If the channel found to be busy, the station will wait for the next time-slot.
• But if the channel is found to be idle, the station transmits the frame
immediately with a probability p.
• The station then waits for the beginning of the next time-slot with a probability
q = (1-p).
• If the next time-slot is also found idle, the station transmits or waits again with
the probabilities p and q.
• This process repeats until either the frame gets transmitted or another station
starts transmitting.
Computer Networks - Prof Ashok Herur 53
Throughput of all CSMA protocols
• CSMA with CD (Collision Detection) is the most popular MAC protocol used
on the classic Ethernet LAN.
• If two stations transmit at around the same time, it will result in a collision.
• In that case, both the stations should suspend their transmissions, and try
after a random time later.
• The NIC of a station will compare the signal on the Bus with what it had
actually transmitted.
• If they do not match, it means that there is a collision.
• Collision detection is a comparison done in the analog domain.
• Note that once the signal representing the first bit of a frame has reached
both the ends of the Bus, there will be no collisions since all the stations will
be able to sense the carrier.
• 10 Mbps bit-rate
• Base-band signalling is used (just pulses, no modulation)
• 5 x 100 = 500 metre is the maximum length of the Bus without a repeater
• Maximum of four repeaters allowed, implying a maximum overall length
of 2.5 kms for the Bus
• Also called “Thick Ethernet”, because of the thick coax used as the Bus.
7 1 2 or 6 2 or 6 2 0-1500 0-46 4
SFD Length of
Start of Frame Destination Address Source Address Data / Data Pad Frame Check Sequence
Preamble Delimiter Type of data
• There are times when it is necessary to break up a large LAN into smaller
segments to improve the network performance.
• A Bridge is used to interconnect two LAN segments, while a Switch
interconnects 2 or more LAN segments.
• A Switch is just a multi-port bridge.
• The function of the bridge is to make intelligent decisions about whether
or not to pass signals between the two segments of a network.
• Bit-map protocol.
• Token passing protocol.
• Here, each contention period consists of exactly N slots. If any station has
to send a frame, then it transmits a ‘1’ bit in it’s corresponding slot.
• For example, if station 2 has a frame to send, it transmits a 1 bit in the
2nd slot.
• In this way, each station has complete knowledge of which station wishes
to transmit.
• There will never be any collisions because everyone agrees on who goes
next.
• Protocols like this in which the desire to transmit is broadcasted, for the
actual transmission, are called Reservation Protocols.
• Stations on a Token ring LAN are organized in a ring topology, with the data
being transmitted sequentially from one station to the next.
• The message sent by any station goes round the ring and is finally drained
off the ring by the transmitting station itself.
• A control ‘token’ frame circulates around the ring to control access of the
ring.
• A station would ‘seize’ the token, send its message frame and release the
token.
• As the message frame circles around the ring, each station will observe the
destination address in the frame to decide whether to make a copy.
• IEEE 802.5 defines the standard for this type of LANs
• After the message frame circles the ring and returns to its origin, the
originating station removes it from the ring and transmits a new token for
another station to use.
• A station cannot hold on to a token for more than the set Token-holding
time (default – 20 ms).
P P P T M R R R
T – Token bit
M – Monitor bit
• A token can be seized only if the message frame priority is equal or higher
than the token priority (PPP)
• A reservation to use the next token can be made, when a token or a
message is passing by, by writing the message priority in the RRR field
• Reservations can be overwritten by subsequent stations if the priority of
their message is higher than the current value in RRR.
• Here clients, such as laptops and smart phones, connect to networks like
the company intranet or the Internet.
• The client sends and receives its packets via the AP.
• The client has access to the network resources (server, shared printer, etc)
as well as to other clients.
Printer
Access
Points
If A “senses the
channel, it will not
hear C’s
transmission and will
falsely conclude that
it can begin a
transmission to B.
• Any station hearing the RTS is close to ‘A’, and will remain silent long
enough for the CTS to be transmitted back to A.
• Any station hearing the CTS is close to ‘B’, and will remain silent during the
upcoming transmission, whose length was mentioned in the CTS frame.
• ‘C’ is within the range of ‘A’ but not within the range of ‘B’; Therefore, it
hears the RTS but not the CTS.
• In contrast ‘D’ is within the range of ‘B’ but not within the range of ‘A’;
Therefore, it does not hear the RTS but hears the CTS.
• A station like ‘E” will hear both, and will not interfere.