CS5480: Data Communication and Networks Lecture Overall organization: - Types of direct link networks - Issues related to getting packets across - Encoding - Framing - Error Detection/Error Correction - Introduce Reliable Transmission --------------------------------------------------------------------------- Topic: Introduction to direct link networks and issues * We will consider direct link networks and discuss issues related to this. * What we discuss today covers a large portion of the issues in the lower layer (physical/data) link in the OSI model. Draw diagram of different types of network - point to point - ethernet (CSMA) - token ring - wireless Explain what each scenario is in short. Problem ======= How do we transfer packets between directly connected nodes over these links? 5 issues/problems to be solved before we can do that. - Data encoding Encoding data on the links such that the receiving host can recieve it correctly. - Framing: Packet based networks have packets as the switching element. We want to be able to delineate bits into frames/packets. - Error detection/error correction Frames can become corrupt during transmission. How to detect that frames are bad ? Should we just detect and ask sender to retransmit or should we encode enough redundant information so that the receiver can correct the frame. - Reliable transmission To provide service to the higher layer in which the "unreliable" link is made to look reliable. Define a protocol to exchange frames, to make use of the link's bandwidth effeciently with the least protocol overhead. - Mediating access to shared medium In CSMA networks, token ring, wireless, multiple hosts connected to the same "link". Need to mediate access . We will consider first three issues assuming a point to point link, but issues are same in general even for the shared medium technologies. --------------------------------------------------------------------------- Topic: Data Encoding Can switch back and forth between digital and analog: +-----------+ +-------------+ m(t) ------->| Modulator |----> s(t) ---->| Demodulator |---> m(t) +-----------+ +-------------+ analog analog original or (usually based on signal digital a carrier signal) restored [DRAW analog s(t)] +---------+ +---------+ g(t) ------->| Encoder |----> x(t) ---->| Decoder |---> g(t) +---------+ +---------+ analog digital original or signal digital restored [DRAW digital x(t)] Modulation/Demodulation or encoding analog data over digital signal is not focus of this course. We assume that we know how to convert digital data to analog signal and vice versa and work only with high/low signals . We assume that we have a way of distinguishing between "high" and "low" signals on the sender and receiver and we want to be able to encode useful information on this. Problem ======== How do we encode '0' and '1' on these high and low values ? Issue ----- - agreeing on high and low - clock synch between the two nodes - can we send clock on a seperate wire? - solution convey clock transitions through data signalling inband. Different types of encoding: Explain with quick diagrams NRZ: - '0' represented by low value, '1' by high value - Problem caused by long strings of 1's? * Baseline wandering long strings of '0' and '1' cause a drift in the baseline for detecting signals. * reciever clock recovery problem Normally high transitions of signal needed, receiver synchronises clocks at these transitions. Low transitions can cause recr. to go out of sync. NRZI: - Fixes the '1' problem by inverting current value. - '0' is encoded as "stay at the current signal" Solves the strings of '1' problem. Manchester encoding - Fixes the problem by sending the exclusive OR of the clock and NRZ data. - "0" indicated by low to high transition, 1 is vice versa. - have to detect pulses at twice the rate - Thus bit rate is only half the baud rate. (50% effecient) - Clock recover is possible since both 0s and 1s cause transitions in the signal. 4B/5B - every nibble is represented by a 5 bit code - such that no 5 bit code has more than 1 leading zero and not more than 2 lagging zeroes. Thus sent one after another, there are no more than 3 consecutive zeroes. - 80% effecient. Uses NRZI encoding, hence fixes only '0' problem. --------------------------------------------------------------------------- Topic: Framing Problem ======== converting the bit stream to frames. recognizing frame boundaries. Draw diagram Three types of protocols - byte oriented (eg. BISYNC, PPP : run commonly over dialup links) - bit oriented (eg. HDLC) - clock based framing (SONET) ============================ question: Motivate why a frame looks like how it should? - SOF/EOF - count field - data - error detection/correction field - header to convey some information =========================== Byte oriented: - Frame viewed as a collection of bytes. Compare to file system and motivate need for the two approaches Two main approaches - Sentinel approach - byte counting approach Sentinel approach: STX and ETX characters mark the beginning and ending of data. What is the obvious problem? Problem: What happens if ETX character appears in the body? Could happen for binary files (images/executables) Character stuffing Special character inserted, in spirit to \ excape sequence in C What if special character appears in the stream? CRC field : will discuss this later Byte counting approach: Have a special field which encodes the size of the frame. What if count field is corrupted during tranmission? Same thing can happen for ETX? One way of recovery is to gobble all bytes upto the next starting SYN character. Can result in losing back-to-back frames. ============================ Bit oriented: - Frame is viewed as a collection of bits - Special start of frame and end of frame markers. - what happens if that bit pattern comes in the frame? Question - bit stuffing? How? Since the pattern consists of six consecutive 1's, in the data whenever we see 5 consecutive 1's the next position is stuffed with a zero. At the recvr, after 5 consecutive 1's , 2 possible cases - if next bit is zero, it is stuffed, so remove it. - if the next bit is 1, then check the next to next. If it is consistent with EOF, then fine, else signal error. Wait for next SOF to sync back. Can lose backtoback frames in this process. ============================ Clock based. (Sonet) : Read from the book =========================== --------------------------------------------------------------------------- Topic: Error Detection/Error Correction Introduce both: Error detection: have just enuf redundant information so that the recvr. can detect error. Error detection: encode enuf redundant information to recover from the error. Hamming codes for detection and correction ------------------------------------------- Introduce Hamming distance and codewords with distance "d". Give an example. 0000000000, 0000011111, 1111100000, and 1111111111 Hamming Distance = 5 => it can correct double errors. Eg. show how double errors can be corrected, triple error results in an ambiguity. Derive formula for minimum "r" for correcting single bit errors. (n+1)* 2^m <= 2^n since n = m + r, => (m + r + 1) <= 2^r. ---------------------------- Problem: When would you prefer one or the other? Assume error prob. of 1/10^6 Assume blocks of size 1000 Assume that we transfer 1000 such blocks. Number of hamming correction bits = 10 * 1000 = 10,000 Number of parity bits = 1000 (for the 1000 blocks) + 1001 (plus an extra frame with one parity bit). - noisy links (wireless) error correction might be advisable since even retransmitted frame can have errors. Or on simplex channels where the recvr. cannot ACK or signal error. - for "not so bad" links, error detection with retransmission is probably a good idea. Since we dont waste bandwidth on more redundant bits for good frames. In general, error detection with retransmission is preferred. Different ways of error detection - parity * single bit parity (can detect 1 bit errors) * 2 dimensional parity Add one bit per word, plus one extra parity word. 14 bits of extra information. Can catch 1,2,3 bit errors and some 4 bit errors. - checksum * consider the data to be checksummed as a bunch of 16 bit integers. Add them. The sum is the checksum. At the recr, do the same and compare the checksums. When can it go wrong? Eg. Weaker than CRC but sufficient for end to end use when CRC has already got most of the link errors. - CRC Normally CRC used at link layer, constant number of bits, however large the frame, can detect most errors with less overhead. Can be implemented in hardware on adaptor. Higher layers can do end to end checksum which is easily done in software, less overhead, normally for catching end to end errors. Idea behind CRC (Based on branch of mathematics called finite fields, but concepts are simple to understand) ====================================== Consider the (n+1) bit message as a n degree polynomial with binary coeffecients. Consider a divisor polynomial of degree k (K +1 bits). Divide M(X) by C(x) to get R(X) which is the CRC. Append these k bits to the message. Now this polynomial T(X) is exactly divisible by C(X). Send T(X) to the receiver. Reciever divides T(X) by C(X), if remainder is zero, fine, else error in transmission. Eg of binary long division and forming T(X) M = 1010001101 C = 110101 R = 01110 Show at sender and reciever. What kind of errors can CRC catch? - all single-bit errors as long as the x^k and x^0 coeffecients are non-zero. Since T(x) + e(x), now e(x) = x^i is not divisible by (x^k + 1) - All double bit errors as long as C(x) has a factor with atleast 3 terms. - Any odd number of errors, as long as C(x) contains the factor (x+1) - Any burst error (consecutive error bits) for bursts of size < k Some example CRC divisor polynomials CRC-12 x^12 + x^11 + x^3 + x^2 + x + 1 CRC-32 x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x + 1 Explain the hardware implementation of CRC using shift registers and XOR gates. For a 5 degree CRC divisor poly, a 5 bit shift register needed. XOR gate to the right of a shift bit corresponding to the term in the polynomial with non-zero coefficient. - c4 <--(+)-- c3 <--c2 <--(+)--c1<--c0<--(+)-- input bits | ^ ^ ^ | | | | |--------|-----------------|--------------| M = 1010001101 C = 110101 Question: ========= Why are end-2-end checksums needed? What happens if router software garbles frames? CRC at all links will be fine, but checksum can catch this error. Research angle ============== When the CRC and TCP checksum disagree: Sigcomm 2000. - put link on the webpage ************************************************************************ Homework assignment 1 -------------------- 21 and 26 from Chapter 1 (for grads) 13,15,16,23 from Chapter 1 (for everybody) 2.2, 2.15. 2.19, 2.26, 2.39 ( for everybody) For problem 2, assume NRZI Signal starts low. Due date : Thursday, sept 12, 5 pm in drop box outside CS office