Chp. 2, Part I - comp

Download Report

Transcript Chp. 2, Part I - comp

Chapter 2:
Direct Link Networks
(Part One)
Dr. Rocky K. C. Chang
30 January 2004
1
0. Summary of the last lecture
• Classification of computer networks
• Four basic requirements for designing a
computer network
• Network architectures
• Network programming
2
1. Overview of this chapter
• The lowest two layers:
Provide a virtual link for (unreliable) packets to above
Datalink layer
Datalink layer
Provide a virtual (unreliable) bit pipe to above
Physical layer
Physical layer
3
1. Overview of this lecture
• Direct link networks: point-to-point links or
shared media
• Five problems:
–
–
–
–
–
Bit synchronization
Frame synchronization
Error detection
Reliable link service
Multiple access control problem (for shared media
only)
4
2. Some networking hardware
• Network nodes
– Switches and routers (highly specialized hardware)
– Hosts (general-purpose computers):
CPU
Network
adaptor
Cache
Memory
(To network)
I/O bus
5
2.1 Network hosts
• Network adaptors and device drivers
– All the networking functionality described in this
chapter, except ARQ schemes, is implemented in
the network adaptor.
– The device driver interfaces between the network
adaptor and the OS.
• Unparalleled performance improvement of
memory latency and processor speed
– A network host runs at memory speeds, not
processor speeds.
• Take a look at a posted message titled “Solving the
Memory Wall Workshop” in the discussion forum.
6
2.2 Network links
• A network link is a physical medium carrying
signals in the form of electromagnetic waves.
• Cabling:
– Local links (office, lab, campus): Twisted pairs,
coaxial cables, and optical fibers
– Leased links from carriers: T1, T3; and OC-N,
where N = 1, 3, 9, 12, 18, 24, ….
– Links to residential home: POTS, ISDN, xDSL,
CATV, ATM, etc.
– Wireless: radio, microwave, infrared, light; small
area, cellular network, satellite network.
7
2.2 Network links
• Generally, a packet may go through different
types of network link.
– The slowest link determines the end-to-end
throughput.
• Bandwidth
– Narrowband vs. broadband (ISDN vs. B-ISDN)
– Increase bandwidth either by operating in a higher
frequency band or increase the signal-to-noise ratio
– Upper bound on the link’s data rate: Blog2(1+S/N)
8
2.2 Network links
f (Hz) 100
102
104
106
Radio
4
10
5
10
6
10
7
10
108
1010
Microw ave
8
10
9
10
1012
1014
Inf rared
10
10
10
1016
1018
UV
11
1020
1022
X ray
12
10
Satellite
10
13
1024
Gamma ray
14
10
10
15
16
10
Fiber optics
Coax
AM
FM
Terrestrial microw ave
TV
• Bluetooth is based on a global radio-frequency
(RF) standard, operating on the 2.4 GHz ISM
band.
• 3G mobile phone: 2,500MHz-2,690MHz band9
2.2 Network links
• Sending binary bits onto a physical link (bitserial transmission):
– Encoding the bits before transmission
• for the purpose of bit synchronization to be discussed
later)
– Modulation: a process by which a property or a
parameter (frequency, amplitude, phase) of a signal
is varied in proportion to a second signal.
• For encoding binary data onto electromagnetic signals
– Signals are carried in the form of electromagnetic
waves.
10
3. The five problems
• Assume modulation schemes given.
• Five problems:
– Bit synchronization (need additional encoding data,
such as from Manchester encoding, to delineate bits)
– Frame synchronization (need additional protocols to
delineate frames)
– Error detection (need additional algorithms to detect
errors, if occurred)
– Reliable link service (need additional schemes to
recover from errors)
– Multiple access control problem (for shared media
only; need additional protocols to share the medium)
11
3.1 An Ethernet network adaptor
H
O
S
T
B
U
S
LAN controller
System
bus
interface
TX
FIFO
RX
FIFO
TX
802.3
MAC
Transceiver N
E
Data out
Medium T
Physical
W
attachData in
signalling
O
Control in ment unit
R
K
Manchester codec
RX
12
4. Problem 1: Bit synchronization (BS)
• Problem: How does a receiver synchronize with
a sender, so that bits can be decoded correctly
from the signals?
Signalling component
Signal
Node
Adaptor
Adaptor
Node
Bits
13
4.1 BS: four encoding methods
• Assume that two discrete signals: high and low
are used to encode 0s and 1s.
• Solutions: NRZ, NRZI, Manchester, and
4B/5B:
Bits
0
0
1
0
1
1
1
1
0
1
0
0
0
0
1
0
NRZ
Clock
Manchester
NRZI
14
4.2 BS: NRZ and NRZI
• Non-return to zero (NRZ)
– 0: a low signal; 1: a high signal
– Problem: A consecutive of 0s or 1s causes baseline
wander, as well as not providing enough signal
transitions for bit synchronization.
• Non-return to zero inverted (NRZI)
– 1: making a transition from the current signal;
0: staying at the current signal.
– Problem: The problem of having consecutive 0s
remains.
15
4.3 BS: Manchester encoding
• Manchester encoding
– 0: low-to-high transition; 1: high-to-low transition
(the result of exclusive-OR of the NRZ-encoded
data with the clock)
– Advantage: provide enough signal transitions for bit
synchronization.
– Disadvantage: double the rate of signal transitions.
– Baud rate is the rate at which the signal changes. In
this case, baud rate is double of data rate.
16
4.4 BS: 4B/5B encoding
• 4B/5B encoding
– Insert a bit to every four bits of data, such that
consecutive 0s or 1s will be broken up.
– (breaking up consecutive 0s) Each code must have
no more than one leading 0 and no more than two
trailing 0s.
• E.g., 00110 and 01000 are not used.
• As a result, the encoded data would not contain more
than 3 consecutive 0s.
• See Table 2.5 in the text for the encoding.
– (breaking up consecutive 1s) The resulting 5-bits
are transmitted using the NRZI encoding.
17
4.4 BS: 4B/5B encoding
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Data
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
5-bit codes
11110
01001
10100
10101
01010
01011
01110
01111
10010
10011
10110
10111
11010
11011
11100
11101
18
5. Problem 2: Frame synchronization (FS)
• Problem: Given that a receiver can synchronize
bits sent by a sender, how does the receiver
recognize bits belonging to the same frame?
Signalling component
Signal
Node
Adaptor
Adaptor
Node
Bits
Frames
19
5.1 FS: IP over Ethernet
• For example, when an IP datagram is handed
down to an Ethernet network adaptor, the IP
datagram is sent out in an Ethernet frame.
Dest
address
Src
Type
address
Type
0800
Data
CRC
IP datagram
20
5.2 Several solutions
• Byte-oriented protocols (e.g. PPP)
– Data unit in terms of bytes (ASCII, EBCDIC)
– Sentinel approach vs. byte counting approach
• Bit-oriented protocols (e.g. HDLC, Ethernet)
– Sentinel approach
• Clock-based framing (SONET)
– It addresses both the framing and encoding
problems.
21
5.3 Byte-oriented protocols
• Sentinel approach to framing
– A special character 01111110 (0x7e) serves as a
start-of-text character (flag field)
– Character stuffing: escape this special character in
the data by prepending it with an escape character
0x7d.
• 0x7e escaped to 0x7d, 0x5e
• 0x7d escaped to 0x7d, 0x5d
22
5.3 Byte-oriented protocols
• PPP’s frame structure:
Flag Addr Control
Protocol
7E FF
03
Protocol
0021
Information
CRC
Flag
7E
IP datagram
23
5.3 Byte-oriented protocols
• Byte-counting approach to framing, e.g.
DECNET’s DDCMP
8
8
8
14
42
SYN
SYN
Class
– SYN character serves as a synchronization
character.
– The COUNT field specifies how many bytes are
contained in the frame.
Count
Header
16
Body
CRC
24
5.4 Bit-oriented protocols
• For example, High-Level Data Link Control
(HDLC) protocol.
– A special bit sequence 01111110 is transmitted
when the link is idle.
– When this sequence appears in the data, it is
escaped using bit stuffing.
8
16
Beginning
sequence
Header
16
Body
8
Ending
CRC sequence
25
5.4 Bit-oriented protocols: bit stuffing
• On sending side:
– Except for transmitting the special 01111110
sequence, 0 is inserted after 5 consecutive 1s.
• On receiving side:
– If five consecutive 1s arrive,
• if the next bit is 0, it must be a stuffed bit. It is therefore
removed.
• If the next bit is 1,
– If the next bit is 0, then the sequence indicates the end of the
frame.
– If the next bit is 1, there must be an error, and the whole frame is
discarded.
26
5.4 Bit-oriented protocols: bit stuffing
• For example,
– Original bit stream:
•011011111111111111110010
– After bit stuffing by source:
•011011111011111011111010010
– After bit de-stuffing by receiver:
•011011111111111111110010
• What happens if transmission errors
– occurred to the stuffed bits?
– occurred to the nonstuffed bits?
27
6. Problem 3: Error detection (ED)
• Transmission errors do occur, with different
probabilities in different media.
• Two general approaches:
– Error correction code (forward error correction)
– Error detection code + an error correction
mechanism when errors are detected.
– Insert redundancy for error correction or detection.
• Common error detection methods:
– Cyclic redundancy check (CRC)
– Checksum
28
6.1 ED: error detection codes
• Error detection codes are usually inserted in
more than one layer, e.g.
–
–
–
–
HTTP
TCP (16-bit checksum for the TCP header and data)
IPv4 (16-bit checksum for the IP header)
PPP/Ethernet (CRC-16, CRC-32 for the whole
frame)
• Why don’t we just have CRCs on the datalink
layer?
29
6.2 ED: two-dimensional parity
• The 2-dim parity catches all 1-, 2-, and 3-bit
errors, and most 4-bit errors.
Parity
bits
Data
Parity
byte
0101001
1
1101001
0
1011110
1
0001110
1
0110100
1
1011111
0
1111011
0
30
6.3 ED: Checksum
• Add up all the words that are transmitted and
then transmit the result of that sum.
– If any transmitted data, including the checksum
itself, is corrupted, then the results will not match.
• Internet checksum:
– A sender add 16-bit words using ones complement
arithmetic, and then take ones complement of the
result. The result is stored in the checksum field.
– A receiver performs 16-bit checksum. If no error,
the checksum should give all 1s.
31
6.3 ED: Checksum
• Ones complement arithmetic:
– A negative integer -x is represented as the
complement of x.
– A carryout from the most significant bit needs to be
added to the result.
• For example: 4-bit word checksum
– Data: 1010 1100, and its checksum: 1000.
– Data sent: 1010 1100 1000
– Receiver adds all the data sent in 4-bit word in ones
complement, which gives 1111.
32
6.3 ED: Checksum
• Advantages:
– Use a relatively small number of bits.
– Easy to implement in software.
• Disadvantages:
– Not a strong error detection algorithm, as compared
with CRC
33
6.4 ED: cyclic redundancy check (CRC)
• Think of an (n+1)-bit message, M(x), as a
polynomial of degree n, e.g.
– 10011010 as
– 1x7 + 0x6 + 0x5 + 1x4 + 1x3 + 0x2 + 1x1 +
0x0.
• Given a divisor polynomial of order k, C(x),
find a code word of k bits, such that M(x)
concatenated with the code word is divisible by
C(x).
– P(x) is a concatenation of M(x) and the code word.
34
6.4 ED: cyclic redundancy check
• For example, C(x) = 1x3 + 1x2 + 0x1 + 1x0.
– The computed code word is 101.
– P(x) is given by 10011010 concatenated with 101,
or 1x10 + 0x9 + 0x8 + 1x7 + 1x6 + 0x5 + 1x4
+ 0x3 + 1x2 + 0x1 + 1x0.
– One may verify that P(x) is divisible by C(x), i.e. 0
remainder.
– Errors can be detected when the remainder is not
zero when a receiver divides P(x) by C(x).
35
6.4 ED: cyclic redundancy check
• To obtain the code word,
– Divide 1x10 + 0x9 + 0x8 + 1x7 + 1x6 + 0x5 +
1x4 + 0x3 + 0x2 + 0x1 + 0x0
by 1x3 + 1x2 + 0x1 + 1x0 .
– Subtraction is performed by an exclusive-OR
operation (XOR).
– The result is a 3-bit remainder, one bit less than the
divisor polynomial.
– It can be implemented efficiently in hardware.
36
6.4 ED: cyclic redundancy check
Generator
11111001
1101 10011010000
1101
Message
1001
1101
1000
1101
1011
1101
1100
1101
1000
1101
101
Remainder
37
6.4 ED: cyclic redundancy check
• Choice of the divisor polynomial:
– Express a corrupted message received by a receiver
as P(x) + E(x), where E(x) is an error polynomial.
– Errors go undetected if E(x) is divisible by C(x).
• For example, the CRC can catch
– all single-bit errors if the xk and x0 terms in C(x)
have nonzero coefficients, and
– any odd number of errors if C(x) contains the factor
(x+1).
• Refer to p.102 of the text for common C(x)s.
– CRC-8/10/12/16/32
38