THE DATA LINK LAYER. From: Computer Networks, 3rd ed. by Andrew S. Tanenbaum, 1996 Prentice Hall

Similar documents
Chapter 3. The Data Link Layer

C08a: Data Link Protocols

Computer Networks. Data Link Layer. Design Issues. Basic Services. Notes. Paolo Costa costa. Notes. Note.

UNIT II THE DATA LINK LAYER DESIGN ISSUES

Chapter 3. The Data Link Layer

Jaringan Komputer. Data Link Layer. The Data Link Layer. Study the design principles

The Transport Layer. Why is there a transport layer? Addressing

Inst: Chris Davison

CS422 Computer Networks

User watching video clip. Server with video clips Chapter 4: Data Link Layer Application Layer Application Layer. Beispielbild. Presentation Layer

CSMC 417. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala Set 4. September 09 CMSC417 Set 4 1

06/05/2008. Chapter 3. The Data Link Layer. Data Link Layer Design Issues. Services Provided to the Network Layer. Error Control Flow Control

DATA LINK LAYER UNIT 7.

Flow control: Ensuring the source sending frames does not overflow the receiver

The Data Link Layer Chapter 3

The Data Link Layer. Data Link Layer Design Issues

CSMC 417. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala. Nov 1,

Telematics Chapter 4: Data Link Layer

Advanced Computer Networks. Rab Nawaz Jadoon DCS. Assistant Professor COMSATS University, Lahore Pakistan. Department of Computer Science

Lesson Schedule: Class No. Portion covered per hour (An estimate)

Outline. EEC-484/584 Computer Networks. Data Link Layer Design Issues. Framing. Lecture 6. Wenbing Zhao Review.

Chapter 3. The Data Link Layer. Wesam A. Hatamleh

Chapter 11 Data Link Control 11.1

ERROR AND FLOW CONTROL. Lecture: 10 Instructor Mazhar Hussain

DLL: Flow Control DLL. Simplex. Fast sender / slow receiver scenario. Various protocols used. Simplified examples implemented in C.

2.1 CHANNEL ALLOCATION 2.2 MULTIPLE ACCESS PROTOCOLS Collision Free Protocols 2.3 FDDI 2.4 DATA LINK LAYER DESIGN ISSUES 2.5 FRAMING & STUFFING

Data Link Layer. Overview. Links. Shivkumar Kalyanaraman

The data link layer has a number of specific functions it can carry out. These functions include. Figure 2-1. Relationship between packets and frames.

Data Link layer (CN chap 3.1, 3.4, 3.6)

Data link layer functions. 2 Computer Networks Data Communications. Framing (1) Framing (2) Parity Checking (1) Error Detection

Chapter 11 Data Link Control 11.1

The Data Link Layer Chapter 3

3. Data Link Layer 3-2

Data Link Layer: Overview, operations

Data Link Control. Outline. DLC functions

The Transport Layer Reliability

Direct Link Networks. Framing. Lecture - Encoding & Framing 1. Problems. Areas for Discussion

Networking Link Layer

CSCI Topics: Internet Programming Fall 2008

Chapter 5 Peer-to-Peer Protocols. School of Info. Sci. & Eng. Shandong Univ..

1.Write about the Data Link layer design issues.

Computer Network. Direct Link Networks Reliable Transmission. rev /2/2004 1

Direct Link Networks. Lecture - Encoding & Framing 1. Areas for Discussion. Problems

10.1 REVIEW QUESTIONS

Computer Networking. Reliable Transport. Reliable Transport. Principles of reliable data transfer. Reliable data transfer. Elements of Procedure

NWEN 243. Networked Applications. Layer 4 TCP and UDP

INF Data Communication Data Link Layer

Analyzation of Automatic Repeat Request (ARQ) Protocols

Stream Control Transmission Protocol

Chapter 3: Transport Layer. Chapter 3 Transport Layer. Chapter 3 outline. Transport services and protocols

EITF25 Internet Techniques and Applications L3: Data Link layer. Stefan Höst

CS 640 Introduction to Computer Networks. Role of data link layer. Today s lecture. Lecture16

TCP : Fundamentals of Computer Networks Bill Nace

TCP and Congestion Control (Day 1) Yoshifumi Nishida Sony Computer Science Labs, Inc. Today's Lecture

Comparison of ISO-OSI and TCP/IP Suit. Functions of Data Link Layer:

CSCI-1680 Link Layer I Rodrigo Fonseca

CSCE 463/612 Networks and Distributed Processing Spring 2017

DATA LINK LAYER: NEED

TYPES OF ERRORS. Data can be corrupted during transmission. Some applications require that errors be detected and corrected.

COMPUTER NETWORK. Homework #2. Due Date: April 12, 2017 in class

Principles of Reliable Data Transfer

Data Link Layer, Part 4. Exemplary Protocols

Data Link Technology. Suguru Yamaguchi Nara Institute of Science and Technology Department of Information Science

Framing and Stuffing. Advanced Computer Networks

Networking Technologies and Applications

CS 5520/ECE 5590NA: Network Architecture I Spring Lecture 13: UDP and TCP

Code No: RR Set No. 1

CSCD 330 Network Programming

Computer Networking : Principles, Protocols and Practice

Data Link Control Protocols

The flow of data must not be allowed to overwhelm the receiver

16.682: Communication Systems Engineering. Lecture 17. ARQ Protocols

SRI RAMAKRISHNA INSTITUTE OF TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY COMPUTER NETWORKS UNIT - II DATA LINK LAYER

The GBN sender must respond to three types of events:

Department of Computer and IT Engineering University of Kurdistan. Data Communication Netwotks (Graduate level) Data Link Layer

Protocol Specification. Using Finite State Machines

Intro to LAN/WAN. Transport Layer

Internet transport-layer protocols. Transport services and protocols. Sending and receiving. Connection-oriented (TCP) Connection-oriented

Hamming codes can also correct burst of errors by using iterleaving

Lecture 11: Transport Layer Reliable Data Transfer and TCP

Lecture 11 Overview. Last Lecture. This Lecture. Next Lecture. Medium Access Control. Flow and error control Source: Sections , 23.

UNIT IV -- TRANSPORT LAYER

Data Link Layer. Indian Institute of Technology Madras

Peer-to-Peer Protocols and Data Link Layer. Chapter 5 from Communication Networks Leon-Gracia and Widjaja

CMSC 417. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala. October 25, 2018

P1 : Distributed Bitcoin Miner / /19/2018

TCP/IP Protocol Suite 1

Sequence Number. Acknowledgment Number. Data

Lecture - 14 Transport Layer IV (Reliability)

The Transport Layer: TCP & Reliable Data Transfer

CS4700/CS5700 Fundamentals of Computer Networks

Data Link Control Protocols

Network Working Group

CSE 461: Framing, Error Detection and Correction

32 bits. source port # dest port # sequence number acknowledgement number not used. checksum. Options (variable length)

Chapter 3 Transport Layer

RSC Part III: Transport Layer 3. TCP

Transport Layer Marcos Vieira

QUIZ: Longest Matching Prefix

IS370 Data Communications and Computer Networks. Chapter 5 : Transport Layer

Transcription:

3 THE DATA LINK LAYER

Host 1 Host 2 Host 1 Host 2 4 4 4 4 3 2 Virtual data path 3 2 3 2 3 2 1 1 1 Actual data path 1 (a) (b) Fig. 3-1. (a) Virtual communication. (b) Actual communication.

Router Data link layer process Routing process 2 2 3 2 2 3 Frames here Packets here Data link protocol Transmission line to a router Fig. 3-2. Placement of the data link protocol.

Character count One character (a) 5 1 2 3 4 5 6 7 8 9 8 1 2 3 4 5 6 8 7 8 9 1 2 3 Frame 1 5 characters Frame 2 5 characters Frame 3 8 characters Frame 4 8 characters Error (b) 5 1 2 3 4 7 6 7 8 9 8 1 2 3 4 5 6 8 7 8 9 1 2 3 Frame 1 Frame 2 (Wrong) Now a character count Fig. 3-3. A character stream. (a) Without errors. (b) With one error.

(a) DLE STX A DLE B DLE ETX (b) (c) DLE STX A DLE DLE B DLE ETX Stuffed DLE DLE STX A DLE B DLE ETX Fig. 3-4. (a) Data sent by the network layer. (b) Data after being character stuffed by the data link layer. (c) Data passed to the network layer on the receiving side.

(a) (b) 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Stuffed bits (c) 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Fig. 3-5. Bit stuffing. (a) The original data. (b) The data as they appear on the line. (c) The data as they are stored in the receiver s memory after destuffing.

Char. H a m m i n g c o d e ASCII Check bits 11 111 111 111111 11111 1111111 11111 1111111 1111 111111 11111 111111 11111 111111111 1 111 1111 1111111 111111 1111111 111 1111111 1111 11111 Order of bit transmission Fig. 3-6. Use of a Hamming code to correct burst errors.

Frame : 1 1 1 1 1 1 1 Generator: 1 1 1 Message after appending 4 zero bits: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Remainder Transmitted frame: 1 1 1 1 1 1 1 1 1 1 Fig. 3-7. Calculation of the polynomial code checksum.

#define MAX PKT 124 * determines packet size in bytes * typedef enum {false, true boolean; * boolean type * typedef unsigned int seq nr; * sequence or ack numbers * typedef struct {unsigned char data[max PKT]; packet;* packet definition * typedef enum {data, ack, nak frame kind; * frame kind definition * typedef struct { * frames are transported in this layer * frame kind kind; * what kind of a frame is it? * seq nr seq; * sequence number * seq nr ack; * acknowledgement number * packet info; * the network layer packet * frame; * Wait for an event to happen; return its type in event. * void wait for event(event type * event); * Fetch a packet from the network layer for transmission on the channel. * void from network layer(packet * p); * Deliver information from an inbound frame to the network layer. * void to network layer(packet * p); * Go get an inbound frame from the physical layer and copy it to r. * void from physical layer(frame * r); * Pass the frame to the physical layer for transmission. * void to physical layer(frame * s); * Start the clock running and enable the timeout event. * void start timer(seq nr k); * Stop the clock and disable the timeout event. * void stop timer(seq nr k); * Start an auxiliary timer and enable the ack timeout event. * void start ack timer(void); * Stop the auxiliary timer and disable the ack timeout event. * void stop ack timer(void); * Allow the network layer to cause a network layer ready event. * void enable network layer(void); * Forbid the network layer from causing a network layer ready event. * void disable network layer(void); * Macro inc is expanded in-line: Increment k circularly. * #define inc(k) if (k < MAX SEQ) k = k + 1; else k = Fig. 3-8. Some definitions needed in the protocols to follow.

* Protocol 1 (utopia) provides for data transmission in one direction only, from sender to receiver. The communication channel is assumed to be error free, and the receiver is assumed to be able to process all the input infinitely fast. Consequently, the sender just sits in a loop pumping data out onto the line as fast as it can. * typedef enum {frame arrival event type; #include "protocol.h" void sender1(void) { frame s; * buffer for an outbound frame * packet buffer; * buffer for an outbound packet * while (true) { from network layer(&buffer); * go get something to send * s.info = buffer; * copy it into s for transmission * to physical layer(&s); * send it on its way * * Tomorrow, and tomorrow, and tomorrow, Creeps in this petty pace from day to day To the last syllable of recorded time - Macbeth, V, v * void receiver1(void) { frame r; event type event; * filled in by wait, but not used here * while (true) { wait for event(&event); * only possibility is frame arrival * from physical layer(&r); * go get the inbound frame * to network layer(&r.info); * pass the data to the network layer * Fig. 3-9. An unrestricted simplex protocol.

* Protocol 2 (stop-and-wait) also provides for a one-directional flow of data from sender to receiver. The communication channel is once again assumed to be error free, as in protocol 1. However, this time, the receiver has only a finite buffer capacity and a finite processing speed, so the protocol must explicitly prevent the sender from flooding the receiver with data faster than it can be handled. * typedef enum {frame arrival event type; #include "protocol.h" void sender2(void) { frame s; * buffer for an outbound frame * packet buffer; * buffer for an outbound packet * event type event; * frame arrival is the only possibility * while (true) { from network layer(&buffer); * go get something to send * s.info = buffer; * copy it into s for transmission * to physical layer(&s); * bye bye little frame * wait for event(&event); * do not proceed until given the go ahead * void receiver2(void) { frame r, s; * buffers for frames * event type event; * frame arrival is the only possibility * while (true) { wait for event(&event); * only possibility is frame arrival * from physical layer(&r); * go get the inbound frame * to network layer(&r.info); * pass the data to the network layer * to physical layer(&s); * send a dummy frame to awaken sender * Fig. 3-1. A simplex stop-and-wait protocol.

* Protocol 3 (par) allows unidirectional data flow over an unreliable channel. * #define MAX SEQ 1 * must be 1 for protocol 3 * typedef enum {frame arrival, cksum err, timeout event type; #include "protocol.h" void sender3(void) { seq nr next frame to send; * seq number of next outgoing frame * frame s; * scratch variable * packet buffer; * buffer for an outbound packet * event type event; next frame to send = ; * initialize outbound sequence numbers * from network layer(&buffer); * fetch first packet * while (true) { s.info = buffer; * construct a frame for transmission * s.seq = next frame to send; * insert sequence number in frame * to physical layer(&s); * send it on its way * start timer(s.seq); * if (answer takes too long, time out * wait for event(&event); * frame arrival, cksum err, timeout * if (event == frame arrival) { from physical layer(&s); * get the acknowledgement * if (s.ack == next frame to send) { from network layer(&buffer); * get the next one to send * inc(next frame to send); * invert next frame to send * void receiver3(void) { seq nr frame expected; frame r, s; event type event; frame expected = ; while (true) { wait for event(&event); * possibilities: frame arrival, cksum err * if (event == frame arrival) { * a valid frame has arrived. * from physical layer(&r); * go get the newly arrived frame * if (r.seq == frame expected) { * this is what we have been waiting for. * to network layer(&r.info); * pass the data to the network layer * inc(frame expected); * next time expect the other sequence nr * s.ack = 1 frame expected; * tell which frame is being acked * to physical layer(&s); * none of the fields are used * Fig. 3-11. A positive acknowledgementretransmission protocol.

Sender 7 7 7 7 6 1 6 1 6 1 6 1 5 2 5 2 5 2 5 2 4 3 4 3 4 3 4 3 Receiver 7 7 7 7 6 1 6 1 6 1 6 1 5 2 5 2 5 2 5 2 4 3 4 3 4 3 4 3 (a) (b) (c) (d) Fig. 3-12. A sliding window of size 1, with a 3-bit sequence number. (a) Initially. (b) After the first frame has been sent. (c) After the first frame has been received. (d) After the first acknowledgement has been received.

* Protocol 4 (sliding window) is bidirectional and is more robust than protocol 3. * #define MAX SEQ 1 * must be 1 for protocol 4 * typedef enum {frame arrival, cksum err, timeout event type; #include "protocol.h" void protocol4 (void) { seq nr next frame to send; * or 1 only * seq nr frame expected; * or 1 only * frame r, s; * scratch variables * packet buffer; * current packet being sent * event type event; next frame to send = ; * next frame on the outbound stream * frame expected = ; * number of frame arriving frame expected * from network layer(&buffer); * fetch a packet from the network layer * s.info = buffer; * prepare to send the initial frame * s.seq = next frame to send; * insert sequence number into frame * s.ack = 1 frame expected; * piggybacked ack * to physical layer(&s); * transmit the frame * start timer(s.seq); * start the timer running * while (true) { wait for event(&event); * frame arrival, cksum err, or timeout * if (event == frame arrival) { * a frame has arrived undamaged. * from physical layer(&r); * go get it * if (r.seq == frame expected) { * Handle inbound frame stream. * to network layer(&r.info); * pass packet to network layer * inc(frame expected); * invert sequence number expected next * if (r.ack == next frame to send) { * handle outbound frame stream. * from network layer(&buffer); * fetch new pkt from network layer * inc(next frame to send); * invert sender s sequence number * s.info = buffer; * construct outbound frame * s.seq = next frame to send; * insert sequence number into it * s.ack = 1 frame expected; * seq number of last received frame * to physical layer(&s); * transmit a frame * start timer(s.seq); * start the timer running * Fig. 3-13. A 1-bit sliding window protocol.

A sends (, 1, A) A gets (,, B)* A sends (1,, A1) A gets (1, 1, B1)* A sends (, 1, A2) A gets (,, B2)* A sends (1,, A3) B gets (, 1, A)* B sends (,, B) B gets (1,, A1)* B sends (1, 1, B1) B gets (, 1, A2)* B sends (,, B2) B gets (1,, A3)* B sends (1, 1, B3) A sends (, 1, A) A gets (, 1, B)* A sends (,, A) A gets (,, B) A sends (1,, A1) A gets (1,, B1)* A sends (1, 1, A1) B sends (, 1, B) B gets (, 1, A)* B sends (,, B) B gets (,, A) B sends (1,, B1) B gets (1,, A1)* B sends (1, 1, B1) B gets (1, 1, A1) B sends (, 1, B2) (a) Time (b) Fig. 3-14. Two scenarios for protocol 4. The notation is (seq, ack, packet number). An asterisk indicates where a network layer accepts a packet.

Timeout interval 1 2 3 4 5 6 7 8 2 3 4 5 6 7 8 9 1 Ack Ack 1 Ack 2 Ack 3 Ack 4 Ack 5 Ack 6 Ack 7 1 E D D D D D D 2 3 4 5 6 7 8 Error Frames discarded by data link layer Time (a) Timeout interval 1 2 3 4 5 6 7 8 2 9 1 11 12 13 14 Ack Ack 1 Ack 1 Ack 1 Ack 1 Ack 1 Ack 1 Ack 1 Ack 8 Ack 9 Ack 1 1 E 3 4 5 6 7 8 2 9 1 11 12 Error Buffered by data link layer Packets 2-8 passed to network layer (b) Fig. 3-15. (a) Effect of an error when the receiver window size is 1. (b) Effect of an error when the receiver windowsize is large.

* Protocol 5 (pipelining) allows multiple outstanding frames. The sender may transmit up to MAX SEQ frames without waiting for an ack. In addition, unlike the previous protocols, the network layer is not assumed to have a new packet all the time. Instead, the network layer causes a network layer ready event when there is a packet to send. * #define MAX SEQ 7 * should be 2ˆn 1 * typedef enum {frame arrival, cksum err, timeout, network layer ready event type; #include "protocol.h" static boolean between(seq nr a, seq nr b, seq nr c) { * Return true if (a <=b < c circularly; false otherwise. * if (((a <= b) && (b < c)) ((c < a) && (a <= b)) ((b < c) && (c < a))) return(true); else return(false); static void send data(seq nr frame nr, seq nr frame expected, packet buffer[]) { * Construct and send a data frame. * frame s; * scratch variable * s.info = buffer[frame nr]; * insert packet into frame * s.seq = frame nr; * insert sequence number into frame * s.ack = (frame expected + MAX SEQ) % (MAX SEQ + 1); * piggyback ack * to physical layer(&s); * transmit the frame * start timer(frame nr); * start the timer running * void protocol5(void) { seq nr next frame to send; * MAX SEQ > 1; used for outbound stream * seq nr ack expected; * oldest frame as yet unacknowledged * seq nr frame expected; * next frame expected on inbound stream * frame r; * scratch variable * packet buffer[max SEQ + 1]; * buffers for the outbound stream * seq nr nbuffered; * # output buffers currently in use * seq nr i; * used to index into the buffer array * event type event; enable network layer(); * allow network layer ready events * ack expected = ; * next ack expected inbound * next frame to send = ; * next frame going out * frame expected = ; * number of frame expected inbound * nbuffered = ; * initially no packets are buffered *

while (true) { wait for event(&event); * four possibilities: see event type above * switch(event) { case network layer ready: * the network layer has a packet to send * * Accept, save, and transmit a new frame. * from network layer(&buffer[next frame to send]); * fetch new packet * nbuffered = nbuffered + 1; * expand the sender s window * send data(next frame to send, frame expected, buffer); * transmit the frame * inc(next frame to send); * advance sender s upper window edge * break; case frame arrival: * a data or control frame has arrived * from physical layer(&r); * get incoming frame from physical layer * if (r.seq == frame expected) { * Frames are accepted only in order. * to network layer(&r.info); * pass packet to network layer * inc(frame expected); * advance lower edge of receiver s window * * Ack n implies n 1, n 2, etc. Check for this. * while (between(ack expected, r.ack, next frame to send)) { * Handle piggybacked ack. * nbuffered = nbuffered 1; * one frame fewer buffered * stop timer(ack expected); * frame arrived intact; stop timer * inc(ack expected); * contract sender s window * break; case cksum err: break; * just ignore bad frames * case timeout: * trouble; retransmit all outstanding frames * next frame to send = ack expected; * start retransmitting here * for (i = 1; i <= nbuffered; i++) { send data(next frame to send, frame expected, buffer); * resend 1 frame * inc(next frame to send); * prepare to send the next one * if (nbuffered < MAX SEQ) enable network layer(); else disable network layer(); Fig. 3-16. A sliding window protocol using go back n.

Real time 1::. 1::.5 5 1 8 2 6 3 8 2 6 3 Pointer to next timeout Frame being timed Ticks to go (a) (b) Fig. 3-17. Simulation of multiple timers in software.

* Protocol 6 (nonsequential receive) accepts frames out of order, but passes packets to the network layer in order. Associated with each outstanding frame is a timer. When the timer goes off, only that frame is retransmitted, not all the outstanding frames, as in protocol 5. * #define MAX SEQ 7 * should be 2ˆn 1 * #define NR BUFS ((MAX SEQ + 1)2) typedef enum {frame arrival, cksum err, timeout, network layer ready, ack timeout event type; #include "protocol.h" boolean no nak = true; * no nak has been sent yet * seq nr oldest frame = MAX SEQ + 1; * initial value is only for the simulator * static boolean between(seq nr a, seq nr b, seq nr c) { * Same as between in protocol5, but shorter and more obscure. * return ((a <= b) && (b < c)) ((c < a) && (a <= b)) ((b < c) && (c < a)); static void send frame(frame kind fk, seq nr frame nr, seq nr frame expected, packet buffer[]) { * Construct and send a data, ack, or nak frame. * frame s; * scratch variable * s.kind = fk; * kind == data, ack, or nak * if (fk == data) s.info = buffer[frame nr % NR BUFS]; s.seq = frame nr; * only meaningful for data frames * s.ack = (frame expected + MAX SEQ) % (MAX SEQ + 1); if (fk == nak) no nak = false; * one nak per frame, please * to physical layer(&s); * transmit the frame * if (fk == data) start timer(frame nr % NR BUFS); stop ack timer(); * no need for separate ack frame * void protocol6(void) { seq nr ack expected; * lower edge of sender s window * seq nr next frame to send; * upper edge of sender s window + 1 * seq nr frame expected; * lower edge of receiver s window * seq nr too far; * upper edge of receiver s window + 1 * int i; * index into buffer pool * frame r; * scratch variable * packet out buf[nr BUFS]; * buffers for the outbound stream * packet in buf[nr BUFS]; * buffers for the inbound stream * boolean arrived[nr BUFS]; * inbound bit map * seq nr nbuffered; * how many output buffers currently used * event type event; enable network layer(); * initialize * ack expected = ; * next ack expected on the inbound stream * next frame to send = ; * number of next outgoing frame * frame expected = ; too far = NR BUFS; nbuffered = ; * initially no packets are buffered * for (i = ; i < NR BUFS; i++) arrived[i] = false;

while (true) { wait for event(&event); * five possibilities: see event type above * switch(event) { case network layer ready: * accept, save, and transmit a new frame * nbuffered = nbuffered + 1; * expand the window * from network layer(&out buf[next frame to send % NR BUFS]); * fetch new packet * send frame(data, next frame to send, frame expected, out buf); * transmit the frame * inc(next frame to send); * advance upper window edge * break; case frame arrival: * a data or control frame has arrived * from physical layer(&r); * fetch incoming frame from physical layer * if (r.kind == data) { * An undamaged frame has arrived. * if ((r.seq!= frame expected) && no nak) send frame(nak,, frame expected, out buf); else start ack timer(); if (between(frame expected, r.seq, too far) && (arrived[r.seq%nr BUFS] == false)) { * Frames may be accepted in any order. * arrived[r.seq % NR BUFS] = true; * mark buffer as full * in buf[r.seq % NR BUFS] = r.info; * insert data into buffer * while (arrived[frame expected % NR BUFS]) { * Pass frames and advance window. * to network layer(&in buf[frame expected % NR BUFS]); no nak = true; arrived[frame expected % NR BUFS] = false; inc(frame expected); * advance lower edge of receiver s window * inc(too far); * advance upper edge of receiver s window * start ack timer(); * to see if a separate ack is needed * if((r.kind==nak) && between(ack expected,(r.ack+1)%(max SEQ+1),next frame to send)) send frame(data, (r.ack+1) % (MAX SEQ + 1), frame expected, out buf); while (between(ack expected, r.ack, next frame to send)) { nbuffered = nbuffered 1; * handle piggybacked ack * stop timer(ack expected % NR BUFS); * frame arrived intact * inc(ack expected); * advance lower edge of sender s window * break; case cksum err: if (no nak) send frame(nak,, frame expected, out buf); * damaged frame * break; case timeout: send frame(data, oldest frame, frame expected, out buf); * we timed out * break; case ack timeout: send frame(ack,,frame expected, out buf); * ack timer expired; send ack * if (nbuffered < NR BUFS) enable network layer(); else disable network layer();

Fig. 3-18. A sliding window protocol using selective repeat.

Sender 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 1 2 3 4 5 6 7 Receiver 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 1 2 3 4 5 6 7 (a) (b) (c) (d) Fig. 3-19. (a) Initial situation with a window of size seven. (b) After seven frames have been sent and received but not acknowledged. (c) Initial situation with a window size of four. (d) After four frames have been sent and received but not acknowledged.

1 1 7 7 5 1 1 A 4 2 3 1 A 1 1 1 6 8 1 1 1 1 1 8 (a) Transition 1 2 3 4 5 6 7 8 Who runs? R S R S R R S S Frame accepted A 1 A 1 (timeout) (timeout) Frame emitted (frame lost) (b) A 1 A A A 1 To network layer Yes Yes No No Fig. 3-2. (a) State diagram for protocol 3. (b) Transitions.

A 1 A 1 7 7 7 A 1 1 A 5 1 4 + 6 7 2 + 5 2 4 2 4 8 3 1 1 A 1 A 1 1 1 1 1 A 6 8 8 8 1 1 1 1 1 1 1 1 A 1 + 2 3 + 4 (a) ( ), ( 1 A), ( 1 A), (1 1 1 A), (1 1 A), ( 1 ), ( 1 A), (1 1 1 ) (b) Fig. 3-21. (a) State graph for protocol 3 and a full-duplex channel. (b) Sequence of states causing the protocol to fail.

A 1 B 2 Fig. 3-22. A Petri net with two places and two transitions.

C: Seq on the line D: Ack on the line E: Seq 1 on the line Emit 1 C 1 Process Wait for Ack A 2 5 Loss Timeout Reject 8 F Expect 1 Emit 1 3 D Ack 11 Process 1 Wait for Ack 1 B 4 Timeout 6 Loss E 1 9 Reject 1 G Expect 7 Loss Sender's state Channel Receiver's state Fig. 3-23. A Petri net model for protocol 3.

Bits 8 8 8 > 16 8 1 1 1 1 1 1 Address Control Data Checksum 1 1 1 1 1 1 Fig. 3-24. Frame format for bit-oriented protocols.

! Bits (a) 1 3 1 3 Seq PF Next! (b) 1 Type PF Next! (c) 1 1 Type PF Modifier Fig. 3-25. Control field of (a) an information frame, (b) a supervisory frame, (c) an unnumbered frame.

PC User's home Client process using TCPIP Dial-up telephone line Internet provider's office Modems Modem TCPIP connection using SLIP or PPP Router Routing process Fig. 3-26. A home personal computer acting as an Internet host.

Bytes 1 1 1 1 or 2 Variable 2 or 4 1 Flag 111111 Address 11111111 Control 11 Protocol Payload Checksum Flag 111111 Fig. 3-27. The PPP full frame format for unnumbered mode operation.

& ' Carrier detected Both sides ( agree on options Authentication ) successful $ Establish % Authenticate Failed Dead + Failed Network " Terminate # Open & ' Carrier dropped Done NCP * configuration Fig. 3-28. A simplified phase diagram for bringing a line up and down.

,,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,,,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-, Name Direction Description,,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-, Configure-request I R List of proposed options and values,,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-, Configure-ack I R All options are accepted,,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-, Configure-nak I R Some options are not accepted,,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-, Configure-reject I R Some options are not negotiable,,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-, Terminate-request I R Request to shut the line down,,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-, Terminate-ack I R OK, line shut down,,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-, Code-reject I R Unknown request received,,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-, Protocol-reject I R Unknown protocol requested,,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-, Echo-request I R Please send this frame back,,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-, Echo-reply I R Here is the frame back,,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-,-,-,-,-,.,-,-,-,-,-,-,-, Discard-request I R Just discard this frame (for testing) Fig. 3-29. The LCP packet types.

; 5 6 2 7 3 4 9 ; : Bit-by-bit : check Correc 1 t HEC d e tected ; Cell-by-cell : check HUNT Incorrec t HEC de 8 t ected PRESYNCH < α Consecutive incorrect HECs SYNCH = δ Consecutive correct HECs Fig. 3-3. The cell delineation heuristic.