Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Computer Networks (2IC10) Communication Protocols Igor Radovanović Thanks to P. van der Stok A. B. Forouzan A. Tanenbaum 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Packet transmission in ideal network 1 2 2 1 3 4 5 6 t 1 2 d1 4 5 d3 d2 1 • • • 3 2 All packets delivered to the destination node without loss or distortion All packets delivered in the same order Delivery with minimum delay (d1=d2=d3) 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking 6 t N. Olifer, V. Olifer Computer Networks, principles, technologies and protocols for network design, Wiley & Sons Communication problems • • • • • corruption of packets loss of packets replication of packets ordering of packets independent failures of nodes 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Packet transmission in a real network 1 2 1 3 4 5 6 t 1 2 d1 3 6 d4 d2 1’ • • • • 4 d3 t N. Olifer, V. Olifer Computer Networks, principles, technologies and protocols for network design, Wiley & Sons Packets are delivered with variable delays (d1≠d2 ≠d3) Packets are delivered out of order Packets may be lost or corrupted Average rate of information flow is different at the input and at the output of the network 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Packet corruption • Error detection • Error correction Types of errors: – single bit; only 1 bit in the data unit has changed less likely – burst error; 2 or more bits in the data unit have changed Example: 0.01 s of burst impulse noise 1200 bps data rate 12 bits of errors 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Error detection • Redundancy: adding extra bits for detecting errors at the destination 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Error detection • All methods use redundancy 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Parity check ASCII a even parity • A parity bit is added to every data unit so that the total number of 1’s is even (or odd for odd parity) 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Parity check -example• 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 • Parity check can detect single-bit errors • What about burst errors? 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Error detection 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking CRC check • based on binary division • CRC added to the data unit so that the resulting data becomes exactly divisible by a predetermined number • CRC – exactly 1 less bit than the divisor 1. A string of n zeros added to the data unit 2. New data divided by divisor 3. Replace 0’s by CRC 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking CRC generator • Modulo-2 division 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking CRC generator (cnt’d) 5/25/2017 Name Polynomial Application CRC-8 x8 + x 2 + x + 1 ATM header CRC-10 x10 + x9 + x5 + x4 + x 2 + 1 ATM AAL ITU-16 x16 + x12 + x5 + 1 HDLC ITU-32 x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1 LANs Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking CRC performance • CRC can detect 1. all burst errors that affect odd number of bits 2. all burst errors of length degree of polynomial 3. with high probability burst errors > degree of polynomial Example: CRC-12 (degree of 12) 1. OK 2. OK 3. 99.97 % 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Error detection 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Checksum Example: IP header 1. 2. 3. 4. The data unit is divided into k sections, each of n bits All sections are added using 1’s complement The sum is complemented The checksum is sent with data 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking 1’s complement • Suppose the following block of 16 bits is to be sent using 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 5/25/2017 10101001 00111001 00011101 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Checksum (cnt’d) • Performance – Can we use this technique to detect an error if 2 corresponding opposite bits in 2 data segments become corrupted? – An example: Transmitted sequence: 10101001 00111001 00011101 Received sequence: 00101001 10111001 00011101 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Error correction 1. By retransmission – flow and error control protocols 2. Forward Error Correction (FEC) – require more redundancy bits – should locate the invalid bit or bits – n-bit code word contains m data bits + r redundancy bits n=m+r – m+r+1 bits discoverable by r bits 2r m r 1 Example: – For m=5 data bits can r be 3? 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Hamming code Example: 7-bit ASCII code + 4 bit redundancy – Each r bit is the parity bit for one combination of data bits 20 1 r1: bits: 1, 3, 5, 7, 9, 11 r2: bits: 2, 3, 6, 7, 10, 11 r3: bits 4, 5, 6, 7 r4: bits 8, 9, 10, 11 5/25/2017 21 22 1 1 2 2 1 1 2 2 1 2 2 8 8 8 8 1 2 3 4 5 6 7 8 9 10 11 4 4 4 4 23 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Hamming code (cnt’d) Example of redundancy bit calculation (even parity) 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Hamming code (cnt’d) Error detection using Hamming code once the bit is identified the receiver can reverse its value 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Communication protocols 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Communication protocols -Wanted behavior• Communicating sender and receiver: • Order – When sender has sent mi before mj and receiver has accepted mj, then receiver has also accepted mi • Validity – When receiver has accepted mi then mi was sent by sender • Progress – A sent message is eventually accepted 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Stop-and-Wait Automatic Repeat reQuest • simplest flow and error control mechanism • the sending device keeps a copy of the last frame transmitted until it receives an acknowledgement – identification of duplicate transmission (lost or delayed ACK) • a damaged or lost frame is treated in the same way • timers introduced • positive ACK sent only for frames received safe & sound 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking A Simplex Stop-and-Wait ARQ 1. 2. 3. 4. normal operation the frame is lost the ACK is lost the ACK is delayed 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Stop-and-Wait ARQ -Normal operation• The sender will not send the next piece of data until it is sure that the current one is correctly received • sequence number necessary to check for duplicated packets • No NACK – when packet is corrupted – duplicate ACKs instead 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Stop-and-Wait ARQ -Lost or damaged frame- roundtrip delay + processing in the receiver Should be as short as possible. Why? 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Stop-and-Wait ARQ -Lost ACK- Importance of numbering 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Stop-and-Wait ARQ -Delayed ACK- Importance of ACK numbering 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Duplex Stop-and-Wait ARQ • Piggybacking – combine data with ACK (less overhead saves bandwidth) 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Drawbacks of Stop-and-Wait ARQ • after each frame sent the host must wait for an ACK – inefficient use of bandwidth • to improve efficiency ACK should be sent after multiple frames • Alternatives: Sliding Window protocols 1. Go-back-N ARQ 2. Selective Repeat ARQ 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Pipelining • One task begins before the other one ends – increases efficiency in transmission 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Sliding Window Protocols • Sequence numbers – sent frames are numbered sequentially – number of frames stored in the header • if the number of bits in the header is m than sequence number goes from 0 to 2^m-1 • Sliding window frame – to hold the unacknowledged outstanding frames – the receiver window size always 1 acknowledged frames 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking sequence number Question • What is the consequence of the window size in the receiver on the order of the received packets? Answer: • Window size 1 means that the packets are received in order – Note: this is not the case for the larger receiver window size 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Go-back-N -Control variables• • • • S- holds the sequence number of the recently sent frame SF – holds sequence number of the first frame in the window SL – holds the sequence number of the last frame R – sequence number of the frame expected to be received 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking The name of Go-back-N: why? • Re-sending frame – when the frame is damaged the sender goes back and sends a set of frames starting from the last one ACKn’d – the number of retransmitted frames is N Example: The window size is 4. A sender has sent frame 6 and the timer expires for frame 3 (frame 3 not ACKn’d). The sender goes back and re-sends the frames 3, 4, 5 and 6. 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Go-back-N -normal operation• How many frames can be transmitted without acknowledgment? • ACK1 – not necessary if ACK2 is sent – Cumulative ACK expected sequence number 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Go-back-N -damaged or lost framedamaged frames are discarded! Why are correctly received packets not buffered? What is the disadvantage of this? 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Go-back-N -sender window size- sequence number 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Go-back-N • Inefficient – all out of order received packets are discarded • This is a problem in a noisy link – many frames must be retransmitted -> bandwidth consuming • Solution – re-send only the damaged frames • Selective Repeat ARQ – avoid unnecessary retransmissions 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Selective Repeat ARQ • Processing at the receiver more complex • The window size is reduced to 2m-1 (at most) • Both the transmitter and the receiver have the same window size • Receiver expects frames within the range of the sequence numbers 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Selective Repeat ARQ -lost frame- Note: retransmission triggered with NACK and not with expired timer 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Selective Repeat ARQ -sender window size- 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Communication problems • • • • • corruption of packets loss of packets replication of packets ordering of packets independent failures of nodes 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Communication protocols • We have assumed until now that packets cannot be reordered – this when the parties are connected by a single physical line • What if the channel is a network? – the packets may arrive out of order • Sequence number might be reused – duplications possible • How to solve this problem? • Introduce the lifetime of the packet 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Connection establishment • Connection request PDU • Connection accepted PDU • Is this enough? – What if the network can store or duplicate packets? – What if the subnet is so congested that ACK or datagrams cannot go through? Example: bank transaction (delayed duplicates) Solutions: – new addresses for each connection? – incremented sequence numbers? – PACKET LIFETIME 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Packet lifetime • Can be restricted using: – restricted subnet design • prevents looping • bounding congestion delay over the longest possible path – putting a hop counter in each packet • decrementing default value & dropping when zero – time stamping each packet • carry the time when it was created • discarded after some predefined time – all the routers synchronized – nontrivial • Lifetime expires: – Not only the packets but all the ACKs must be dead 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Connection Establishment (2) dead time after crash data rate < clk rate (max packet lifetime) the same seq num connection 5 crash restart Time-of-day clock (not necessarily sync) – 2 PDU with the same seq. num. are never outstanding at the same time solves the delayed duplicate problem for data PDU (a) PDUs may not enter the forbidden region. (b) The resynchronization problem. 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Connection Establishment (2) different sequence numbers used by the sender & receiver Three protocol scenarios for establishing a connection using a three-way handshake. CR denotes CONNECTION REQUEST. (a) Normal operation, (b) Old CONNECTION REQUEST appearing out of nowhere. (c) Duplicate CONNECTION REQUEST and duplicate ACK. 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Connection Release • asymmetric release – a telephone line • connection is broken when one party hangs up – abrupt disconnection with loss of data. • symmetric release – each connection released separately – continue to receive after disconnect PDU is sent – avoid data loss 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Connection Release (2) unreliable communication channel The two-army problem. 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Connection Release (3) disconnect request 6-14, a, b Four protocol scenarios for releasing a connection. (a) Normal case of a three-way handshake. (b) final ACK lost. 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking Connection Release (4) 6-14, c,d (c) Response lost. (d) Response lost and subsequent DRs lost. 5/25/2017 Igor Radovanović, [email protected] TU/e Computer Science, System Architecture and Networking