Download presentation
Presentation is loading. Please wait.
Published byMark Snow Modified over 9 years ago
1
CS 453 Computer Networks Lecture 9 Layer 2 – Data Link Layer
2
Data Link Protocols The Data Link Layer is responsible for moving frames of bit, moving frames of bit, via the physical layer, via the physical layer, across the communications medium across the communications medium to a destination machine to a destination machine …not a bit siphon,… these frames of bit don’t just leak across the physical layer and communications medium We need a procedure or protocol to make this happen
3
Data Link Protocols In order to explore the issue of data link protocols we need to make some assumptions (Some of which we will abandon later)
4
Data Link Protocols Assumptions Data link layer services the physical layer and the network layer Data link layer services the physical layer and the network layer Although the implementation of the data link layer can vary – sometimes in hardware, sometimes as a software process, we will consider the physical layer, data link layer and the network layer as three independent processes Although the implementation of the data link layer can vary – sometimes in hardware, sometimes as a software process, we will consider the physical layer, data link layer and the network layer as three independent processes Computer A wants to send data to computer B (unidirectional) Computer A wants to send data to computer B (unidirectional) Computer A has a ready supply of data to send Computer A has a ready supply of data to send
5
Data Link Protocols Assumptions Computers A and B do not crash Computers A and B do not crash So we don’t have to deal with crash recovery Frame transmitted from DLL (Data Link Layer) to DLL is considered pure data to the DLL (excluding its own control information) Frame transmitted from DLL (Data Link Layer) to DLL is considered pure data to the DLL (excluding its own control information) DLL on the sending computer DLL on the sending computer receives a packet from the Network Layer Adds DLL headers/trailer to it Hands it off the physical layer
6
Data Link Protocols Assumptions DLL on the receiving computer DLL on the receiving computer receives a frame from the physical layer Extracts a packet (payload) from the DLL frame Hands the packet off the physical layer Network layer never sees a frame – only packet Network layer never sees a frame – only packet Data (frames) at DLL level is clean Data (frames) at DLL level is clean We have a suitable set of procedures (functions) to implement the protocol We have a suitable set of procedures (functions) to implement the protocol
7
Data Link Protocols To implement a very simple simplex DLL protocol Lets look at some definitions (in C) Lets look at some definitions (in C)
8
Data Link Protocols Basic Definitions From: Tanenbaum (2003) pg. 203
9
Data Link Protocols Basic Definitions From: Tanenbaum (2003) pg. 203 MAX_PKT 1024 – packet size typedef enum (false, true) boolean; define a boolean data type typedef unsigned int seq_nr – frame sequence number typedef struct{unsigned char data[MAX_PKT];} packet; - define packet as char array typedef enum {data, ack, nak} frame_kind - define a type to classify the type of frame
10
Data Link Protocols Basic Procedure Definitions From: Tanenbaum (2003) pg. 203
11
Data Link Protocols Basic Procedure Definitions From: Tanenbaum (2003) pg. 203 wait_for_event(event_type *event) – wait for a network event and return the type of event in event from_network_layer(packet *p) – take a packet from the network layer to_network_layer(packet *p) – send a packet to the network layer from_physical_layer(frame *r) – take a frame from the physical layer, return as r to_physical_layer(frame *s) – send the frame s to the physical layer for transmission
12
Data Link Protocols Basic Procedure Definitions From: Tanenbaum (2003) pg. 203 start_timer(seq_nr k) – start timer – look for timeout stop_timer(seq_nr k) – stop timer and disable timeout start_ack_timer(void) – start aux timer, enable ack timeouts stop_ack_timer(void) – stop aux timer, disable ack timeouts enable_network_layer(void) – enable the interface to the network layer disable_network_layer(void) – disable the interface to the network layer #define inc(k) if (k<MAX_SEQ) k=k+1; else k=0 -- macro to increment a sequence counter modulo(MAX_SEQ)
13
Data Link Protocols Simple Simplex DLL Protocol General Logic- receiver - receiver - goes into wait state until a frame_arrival event (only event possible in this simple protocol) On frame_arrival event receiver fetches frame from the physical layer passes packet (frame less frame control header/trailer, etc.) to network layer returns to wait state
14
Data Link Protocols Simple Simplex DLL Protocol General Logic- sender – sender – fetches a packet from the network layer stores it in frame buffer where it is wrapped with frame header/trailer to make it a frame passes it to the physical layer for transmission returns to first step
15
Data Link Protocols Simple Simplex DLL Protocol From: Tanenbaum (2003) pg. 203
16
Data Link Protocols Simple Simplex DLL Protocol Things to note: network layers on both machines always ready network layers on both machines always ready No error or lost data between DLLs on the two machines No error or lost data between DLLs on the two machines No acknowledgements – no sequence numbers No acknowledgements – no sequence numbers No error control – no flow control No error control – no flow control
17
Data Link Protocol Lets get rid of the assumption that the receiver can process frames to packet and move them to the network layer as fast as the sender can send them.. Not realistic – results in data overruns, lost data We need some form of flow control Clock or rate synchronization possible but not good Us a control frame
18
Data Link Protocol Simplex with Flow Control from: Tanenbaum (2003) pg. 207
19
Data Link Protocol Simplex with Flow Control Sender – fetches a packet fetches a packet places the packet in a frame places the packet in a frame sends the frame to the physical layer for transmission sends the frame to the physical layer for transmission then, waits for a control frame from the receiver saying it it OK to send another frame then, waits for a control frame from the receiver saying it it OK to send another frame Receiver – listens for frame arrival event, when it happens listens for frame arrival event, when it happens fetches frame from the physical layer fetches frame from the physical layer extracts packet from frame and send to network layer, and when completed… extracts packet from frame and send to network layer, and when completed… sends control frame to sender to say it is ok to send another frame sends control frame to sender to say it is ok to send another frame from: Tanenbaum (2003) pg. 207
20
Data Link Protocol Simplex with Flow Control and Error Control from: Tanenbaum (2003) pg. 207
21
Data Link Protocol Simplex with Flow and Error Control Sender – 1. fetches a packet 2. places the packet in a frame 3. sends the frame to the physical layer for transmission 4. Starts a time-out timer 5. then, waits for a reply frame 6. If the wait event was a frame_arrival, fetch frame from physical layer 7. Check packet in frame for “all clear” acknowledgement, 8. If “all clear” turn off time-out timer Fetch next packet from network layer Increment frame sequence number 9. Go to step 2 from: Tanenbaum (2003) pg. 207
22
Data Link Protocol Simplex with Flow Control and Error Control from: Tanenbaum (2003) pg. 207
23
Data Link Protocol Simplex with Flow and Error Control Receiver – Defines expected frame sequence number Defines expected frame sequence number Enters wait state for event Enters wait state for event If event is frame_arrival If event is frame_arrival Fetch frame from physical layer If frame sequence number is what is expected Extract packet from frame and send to network layer Extract packet from frame and send to network layer Increment expected frame counter Increment expected frame counter Create acknowledgement frame Send acknowledgement frame to physical layer – and therefore, back to sender from: Tanenbaum (2003) pg. 207
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.