Title: CSE524: Lecture 4
1CSE524 Lecture 4
2Administrative
- Homework 1 due
- Reading assignment due by Mon. 10/8/2001
- Chapter 5 Sections 5.1-5.4
- CSE524 e-mail list
- E-mail TA if you still have not received any
messages from the list
3Last class
- Physical layer
- Copper
- Fiber
- Wireless
4Next layer
- Data-link layer
- Functions
- Specific link layer examples
- Data-link layer devices
5Data-link layer
6Data-link layer
- Two physically connected devices
- host-router, router-router, host-host,
host-switch, host-hub - Implemented on network adapter card
- typically includes RAM, DSP chips, host bus
interface, and link interface
network link physical
data link protocol
frame
phys. link
adapter card
7Data-link layer functions
- Moving datagrams between adjacent nodes
- Digital to analog conversion
- Framing
- Physical addressing
- Demux to upper protocol
- Flow control
- Error detection and correction
- Reliable delivery
- Security
- Media access and quality of service
8Data-link layer examples
- Specific implementations
- Ethernet 802.3
- Token ring 802.5
- WiFi 802.11b
- PPP
- FDDI
- ATM
- SONET/SDH
9Data-link layer devices
- Devices which operate at the data-link layer
level - Hubs
- Bridges
- Switches
10DL Digital to analog conversion
- Bits sent as analog signals
- Photonic pulses of a given wavelength over
optical fiber - Electronic signals of a given voltage
11DL Digital to analog conversion
- Will cover electronic transmission (optical
transmission left for you to research) - When to sample voltage?
- Detecting sequences involves clocking with the
same clock - How to synchronize sender and receiver clocks?
- Need easily detectible event at both ends
- Signal transitions help resync sender and
receiver - Need frequent transitions to prevent clock skew
- http//www.mouse.demon.nl/ckp/telco/encode.htm
12DL RZ
- Return to Zero (RZ)
- 1pulse to high, dropping back to low
- 0no transition
13DL NRZ-L
- Non-Return to Zero Level (NRZ-L)
- 1high signal, 0lower signal
- Long sequence of same bit causes difficulty
- DC bias hard to detect low and high detected by
difference from average voltage - Clock recovery difficult
- Used by Synchronous Optical Network (SONET)
- SONET XORs bit sequence to ensure frequent
transitions - Used in early magnetic tape storage
14DL NRZ-L
15DL NRZ-M
- Non-Return to Zero Mark
- Less power to transmit versus NRZ
- 1signal transition at start of bit, 0no change
- No problem with string of 1s
- NRZ-like problem with string of 0s
- Used in SDLC (Synchronous Data Link Control)
- Used in modern magnetic tape storage
16DL NRZ-S
- Non-Return to Zero Space
- 1no change, 0signal transition at start of bit
- No problem with string of 0s
- NRZ-like problem with string of 1s
17DL Manchester (Bi-Phase-Level) coding
- Used by Ethernet
- 0low to high transition, 1high to low
transition - Transition for every bit simplifies clock
recovery - Not very efficient
- Doubles the number of transitions
- Circuitry must run twice as fast
18DL Manchester coding
Bit stream
1
1
0
1
0
0
Manchester encoding
19DL Other coding schemes
- Bi-Phase-Mark, Bi-Phase-Space
- Level change at every bit period boundary
- Mid-period transition determines bit
- Bi-Phase-M 0no change, 1signal transition
- Bi-Phase-S 0signal transition, 1no change
20DL Other coding schemes
- Differential Bi-Phase-Space, Differential
Bi-Phase-Mark - Level change at every mid-bit period boundary
- Bit period boundary transition determines bit
- Diff-Bi-Phase-M 0signal transition, 1no change
- Diff-Bi-Phase-S 0no change, 1signal transition
21DL Framing
- Data encapsulation for transmission over physical
link - Data embedded within a link-layer frame before
transmission - Data-link header and/or trailer added
- Physical addresses used in frame headers to
identify source and destination (not IP)
22DL Fixed length framing
- Length delimited
- Beginning of frame has length
- Single corrupt length can cause problems
- Must have start of frame character to
resynchronize - Resynchronization can fail if start of frame
character is inside packets as well
23DL Variable length framing
- Byte stuffing
- Special start of frame byte (e.g. 0xFF)
- Special escape byte value (e.g. 0xFE)
- Values actually in text are replaced (e.g. 0xFF
by 0xFEFF and 0xFE by 0xFEFE) - Worst case can double the size of frame
- Bit stuffing
- Special bit sequence (0x01111110)
- 0 bit stuffed after any 11111 sequence
24DL Clock-Based Framing
- Used by SONET
- Fixed size frames (810 bytes)
- Look for start of frame marker that appears every
810 bytes - Will eventually sync up
25DL Physical addressing
- LAN (or MAC or physical) address
- Used to get datagram from one interface to
another physically-connected interface (same
network) - IP address used to route between networks
- 48 bit MAC address (for most LANs) burned in
adapter ROM - ifconfig a
- arp -a
- Address space assigned and managed by IEEE
- Manufacturer buys portion of MAC address space to
ensure uniqueness - Special LAN broadcast address
- FF-FF-FF-FF-FF-FF
26DL Physical addressing
- Why have separate IP and hardware addresses?
- Assign adapters an IP address
- Hardware only works for IP (no IPX, DECNET)
- Must be reconfigured when moved
- Use hardware address as network address
- Need standardized fixed length hardware address
- No route aggregation
27DL Physical addressing
- Analogy
- (a) MAC address like Social Security
Number - (b) IP address like postal address
- MAC flat address gt portability
- can move LAN card from one LAN to another
- IP hierarchical address NOT portable
- depends on network to which one attaches
28DL Demux to upper protocol
- Protocol type specification interfaces to network
layer - Data-link layer can support any number of network
layers - Type field in data-link header specifies network
layer of packet - IP is one of many network layers
- Each data-link layer defines its own protocol
type numbering for network layer
29DL Demux to upper protocol
- http//www.cavebear.com/CaveBear/Ethernet/type.htm
l - Some Ethernet protocol types
- 0800 DOD Internet Protocol (IP)
- 0806 Address Resolution Protocol (ARP)
- 8037 IPX (Novell Netware)
- 80D5 IBM SNA Services
- 809B EtherTalk (AppleTalk over Ethernet)
30DL LAN Addresses and ARP
Each adapter on LAN has unique LAN address
31DL Recall earlier routing discussion
frame source, dest address
datagram source, dest address
As IP addr
Bs IP addr
Bs MAC addr
As MAC addr
IP payload
datagram
frame
32DL ARP Address Resolution Protocol
- Each IP node (Host, Router) on LAN has ARP
module, table - ARP Table IP/MAC address mappings for some LAN
nodes - lt IP address MAC address TTLgt
- lt .. gt
- TTL (Time To Live) time after which address
mapping will be forgotten (typically 20 min)
33DL ARP protocol
- A knows B's IP address, wants to learn physical
address of B - A broadcasts ARP query pkt, containing B's IP
address - all machines on LAN receive ARP query
- B receives ARP packet, replies to A with its
(B's) physical layer address - A caches (saves) IP-to-physical address pairs
until information becomes old (times out) - soft state information that times out (goes
away) unless refreshed
34DL Routing to another LAN
- walkthrough routing from A to B via R
- In routing table at source Host, find router
111.111.111.110 - In ARP table at source, find MAC address
E6-E9-00-17-BB-4B, etc
A
R
B
35- A creates IP packet with source A, destination B
- A uses ARP to get Rs physical layer address for
111.111.111.110 - A creates Ethernet frame with R's physical
address as dest, Ethernet frame contains A-to-B
IP datagram - As data link layer sends Ethernet frame
- Rs data link layer receives Ethernet frame
- R removes IP datagram from Ethernet frame, sees
its destined to B - R uses ARP to get Bs physical layer address
- R creates frame containing A-to-B IP datagram
sends to B
A
R
B
36DL RARP, BOOTP, DHCP
- ARP Given an IP address, return a hardware
address - RARP Given a hardware address, give me the IP
address - DHCP, BOOTP Similar to RARP
- Hosts (host portion)
- hard-coded by system admin in a file
- DHCP Dynamic Host Configuration Protocol
dynamically get address plug-and-play - host broadcasts DHCP discover msg
- DHCP server responds with DHCP offer msg
- host requests IP address DHCP request msg
- DHCP server sends address DHCP ack msg
37DL Flow control
- Pacing between sender and receiver
- Sender prevented from overrunning receiver
- Ready-To-Send, Clear-To-Send
38DL Error detection/correction
- Errors caused by signal attenuation, noise.
- Receiver detects presence of errors
- Possible actions
- Signal sender for retransmission
- Drops frame
- Correct bit errors if possible and continue
39DL Error detection/correction
- EDC Error Detection and Correction bits
(redundancy) - D Data protected by error checking, may
include header fields - Error detection not 100 reliable!
- protocol may miss some errors, but rarely
- larger EDC field yields better detection and
correction
40DL Parity checking
Two Dimensional Bit Parity Detect and correct
single bit errors
Single Bit Parity Detect single bit errors
0
0
41DL Checksums
- Sender
- treat segment contents as sequence of 16-bit
integers - checksum addition (1s complement sum) of
segment contents - simple to implement, weak detection (easily
tricked by common bit error patterns) - used by TCP, UDP, IP..
- sender puts checksum value into header
- Receiver
- compute checksum of received segment
- check if computed checksum equals checksum field
value - NO - error detected
- YES - no error detected. But maybe errors
nonethless? More later .
42DL Cyclic Redundancy Check (CRC)
- Polynomial code
- Treat packet bits a coefficients of n-bit
polynomial - Choose r1 bit generator polynomial (well known
chosen in advance) - Add r bits to packet such that message is
divisible by generator polynomial - Better loss detection properties than checksums
- All single bit errors, all double bit errors, all
odd-numbered errors, burst errors less than r
43DL Cyclic Redundancy Check (CRC)
- Calculate code using modulo 2 division of data
by generator polynomial - Subtraction equivalent to XOR
- Weak definition of magnitude
- X gt Y iff position of highest 1 bit of X is the
same or greater than the highest 1 bit of Y - Record remainder after division and send after
data - Result divisible by generator polynomial
44DL Cyclic Redundancy Check (CRC)
45DL CRC example
- Data
- 101110
- Generator Polynomial
- x3 1 (1001)
- Send
- 101110011
46DL CRC example
- Data
- 10000
- Generator Polynomial
- x2 1 (101)
- Send
- 1000001
G
10101
101 1000000 101 010
000 100 101
010 000 100
101 01
D
R
47DL Cyclic Redundancy Check (CRC)
- CRC-16 implementation
- Shift register and XOR gates
48DL CRC polynomials
- CRC-16 x16 x15 x2 1 (used in HDLC)
- CRC-CCITT x16 x12 x5 1
- CRC-32 x32 x26 x23 x22 x16 x12 x11
x10 x8 x7 x5 x4 x2 x 1 (used in
Ethernet)
49DL Forward error correction
- FEC
- Use error correcting codes to repair losses
- Add redundant information which allows receiver
to correct bit errors - Suggest looking at information and coding theory
work.
50DL Reliable delivery
- Reliability at the link layer
- Handled in a similar manner to transport
protocols - When and why should this be used?
- Rarely done over twisted-pair or fiber optic
links - Usually done over lossy links for performance
improvement (versus correctness)
51DL ARQ
- Automatic Repeat Request (ARQ)
- Receiver sends acknowledgement (ACK) when it
receives packet - Sender waits for ACK and timeouts if it does not
arrive within some time period
52DL Stop and Wait
Sender
Receiver
Time
Timeout
53DL Recovering from Error
Timeout
Timeout
Timeout
Time
Packet
Timeout
Timeout
Timeout
Early timeout
ACK lost
Packet lost
54DL Stop and Wait Problems
- How to recognize a duplicate?
- Performance
- Can only send one packet per round trip
55DL How to Recognize Resends?
- Use sequence numbers
- both packets and acks
- Sequence in packet is finite -- how big should
it be? - For stop and wait?
- One bit wont send seq 1 until received ACK
for seq 0
Pkt 0
Pkt 1
56DL How to Keep the Pipe Full?
- Send multiple packets without waiting for first
to be acked - Number of pkts in flight window
- How large a window is needed
- Round trip delay bandwidth capacity of pipe
- Reliable, unordered delivery
- Several parallel stop waits
- Send new packet after each ack
- Sender keeps list of unacked packets resends
after timeout - Receiver same as stopwait
57DL Sliding Window
- Reliable, ordered delivery
- Receiver has to hold onto a packet until all
prior packets have arrived - Sender must prevent buffer overflow at receiver
- Circular buffer at sender and receiver
- Packets in transit lt buffer size
- Advance when sender and receiver agree packets at
beginning have been received
58DL Sender/Receiver State
Max acceptable
Next expected
Max ACK received
Next seqnum
Receiver window
Sender window
Sent Acked
Sent Not Acked
Received Acked
Acceptable Packet
OK to Send
Not Usable
Not Usable
59DL Window Sliding Common Case
- On reception of new ACK (i.e. ACK for something
that was not acked earlier - Increase sequence of max ACK received
- Send next packet
- On reception of new in-order data packet (next
expected) - Hand packet to application
- Send cumulative ACK acknowledges reception of
all packets up to sequence number - Increase sequence of max acceptable packet
60DL Loss Recovery
- On reception of out-of-order packet
- Send nothing (wait for source to timeout)
- Cumulative ACK (helps source identify loss)
- Timeout (Go Back N recovery)
- Set timer upon transmission of packet
- Retransmit max ACK received sequence 1
- Restart from max ACK received sequence 1
- Performance during loss recovery
- No longer have an entire window in transit
- Can have much more clever loss recovery
- Covered in TCP lectures
61DL Sequence Numbers
- How large do sequence numbers need to be?
- Must be able to detect wrap-around
- Depends on sender/receiver window size
- E.g.
- Max seq 7, send winrecv win7
- If pkts 0..6 are sent succesfully and all acks
lost - Receiver expects 7,0..5, sender retransmits old
0..6 - Max sequence must be gt send window recv window
62DL Security
- Mainly for broadcast data-link layers
- Encrypt payload of higher layers
- Hide IP source/destination from eavesdroppers
- Important for wireless LANs especially
- Parking lot attacks
- 802.11b and WEP
- If time permits, security will be covered at the
end of the course.