Basic Packet Processing: Algorithms and Data Structures

34
EECB 473 DATA NETWORK ARCHITECTURE AND ELECTRONICS PREPARED BY JEHANA ERMY JAMALUDDIN Basic Packet Processing: Algorithms and Data Structures

description

Basic Packet Processing: Algorithms and Data Structures. EECB 473 Data Network Architecture and Electronics Prepared By Jehana Ermy Jamaluddin. Copying. Used when packet moved from one memory location to another Expensive Must be avoided whenever possible Leave packet in buffer - PowerPoint PPT Presentation

Transcript of Basic Packet Processing: Algorithms and Data Structures

Page 1: Basic Packet Processing: Algorithms and Data Structures

EECB 473DATA NETWORK ARCHITECTURE AND

ELECTRONICS

PREPARED BYJEHANA ERMY JAMALUDDIN

Basic Packet Processing:Algorithms and Data

Structures

Page 2: Basic Packet Processing: Algorithms and Data Structures

Copying

Used when packet moved from one memory location to another

Expensive

Must be avoided whenever possible Leave packet in buffer Pass buffer address among threads/layers

Page 3: Basic Packet Processing: Algorithms and Data Structures

Buffer Allocation

Possibilities Large, fixed buffers Variable-size buffers Linked list of fixed-size blocks

Page 4: Basic Packet Processing: Algorithms and Data Structures

Buffer Addressing

Buffer address must be resolvable in all contextsEasiest implementation: keep buffers in kernel space

Page 5: Basic Packet Processing: Algorithms and Data Structures

Integer Representation

Two standards Little endian (least-significant byte at lowest address) Big endian (most-significant byte at lowest address)

Page 6: Basic Packet Processing: Algorithms and Data Structures

Illustration Of Big And Little Endian Integers

Page 7: Basic Packet Processing: Algorithms and Data Structures

Integer Conversion

Needed when heterogeneous computers communicate

Protocols define network byte orderComputers convert to network byte orderTypical library functions

Page 8: Basic Packet Processing: Algorithms and Data Structures

Examples Of Algorithms ImplementedWith Software-Based Systems

Layer 2 Ethernet bridge

Layer 3 IP forwarding IP fragmentation and reassembly

Layer 4 TCP connection recognition and splicing

Other Hash table lookup

Page 9: Basic Packet Processing: Algorithms and Data Structures

Why Study These Algorithms?

Used between a pair of EthernetsProvides transparent connectionListens in promiscuous modeForwards frames in both directionsUses addresses to filter

Page 10: Basic Packet Processing: Algorithms and Data Structures

Bridge Filtering

Uses source address in frames to identify computers on eachnetwork

Uses destination address to decide whether to forward frame

Page 11: Basic Packet Processing: Algorithms and Data Structures

Bridge Algorithm

Page 12: Basic Packet Processing: Algorithms and Data Structures

Implementation Of Table Lookup

Need high speed (more on this later)Software-based systems typically use hashing

for table lookup

Page 13: Basic Packet Processing: Algorithms and Data Structures

Hashing

Optimizes number of probesWorks well if table not fullPractical technique: double hashing

Page 14: Basic Packet Processing: Algorithms and Data Structures

Hashing Algorithm

Page 15: Basic Packet Processing: Algorithms and Data Structures

Address Lookup

Computer can compare integer in one operation

Network address can be longer than integer (e.g., 48 bits)

Two possibilities Use multiple comparisons per probe Fold address into integer key

Page 16: Basic Packet Processing: Algorithms and Data Structures

Folding

Maps N-bit value into M-bit key, M < NTypical technique: exclusive orPotential problem: two values map to same

keySolution: compare full value when key

matches

Page 17: Basic Packet Processing: Algorithms and Data Structures

IP Forwarding

Used in hosts as well as routersConceptual mapping

(next hop, interface) ¬ f(datagram, routing table)

Table driven

Page 18: Basic Packet Processing: Algorithms and Data Structures

IP Routing Table

One entry per destinationEntry contains

32-bit IP address of destination 32-bit address mask 32-bit next-hop address N-bit interface number

Page 19: Basic Packet Processing: Algorithms and Data Structures

Example IP Routing Table

Values stored in binaryInterface number is for internal use onlyZero mask produces default route

Page 20: Basic Packet Processing: Algorithms and Data Structures

IP Forwarding Algorithm

Page 21: Basic Packet Processing: Algorithms and Data Structures

IP Fragmentation

Needed when datagram larger than network MTU

Divides IP datagram into fragmentsUses FLAGS bits in datagram header

Page 22: Basic Packet Processing: Algorithms and Data Structures

IP Fragmentation Algorithm(Part 1: Initialization)

Page 23: Basic Packet Processing: Algorithms and Data Structures

IP Fragmentation Algorithm(Part 2: Processing)

Page 24: Basic Packet Processing: Algorithms and Data Structures

Reassembly

Complement of fragmentationUses IP SOURCE ADDRESS and

IDENTIFICATION fields in datagram header to group related fragments

Joins fragments to form original datagram

Page 25: Basic Packet Processing: Algorithms and Data Structures

Reassembly Algorithm

Page 26: Basic Packet Processing: Algorithms and Data Structures

Data Structure For Reassembly

Two parts Buffer large enough to hold original datagram Linked list of pieces that have arrived

Page 27: Basic Packet Processing: Algorithms and Data Structures

TCP Connection

Involves a pair of endpointsStarted with SYN segmentTerminated with FIN or RESET segmentIdentified by 4-tuple

( src addr, dest addr, src port, dest port )

Page 28: Basic Packet Processing: Algorithms and Data Structures

TCP Connection Recognition Algorithm(Part 1)

Page 29: Basic Packet Processing: Algorithms and Data Structures

TCP Connection Recognition Algorithm(Part 2)

Page 30: Basic Packet Processing: Algorithms and Data Structures

TCP Splicing

Join two TCP connectionsAllow data to pass between themTo avoid termination overhead translate

segment header fields Acknowledgement number Sequence number

Page 31: Basic Packet Processing: Algorithms and Data Structures

Illustration Of TCP Splicing

Page 32: Basic Packet Processing: Algorithms and Data Structures

TCP Splicing Algorithm(Part 1)

Page 33: Basic Packet Processing: Algorithms and Data Structures

TCP Splicing Algorithm(Part 2)

Page 34: Basic Packet Processing: Algorithms and Data Structures

Summary

Packet processing algorithms include Ethernet bridging IP fragmentation and reassembly IP forwarding TCP splicing

Table lookup important Full match for layer 2 Longest prefix match for layer 3