Making ANTS Suitable for Per-Protocol Resource Control

Summary of Changes
  • Extracted NodeOS service APIs from ANTS API; now included in the nodeos Java package.
  • Implemented a new dispatch framework that allows early demultiplexing such that resources used in processing capsules are charged to appropriate protocols.
  • ANTS 1.2 used one namespace for all remotely loaded protocols; now have a separate namespace (using a new class loader for each protocol) for each protocol. ANTS 1.2 used one thread per channel; now use one thread per protocol. Because "protocol" in ANTS nomenclature represents a capsule type, this allows finer control of resource accounting.
  • Simple remote console, updated to JDK1.1 (instead of 1.0.2).

    Separation of ANTS run-time and Node OS services. Work-in-progress. Two services extracted: dispatching incoming packets, scheduling of outgoing packets.

    Dispatch framework for incoming packets.

    ANTS: - the channel entity would send and receive  capsules
          - Channel base class : encode, decode.
          - Channel subclasses : send and receive 
          - ChannelThread      : loop receiving, decoding, executing channel's packets
    
    UTAH: - Channel class separated into:
    	1. Channel   : sending (includes scheduling) and encoding
    	2. InChannel : executing packets; has a thread so it loops (similar to
                           ChannelThread)
          - NodeOS : packet dispatching (and ANTS runtime - described below)
    
    Dispatching. Accounting problem with dispatching: the cpu time and memory needed to dispatch can't be charged until the destination is known. (Lazy Receiver Processing - Druschel, et.al., showed that overall system throughput suffered if too much time spent on processing packets that were ultimately discarded.) Traditional solution: minimize amt of processing that is not accounted for.

    Flow dispatchers. Use a chain of dispatchers, a class that implements the Utah Dispatcher interface. Dispatcher has one method: to accept packets. Since these routines execute at non-accounted-for interrupt time, must be bounded: don't make copies of the buffer. Trusted dispatchers adhere to boundedness restrictions; untrusted (such as those used by untrusted active code extending the dispatch chain) are implemented as subclasses of trusted dispatchers and only implement a single untrusted accept-packet/drop- packet method (akin to traditional packet filters).

    Flow handles. Unit of resource consumption. Special kind of dispatcher associated with two queues: packets to process & free buffers. In its dispatch routine, checks for a free buffer; if one is free, "exchanges" it for the packet. "Flow handles must be supplied with buffer space up front" (by those that create the flow handle, i guess). This provides a way to charge the creator.

    Dependent buffers. Dispatchers cannot copy buffers (boundedness), so how can the same packet be passed to multiple flows? Utah has a way to do this such that each flow can have its own copy, yet by the time the copying is done, the owner is known and can be charged. Copying is postponed until a write is done. The first flow given the packet has the "master" copy. Subsequent flows have dependent buffers chained off the master. If the master copy is modified, it copies the data to the first dependent in the chain and calls that the master. If a dependent needs to modify the buffer, it copies the master into its own and removes itself from the dependent list.

    I thought that ANTS protocols corresponded to a packet type. However, paper says that in ANTS a protocol could have multiple code groups and each code group could have multiple packet types. In Utah ANTS, protocols can spawn threads and associate flow handles with the new threads such that they can control their resources in a more fine-grained manner.

    Overhead. Currently the implementation is in usermode so we have to use a special thread to receive the packet from the OS's interrupt handler and demultiplex to the correct flowhandle thread. With OS support, this extra context switch will go away.

    	now:   OS -> special receiving thread -> flowhandle thread
    	later: OS -> flowhandle thread
    

    Separate name spaces and threads per protocol.

    	ANTS: shared name space for all capsules
    	UTAH: new class loader for each protocol (not applications, just capsules -
    	      to be fixed)
    
    	ANTS: one thread per channel + no timers (malicious capsule could
    	      kill system)
    	UTAH: one thread per protocol TO BEGIN WITH - the protocol may start
    	      up more + other flowhandles
    
    Misc.