Communications Protocol Engineering 中華大學資工系 嚴力行 1 Protocol Hierarchies • Most networks are organized as a series of layers or levels. – Each layer offers certain services to the higher layers • Protocol – an agreement between the communicating parties on how communication is to proceed. – Layer n protocol 2 Peers and Interfaces • Peers – The entities comprising the corresponding layers on different machines • Interface – between each pair of adjacent layers – defines which primitive operations and services the lower layer offers to the upper one. 3 Entities and Peer Entities • An entity – an active element in a layer – can be a software entity (a process), a hardware entity (an I/O chip), or both (an I/O chip with its driver). • Peer entities – entities in the same layer on different machines 4 Protocol Stacks • A protocol stack. – A list of protocols used by a certain system, one protocol per layer • Network architecture – A set of layers and protocols 5 Layers at An Interface SAP = Service Access Point IDU = Interface Data Unit SDU = Service Data Unit PDU = Protocol Data Unit ICI = Interface Control Information IDU Layer N+1 ICI SDU SAP Interface Layer N ICI SDU SDU N-PDU Layer N entities exchange N-PDUs in their layer N protocol Header 6 Service Primitives • Request Layer N+1 Layer N+1 1 3 – layer n+1 to layer n • Indication – layer n to layer n+1 – signal an event 4 Layer N 2 Layer N • Response – layer n+1 to layer n – respond to the previous indication • Confirm – layer n to layer n+1 – confirm the previous request 1. CONNECT.request 2. CONNECT.indication 3. CONNECT.response 4. CONNECT.confirm 7 Reference Models • The OSI Reference Model – based on a proposal developed by the International Standards Organization (ISO) – a first step toward international standardization of the protocols used in the various layers. • The TCP/IP Reference Model 8 The OSI Reference Model 7 Application 6 Presentation 5 Session 4 Transport Application Protocol Presentation Protocol Application APDU Presentation PPDU Session Protocol Transport Protocol Session SPDU Transport TPDU Network Packet Frame 3 Network Internal Subnet Protocol Network Network 2 Data Link Data Link Data Link Data Link 1 Physical Physical Physical Physical Layer Host A Router Router Host B Bit 9 The Physical Layer • Functions – Concerned with transmission of unstructured bit stream over physical medium – Deals with the mechanical, electrical, functional, and procedural characteristics to access the physical medium • Examples – – – – – baud rate simplex/half duplex/full duplex parallel/serial error detection (odd/even parity) synchronization/asynchronization 10 The Data Link Layer • Main task – to take a raw transmission facility and transform it into a line that appears free of transmission errors to the network layer • The sender – breaks the input data up into data frames – transmits the frames sequentially – processes the acknowledgement frames sent back by the receiver 11 Issues of the Data Link Layer • error handling: solve the problem caused by damaged, lost and duplicate frames • flow control: keep a fast transmitter from drowning a slower receiver in data • piggybacking: attach data with ack. information • medium access control (MAC) – a sublayer that controls access to the shared channel in broadcast network 12 The Network Layer • determine how packets are routed from source to destination (routing) • congestion control • accounting function • to allow heterogeneous networks to be interconnected – address conversion – packet conversion • In broadcast networks – the network layer is often thin or even nonexistent 13 The Transport Layer • Functions – Provides reliable, transparent transfer of data between end-points – Provides end-to-end error recovery and flow control • Tasks – – – – – error control flow control multiplexing fragmentation/reassembly quality of service 14 The Session Layer • Functions – Provides the control structure for communication between applications – Establishes, manages, and terminates connections (sessions) between cooperating applications • Examples – dialogue control (simplex/half-duplex/full-duplex) – synchronization (checkpoint) – token management 15 The Presentation Layer • Functions – Provides independence to the application processes from differences in data representation (syntax) • Examples – data encoding (character string, integer, floating-point number) – data conversion (Big-5/IBM 5550/ET/Telecom, ASCII/EBCDIC) – data encryption – data compression/expansion 16 The Application Layer • Functions – Provides access to the OSI environment for users and also provides distributed information services • Examples – virtual terminal • deals with different terminal types, screen layouts, escape sequences for inserting and deleting text, etc. – file transfer: naming, line feed, ... – electronic mail 17 The TCP/IP Reference Model 7 6 5 4 3 2 1 Application Application Presentation Not present in the model Session Transport Transport Network Internet Data Link Physical Host-tonetwork OSI TCP/IP 18 Protocol Stack Performance • Depends on structure and environment • Structure – partitioning of functionality between user and kernel – separation of layer processing (interface) • Environment (cost of O.S. functions) – – – – – data copy cost interrupt overhead context switch time latency in accessing memory cache effects 19 Partitioning Strategies • How much to put in user space, and how much in kernel space? tradeoff between • software engineering • customizability • security • performance • Monolithic in kernel space • Monolithic in user space • Per-process in user space 20 Monolithic in Kernel Application Application User Kernel Session • Place all but the application layer in kernel • Great security Transport • Potentially the best performance Network Device Driver • expensive implementation cost Device 21 Monolithic in User Space Session Application • Secure Application • reasonable protocol implementation cost Transport Network Device Driver User Kernel Proxy Device • Poor performance – every read or write accesses requires 2 context switches A trusted user-level server process 22 Per-process in User Space • Implement stack as a library linked to an application • high performance • low cost 23 Interface Strategies • Single-context – protocol layers share a single uninterrupted thread of execution • Tasks – write each layer as a task • Upcalls – associated a thread per packet 24 Single context A whole 25 Tasks Task: a procedure called from task scheduler with a pointer to a data buffer containing a packet 26 Upcalls 27 Implement a Single Layer Entry points to a protocol layer 28