Ad hoc and Sensor Networks Chapter 6: Link layer protocols Holger Karl
Goals of this chapter Link layer tasks in general Framing group bit sequence into packets/frames Important: format, size Error control make sure that the sent bits arrive and no other One of the most important tasks in data link layer Flow control ensure that a fast sender does not overrun its slow(er) receiver Not an issue in sensor networks Link management discovery and manage links to neighbors Do not use a neighbor at any cost, only if link is good enough! Understand the issues involved in turning the radio communication between two neighboring nodes into a somewhat reliable link
Overview Error control Framing Link management
Error control Error control has to ensure that data transport is Error-free deliver exactly the sent bits/packets In-sequence deliver them in the original order Duplicate-free and at most once Loss-free and at least once Causes: fading, interference, loss of bit synchronization, Results in bit errors, bursty, sometimes (see physical layer chapter) In wireless, sometimes quite high average bit error rates 10-2 10-4 possible! Approaches Backward error control ARQ (Automatic Repeat Request) Forward error control FEC
Causes and characteristics of transmission error Sync: consists of a string of 0s or 1s, alerting the receiver that a potentially receivable signal is present. SFD (start frame delimiter): defines the beginning of a frame. Signal: identifies the type of modulation that the receiver must use to demodulate the signal. Services: reserves for future use. CRC: The Signal, Service, and Length fields are all protected with a CCITT CRC-16 frame check sequence Sync(128-bit) SFD(16-bit) Signal(8-bit) Services(8-bit) Length(16-bit) CRC(16-bit) MPDU (variable) Preamble PHY header Format of an IEEE 802.11 physical layer frame
Backward error control ARQ Basic procedure (a quick recap) Put header information around the payload Compute a checksum and add it to the packet Typically: Cyclic redundancy check (CRC), quick, low overhead, low residual error rate Provide feedback from receiver to sender Send positive or negative acknowledgement Sender uses timer to detect that acknowledgements have not arrived Assumes packet has not arrived Optimal timer setting? If sender infers that a packet has not been received correctly, sender can retransmit it What is maximum number of retransmission attempts? If bounded, at best a semi-reliable protocols results
Standard ARQ protocols Alternating bit at most one packet outstanding, single bit sequence number Go-back N send up to N packets, if a packet has not been acknowledged when timer goes off, retransmit all unacknowledged packets Selective Repeat when timer goes off, only send that particular packet
How to use acknowledgements Be careful about ACKs from different layers A MAC ACK (e.g., S-MAC) does not necessarily imply buffer space in the link layer On the other hand, having both MAC and link layer ACKs is a waste Do not (necessarily) acknowledge every packet use cumulative ACKs Tradeoff against buffer space Tradeoff against number of negative ACKs to send
When to retransmit Assuming sender has decided to retransmit a packet when to do so? In a BSC (binary symmetric channel) channel, any time is as good as any In fading channels, try to avoid bad channel states postpone transmissions Instead (e.g.): send a packet to another node if in queue (exploit multi-user diversity) How long to wait? Example solution: Probing protocol Idea: reflect channel state by two protocol modes, normal and probing When error occurs, go from normal to probing mode In probing mode, periodically send short packets (acknowledged by receiver) when successful, go to normal mode
Forward error control Idea: Endow symbols in a packet with additional redundancy to withstand a limited amount of random permutations Additionally: interleaving change order of symbols to withstand burst errors
Block Error Correction Codes Transmitter Forward error correction (FEC) encoder maps each k -bit block into an n -bit block codeword Codeword is transmitted; analog for wireless transmission Receiver Incoming signal is demodulated Block passed through an FEC decoder 4/29/2008
FEC Decoder Possible Outcomes No errors present Codeword produced by decoder matches original codeword Decoder detects and corrects bit errors Decoder detects but cannot correct bit errors; reports uncorrectable error Decoder detects no bit errors, though errors are present 4/29/2008
Block Code Principles Hamming distance- for 2 n -bit binary sequences, the number of different bits E.g., v 1=011011; v 2=110001; d (v 1, v 2) = 3 Example: Data block Codeword 00 00000 01 00111 10 11001 11 11110 We can correct 1-bit error and detect 2-bit error 4/29/2008
Block Code Principles Redundancy ratio of redundant bits to data bits that is (n - k )/k Code rate ratio of data bits to total bits Coding gain the reduction in the required Eb /N0 to achieve a specified BER of an error-correcting coded system 4/29/2008
Block-coded FEC Level of redundancy: blocks of symbols Block: k p -ary source symbols (not necessarily just bits) Encoded into n q -ary channel symbols Injective mapping (code) of pk source symbols into qn channel symbols Code rate : (k ld p) / (n ld q ) When p=q=2: k/n is code rate For p=q =2: Hamming bound code can correct up to t bit errors only if Codes for (n, k, t) do not always exist
Hamming Code Process Hamming codes are designed to correct single bit errors Encoding: k data bits + (n - k ) check bits Decoding: compares received (n -k ) bits with calculated (n - k ) bits using XOR Resulting (n - k ) bits called syndrome word Syndrome range is between 0 and 2(n -k ) - 1 Each bit of syndrome indicates a match (0) or conflict (1) in that bit position and hence 2(n -k ) 1 >= k + (n k ) = n 4/29/2008
Hamming Code Characteristics We would like to generate a syndrome with the following characteristics: If the syndrome contains all 0s, no error has been detected If the syndrome contains only one bit set to 1, then an error has occurred in one of the check bits If the syndrome contains more than one bit set to 1, then the numerical value of the syndrome indicates the position of the data bit in error 4/29/2008
Hamming Code Generation Hamming check bits are inserted at the position of power of 2 i.e., positions 1, 2, 4,, 2(n-k-1 ) The remaining bits are data bits Each data position which has a value 1 is presented by a binary value equal to its position; thus if the 9th bit is 1 the corresponding value is 1001 All of the position values are then XORed together to produce the bits of the Hamming code Example: The 8-bit data block is 00111001 4/29/2008
BCH Codes For positive pair of integers m and t, a (n, k ) BCH code has parameters: Block length: n = 2m 1 Number of check bits: n k <= mt Minimum distance:d min >= 2t + 1 Correct combinations of t or fewer errors Flexibility in choice of parameters Block length, code rate 4/29/2008
Reed-Solomon Codes (Option) Subclass of nonbinary BCH codes Data processed in chunks of m bits, called symbols An (n, k ) RS code has parameters: Symbol length: m bits per symbol Block length: n = 2m 1 symbols = m (2m 1) bits Data length: k symbols Size of check code: n k = 2t symbols = m (2t ) bits Minimum distance: d min = 2t + 1 symbols 4/29/2008
Example Let t = 1 and m = 2. Denoting the symbols as 00, 01, 10, and 11 Then n = 22 1 = 3 symbols = 6 bits Check code = (n - k ) = 2 symbols = 4 bits This code can correct any burst error <= 2 bits 4/29/2008
Block Interleaving Data written to and read from memory in different orders Data bits and corresponding check bits are interspersed with bits from other blocks At receiver, data are de-interleaved to recover original order A burst error that may occur is spread out over a number of blocks, making error correction possible 4/29/2008
Block Interleaving
Convolutional Codes Generates redundant bits continuously Error checking and correcting carried out continuously (n, k, K ) code Input processes k bits at a time Output produces n bits for every k input bits K = constraint factor k and n generally very small n -bit output of (n, k, K ) code depends on: Current block of k input bits Previous K -1 blocks of k input bits 4/29/2008
Convolutional codes Code rate: ratio of k user bits mapped onto n coded bits Constraint length K determines coding gain Energy Encoding: cheap Decoding: Viterbi algorithm, energy & memory depends exponentially on constraint length K
Convolutional Encoder Ex: input 1011 generates output 11100001
Energy consumption of convolutional codes Tradeoff between coding energy and reduced transmission power (coding gain) Overall: block codes tend to be more energyefficient residual bit error prob.!
Comparison: FEC vs. ARQ FEC t: error correction capacity Constant overhead for each packet Not (easily) possible to adapt to changing Relative energy consumption channel characteristics ARQ Overhead only when errors occurred (expect for ACK, always needed) Both schemes BCH + unlimited number of retransmissions have their uses! hybrid schemes
Power control on a link level Further controllable parameter: transmission power Higher power, lower error rates less FEC/ARQ necessary Lower power, higher error rates higher FEC necessary Tradeoff!
Overview Error control Framing Link management
Frame, packet size Small packets: low packet error rate, high packetization overhead Large packets: high packet error rate, low overhead Depends on bit error rate, energy consumption per transmitted bit Notation: h(overhead, payload size, BER)
Dynamically adapt frame length For known bit error rate (BER), optimal frame length is easy to determine Problem: how to estimate BER? Collect channel state information at the receiver (RSSI, FEC decoder information, ) Example: Use number of attempts T required to transmit the last M packets as an estimator of the packet error rate (assuming a BSC) Details: see the references of text book Second problem: how long are observations valid/how should they be aged? Only recent past is if anything at all somewhat credible
Putting it together: ARQ, FEC, frame length optimization Applying ARQ, FEC (both block and convolutional codes), frame length optimization to a Rayleigh fading channel Channel modeled as Gilbert-Elliot
Overview Error control Framing Link management
Link management Goal: decide to which neighbors that are more or less reachable a link should be established Problem: communication quality fluctuates, far away neighbors can be costly to talk to, error-prone, quality can only be estimated The quality of a link is not binary The quality of a link is time variable The quality can only to be estimated Establish a neighborhood table for each node Partially automatically constructed by MAC protocols
Link quality characteristics Expected: simple, circular shape of region of communication not realistic Sometimes links are asymmetric Instead: Correlation between distance and loss rate is weak; iso-losslines are not circular but irregular Asymmetric links are relatively frequent (up to 15%) Significant short-term PER variations even for stationary nodes
Three regions of communication Effective region : PER consistently < 10% Transitional region: anything in between, with large variation for nodes at same distance Poor region : PER well beyond 90%
Link quality estimation How to estimate, on-line, in the field, the actual link quality? Requirements for estimator Precision estimator should give the statistically correct result Agility estimator should react quickly to changes Stability estimator should not be influenced by short aberrations Efficiency avoid too much listening for other nodes transmission There are active or passive estimator Example: only estimates at fixed intervalsrn : received packets in interval fn : packet identified as lost Pn = αpn-1 + (1- α ) fn /(rn + fn ) Pn is the prediction of packet loss rate at time t + nt
Conclusion Link layer combines traditional mechanisms Framing, Error control, flow control with relatively specific issues Careful choice of error control mechanisms tradeoffs between FEC & ARQ & transmission power & packet size Link estimation and characterization