No Slide Title

Download Report

Transcript No Slide Title

CSIS 625 Week 6
Data Link Layer
Copyright 2001, 2002 - Dan Oelke
For use by students of CSIS 625 for purposes of this class only.
CSIS 625
1
Overview
• Data Link Layer
– Line Discipline
– Flow Control
– Error Control
• Byte Oriented Link Control
• Bit Oriented Link Control
– HDLC
• MAC Protocols
– Wireless
– Ethernet
CSIS 625
2
Line Discipline
• Line Discipline defines who can send and
when they can send.
• Simplex system
– Who is always known
– When is usually any time
• In a duplex system, the sender should send
only when it knows that the receiver is
ready.
– This is in theory, but in practice it only
sometimes works this way
CSIS 625
3
Line Discipline
• Three phases of communication
– Establishment of communication
• Determines who is sending to whom
– Data transfer
• Moving the data
– Termination
• Tying up loose ends
CSIS 625
4
ENQ/ACK system
• Process
• Sender sends a ENQ (Enquiry) to the intended
receiver.
• Receiver sends back an ACK (Acknowledgement)
when it is ready to receive
• Sender sends data
• Sender sends EOT (End of Transmission) when
done sending.
• Receiver may send a NAK (Negative
Acknowledgement) if it isn’t ready.
• Used in point to point systems
CSIS 625
5
ENQ/ACK system
• Common to have one node a primary and
another a secondary
– Primary is responsible for initiating
communication
• Some systems have nodes as peers
– Either can initiate a transfer
• In full-duplex system, data and control
messages can be sent simultaneously
CSIS 625
6
Poll & Select system
• Always has a primary and secondary nodes
• Process - Poll
– Primary node requests data from the secondary
– If no data, secondary responds with a NAK
– Otherwise secondary responds with the data
• Process - Select
– Primary node selects a secondary node and
sends data to it
– Secondary responds with ACK after successful
transfer of data
CSIS 625
7
Network Addresses
– In a multi-point system, addresses needed so
that nodes know who is talking to who
– Simple in some systems where physical
position or dip-switch sets it.
– Ethernet defines that all manufactures of
devices include a unique 48-bit (6-byte) address
in every device.
– Polling 2^48 devices isn’t practical
• at 10Mbps, with a 60 byte poll it would take
– 2^24 / 10Mbps * 60 * 8 bytes = 1.35E+10 seconds
– or about 428 years
CSIS 625
8
Media Access Control
• MAC - Media access Control
• A multipoint network with no clear master
and slave.
– master == primary
– slave == secondary
• In this system, there needs to be more
complicated protocol than ENQ/ACK or
select/poll to figure out who sends when
• See later on in this lecture….
CSIS 625
9
Flow Control
• Flow control - a protocol to ensure that the
sender does not overwhelm a receiving
station
• Incoming data must be checked and
processed before it can be used
– This is often slower than the transmission rate
– Receivers need to buffer received data until it is
processed
– Buffers are always limited
CSIS 625
10
Flow Control - Stop-n-Wait
• Stop and Wait flow control is simplest form
of flow control
• Process
– Sender sends one frame of data
– Sender waits for ACK before sending more
– Receiver can slow down process by waiting to
send ACK
• May be simple - but it is inefficient
CSIS 625
11
Stop-n-Wait efficiency
– Entire set of data is divided into n frames
– tprop = time to go from sender to receiver
• depends on distance and medium
– tframe = time to send one data frame
• depends on bit rate and frame size
–
–
–
–
–
CSIS 625
TD = n(2 tprop + tframe) = Time to send data
Actual transmission of data is n* tframe
Efficiency is (n* tframe )/ n(2 tprop + tframe)
= 1 / (1 +2(tprop / tframe))
If tprop is small and tframefor frame is large, it
approaches 100%, but never reaches it.
12
Sliding Window Protocol
• Sliding Window flow control allows for
more than one frame to be sent before an
acknowledgement is received
• frames are numbered from 0 to n-1
• Sender sends frames up until it has sent n-1
frames
• Receiver sends back an ACK with the
number of the next frame it expects
• Sender can now send up to this new number
•CSISMaximum
window size is n-1 frames
625
13
Figure 10-14
CSIS 625
WCB/McGraw-Hill
Sliding Window Example
14
 The McGraw-Hill Companies, Inc., 1998
Sliding Window Efficiency
• If the sliding window is big enough, and the
receiver is fast enough, then 100%
efficiency can be achieved
• To get 100% – 2 * tprop  ((n - 1) * tframe )
– tprop = Time for a frame to propagate from one
end to the other of the system
– tframe = Time to send a frame (based on frame
size and bit rate)
CSIS 625
15
Error Control
• Error detection and retransmission
• Error detection is achieved using parity,
checksums, CRC, etc
– Extra data added to each frame
• ARQ - Automatic Repeat Request
– This abbreviation isn’t really used much
CSIS 625
16
Stop-n-Wait Error Control
• Extension of Stop-n-Wait flow control
– When a good frame is received, an ACK sent
back to originator.
– When a damaged frame is received, a NAK is
sent back to originator
– When a NAK is received, the same frame is
retransmitted
CSIS 625
17
Stop-n-Wait Error Control
• Any frame may be dropped - data or NAK
or ACK.
– If ACK isn’t received after some time, a NAK
is assumed
– If a NAK is lost - timeout and retransmission
– If a ACK is lost timeout and retransmission
• Frames must be numbered so receiver can throw
away duplicates
– If data is lost - timeout and retransmission
• Has same efficiency issues
CSIS 625
18
Go-back-N Error Control
• Uses a Sliding window
• If a NAK is received or an ACK timeout
occurs
– all data since last ACK received is resent
– This may be several frames
• ACKs contain next expected frame number
• NAKs contain errored frame number
CSIS 625
19
Selective-Reject Error Control
• Uses a Sliding window
– If a NAK is received, only the damaged frame
is resent
• Selective Reject is more complicated to
implement
– Receiver must contain the sorting logic to enable it to reorder
frames
– Sending device must contain searching mechanism to enable it to
find and select only the requested frame for retransmission
– Buffer in the receiver must keep all previously received frames on
hold until all retransmissions have been sorted, duplicates
identified and discarded
– ACK numbers must refer to the frame received instead of next
CSIS 625 frame expected
20
Selective-Reject Error Control
• More efficient as it resends less data
– If errors don’t occur very often - there isn’t a
big difference in efficiency
• Selective Reject is rarely implemented over
Go-back-N method
CSIS 625
21
Byte Oriented Link Control
• List here is all from Modem communications
world
– Normally people don’t address these as link layer
controls
• Not just data-link as most of these protocols
addressed issues of file-transfer
• XMODEM
– Stop-n-Wait error control
– Fixed data field of 128 bytes, CRC-8
• YMODEM
– increased data field to 1024 bytes, CRC-16
CSIS 625
22
Byte Oriented Link Control
• ZMODEM
– More features
– Sliding window
• Kermit
– sliding window
– Also a terminal emulation package
• BSC - Binary synchronous communication
– No-one cares about this one
CSIS 625
23
Bit Oriented Link Control
• Many bit Oriented protocols today are
oriented around HDLC
• Ethernet, Token-Ring and other LAN
technologies are also bit-oriented
• SONET, T1, and most telephony systems
are bit-oriented.
• It is common to use HDLC over a SONET
or T1 system
CSIS 625
24
HDLC node types
• Primary station
– Has complete control over the link
– Can be used in point-to-point or multi-link
• Secondary station
– Receives commands from the primary and
responds accordingly
• Combined station
– Can both command and respond to commands
– Used in peer to peer (or balanced)
configurations
CSIS 625
25
HDLC Configurations
• Unbalanced
– One primary node and one or more secondary
nodes
– May be point-to-point or multi-point
– Full or half-duplex
• Balanced
– point-to-point topology only
– Both nodes are combined stations
CSIS 625
26
HDLC Modes of Communication
• NRM - Normal Response mode
– Standard Primary-secondary relationship
– Secondary can transmit only when polled
• ARM - Asynchronous Response Mode
– A secondary may initiate a transmission without
permission from the primary
• ABM - Asynchronous Balanced Mode
– Combined stations - either can initiate
– Point-to-point topology
CSIS 625
27
HDLC Frame structure
• Frame of data consists of:
–
–
–
–
–
–
CSIS 625
Flag: 8 bits
Address: 1 or more bytes
Control: 8 or 16 bits
Information: many bits
Frame Check Sequence (FCS): 16 or 32 bits
Flag: 8 bits
28
HDLC Flag byte
• The flag is a special bit pattern that signifies
the start/end of a frame.
• A single flag byte may be used to end one
frame and start another
• Flag bit pattern is 0111 1110
• Bit stuffing is used to make sure this pattern
does not occur any where else.
• Bit stuffing occurs on all bytes (control or
data) that are not flag bytes
CSIS 625
29
HDLC Address field
• First seven bits are used for address
• Last bit - if a 1 then there are no more
address bytes
• Last bit - if a 0 then there is another address
byte
• Last bit of last address byte is always a 1
• Number of address bits is a multiple of 7
CSIS 625
30
HDLC Control Field
• One or two byte segment for flow
management
• Control fields change based on type of
frame
• If first bit is 0
– frame is an I-Frame
• If first bit is 1 and second 0
– frame is an S-Frame
• If first bit is 1 and second 1
– frame is a U-Frame
CSIS 625
31
HDLC Control Field
• I-Frame - Information Frame
– 3 bits for send sequence number
– 3 bits for receive sequence number (ACKs)
– 1-bit - Poll/Final bit
• From secondary - set to 1 if last I-frame of response
• From primary - set to 1 if polling secondary for data
• S-Frame - Supervisory Frame
–
–
–
–
CSIS 625
3 bits for receive sequence number
2 bits for “supervisory” functions
1 bit - Poll/final bit
S-Frames used for ACK when no data
32
HDLC Control Field
• U-Frame - Unnumbered frame
– 1 bit- Poll/Final bit
– 5 bits - “Unnumbered function” bits
• S-frames can be used for:
•
•
•
•
CSIS 625
reject
selective rejects
receiver ready
receiver not ready
33
HDLC Control Field
• U-frames can be used for
•
•
•
•
•
•
CSIS 625
Mode setting (primary/secondary)
unnumbered information transfer
recovery - bad commands, etc
initialization
disconnect
test command/response
34
HDLC - Information field
• The information field is a series of bits until
the next flag byte is found
• S-Frame has no information field
• The last 16 or 32 bits of the Information
field is actually the FCS
• FCS - Frame check sequence
– a 16 or 32-bit CRC on the data
CSIS 625
35
MAC - Media Access Control
• When there are multiple nodes that can all
transmit on a given link, a means of
controlling them is necessary
• The MAC layer is a sub-layer of data link
layer in these situations.
• The Logical Link Control (LLC) Layer is
the other sub-layer
• MAC is the lower sub-layer, LLC is the
upper sub-layer
CSIS 625
36
MAC assumptions
1 - Station Model
• There are N independent stations (aka nodes) that
generates frames of data for transmission
2 - Single Communications Channel
3 - Collision detection
• All stations can detect collisions
4 - Time frame
• Continuous time - any frames starts at any time
• Slotted time - Time divides into discrete slots
5 - Carrier sense (or not)
• The nodes can detect if the channel is busy
CSIS 625
37
ALOHA protocol
• Ground based radio broadcasting
• Developed at University of Hawaii
• Pure ALOHA
– Any node starts transmitting at any time
– Receiving node detects if a collision occurs
• Same if partially or completely clobbered
– If data not properly received, the transmitter
waits a random amount of time and resends.
CSIS 625
38
ALOHA Protocol
• Slotted ALOHA
– A special node emits a “pip” at the start of each
interval.
– All frames start at the beginning of an interval
• Both Pure ALOHA and Slotted ALOHA
have a point at which adding more traffic
results in worse throughput
– The collisions keep piling up and causing more
and more collisions
– Slotted ALOHA will take about 2x as much
load as Pure ALOHA
CSIS 625
39
Carrier Sense Multiple Access (CSMA)
Protocols
• Nodes listen to see if someone else is
transmitting before they send their packet.
– Better performance than ALOHA
• 1-Persistent CSMA
– Transmitter waits until the the line is idle and
sends immediately
• Nonpersistent CSMA
– Transmitter waits random time time if the line
isn’t idle
– Leads to better utilization AND longer delays
CSIS 625
40
CSMA Protocols continued
• p-Persistent CSMA
– Uses slotted channels - If slot is idle there is a
probability of p that transmitter will use the
channel.
CSIS 625
41
CSMA/CD - Carrier Sense Multiple
Access with Collision Detection
• Extend the idea so that if two nodes detect a
collision they stop transmitting immediately
• Quickly terminating the transmission saves
time and bandwidth
• To detect collision, need to transmit for 2x
the maximum propagation time.
– Time for signal to transmit from one end to the
other
– PLUS Time for colliding signal to transmit
from far end back
CSIS 625
42
Wireless Protocols
• Typically nodes are all trying to talk with a
central (wired) hub
• Sometimes (but not always) the nodes can
“hear” one another
• Hidden station problem
– When one node can’t hear another and tromps
on transmission to a third node
• Exposed station problem
– When one node hears another node and so
won’t transmit to a third, even through it could.
CSIS 625
43
Wireless Protocols and CSMA
• CSMA tells the transmitter if there is
activity near, but you want to know if there
is activity by the receiver.
• MACA - Multiple Access with Collision
Avoidance.
• MACAW - MACA with refinements
• CSMA/CA - another name for MACA like
system
– Carrier Sense Multiple Access with Collision
Avoidance
CSIS 625
44
Wireless Protocols continuted
• MACAW basics - A sending to B
– A sends B an RTS (Request to Send) frame
with length
– B sends A a CTS (Clear to Send) frame with
length
– A sends B the data frame
– Other nodes that hear CTS know to be quiet for
that time period (based on length)
CSIS 625
45
Further reference
• http://www.techfest.com/networking/index.
htm
CSIS 625
46