Lecture 5 Homework 2 posted, due September 15. Reminder: Homework 1 due today. Questions? Thursday, September 8 CS 475 Networks - Lecture 5 1
Outline Chapter 2 - Getting Connected 2.1 Perspectives on Connecting 2.2 Encoding 2.3 Framing 2.4 Error Detection 2.5 Reliable Transmission 2.6 Ethernet 2.7 Wireless 2.8 Summary Thursday, September 8 CS 475 Networks - Lecture 5 2
Error Detection Bit errors in a frame will occur. How do we detect (and then recover) from them? We look at error detection first. We detect errors by adding redundant information. We could transmit duplicate frames. If the frames differ on reception, one (or both) frames contains an error. This is inefficient (and not that reliable). We will look at the two-dimensional parity, checksum, and cyclic redundancy check (CRC) error detection methods. Thursday, September 8 CS 475 Networks - Lecture 5 3
Two-Dimensional Parity Two-dimensional parity is often used with 7-bit codes (ASCII). It requires the addition of a parity byte (and 1 parity bit per word). Two-dimensional parity catches all 1, 2, and 3 bit errors (and most 4 bit errors). Fig 2.14: 2D Parity (Even Parity) Thursday, September 8 CS 475 Networks - Lecture 5 4
Two-Dimensional Parity PC serial port hardware can be configured to transmit and receive using 1-D parity. The settings must be identical on both ends of the link. Windows Serial Port Properties Window Thursday, September 8 CS 475 Networks - Lecture 5 5
Internet Checksum Algorithm Checksums are not used at the link layer, but are used at the higher layers in the TCP/IP stack. The checksum algorithm is easy to implement in software. In the Internet (TCP/IP) checksum algorithm, data is treated as 16-bit integers. The integers are added using ones complement arithmetic. The ones complement of the sum is sent as the checksum. Thursday, September 8 CS 475 Networks - Lecture 5 6
Internet Checksum Algorithm In ones complement addition any carry out of the most significant bit is added back in at the least significant position. Example: Compute the 8-bit check sum of 11000011, 10101010, 0111 using the Internet checksum algorithm. 11000011 10101010 0101 1 0110 0110 0111 11100101 A carry wrap around. Final sum. Checksum is 0000 The checksum is the ones complement (inverse) of the sum. Thursday, September 8 CS 475 Networks - Lecture 5 7
Internet Checksum Algorithm At the receiver all words are added (including the checksum) using ones complement arithmetic. If there are no errors the sum will be all 1s (11111111 in the previous example). The Internet checksum algorithm uses only a small number of extra bits (16 for a message of any size), but it is relatively weak. Experience has shown that the algorithm is sufficient as long as stronger error detection (CRC) is used at the link layer. Thursday, September 8 CS 475 Networks - Lecture 5 8
Cyclic Redundancy Check The CRC algorithm is based on polynomial division. The bits in the message are treated as coefficients of a polynomial. For example, the four bit message 1011 represents: M(x) = 1 x 3 + 0 x 2 + 1 x 1 + 1 = x 3 + x + 1 Note that most messages are thousands of bits long and would represent polynomials of high degree. Thursday, September 8 CS 475 Networks - Lecture 5 9
Cyclic Redundancy Check To calculate a CRC, the sender and receiver agree on a divisor polynomial, C(x) Standard divisor polynomials are known to give good results. (Ethernet uses CRC-32). CRC C(x) CRC-8 x 8 + x 2 + x + 1 CRC-10 x 10 + x 9 + x 5 + x 4 + x + 1 CRC-12 x 12 + x 11 + x 3 + x 2 + 1 CRC-16 x 16 + x 12 + x 2 + 1 CRC-CCITT x 16 + x 12 + x 5 + 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 2 + x + 1 Thursday, September 8 CS 475 Networks - Lecture 5 10
Cyclic Redundancy Check To compute the k-bit CRC: 1)Multiply M(x) by x k (add k zeros at the end of the message). Call this message T(x). 2)Divide T(x) by C(x) and find the remainder. 3)Subtract the remainder from T(x). In performing the division, exclusive-or is used instead of subtraction. Polynomials of equal order can always be divided. The result is the original message followed by the remainder in step 2). Thursday, September 8 CS 475 Networks - Lecture 5 11
Cyclic Redundancy Check Consider computing the 3-bit CRC for the message M(x) = 1000 using C(x) =. )1000000 Message Thursday, September 8 CS 475 Networks - Lecture 5 12
Cyclic Redundancy Check 1 )1000000 Message 100 Thursday, September 8 CS 475 Networks - Lecture 5 13
Cyclic Redundancy Check 11 )1000000 Message 1001 100 Thursday, September 8 CS 475 Networks - Lecture 5 14
Cyclic Redundancy Check 111 )1000000 Message 1001 1000 101 Thursday, September 8 CS 475 Networks - Lecture 5 15
Cyclic Redundancy Check 1111 )1000000 Message 1001 1000 1011 110 Thursday, September 8 CS 475 Networks - Lecture 5 16
Cyclic Redundancy Check 11111 )1000000 Message 1001 1000 1011 1100 1 Thursday, September 8 CS 475 Networks - Lecture 5 17
Cyclic Redundancy Check The transmitted signal is 1000101. If this polynomial is divided by at the receiver, the remainder should be 0. If it is not, then an error has occurred. 11111001 )1000000 Message 1001 1000 1011 1100 1000 101 Remainder Thursday, September 8 CS 475 Networks - Lecture 5 18
Cyclic Redundancy Check Although the CRC calculation appears complex, it can be computed in hardware using a shift register and exclusive-or gates. Fig. 2.16: CRC calc. using a shift register Division by x 3 + x 2 + 1. Thursday, September 8 CS 475 Networks - Lecture 5 19
Reliable Transmission A link-level protocol that wants to deliver frames reliably must recover frames that have errors. This is usually done by using some combination of acknowledgments (ACKs) and timeouts. Recovery algorithms that use ACKs and timeouts are known as automatic repeat request (ARQ) algorithms. We will examine three such algorithms. Thursday, September 8 CS 475 Networks - Lecture 5 20
Stop-and-Wait The simplest ARQ scheme is the stop-and-wait algorithm. After transmitting one frame the sender waits for an acknowledgment before transmitting the next frame. If the ACK does not arrive after a certain interval, the sender retransmits the original frame. Thursday, September 8 CS 475 Networks - Lecture 5 21
Stop-and-Wait If there are no errors, the timeline is as shown at right. (If an error is detected in the received frame, the receiver does not return an ACK. It waits for the frame to be retransmitted.) Fig. 2.17: ACK received Thursday, September 8 CS 475 Networks - Lecture 5 22
Stop-and-Wait If a frame is lost, the sender automatically retransmits the frame after the timer has expired. Fig. 2.17: Lost frame Thursday, September 8 CS 475 Networks - Lecture 5 23
Stop-and-Wait If the ACK is lost, the sender automatically retransmits the frame after the timer has expired. The receiver can discard the duplicate frame, but must still send an ACK. Fig. 2.17: Lost ACK Thursday, September 8 CS 475 Networks - Lecture 5 24
Stop-and-Wait If the ACK is delayed, the sender automatically retransmits the frame after the timer has expired. The receiver can discard the duplicate frame, but must still send an ACK. Fig. 2.17: Slow ACK Thursday, September 8 CS 475 Networks - Lecture 5 25
Stop-and-Wait To simplify detection of duplicate frames, the frame header includes a bit that alternates between 0 and 1. If two consecutive 0 (or 1) frames are received, the receiver knows that the second frame is a duplicate. Fig. 2.18: Stop and wait with 1-bit sequence number. Thursday, September 8 CS 475 Networks - Lecture 5 26
Stop-and-Wait The main problem with the stop-and-wait algorithm is that it does not use the link to its full capacity. A 1.5 Mbps link with a 45 ms RTT has a delay x BW product of 67.5 kb (8 kb). Assuming a 1 kb frame, stop-and-wait would only allow a throughput of 1 kb x 8 b/b / 45 ms = 182 kbps This is only 1/8 of the link BW! Thursday, September 8 CS 475 Networks - Lecture 5 27
Sliding Window To fully utilize the available BW we allow the sender to transmit multiple frames in sequence. Fig. 2.19: Sliding Window Timeline On the 1.5 Mbps link from the previous slide we want the sender to transmit 8 frames and be ready to send the 9 th as soon as the ACK for the first frame is received. Thursday, September 8 CS 475 Networks - Lecture 5 28
Sliding Window The sender assigns a sequence number, SeqNum, to each frame. The sender has to maintain three variables related to the sliding window algorithm: SWS, the send window size, LAR, the seq. num. of the last acknowledgment received, LFS, the seq. num. of the last frame sent Thursday, September 8 CS 475 Networks - Lecture 5 29
Sliding Window A new frame is sent (and LFS incremented) only if: LFS LAR SWS Fig. 2.20: Sliding window on the sender. Thursday, September 8 CS 475 Networks - Lecture 5 30
Sliding Window The receiver maintains the following three variables: RWS, the receive window size, LAF, the sequence number of the largest acceptable frame, LFR, the seq. num. of the last frame received Thursday, September 8 CS 475 Networks - Lecture 5 31
Sliding Window The receiver maintains the following invariant: LAF LFR RWS Fig. 2.21: Sliding window on the receiver. Thursday, September 8 CS 475 Networks - Lecture 5 32
Sliding Window If the SeqNum of a received frame satisfies LFR < SeqNum LAF, the frame is accepted. If all frames with seq. numbers less than SeqNum have been ACKed then this frame is ACKed, LFR is set to SeqNum and LAF is set to LFR + RWS. When frames are received out of order the details are a bit more complicated. See the text for details. Thursday, September 8 CS 475 Networks - Lecture 5 33
Concurrent Logical Channels ARPANET used a variation of stop-and-wait while still keeping the pipe full. It worked by using multiple logical channels and running stop-andwait on each channel. The header of each frame contained a 1-bit sequence number and the number of the logical channel. Thursday, September 8 CS 475 Networks - Lecture 5 34
In-class Exericses If time allows, start work on the homework problems. Thursday, September 8 CS 475 Networks - Lecture 5 35