Download presentation
Presentation is loading. Please wait.
Published byHaakon Samuelsen Modified over 6 years ago
1
CSS432 Point-to-Point Links Textbook Ch2.1 – 2.5
Prof. Athirai Irissappane CSS 432
2
Outline Perspectives on Connecting nodes Encoding Framing
Error Detection Reliable Transmission CSS 432
3
Links All practical links rely on some sort of electromagnetic radiation propagating through a medium or, in some cases, through free space One way to characterize links, then, is by the medium they use Typically copper wire in some form (as in coaxial cable), Optical fiber (as in both commercial fiber-to-the home services and many long-distance links in the Internet’s backbone), or Air/free space (for wireless links) CSS 432
4
Links Full-duplex versus Half-duplex Local cable types
Category 5 twisted pair Coax Multimode fiber LED-based, 2km Single-mode fiber laser-diode-based, 40km Carrier-supported cables/fibers DS1 (T1): 1.544Mbps, 24-digital voice circuits of 64 Kbps each DS3 (T3): Mbps, 28 DS1 links STS-1 (OC-1): Synchronous Transport signal, the base link speed= Mbps STS-3, 12, 48, 192 (OC-3, OC-12, OC-48, OC-192) at time t at time u In networking, the term ‘duplex’ signifies the ability for two points or devices to communicate with each other, as opposed to ‘simplex’ which refers to unidirectional communication Full-duplex communication between two components means that both can transmit and receive information between each other simultaneously. Telephones are full-duplex systems so both parties on the phone can talk and listen at the same time. In half-duplex systems, the transmission and reception of information must happen alternately. While one point is transmitting, the other must only receive. Walkie-talkie radio communication is a half-duplex system, this is characterised by saying “over” at the end of a transmission to signify that the party is ready to receive information Tranfer of info -> electromagnetic waves; v=flambda; v-> velo; f-frequency; lam-wavelength em waves created by the vibration of an electric charge hence have frequency; synchronized oscillations of electric and magnetic fields that propagate at the speed of light through a vacuum Wavelength: dist bet pair of maxima, minima of wae Wired: Twisted pair: 4 pairs of twisted cables of copper wire; twisted to avoid em interference (shielded (less interference)/unshielded) Coaxial: single copper wire: more bandwidth and less interference Fiber optics: cable has optical fibers(glass) transferring light; information transferred by sending pulses of light No em interference; less loss Optical fiber: cylindrical guide with a core surrounded by cladding: light is transmitted through the core by total internal reflection Light should enter > than critical angle to be refected inside without leaking and thereby reaching destination: Mutimode: greater diameter; greater critical angle: multiple light modes (wave) to be propagated Modal dispersion: because the propagation velocity of the optical signal is not the same for all modes; as rays at different angles have different path lengths and therefore take different times to traverse the fiber Multi mode: short distance communication; multiple light modes to be propagated and limits the maximum length of a transmission link Led for light pulse; bandwidth low Single mode: laser for pulse; longer distance; larger bandwidth; costly A carrier system is a telecommunications system that transmits information; T-carrier is a member of the series of carrier systems developed by AT&T Bell Laboratories; DS1 is the primary digital telephone standard used in the United States and Japan and is able to transmit up to 24 multiplexed voice and data calls over telephone lines (physical/wireless/of) A Digital Signal 3 (DS3) is a digital signal level 3 T-carrier; This level of carrier can transport 28 DS1 level signals within its payload.(physical, wireless, optical) Sts-1: optical fibre; Optical Carrier transmission rates are a standardized set of specifications of transmission bandwidth for digital signals that can be carried on Synchronous Optical Networking (SONET) fiber optic networks. OC-1 is a SONET line with transmission speeds of up to Mbit/s ; OC-3 is a network line with transmission data rate of up to Mbit/s Data transfer method in which a continuous stream of data signals is accompanied by timing signals (generated by an electronic clock) to ensure that the transmitter and the receiver are in step (synchronized) with one another. The data is sent in blocks (called frames or packets) spaced by fixed time intervals. In contrast, asynchronous transmission works in spurts and must insert a start bit before each data character and a stop bit at its termination to inform the receiver where it begins and ends. Most network protocols (such as Ethernet, SONET, Token Ring) use synchronous transmission whereas asynchronous transmission is used commonly for communications over telephone lines. Read more: CSS 432
5
Links Last-Mile Links Wireless Links POTS: Plain Old Telephone Service
ISDN: Integrated Services Digital Network ADSL: Asynchronous Digital Subscriber Line VDSL: Very high data rate Digital Subscriber Line Wireless Links AMPS, PCS, GSM: Wide-area analog/digital-based mobile phone services IEEE : wireless LAN with up to 54Mbps transfer rate BlueTooth radio interface: 1Mpbs piconet in 10m Voice line 28.8~56Kbps CODEC Digital line 64-128Kbps Mbps 16-640Kbps 12.96~ 55.2Mbps STS-N Last mile links: Links classified based on deployment and economic issues; links provided by isp’s Plain old telephone service (POTS) is a retronym for voice-grade telephone service employing analog signal transmission over copper loops; POTS remains the basic form of residential and small business service connection to the telephone network in many parts of the world Integrated Services Digital Network (ISDN) is a set of communication standards for simultaneous digital transmission of voice, video, data, and other network services over the traditional circuits of the public switched telephone network. ISDN is a circuit-switched telephone network system, which also provides access to packet switched networks, designed to allow digital transmission of voice and data over ordinary telephone copper wires, resulting in potentially better voice quality than an analog phone can provide (now obsolete) Symmetric digital subscriber line (SDSL) refers to digital subscriber line (DSL) technologies, that is, technologies for transmission of digital data over the copper wires of the telephone network where the bandwidth in the downstream direction, from the network to the subscriber, is identical to the bandwidth in the upstream direction, from the subscriber to the network. In ADSL, Bandwidth and bit rate are said to be asymmetric, meaning greater toward the customer premises (downstream) than the reverse (upstream) Very-high-bit-rate digital subscriber line 2 (VDSL2[2]) are digital subscriber line (DSL) technologies providing data transmission faster than asymmetric digital subscriber line (ADSL). VDSL offers speeds of up to 52 Mbit/s downstream and 16 Mbit/s upstream,[3] over a single flat untwisted or twisted pair of copper wires using the frequency band from 25 kHz to 12 MHz. Wireless communication is the transfer of information or power between two or more points that are not connected by an electrical conductor. The most common wireless technologies use radio. With radio waves distances can be short, such as a few meters for television or as far as thousands or even millions of kilometers for deep-space radio communications. Bluetooth is a wireless technology standard for exchanging data over short distances (using short-wavelength UHF radio waves in the ISM band from 2.4 to 2.485 GHz[4]) . A piconet is an adhoc network which links a wireless user group of devices using Bluetooth technology protocols. A piconet consists of two or more devices occupying the same physical channel (synchronized to a common clock and hopping sequence). IEEE is a set of media access control (MAC) and physical layer (PHY) specifications for implementing wireless local area network (WLAN) computer communication in the 900 MHz and 2.4, 3.6, 5, and 60 GHz frequency bands. A cellular network or mobile network is a communication network where the last link is wireless. The network is distributed over land areas called cells, each served by at least one fixed-location transceiver, known as a cell site or base station. This base station provides the cell with the network coverage which can be used for transmission of voice, data and others. A cell might use a different set of frequencies from neighboring cells, to avoid interference and provide guaranteed service quality within each cell.[1] When joined together these cells provide radio coverage over a wide geographic area GSM (Global System for Mobile Communications, originally Groupe SpécialMobile), is a standard developed by the European Telecommunications Standards Institute (ETSI) to describe the protocols for second-generation (2G) digital cellular networks used by mobile phones, 1G (or 1-G) refers to the first generation of wireless telephone technology (mobile telecommunications). These are the analog telecommunications standards that were introduced in the 1980s and continued until being replaced by 2G digital telecommunications. The main difference between the two mobile telephone systems (1G and 2G), is that the radio signals used by 1G networks are analog, while 2G networks are digital An analog signal is any continuous signal for which the time varying feature (variable) of the signal is a representation of some other time varying quantity, i.e., analogous to another time varying signal. For example, in an analog audio signal, the instantaneous voltage of the signal varies continuously with the pressure of the sound waves. It differs from a digital signal, in which the continuous quantity is a representation of a sequence of discrete values which can only take on one of a finite number of values. The primary disadvantage of analog signals is that any system has noise; 2G introduced data services for mobile, starting with SMS text messages. 2G technologies enabled the various mobile phone networks to provide the services such as text messages, picture messages, and MMS 3G telecommunication networks support services that provide an information transfer rate of at least 200 kbit/s; 3G finds application in wireless voice telephony, mobile Internet access, fixed wireless Internet access, video calls and mobile TV. 4G Potential and current applications include amended mobile web access, IP telephony, gaming services, high-definition mobile TV, video conferencing, and 3D television Advanced Mobile Phone System (AMPS) is an analog mobile cell phone system standard developed by Bell Labs At the most basic level Personal Communications Service or PCS describes a set of wireless communications capabilities which allows some combination of terminal mobility, personal mobility, and service profile management In Canada, Mexico and the United States, PCS are provided in the "1900 MHz band" (specifically MHz).[ CSS 432
6
Links Another important link characteristic is the frequency
Measured in hertz, rate with which the electromagnetic waves oscillate, number of cycles per unit time. Distance between the adjacent pair of maxima or minima of a wave measured in meters is called wavelength Speed of light divided by frequency gives the wavelength. Frequency on a copper cable range from 300Hz to 3300Hz; Wavelength for 300Hz wave through copper is (speed of light on a copper / frequency) 2/3 x 3 x 108 /300 = 667 x 103 meters. Bandwidth: width of frequency band ( = 3000 Hz) Placing binary data on a signal is called encoding. Modulation involves modifying the signals in terms of their frequency, amplitude, etc. The number of crests that pass a given point within one second is described CSS 432
7
255 frequencies for downstream
Focusing on ADSL Long distance Residence A Residence B To telephone switch 255 frequencies for downstream 31 use for upsreams 2 taken for control downstream refers to data sent from a network service provider to a customer (downloading) upstream refers to the direction in which data can be transferred from the client to the server (uploading) Downloading speed > uploading Signal divided into frequency bins; bandwidth is divided into sub channels/ 286 frequency bands Preparing 286 frequencies and agreeing at the available frequencies between two modems Fitting to most usages where a user tends to retrieve Internet information. CSS 432
8
Encoding Signals travel between signaling components; bits flow between adaptors Signals propagate over a physical medium modulate electromagnetic waves e.g., vary frequency, amplitude CSS 432
9
Encoding Encode binary data onto signals Consecutive 1s and 0s
e.g., 0 as low signal and 1 as high signal known as Non-Return to zero (NRZ) Consecutive 1s and 0s Baseline wander: if the receiver averages signals to decide a threshold Clock recovery: both sides must be strictly synchronized Bits NRZ 1 CSS 432
10
Encoding Problem with NRZ Baseline wander
The receiver keeps an average of the signals it has seen so far Receiver uses the average to distinguish between low and high signal When a signal is significantly low than the average, it is 0, else it is 1 Too many consecutive 0’s and 1’s cause this average to change, making it difficult to detect CSS 432
11
Encoding Problem with NRZ Clock recovery
Both encoding, decoding is driven by a clock Clock is an internal signal that alternates from low to high, a low/high pair one clock cycle Every clock cycle, the sender transmits a bit and the receiver recovers a bit Sender and receiver must be synchronized Receiver re-synchronizes its clock when signal changes (clock recovery) Frequent transition from high to low or vice versa are necessary to enable clock recovery Clock cycle: low high pair of the clock CSS 432
12
Alternative Encodings
Non-return to Zero Inverted (NRZI) Encode 1: make a transition from current signal Encode 0: stay at current signal to encode a zero solves the problem of consecutive 1s Signal flips every 1 is encountered. Manchester Transmit XOR of the NRZ encoded data and the clock Only 50% efficient. Used by Ethernet/Token Ring Ethernet /ˈiːθərnɛt/ is a family of computer networking technologies commonly used in local area networks (LANs) and metropolitan area networks (MANs) Token ring local area network (LAN) technology is a communications protocol for local area networks. It uses a special three-byte frame called a "token" that travels around a logical "ring" of workstations or servers. This token passing is a channel access method providing fair access for all stations, and eliminating the collisions of contention-based access methods. 1 CSS 432
13
Encoding Example Bits NRZ Clock Manchester NRZI 1 CSS 432
14
Alternative Encodings
Problem with Manchester encoding Doubles the rate at which the signal transitions are made on the link Which means the receiver has half of the time to detect each pulse of the signal The rate at which the signal changes is called the link’s baud rate Bit rate is the no.of of data bits transmitted in one second; Here Bit rate is half the baud rate CSS 432
15
4B/5B Encoding Address inefficiency, repeated high/low signals
Insert extra bits into bit stream so as to break up the long sequence of 0’s and 1’s Every 4-bits of actual data are encoded in a 5- bit code that is transmitted to the receiver 5-bit codes are selected in such a way that each one has no more than one leading 0(zero) and no more than two trailing 0’s. No pair of 5-bit codes results in more than three consecutive 0’s NRZI encoding for transmission (repeated 1’s) Achieves 80% efficient: bit rate = 80% (4/5*100) baud rate) CSS 432
16
Framing We are focusing on packet-switched networks, which means that blocks of data (called frames at this level), not bit streams, are exchanged between nodes. It is the network adaptor that enables the nodes to exchange frames. Bits Node A Adaptor Adaptor Node B Frame Bits flow between adaptors, frames between hosts CSS 432
17
Framing When node A wishes to transmit a frame to node B, it tells its adaptor to transmit a frame from the node’s memory. This results in a sequence of bits being sent over the link. The adaptor on node B then collects together the sequence of bits arriving on the link and deposits the corresponding frame in B’s memory. Recognizing exactly what set of bits constitute a frame—that is, determining where the frame begins and ends—is the central challenge faced by the adaptor CSS 432
18
Sentinel approach: PPP, HDLC
Delineate frame (beginning sequence/end sequence) with special pattern: problem: ending sequence appears in the payload/actual data solution: bit stuffing sender: insert 0 after five consecutive 1s receiver: delete 0 that follows five consecutive 1s Other classification: Byte Oriented (PPP), frames are collection of bytes Character stuffing instead of bit stuffing Bit Oriented (HDLC) frames are collection of bits Frame error Header Body 8 16 CRC Beginning sequence Ending BISYNC (Binary Synchronous Communication) Protocol PPP – Point-to=point : IP protocol DDCMP (Digital Data Communication Protocol) CRC – cyclic redundancy check HDLC – High level data link control CSS 432
19
Counter Based: DDCMP include payload length in header
problem: count field corrupted (frame error) solution: Wait for the next beginning sequence Catch when CRC fails Frame error BISYNC (Binary Synchronous Communication) Protocol PPP – Point-to=point : IP protocol DDCMP (Digital Data Communication Protocol) CRC – cyclic redundancy check Accumulate bytes as count specifies: verify with CRC and detect framing error Wait till next beginning of sequence CSS 432
20
Clock Based (SONET: Synchronous Optical Network)
Each frame 9 rows, 90 columns = 9*90=810 bytes First 3 bytes of each row overhead First 2 bytes specific pattern Receiver looks for pattern every 810 bytes each frame is 125us (810*8/51.84Mbps) long STS-1 (SONET link; Mbps) STS-3 (1 frame = 3*810 bytes) (3 STS-1 concatenated) (STS-n) (multiplexes multiple low-speed links) Bytes interleaved (1 byte from 1st STS-1 frame transmitted, 2nd STS-1 frame transmitted, etc) SONET: protocol for transmission over optical fiber Interleaved every byte: keep 51Mbps for each STS-1 CSS 432
21
Error Detections Bit errors are introduced into frames Detecting Error
Because of electrical interference and thermal noises Detecting Error Correction Error when the recipient detects an error Notify the sender that the message was corrupted, so the sender can send again. If the error is rare, then the retransmitted message will be error-free Using some error correct detection and correction algorithm, the receiver reconstructs the message CSS 432
22
Error Detections Add k bits of redundant data to an n-bit message
want k << n (i.e. k is extremely small as compared to n) e.g., k = 32 and n = 12,000 (1500 bytes) in CRC-32 Extra bits are redundant They add no new information to the message Derived from the original message using some algorithm Both the sender and receiver know the algorithm Parity Bit Internet Checksum Algorithm Cyclic Redundancy Check CSS 432
23
Parity One dimensional Parity Two-dimensional parity
1 Parity bits byte Data One dimensional Parity adding one extra bit to a 7-bit code to balance the number of 1s in the byte. Odd parity: add 1 to get odd number of 1s in the byte Even parity: add 1 to get even number of 1s in the byte Two-dimensional parity similar calculation for each bit position across each of the bytes in the frame extra parity byte for the entire frame, in addition to a parity bit for each byte CSS 432
24
Internet Checksum Algorithm
View message as a sequence of 16-bit integers; ( ) Convert each 16-bit integer into a ones-complement arithmetic Sum up each integer Increment the result upon a carryout Example: Ones-complement message 5: 3: -5: -3: -5 + (-3): w/ carry: This corresponds to -8 u_short cksum(u_short *buf, int count) { register u_long sum = 0; while (count--) sum += *buf++; // add each value if (sum & 0xFFFF0000) // carry occurred, so wrap around sum &= 0xFFFF; sum++; } return ~(sum & 0xFFFF); Ones-complement arithmetic: a negative integer −x is represented as the complement of x; When adding numbers in ones complement arithmetic, a carryout from the most significant bit needs to be added to the result. Sender and receiver need to get the same checksum Count: number of 16bit integers Buf: their 1’s complement Int * p =&a (points to 1 value) Int* p = a (a is also a pointer; int[] as) 0x – hexa decimal integers U_short is 32 bits U_long 8 bytes: 64 bits ( ) ( ) : 32 bits (FFFF); F = (1byte=8 bit)(lowest data handled by computer is byte) ( ) ( ): 32 bits (0000) FFFF0000 -> 32 bits of 1 and 32 bits of 0 Sum (32 bits) & (32bits of 1; 32 bits of 0) = 1 if sum has a carry bit Sum(32 bits) & (32 bits of 1) : get the sum bits Add 1; Return original number What if 5 and 3 were changed In 6 and 2 ? CSS 432
25
Cyclic Redundancy Check (CRC)
Reduce the number of extra bits and maximize protection Represent n-bit message as n-1 degree polynomial e.g., MSG= as M(x) = x7 + x4 + x3 + x1 Let k be the degree of some divisor polynomial e.g., C(x) = x3 + x2 + 1 Create P(x) from M(x) such that P(x) % C(x) = 0 T(x) = M(x) * x^k ; P(x) = T(x) – T(x) % C(x) Transmit P(x); sender and receiver know C(x) If P(x) % C (x) =0 at receiver; no transmission error
26
Modulo 2 arithmetic Modulo 2
Modulo 2 multiplication is no different than for decimal numbers, except that modulo 2 addition must be used when computing the final sum. 111 *101 111 (mul 111 by 1) 000 (mul 111 by 0) (mul 111 by 1) 11011 (perform XOR addition)
27
CRC (cont) Sender polynomial M(x) Noise polynomial E(x)
eor 1101 1001 1000 1011 1100 101 Sender polynomial M(x) M(x) = , C(x) = 1101, thus k = 3 T(x) = M(x) * x3 = (<< 3) T(x) % C(x) = 101 T(x) – T(x) % C(x) = = P(x) Noise polynomial E(x) Receiver polynomial P(x) + E(x) E(x) = 0 implies no errors (P(x) + E(x)) % C(x) == 0 if: E(x) was zero (no error), or E(x) is exactly divisible by C(x) To retrieve M(x): P(x)/ x3, (truncate the last 3 bits) Just appended The most significant bit (MSB) is the bit in a multiple-bit binary number with the largest value. (big endian) This is usually the bit farthest to the left, or the bit transmitted first in a sequence. For example, in the binary number 1000, the MSB is 1, and in the binary number 0111, the MSB is 0. The most significant byte, also abbreviated MSB, is the byte in a multiple-byte word with the largest value. As with bits, the MSB (byte) is normally the byte farthest to the left, or the byte transmitted first in a sequence CSS 432
28
CRC Calculation Using Shift Register
XOR C(x) = 1101 CRC x0 x1 x2 M(x) * x^k from left
29
CRC Calculation Using Shift Register
sender receiver M(x) * x^k CRC M(x) + CRC M(x) CRC’ P(x)% C(x) == 0 // CRC == CRC’, no errors x0 x1 x2 Example: M(x) = C(x) = 1101 1 1 000 01 1 1 1 000 0 1 1 101 will be transferred. 000 1 1 00 1 1 CSS 432
30
Reliable Transmission
The University of Adelaide, School of Computer Science 17 September 2018 Reliable Transmission CRC is used to detect errors. Some error codes are strong enough to correct errors. The overhead is typically too high. Corrupt frames must be discarded. A link-level protocol that wants to deliver frames reliably must recover from these discarded frames. Protocols use Acknowledgements and Timeouts Chapter 2 — Instructions: Language of the Computer
31
Reliable Transmission
The University of Adelaide, School of Computer Science 17 September 2018 Reliable Transmission An acknowledgement (ACK for short) is a small control frame (only header no data) that a protocol sends back to its peer saying that it has received the earlier frame. The receipt of an acknowledgement indicates to the sender of the original frame that its frame was successfully delivered. If the sender does not receive an acknowledgment after a reasonable amount of time, then it retransmits the original frame. The action of waiting a reasonable amount of time is called a timeout. Chapter 2 — Instructions: Language of the Computer
32
Frame Transfer Algorithms
Stop and wait After transmitting one frame, the sender waits for an acknowledgement before transmitting the next frame. If the acknowledgement does not arrive after a certain period of time, the sender times out and retransmits the original frame The ACK is received before the timer expires; The original frame is lost; The ACK is lost; the timeout fires too soon CSS 432
33
Frame Transfer Algorithms
If ACK is lost or delayed in arriving The sender times out and retransmits the original frame, but the receiver will think that it is the next frame since it has correctly received and acknowledged the first frame. (duplicate copies of frames will be delivered!!) Solution Use 1 bit sequence number (0 or 1) When the sender retransmits frame 0, the receiver can determine that it is seeing a second copy of frame 0 rather than the first copy of frame 1 and therefore can ignore it (the receiver still acknowledges it, in case the first acknowledgement was lost) CSS 432
34
Stop and Wait Problem: Can’t utilize the link’s capacity Example 1
Consider a 1.5 Mbps link with a 45 ms RTT The link has a capacity, i.e., delay bandwidth = 67.5 Kb ~ 8 KB Sender can send only one frame (size = 1 KB) per RTT 1KB for 45ms RTT (one-eighth of the link’s capacity) To use the link fully, then sender should transmit up to eight frames before having to wait for an acknowledgement Example 2 Ping from uw to uw : 0.200msec = 2 x 10-4sec 1Gbps x (2 x 10-4) = 109 x 2 x 10-4 = 2 x 105 = 200Kbits = 25KB Unless you send 25KB for every 0.2msec, you make the network idle Or, you should send 25KB ÷ 1.5KB/packet = 16.7 packets consecutively. CSS 432
35
Sliding Window Protocol
Utilizes link capacity Transmit 8 frames before receiving ACK0 Transmit 9th frame same time when ACK0 received Allow multiple outstanding (un-ACKed) frames Upper bound on un-ACKed frames (<=8), called window CSS 432
36
Sliding Window Protocol
The University of Adelaide, School of Computer Science 17 September 2018 Sliding Window Protocol Sender assigns a SeqNum to each frame. Sender maintains three variables Sending Window Size (SWS) Upper bound on the number of outstanding (unacknowledged) frames that the sender can transmit (8) Last Acknowledgement Received (LAR) Sequence number of the last acknowledgement received Last Frame Sent (LFS) Sequence number of the last frame sent CSS 432 Chapter 2 — Instructions: Language of the Computer
37
Sliding Window Protocol
The University of Adelaide, School of Computer Science 17 September 2018 Sliding Window Protocol Sender assigns a SeqNum to each frame. Sender maintains three variables Sending Window Size (SWS = 8): Upper bound on the number of outstanding (unacknowledged) frames that the sender can transmit Last Acknowledgement Received (LAR = 1): SeqNum of the last acknowledgement received Last Frame Sent (LFS = 9): SeqNum of the last frame sent LFS – LAR ≤ SWS; Sliding Window on Sender CSS 432 Chapter 2 — Instructions: Language of the Computer
38
Sliding Window Protocol
When an acknowledgement arrives the sender moves LAR to right, thereby allowing the sender to transmit another frame Also the sender associates a timer with each frame it transmits It retransmits the frame if the timer expires before the ACK is received CSS 432
39
Sliding Window Protocol
Receiver maintains three variables Receiving Window Size (RWS =8): Upper bound on the number of out-of-order frames that the receiver is willing to accept Largest Acceptable Frame (LAF = 17): SeqNum of the largest acceptable frame Last Frame Received (LFR = 9): SeqNum of the last frame received LAF – LFR ≤ RWS Sliding Window on Receiver CSS 432
40
Sliding Window Protocol
When a frame SeqNum arrives, If SeqNum ≤ LFR or SeqNum > LAF Discard it (the frame is outside the receiver window) If LFR < SeqNum ≤ LAF Accept it Let SeqNumToAck be largest SeqNum not yet acknowledged, such that all frames with SeqNum < = SeqNumToAck have been received The receiver acknowledges the receipt of SeqNumToAck even if high-numbered packets have been received (cumulative) The receiver then sets, LFR = SeqNumToAck; LAF = LFR + RWS CSS 432
41
Sequence Number Space SeqNum field is finite; e.g., 3-bit SeqNum field (0..7) Repeat sequence numbers, MaxSeqNum: e.g. 8 SWS <= MaxSeqNum-1, differentiate between new, old incarnations when ACK is lost If (RWS = 1), SWS <= MaxSeqNum-1 is sufficient If (RWS = SWS), SWS <= MaxSeqNum-1 is not sufficient suppose 3-bit SeqNum field (0..7) SWS=RWS=7 sender transmit frames 0..6 arrive successfully, but ACKs lost sender retransmits 0..6 receiver expecting 7, 0..5, but receives second incarnation of 0..5 SWS < (MaxSeqNum+1)/2 or 2 x SWS – 1 < MaxSeqNum CSS 432
42
Stop and Wait (HW2) Client writes a message sequence number in message[0], sends message[] and waits until it receives an integer acknowledgment from a server, while the server receives message[], copies the sequence number from message[0] to an acknowledgment, and returns it to the client. UDP bind client socket (connect, sendTo implicit bind but receiveFrom no implicit bind) CSS 432
43
Stop and Wait (use seq num 0 to n)
timeout // Test 2: client stop-and-wait message send int clientStopWait( UdpSocket &sock, const int max, int message[] ) { int retransmits = 0; // # retransmits int ack; // prepare a space to receive ack // transfer message[] max times for ( int sequence = 0; sequence < max; ) { message[0] = sequence; // message[0] has a sequence number sock.sendTo( (char *)message, MSGSIZE ); // udp message send // until a timeout (1500msecs) occurs // keep calling sock.poolRecvFrom( ) // if an ack came, exame if its ack sequence is the same as my sequence // if so, increment my sequence and go back to the loop top // if a timeout occurs, resend the same sequence and increment retransmits } return retransmits; Frame sent 1 1 2 ack=1 seq=1 seq=2 ack=0 seq=1 ack=1 seq=0 late // Test 2: server reliable message receive void serverReliable( UdpSocket &sock, const int max, int message[] ) { int ack; // an ack message // receive message[] max times for ( int sequence = 0; sequence < max; ) { sock.recvFrom( (char *)message, MSGSIZE ); // udp message receive // if this is a message expected to receive send back an ack with this sequence number and increment sequence // if this message is < sequence number of expected message ignore the message but resend an acknowledgement for it } Frame received 1 1 2 discarded CSS 432
44
Sliding Window (HW2) Client keeps writing a message sequence number in message[0] and sending message[] as far as the number of in-transit messages is less than a given window size Server receives message[], memorizes this message's sequence number in its array and returns as its acknowledgment the minimum sequence number of messages it has not yet received Repeat sending and receiving MAX times. CSS 432
45
Sliding Window CSS 432 window max = 5 frame sent lost lost Cum ACK
// Test 3: client sliding window + early-retransmission int clientSlidingWindow( UdpSocket &sock, const int max, int message[], const int windowSize ){ int retransmits = 0; // # retransmits int ack; // prepare a space to receive ack int ackSeq = 0; // the ack sequence expected to receive // transfer message[] max times for ( int sequence = 0; sequence < max || ackSeq < max; ) { if ( ackSeq + windowSize > sequence && sequence < max ) {//send till sliding window full message[0] = sequence; // message[0] has a sequence number sock.sendTo( (char *)message, MSGSIZE ); // udp message send // check if ack arrived and if ack is the same as ackSeq, increment ackSeq // increment sequence } else { // the sliding window is full! // until a timeout (1500msecs) occurs check for ack // keep calling sock.poolRecvFrom( ) // if an ack came, if ack >= ackSeq, ackSeq = ack + 1 // else resend the lost message and increment retransmits // break if (any) ack received // if a timeout occurs, resend the message corresponding to ackSeq and increment retransmits } return retransmits; window max = 5 TimeOUT frame sent 1 2 3 4 5 6 7 3 3 3 3 8 lost lost // Test 3: server early retransmission void serverEarlyRetrans(UdpSocket &sock, const int max, int message[], const int windowSize ){ int ack[3]; // an ack message bool array[max]; //array[i]=true if seqNum=i is received for ( int j = 0; j < max; j++ ) array[j] = false; // no message has arrived yet // receive message[] max times for ( int sequence = 0; sequence < max; ) { sock.recvFrom( (char *)message, MSGSIZE ); // receive a UDP message // if message received has seqNum = sequence. // mark array[sequence]=true, // Increment sequence until you identify the first non-received message // else if seqNum > sequence // mark arrray[seqNum]=true. // send back the ack for the last messages received so far (in order) } } Cum ACK 1 2 2 2 2 2 7 7 7 8 Cum ACK: Last received frame in order CSS 432
46
Sliding Window No. of Packets Sent by Client before detecting packet loss = 5 + 3 If the 3rd packet is lost Client already has sent Window Size packets , i.e., 5 Client has received ACK for 0, 1, 2 packets Thus nPAckets sent before detecting packet loss = 8 If the server sent acknowledgement immediately Timer is triggered only when the expected ACK from Packet 3 is missing If it takes 5us to send 1 packet and the timeout is 100us Total time taken by sender to detect that packet 3 is lost = 8* = 140us CSS 432
47
Sliding Window CSS 432
48
Reviews Exercises in Chapter 2
Encoding (NRZ, NRZI, Manchester, and 4B/5B) Framing (Sentinel and counter-based) Error Detections (Parity, Internet checksum, and CRC) Stop-and-wait Sliding window Exercises in Chapter 2 Ex. 2 and 5 (4B/5B, NRZI, and bit stuffing) Ex. 16 (Internet Checksum) Ex. 18 (CRC) Ex. 24 (Sliding Window) CSS 432
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.