Computer Network
Outline
• Direct link networks (Ch. 2)
– Encoding
– Framing
– Error detection
– Reliable delivery
Hardware Building Blocks
• Nodes
– Hosts: General-purpose computers
– Switches: Typically special-purpose H/W – Routers
• Links
– Cooper with electronic signaling – Glass fibre with optical signaling
Link
• Cooper Based Media
Link
• Optical Media
– Multimode Fibre 100 Mbps
2Km
Link
• Comparison Of Octical Media
– Single mode
• Lower attenuation (longer distances) • Lower dispersion (higher data rates)
– Multi mode
Link
• Advantages of optical communication
– higher bandwidths
– superior attenuation properties
– immune from electromagnetic interference
– no crosstalk between fibers
Link
• Wireless transmission
– 2.4 GHz radio 11 Mbps 7Km
– Infrared (IR) link 1 Mbps 9 m
Encoding (line coding)
problems with signal transmission
– attenuation: signal power absorbed by medium – dispersion: a discrete signal spreads in space – noise: random background “signals”
Encoding Taxonomy
• Digital data, digital signal
– codes which represent bits – our focus
– many strategies!
• Analog data, digital signal
– sampling to represent voltages
• Digital data, analog signal
– modulation to represent bits
• Analog data, analog signal
Non-Return to Zero (NRZ)
• 0 Æ
low signal; 1 Æ
high signal
NRZ-Inverted (NRZI)
• 1 Æ
make transition; 0 Æ
stay at the current
level
• Addresses clock synchronization problem
for long strings of 1’s
Manchester Encoding
• Each bit contains a transition
– 0
Æ
high-to-low transition
– 1
Æ
low-to-high transition
• Enables effective clock recovery at receiver
Manchester Encoding contd.
• Disadvantage: needs a clock that is twice as
fast as the transmission rate
1 1 0 1 0 1 0 0 1
4B/5B Encoding
• Tries to address inefficiencies in Manchester
• Idea is to insert extra bits in bit stream to break up
long strings of 0’s or 1’s
• Every 4 bits of data are encoded in 5 bit code (see
text for details)
– at most one leading 0 – at most two trailing 0’s
• therefore never more than three consecutive 0’s
• Uses NRZI to put bits on wire
Framing
• Blocks of data (not just sequences of bits)
are exchanged across links --- frames
Character-Based Framing
• Special characters (tags) are used to indicate idle
fill (ASCII SYN), start of text (STX) and end of
text (ETX)
• Used by PPP (point-to-point protocol)
Character-Based Framing contd.
Bit-Oriented Framing
• Each frame begins with a start and end bit
sequence (flag)
– 01111110 = 0160 is the usual flag
• Example: HDLC (high-level data link protocol)
Bit Stuffing
• Sender: inserts a 0 after five consecutive 1s
• Receiver: when it sees five 1s makes
decision based on next two bits
– if next bit 0 (this is a stuffed bit), remove it
– if next bit 1, look at next bit
• if 0 this is end of frame (receiver has seen 01111110)
Framing with Length Fields
• Detecting the end of the frame done by sending
length information (e.g. number of bytes in the
frame) in the header
• Used by DECNET’s DDCMP
Digital transmission over
analog
• modulation to represent bits
– amplitude (AM)
– frequency (FM)
– phase/phase shift
Error Detection
• Bit errors can be introduced in packets
• This problem has been studied for a long time
– Error detection (and correction) codes
– Cyclic redundancy check (CRC) is a common error detection method
• Basic idea of any scheme is to add redundant data
– A primary goal is to send minimal amount of redundant data
Error Detection
• We use error-detecting codes to help detect errors
• Example code: Consider the function that
duplicates each bit in the message
– E.g. the message 1011001 would be mapped to the code
Parity
Parity added to make @ 1s even/odd
0 1 1 1 0 1 0 1 1
If parity is wrong ERROR
If parity is right NO ERROR
Two-Dimensional Parity
Two-Dimensional Parity
Arrows indicate failed check bits
Internet Checksum
• Used by IP, TCP, UDP, ...
• Method
– Break message as a sequence of 16-bit integers
– Add these integers using 16-bit one’s complement arithmetic
– Take the one’s complement of the result – Resulting 16-bit number is the checksum
• It’s simple to implement
Reliable Transmission
• Big Q: How do we send a packet reliably when it
can be lost and/or corrupted in the network?
• Mechanisms
– Acknowledgements – Timeouts
• Simplest reliable protocol: Stop and Wait
– send a packet
Reliable Transmission
• How does the receiver recognize a duplicate
transmission (e.g. in the case of a lost ACK)?
– Solution: Put sequence number in packet
• Performance
– No pipeline effect – Example
• For a l.5 Mbps link with 45 ms RTT
How do we keep the pipe full?
• Send multiple packets without waiting for
the first to be ACKed
• Upper bound on un-ACKed packets, called
window
Sender ReceiverT
Sliding Windows: Sender
• State
– Packets sent and ACKed (LAR = last ACK received) – Packets sent but not ACKed (buffer for SWS packets) – Packets not yet sent (LFS = last packet sent)
• Keep LFS - LAR SWS
≤
≤SWS
LAR LFS
Sliding Windows: Receiver
• State
– Packets received and ACKed (NFE = next frame expected, LFR = last packet received)
– Packets received out of order (buffer for RWS packets) – Packets not yet received (LFA = last frame acceptable)
• Keep LFA - LFR RWS
≤
≤RWS
LFR LFA
What if we lose a packet?
• Selective repeat/ack (SACK)
– Receiver sends ACK for each packet in window – On timeout, sender resends only the missing packet – Proposed for TCP
• Go back N with buffering out-of-order packets
(TCP)
– Receiver ACKs “got up through packet k”
• If multiple packets are received, only one ACK is needed
Traditional Go back N window size 4
Sender Algorithm
• Send full window, set timeout
• On ACK
– If it increases LAR (packets sent and ACKed)
• send remaining packets in window
• On timeout
Receiver Algorithm
• On packet arrival
– If packet is the NFE (next frame expected)
• Send ACK • Increase NFE
• Deliver packet(s) to the upper layer (could fill hole in buffer)
– Else
• Send ACK
How to determine timeouts?
• Problem:
– If timeout too small, useless retransmits
– If timeout too large, low utilization (pipe not full)
• Solution:
– On direct link, timeout 2 x PROP
– Trickier to estimate at transport layer
• RTT varies with congestion, route changes, etc.
Sequence Number Space
• Recall seq # (SeqNum) cannot grow arbitrarily
• SWS
MaxSeqNum - 1 is not sufficient
– Suppose 3-bit SeqNum field (0…7) – SWS = RWS = 7
– sender transmits packets 0..6
– arrive successfully, but ACKs lost – sender retransmits 0..6
– receiver expecting 7, 0..5, but receives the original incarnation of 0..5
• SWS (MaxSeqNum + 1)/2 is correct rule
≤
Sliding Window Summary
• Sliding window is best known algorithm in
networking
• First role is to enable reliable delivery of packets
– Timeouts and acknowledgements
• Second role is to enable in order delivery of
packets
– Receiver doesn’t pass data up to app until it has packets in order