Direct Link Networks (II) Computer Networking Lecture 03 HKU SPACE Community College January 30, 2012 HKU SPACE CC CN Lecture 03 1/25
Outline Reliable Link Service Stop-and-Wait Sliding Window Media Access Control Ethernet HKU SPACE CC CN Lecture 03 2/25
Reliable Transmission To correct errors occurred in a transmission, reliable transmission methods is desirable. We can achieve reliable transmission through two fundamental building blocks: acknowledgments (ACK) and timeouts. For acknowledgments, there are two methods, i.e., positive and negative. To make it work, acknowledgment is accompanied with a timeout mechanism, that is, either the receiver or the sender will set a timer, whenever there is a timeout, retransmission occurs. HKU SPACE CC CN Lecture 03 3/25
Reliable Transmission (Cont d) Using positive ACK and timeouts to implement reliable delivery is called automatic repeat request (ARQ). In ARQ, sender assigns a sequence number to each frame. After send out a frame, sender keeps the sent frame in its buffer until it receives the ACK for that frame from receiver. Then the sender deletes the frame from its buffer. Common ARQs are Stop-and-Wait Sliding window In some cases, ACK can be accumulative, e.g., receiving an ACK for frame 4 implies frames 1-3 are correctly received. HKU SPACE CC CN Lecture 03 4/25
Stop-and-Wait Stop-and-wait is the simplest ARQ algorithm. After transmitting a frame, the sender waits for an ACK before transmitting a new frame. If the ACK does not arrive after a certain period of time, the senders times out and retransmits the original frame. To avoid receiving duplicate copies of a frame, one-bit sequence number will be used in the header for a stop-and-wait protocol. Sequence numbers 0 and 1 will be used alternatively. HKU SPACE CC CN Lecture 03 5/25
Stop-and-Wait (Cont d) Figure: Four different scenarios for the stop-and-wait algorithm. HKU SPACE CC CN Lecture 03 6/25
Stop-and-Wait (Cont d) Stop-and-wait is simple to implement, on both sender and receiver sides. However, stop-and-wait only achieves a very low throughput, especially in a high-speed link. Because the maximum number of unacknowledged frames is one, it does not keep the pipe full. In the best case, only one frame can be sent in a round-trip time. When errors occur, an additional number of round-trip times is required. HKU SPACE CC CN Lecture 03 7/25
Sliding Window In sliding window protocol, the maximum number of unacknowledged frames may be more than one. A sender may continue to send frames even when acknowledgments for previously sent frames are not received. Both sender and receiver need to keep track of the states of the frames, (sent, received, acked, and unacked,) such that the pipe is just full and the sender is able to retransmit a frame when error occurs. The size of a so-called window determines the maximum number of unacked frames allowed on the sender side. HKU SPACE CC CN Lecture 03 8/25
Sliding Window (Cont d) Figure: Timeline for the sliding window algorithm. HKU SPACE CC CN Lecture 03 9/25
Sliding Window - Sender Side The sender assigns a sequence number, starting from 1, to each frame. The sender maintains three variables: send window size (SWS): the upper bound of unacked frames that the sender can transmit. last acknowledgment received (LAR): the maximum sequence number has been already acknowledged by the receiver. last frame sent (LFS): the maximum sequence number has been already sent by the sender. We should always have LFS LAR LFS = LAR: All frames sent have been acknowledged. LFS > LAR: LFS - LAR frames are yet to be acknowledged. To make the algorithm work, the sender must make sure LFS - LAR SWS. HKU SPACE CC CN Lecture 03 10/25
Sliding Window - Sender Side (Cont d) When LFS - LAR = SWS, the window is said to be full, and no more new frames can be sent before the (LAR+1)th frame is acknowledged. LFS is initialized to 0, and is incremented by 1 after each frame is sent. LAR is also initialized to 0, and is increased according to the new sequence number(s) acknowledged by the receiver. The sender associates a timer with each frame transmitted, and it retransmits the frame when the associated timer expires before an ACK is received. The sender backups up to SWS frames in case a retransmission is needed. HKU SPACE CC CN Lecture 03 11/25
Sliding Window - Sender Side (Cont d) Figure: Sliding window algorithm. HKU SPACE CC CN Lecture 03 12/25
Sliding Window - Receiver Side The receiver maintains three state variables: receive window size (RWS): the maximum number of out-of-order frames that the receiver is willing to accept. largest acceptable frame (LAF): the maximum sequence number that is acceptable. last frame received (LFR): the sequence number of the last received frame. The receiver also maintains an invariant: LAF - LFR RWS. When a frame with sequence number SeqNum arrives: if LFR < SeqNum LAF, then the frame is accepted. if SeqNum LFR or SeqNum > LAF, the frame is discarded. When a frame is acknowledgeable, the receiver sends an ACK, which is also cumulative. When RWS=1, the receiver will not buffer out-of-order frames. When RWS=SWS, the receiver can buffer any frames the sender sent out. HKU SPACE CC CN Lecture 03 13/25
Sliding Window - Sequence Number Space SeqNum field is finite and will be wrapped around to reuse. Sequence number space must be larger than the number of outstanding frames. SWS MaxSeqNum -1 is not sufficient. A sufficient rule of the sequence number is SWS < (MaxSeqNum+1)/2. Intuitively, SeqNum slides between two halves of the sequence number space. HKU SPACE CC CN Lecture 03 14/25
To provide reliable service. Three Usages of ARQs To provide in-order service: the original order of the frames is preserved even when out-of-order frames are received. To provide flow control: prevent the sender from flooding the receiver; the sender may vary the value of the SWS by taking into account of the state of the receive buffer. HKU SPACE CC CN Lecture 03 15/25
Media Access Control How do multiple hosts share a single transmission medium efficiently? Different solutions result different LAN technologies. Ethernet (bus, star) Token ring, FDDI (ring) Wireless: Bluetooth, WiFi, WiMAX, Cell Phone ATM, Fast Ethernet, Gigabit Ethernet HKU SPACE CC CN Lecture 03 16/25
Ethernet Overview History developed by Xerox PARC in mid-1970s roots in Aloha packet-radio network standardized by Xerox, DEC, and Intel in 1978 absorbed by IEEE 802.3 standard 100-Mbps and 1000-Mbps version are now available, but probably used in switched networks. CSMA/CD carrier sense multiple access collision detection HKU SPACE CC CN Lecture 03 17/25
Properties of Ethernet Hosts are connected to the cable (10base2/5/T) through network adapters. All the logic of the Ethernet protocol is implemented in the adapter. Constrains of the Ethernet: the maximum length of a segment the maximum number of repeaters between two hosts the maximum number of host the minimum bytes of a Ethernet frame: 64 bytes (header + 46 bytes of data) HKU SPACE CC CN Lecture 03 18/25
Properties of Ethernet (Cont d) Figure: Ethernet transceiver and adapter. HKU SPACE CC CN Lecture 03 19/25
Properties of Ethernet (Cont d) Figure: Ethernet repeater. HKU SPACE CC CN Lecture 03 20/25
Properties of Ethernet (Cont d) Figure: Ethernet hub. HKU SPACE CC CN Lecture 03 21/25
Properties of Ethernet (Cont d) Each adapter card is uniquely identified by a 48-bit (physical or MAC) address, e.g., 00-50-DA-26-CD-EE. An Ethernet adapter receives all frames and accepts frames addressed to its own address; broadcast frames; multicast frames, if it is in the group; all frames, if it is in promiscuous mode. Figure: Ethernet frame format. HKU SPACE CC CN Lecture 03 22/25
MAC of Ethernet Any adapter is able to distinguish a busy link from an idle link. If line is idle: send immediately upper bound message size of 1500 bytes must wait 9.6µs between back-to-back frames If line is busy: wait until idle and transmit immediately called 1-persistent (special case of p-persistent) Each adapter is able to detect frame collisions. If collision: jam for 32 bits, then stop transmitting frame delay and try again by using truncated exponential backoff 1st time: 0 or 51.2µs 2nd time: 0, 51.2, 102.4, or 153.6µs 3rd time: 0, 51.2, 102.4, 153.6,..., or k 51.2µs, k =0..7 nth time: k 51.2µs, for a random k =0..2 n 1, up to 1023. give up after several tries (usually 16) HKU SPACE CC CN Lecture 03 23/25
MAC of Ethernet (Cont d) Figure: Worst-case scenario. HKU SPACE CC CN Lecture 03 24/25
Acknowledgments Part of this slide set is referenced, prepared or/and extracted from the books: Computer Networks - A Systems Approach and the book Routing in the Internet. Also, some images and information are sourced from the Internet. This set of slides is for teaching purpose only. HKU SPACE CC CN Lecture 03 25/25