Lecture 4: Framing
Total Page:16
File Type:pdf, Size:1020Kb
Lecture 4: Framing" CSE 123: Computer Networks Alex C. Snoeren Proj 1 out Today, due 11/01! TCP/IP Protocol Stack" host host HTTP Application Layer HTTP TCP Transport Layer TCP router router IP IP Network Layer IP IP Ethernet Ethernet SONET SONET Ethernet Ethernet interface interface interfaceLink Layerinterface interface interface CSE 123 – Lecture 4: Framing" 2 (Data) Link Layer" # Framing ◆# Break stream of bits up into discrete chunks # Error handling ◆# Detect and/or correct errors in received frames # Media access ◆# Arbitrate which nodes can send frames at any point in time ◆# Not always necessary; e.g. point-to-point duplex links # Multiplexing ◆# Determine appropriate destination for a given frame ◆# Also not always required; again, point-to-point CSE 123 – Lecture 4: Framing" 3 Today’s Focus: Framing" # Break down a stream of bits into smaller, digestible chunks called frames # Allows the physical media to be shared ◆# Multiple senders and/or receivers can time multiplex the link ◆# Each frame can be separately addressed # Provides manageable unit for error handling ◆# Easy to determine whether something went wrong ◆# And perhaps even to fix it if desired CSE 123 – Lecture 4: Framing" 4 What’s a Frame?" Header Payload Trailer # Wraps payload up with some additional information ◆# Header usually contains addressing information ◆# Maybe includes a trailer (w/checksum—next lecture) # Basic unit of reception ◆# Link either delivers entire frame payload, or none of it ◆# Typically some maximum transmission unit (MTU) # Some link layers require absence of frames as well ◆# I.e., minimum gaps between frames CSE 123 – Lecture 4: Framing" 5 Identifying Frames" # First task is to delineate frames ◆# Receiver needs to know when a frame starts and ends # Several different alternatives ◆# Fixed length (bits) frames ◆# Fixed duration (seconds) frames ◆# Explicit delimiters indicate start and/or end of each frame »# Alternatively, just start and a length field # Misidentifying frame start and end leads to errors ◆# Topic for next lecture… CSE 123 – Lecture 4: Framing" 6 Fixed-Length Frames" # Easy to manage for receiver ◆# Well understood buffering requirements # Introduces inefficiencies for variable length payloads ◆# May waste space (padding) for small payloads ◆# Larger payloads need to be fragmented across many frames # Requires explicit design tradeoff ◆# ATM uses 53-byte frames (cells) ◆# Why 53? 48 + 5. Why 48? Average of 32 and 64. CSE 123 – Lecture 4: Framing" 7 Length-Based Framing" Start Length Payload # To avoid overhead, we’d like variable length frames ◆# Each frame declares how long it is ◆# E.g. DECNet DDCMP # Why not explicitly include a length field? ◆# Must correctly read the length field »# Need to decode while receiving ◆# Still need to identify the beginning… CSE 123 – Lecture 4: Framing" 8 Flags/Sentinels" # Allows for variable frame lengths # Start (and end) each frame with a special indicator ◆# Could be a special byte/bit patter in header/trailer ◆# Unique (non-data) physical-layer symbol # Reserving physical layer symbols reduces efficiency ◆# Can’t use that symbol to transmit data! # But using bits/bytes in data stream is problematic ◆# What if sentinel happens to appear in the data? CSE 123 – Lecture 4: Framing" 9 Stuffing" # Insert bytes/bits into data stream to make sure that sentinel (flag) does not appear in payload CSE 123 – Lecture 4: Framing" 10 Bit Stuffing" # Avoid sentinel bit pattern in payload data ◆# Commonly, sentinel is bit pattern 01111110 (0x7E) ◆# Invented for SDLC/HDLC, now standard pattern # Any time five ones appear in outgoing data, sender inserts a zero, resulting in 01111101 Stuffed bits 011111100001110111011111011111001 011111010000111011101111100111110001 # Any time receiver sees five ones, it removes next zero ◆# If there is no zero, there will either be six ones (flag) or ◆# It declares an error condition! ◆# Note bit pattern that cannot appear is 01111111 (0x7F) CSE 123 – Lecture 4: Framing" 11 Bit Stuffing Overhead" # We’re adding extra non-data bits to the stream ◆# Not using full capacity of physical layer n # Suppose we use flag 01 0 (zero followed by n 1s) ◆# We need to stuff anytime we get (n-1) 1s n ◆# Assuming uniform bit distribution, happens L/2 times in frame of length L # Tradeoff in flag length ◆# Long packets want long flags (less likely to stuff) ◆# Short packets want short flags (always need to add flag) 6 ◆# Overhead for n=6, long packet: L + L/2 + higher order terms = L + L/64 = 1.015L; 1/1.015 = approximately 98.5% efficient # Real problem is bit stream is now variable length! CSE 123 – Lecture 4: Framing" 12 Byte Stuffing" # Same as bit stuffing, except at byte (character) level ◆# Generally have two different flags, STX and ETX ◆# Found in PPP, DDCMP, BISYNC, etc. # Need to stuff if either appears in the payload ◆# Have another special character, DLE (data-link escape) ◆# New problem: what if DLE appears? # Stuff DLE with DLE! ◆# Could be as bad as 50% efficient to send all DLEs STX HEADER Payload ETX 0x48 ETX 0x69 0x48 DLE ETX 0x69 CSE 123 – Lecture 4: Framing" 13 Consistent-Overhead BS" # Control expansion of payload size due to stuffing ◆# Important for low-bandwidth links or fixed-size buffers # Idea is to use 0x00 as flag, and replace all zeros with distance to next 0x00. ◆# Break frame up into runs without zeros, encode by pre- pending each run with length ◆# Pretend frame ends in 0x00. Max run is 254; if no zeros pre- pend with 255 (0xFF) 45 00 00 2c 4c 79 00 00 40 06 4f 37 02 45 01 04 2c 4c 79 01 05 40 06 4f 37 “Linked list of zeros” CSE 123 – Lecture 4: Framing" 14 Clock-Based Framing" # So far, we’ve based framing on what’s on the wire ◆# Any bit errors may throw off our framing ◆# What happens with missed flag? Spurious flag? # An alternative is to base framing on external clock ◆# Kind of like Phy-layer signaling: sample at specific intervals ◆# This is what SONET does, among others # Significant engineering tradeoffs ◆# No extra bits needed in the data stream itself, but… ◆# Need tight clock synchronization between sender and receiver CSE 123 – Lecture 4: Framing" 15 SONET" # Synchronous Optical NETwork ◆# Engineering goal to reduce delay and buffering # All frames take same amount of time ◆# Independent of bit rate! # Each frame starts with signal bits ◆# Can synch clock just like PLL—look for periodic signal bits ◆# No need to stuff; signal pattern is unlikely, so won’t be periodic in data # Keep sync within frames with transitions ◆# Encoded using NRZ, but ◆# Data is XORed with special 127-bit pattern ◆# Creates lots of transitions, makes signal pattern unlikely CSE 123 – Lecture 4: Framing" 16 SONET Frame" # Every STS frame is 125 us long # Supports multiple bit rates in same network # STS-1 is base (slowest) speed: 51.84 Mbps ◆# Frame contains 9 rows of 90 bytes each (810 bytes) ◆# First 3 bytes of each row are header »# 2-byte sync patter, one byte for “flags” Overhead Payload … … … … 9 rows … 90 bytes CSE 123 – Lecture 4: Framing" 17 Multiplexed SONET Links" # SONET actually defines networking functionality ◆# Conflates layers; we’ll talk more in future lectures ◆# Thinks about how to move frames between links # Higher-speed links are multiples of STS-1 frames ◆# E.g., STS-3 is three times as fast as STS-1 # Frames are byte-wise interleaved ◆# Ensures pace of embedded STS-1 frames remains same A FH STS-1 B FH STS-1 FH A B C A STS-3 C FH STS-1 CSE 123 – Lecture 4: Framing" 18 SONET Networks" # STS-n can send n independent frames ◆# Effectively n parallel links sharing same physical media # Alternatively, can concatenate into one jumbo frame ◆# STS-nc: one link whose bandwidth is n times STS-1 # Each SONET frame takes same time to arrive; Why? not too difficult to synchronize clocks such that first byte of all incoming flows arrives just before sending first 3 bytes of outgoing flow CSE 123 – Lecture 4: Framing" 19 SONET Challenge" ... but now try to synchronize this network’s clocks CSE 123 – Lecture 4: Framing" 20 Floating Payload (SPE)" # Reduce synchronization overhead ◆# Start synchronization payload envelope anywhere CSE 123 – Lecture 4: Framing" 21 When Things Go Wrong" # Clock drift may confuse frame boundaries ◆# Read the end of one frame and beginning of the next # What happens if there are bit errors on channel? ◆# We might misinterpret flags as data or vice versa ◆# What will the frames look like? # In general, need some way to make sure we’re OK ◆# Error detection (and perhaps correction) topic for next time CSE 123 – Lecture 4: Framing" 22 Summary" # Data Link Layer provides four basic services ◆# Framing, multiplexing, error handling, and MAC # Framing determines when payload starts/stops ◆# Lots of different ways to do it, various efficiencies # Sentinel-based framing requires stuffing ◆# Increases the size of the packet ◆# Alternatives include fixed size frames # SONET uses timing-based framing ◆# Gets complicated when trying to switch links CSE 123 – Lecture 4: Framing" 23 For Next (Fri 10/11) Class" # Read 2.4 # Keep going on Homework 1 # Get started on Project 1 ◆# Discussion section TODAY at 3pm # No class Mon/Wed of next week CSE 123 – Lecture 4: Framing" 24 .