• Review:

advertisement
• Review:
• Chapter 3: The Data Link Layer
– achieve reliable, efficient communication
between two physically connected machines.
– Example problems to be addressed:
• Errors in the physical layer
• Two machines may have different speeds
– Design issues:
•
•
•
•
services interface to the network layer
how to group bits into frames (framing)
how to deal with errors (error control).
how to deal with speed mismatch (flow control).
• Service interface:
• unreliable connectionless service
• reliable connectionless service
• reliable connection-oriented service
– Advantages of each service type:
– Unreliable connectionless:
» Efficient when error rate is very low,
» Ideal for real time traffic
– acknowledged connectionless:
» Error rate is high, less retries are needed
– acknowledged connection-oriented
» guarantee order, upper level software is simpler
• Framing (break the bit stream into frames)
– Why framing?
• Raw bit stream cannot provide any error detection
capability.
– Bits may change (lightning strikes).
– Bits may get lost (clock drift).
• Cut the raw bit stream into frames -> can then
compute the checksum for the frame.
Misunderstanding of the two parties will result in an
unmatched checksum.
– How to do framing?
–
–
–
–
Character count
Starting and ending characters with character stuffing
starting and ending flags with bit stuffing
physical level code violation.
• Character count.
Frame: Count + frame data
E.g
512345678980123456
Problem: what if a count is altered during
transmission?
• Byte oriented framing.
– Each frame is a sequence of bytes. Use special
characters to signal the start and end of a frame.
– E.g STX: start of text, ETX: end of text.
Frames: STX frame_data ETX STX frame_data ETX.
PROBLEM: WHAT IF frame_data = ETX
Solution:
Byte stuff the character ETX
Introduce another escape character: DLE: data link escape.
Characters that need to be stuffed?
Example: frame data = STX DLE ETX
frame = ???
– Advantage: can recover frames.
– Limitation: ties to a particular character set.
• Bit oriented framing.
– A frame is a sequence of bits, using special bit
patterns to signal the start and end of a frame.
– E.g: special pattern 01111110
Frames: 01111110 frame_data 01111110.
PROBLEM: WHAT IF frame_data = 01111110
Solution:
Bit stuffing: make sure that such bit pattern will not occur in
the frame data --> after 5 1’s add a 0 automatically.
Example: 011111100111110100111110
The sender always adds a 0 after five1’s, the receiver always
deletes the 0 after five 1’s.
Example: frame_data=011111011111111111111110
• Physical layer coding violation.
– Use special symbol (that never occur in the
data) for the frame boundary.
– E.g: Manchester code
1: low to high, 0: high to low.
Frame boundary symbol: high-high or low-low.
• Error control
– How to make sure that each frame is eventually
delivered to the destination (reliable service)?
– Reliability through acknowledgement
• Sender knows that the frame is delivered when it
gets the acknowledgement.
– Sender sends, resends when NACK.
– Receiver sends ACK when the checksum is correct,
NACK when incorrect.
• Problem? What if the whole packet gets lost?
– Solution: timeout.
• Problem?
– Need to do more.
• Flow control
– To avoid swamping the slow receiver.
– Use a feedback mechanism to make sure that
the sender knows the status of the receiver.
• “send me N frames and no more until I tell you to
continue”
Data link layer protocols:
P0 - Nothing
• Sender
– get a packet from the
network layer
– Add frame header,
send the frame to the
physical layer.
• Receiver
– get a frame from the
physical layer
– strip the header
– pass the packet to the
network layer.
P1: Stop and wait (flow control)
Assumption: no lost packets
• Sender
– get a packet from the
network layer
– Add frame header,
send the frame to the
physical layer.
– Wait for ACK
• Receiver
– get a frame from the
physical layer
– strip the header
– pass the packet to the
network layer.
– Send ACK.
P2: stop and wait + timeout +
sequence number (flow control + error control )
• Sender
– get a packet from the
network layer
– Add frame header
(seq), send the frame to
the physical layer.
– Wait for ACK till
timeout
– If timeout, resend the
packet, back to waiting
• Receiver
– get a frame from the
physical layer
– strip the header
– if (seq = expected)
• pass to the network
layer.
• Send ACK
– Else
• send ACK
Stop and Wait in action
Stop and Wait in action
Stop-and-wait operation
sender
receiver
first packet bit transmitted, t = 0
last packet bit transmitted, t = L / R
first packet bit arrives
last packet bit arrives, send ACK
RTT
ACK arrives, send next
packet, t = RTT + L / R
U
sender
=
L/R
RTT + L / R
Performance of Stop-and-Wait
• rdt3.0 works, but performance stinks
• example: 1 Gbps link, 15 ms e-e prop. delay, 1KB packet:
Ttransmit =
U
L (packet length in bits)
8kb/pkt
=
= 8 microsec
R (transmission rate, bps)
10**9 b/sec
=
sender
L/R
RTT + L / R
=
.008
30.008
= 0.00027
microsec
onds
– U sender: utilization – fraction of time sender busy sending
– 1KB pkt every 30 msec -> 33kB/sec thruput over 1 Gbps
link
– network protocol limits use of physical resources!
Download