VII Protocol Software On A Conventional Processor NSD-Agere -- Chapt. 7 1 2004 Possible Implementations Of Protocol Software In an application program (cid:0) – Easy to program – Runs as user-level process – No direct access to network devices – High cost to copy data from kernel address space – Cannot run at wire speed NSD-Agere -- Chapt. 7 2 2004 Possible Implementations Of Protocol Software (continued) In an embedded system (cid:0) – Special-purpose hardware device – Dedicated to specific task – Ideal for stand-alone system – Software has full control NSD-Agere -- Chapt. 7 3 2004 Possible Implementations Of Protocol Software (continued) In an embedded system (cid:0) – Special-purpose hardware device – Dedicated to specific task – Ideal for stand-alone system – Software has full control – You will experience this in lab! NSD-Agere -- Chapt. 7 3 2004 Possible Implementations Of Protocol Software (continued) In an operating system kernel (cid:0) – More difficult to program than application – Runs with kernel privilege – Direct access to network devices NSD-Agere -- Chapt. 7 4 2004 Interface To The Network Known as Application Program Interface (API) (cid:0) Can be (cid:0) – Asynchronous – Synchronous Synchronous interface can use (cid:0) – Blocking – Polling NSD-Agere -- Chapt. 7 5 2004 Asynchronous API Also known as event-driven (cid:0) Programmer (cid:0) – Writes set of functions – Specifies which function to invoke for each event type Programmer has no control over function invocation (cid:0) Functions keep state in shared memory (cid:0) Difficult to program (cid:0) Example: function f() called when packet arrives (cid:0) NSD-Agere -- Chapt. 7 6 2004 Synchronous API Using Blocking Programmer (cid:0) – Writes main flow-of-control – Explicitly invokes functions as needed – Built-in functions block until request satisfied Example: function wait_for_packet() blocks until packet (cid:0) arrives Easier to program (cid:0) NSD-Agere -- Chapt. 7 7 2004 Synchronous API Using Polling Nonblocking form of synchronous API (cid:0) Each function call returns immediately (cid:0) – Performs operation if available – Returns error code otherwise Example: function try_for_packet() either returns next (cid:0) packet or error code if no packet has arrived Closer to underlying hardware (cid:0) NSD-Agere -- Chapt. 7 8 2004 Typical Implementations And APIs Application program (cid:0) – Synchronous API using blocking (e.g., socket API) – Another application thread runs while an application blocks Embedded systems (cid:0) – Synchronous API using polling – CPU dedicated to one task Operating systems (cid:0) – Asynchronous API – Built on interrupt mechanism NSD-Agere -- Chapt. 7 9 2004
Description: