a)Services Provided to the Network Layerb)Framingc)Error Controld)Flow Control
DLL purpose? The goal of the data link layer is to provide reliable, efficientcommunication between adjacent machines connected by a singlecommunication channel. Specifically:1. Group the physical layer bit stream into units called frames. Note thatframes are nothing more than ``packets or ``messages. Byconvention, well use the term ``frames when discussing DLL packets.2. Sender checksums the frame and sends checksum together with data. Thechecksum allows the receiver to determine when a frame has been damagedin transit.3. Receiver recomputes the checksum and compares it with the received value.If they differ, an error has occurred and the frame is discarded.4. Perhaps return a positive or negative acknowledgment to the sender. Apositive acknowledgment indicate the frame was received withouterrors, while a negative acknowledgment indicates the opposite.5. Flow control. Prevent a fast sender from overwhelming a slower receiver.For example, a supercomputer can easily generate data faster than a PC canconsume it.6. In general, provide service to the network layer. The network layer wants tobe able to send packets to its neighbors without worrying about the detailsof getting it there in one piece.
Functions of the Data Link Layer:a)Provide service interface to the networklayerb)Dealing with transmission errorsc)Regulating data flow1.Slow receivers not swamped by fast senders
Framing by character count.A character stream. (a) Without errors. (b) With one error.Problem: Even if the error is detected, the receiver cannot figure outwhere the next frame starts ... its cannot resynchronize.
(a) A frame delimited by flag bytes.(b) Four examples of byte sequences before and after stuffing.Problem: Too tied to the 8-bit per character format ... UNICODE uses 16-bits/char
Frames that need to be send in a bit stream:FlagFlagThe sender sends the following bit stream:FlagFlag EscThe receiver will ignore this flag.Frames that need to be send in a bit stream:FlagEscThe sender sends the following bit stream:Esc Esc Flag FlagEscThe receiver will ignore this Esc, and accept the flag. The receiver will ignore this flag.
The goal is to have 01111110 as a unique bitpattern.Bit stuffing(a) The original data.(b) The data as they appear on the line.(c) The data as they are stored in receiver’s memory after destuffing.
Include enough redundancy to detect and correct errors. To understand errors, consider the following: Messages (frames) consist of m data (message) bitsand r redundancy bits, yielding an n = (m+r)-bit codeword. Hamming Distance. Given any two codewords, we candetermine how many of the bits differ. Simply exclusive or(XOR) the two words, and count the number of 1 bits in theresult. Significance? If two codewords are d bits apart, d errors arerequired to convert one to the other. A codes Hamming Distance is defined as the minimumHamming Distance between any two of its legal codewords(from all possible codewords). In general, all possible data words are legal. However, bychoosing check bits carefully, the resulting codewords willhave a large Hamming Distance. The larger the Hammingdistance, the better able the code can detect errors.
Use of a Hamming code to correct burst errors.
Error-correcting codes are widely used on wireless links thatare noisy. However, they generate too large transmission overhead forreliable links such as copper wire or fiber. Therefore, hereerror-detection codes are used. When error is detected, the data is retransmitted. The goal for error correcting codes it to add redundancy tothe data so that the errors are not only detected but can be atthe same time corrected (without retransmission). For error-detecting codes the goal is to only detect the errorswith the minimal transmission overhead. They are based onpolynomial code also known as CRC (Cyclic RedundancyCheck) A k-bit frame is regarded as polynomial with coefficients 0and 1 with terms from xk-1 to x0 For example: 110001 -> x5 + x4 + x0
Polynomial arithmetic is done modulo 2 using the rules of algebraic field theory.Both addition and subtraction are identical to exclusive OR. For exampe:10011011 11110000+11001010 -10100110-------------- -------------01010001 01010110The sender and receiver must agree on a generator polynomial G(x).G(x) must have the first and last bit equal to 1.For a given frame, we consider its polynomial M(x) (longer than G(x)).The checksum is the reminder from the division M(x)*xr / G(x),where r is the degree of G(x).Polynomial T(x) obtained as M(x)*xr - checksumrepresents the check-summed frame that is divisible by G(x).An example division is shown on the next page, where the frame is1101011011 (corresponds to M(x))and the generator polynomial G(x) = x4 + x + x0 -> 10011.M(x)*xr -> 11010110110000 (we added 4 zeros at the end)
Upon receiving the check-summed frame, the receiver divides it by G(x):[T(x) + E(x)] / G(x)Since T(x) / G(x) is always zero, the result is always E(x) / G(x).The errors containing G(x) as a factor will slip by, all other errors will be caught.Single bit errors will be detected:We have E(x)=xi for a single bit error,E(x) / G(x) will not be zero, since G(x) must have the first and last bit equal to 1.All errors consisting of an odd number of inverted bits will be detectedif G(x) is divisible by (x + 1).E(x) consists of odd number of terms, e.g., x5 + x2 + x0and therefore, cannot be divisible by (x+1).Since E(x) has an odd number of terms E(1)=1.If E(x) = (x + 1) Q(x), then E(1) = (1 + 1) Q(1) = 0, a contradiction.The polynomial G(x) used in IEEE 802 standard isx32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x1 + 1
In parity check, a parity bit is added to everydata unit so that the total number of 1s is even(or odd for odd-parity).
Suppose the sender wants to send the word world.In ASCII the five characters are coded as 1110111 1101111 1110010 1101100 1100100 The following shows the actual bits sent 11101110 11011110 11100100 11011000 11001001
The sender follows these steps:• The unit is divided into k sections, each of nbits.• All sections are added using one’s complementto get the sum.• The sum is complemented and becomes thechecksum.• The checksum is sent with the data.
The receiver follows these steps:• The unit is divided into k sections, each of nbits.• All sections are added using one’s complementto get the sum.• The sum is complemented.• If the result is zero, the data are accepted:otherwise, rejected.
Suppose the following block of 16 bits is to be sentusing a checksum of 8 bits. 10101001 00111001 The numbers are added using one’s complement 10101001 00111001------------Sum 11100010 Checksum 00011101 The pattern sent is 10101001 0011100100011101
Now suppose the receiver receives the patternsent in Example 7 and there is no error. 10101001 00111001 00011101 When the receiver adds the three sections, it willget all 1s, which, after complementing, is all 0s andshows that there is no error. 10101001 00111001 00011101 Sum 11111111 Complement 00000000 means that thepattern is OK.
Ensuring the sending entity does notoverwhelm the receiving entity Preventing buffer overflow Transmission time Time taken to emit all bits into medium Propagation time Time for a bit to traverse the link
a)A Simplex Stop-and-Wait Protocol.b)Sliding window protocol.- A One Bit sliding window protocol.- A protocol using Go Back N.- A protocol using selective Repeat.
Source transmits frame Destination receives frame and replies withacknowledgement Source waits for ACK before sending nextframe Destination can stop flow by not send ACK Works well for a few large frames
Large block of data may be split into smallframes Limited buffer size Errors detected sooner (when whole frame received) On error, retransmission of smaller frames is needed Prevents one station occupying medium for longperiods Stop and wait becomes inadequate
Allow multiple frames to be in transit Receiver has buffer W long Transmitter can send up to W frames withoutACK Each frame is numbered ACK includes number of next frame expected Sequence number bounded by size of field (k) Frames are numbered modulo 2k
Receiver can acknowledge frames withoutpermitting further transmission (Receive NotReady) Must send a normal acknowledge to resume If duplex, use piggybacking If no data to send, use acknowledgement frame If data but no acknowledgement to send, send lastacknowledgement number again, or have ACK validflag (TCP)
Source transmits single frame Wait for ACK If received frame damaged, discard it Transmitter has timeout If no ACK within timeout, retransmit If ACK damaged,transmitter will not recognizeit Transmitter will retransmit Receive gets two copies of frame Use ACK0 and ACK1
Based on sliding window If no error, ACK as usual with next frameexpected Use window to control number of outstandingframes If error, reply with rejection Discard that frame and all future frames until errorframe received correctly Transmitter must go back and retransmit that frameand all subsequent frames
Receiver detects error in frame i Receiver sends rejection-i Transmitter gets rejection-i Transmitter retransmits frame i and allsubsequent
Frame i lost Transmitter sends i+1 Receiver gets frame i+1 out of sequence Receiver send reject i Transmitter goes back to frame i andretransmits
Frame i lost and no additional frame sent Receiver gets nothing and returns neitheracknowledgement nor rejection Transmitter times out and sendsacknowledgement frame with P bit set to 1 Receiver interprets this as command which itacknowledges with the number of the nextframe it expects (frame i ) Transmitter then retransmits frame i
Receiver gets frame i and sendacknowledgement (i+1) which is lost Acknowledgements are cumulative, so nextacknowledgement (i+n) may arrive beforetransmitter times out on frame i If transmitter times out, it sendsacknowledgement with P bit set as before This can be repeated a number of times beforea reset procedure is initiated
Also called selective retransmission Only rejected frames are retransmitted Subsequent frames are accepted by the receiverand buffered Minimizes retransmission Receiver must maintain large enough buffer More complex login in transmitter