Zefina  Design: Zefina Service

start introspection reader validate is admin is client router writer no bundle activity activity reader/ cla reader/ client reader/ datastore validator validator admin yes client yes datastore delay router router writer/ cla writer/ cla module phase [ key ]
bgcolor = 0x1d2021
boxwid *= 1.3
boxht  *= 0.9
State_start: oval "start" height boxht*0.9
State_introspection: box "introspection" rad 0.3*boxht at boxht*2.5 heading 180 from State_start
State_reader: box "reader" rad 0.3*boxht at boxwid*2 heading -90 from State_introspection
State_validate: box "validate" rad 0.3*boxht at boxht*4.5 heading 180 from State_reader
State_isadmin: diamond "is" "admin" at boxht*3.5 heading 180 from State_validate
State_isclient: diamond "is" "client" at boxht*2.5 heading 180 from State_isadmin
State_router: box "router" rad 0.3*boxht at boxht*2.5 heading 180 from State_isclient
State_writer: box "writer" rad 0.3*boxht at boxwid*2 heading 90 from State_router

arrow -> from State_start.s to State_introspection.n
arrow -> thick from State_introspection.w to State_reader.e
arrow -> thick from State_reader.s to State_validate.n
arrow -> thick from State_validate.s to State_isadmin.n
arrow -> thick from State_isadmin.s to State_isclient.n
arrow -> thick from State_isclient.s to State_router.n
arrow -> thick from State_router.e to State_writer.w
arrow -> thick from State_writer.n to State_introspection.s

arc "" below "" "" "no bundle" -> dashed from State_reader.se to State_introspection.sw

Introspection_1: box "activity" at dist(State_start, State_introspection) heading 70 from State_introspection.ne
Introspection_2: box "activity" at dist(State_start, State_introspection) heading 110 from State_introspection.se
Introspection_dot_1: dot at dist(Introspection_1.s,Introspection_2.n)*0.25 heading 180 from Introspection_1.s
Introspection_dot_2: dot at dist(Introspection_1.s,Introspection_2.n)*0.50 heading 180 from Introspection_1.s
Introspection_dot_3: dot at dist(Introspection_1.s,Introspection_2.n)*0.75 heading 180 from Introspection_1.s

arrow <- from State_introspection.ne to Introspection_1.w
arrow <- from State_introspection.se to Introspection_2.w

Reader_1: box "reader/" "cla"       at dist(State_start, State_introspection) heading -50 from State_reader.w
Reader_2: box "reader/" "client"    at dist(State_start, State_introspection) heading -90 from State_reader.w
Reader_3: box "reader/" "datastore" at dist(State_start, State_introspection) heading -130 from State_reader.w

arrow <- left from Reader_1.w
arrow <- left from Reader_2.w
arrow -> from Reader_1.e to State_reader.nw
arrow -> from Reader_2.e to State_reader.w
arrow -> from Reader_3.e to State_reader.sw

Validate_1: box "validator" at dist(State_start, State_introspection) heading -70 from State_validate.nw
Validate_2: box "validator" at dist(State_start, State_introspection) heading -110 from State_validate.sw
Validate_dot_1: dot at dist(Validate_1.s,Validate_2.n)*0.25 heading 180 from Validate_1.s
Validate_dot_2: dot at dist(Validate_1.s,Validate_2.n)*0.50 heading 180 from Validate_1.s
Validate_dot_3: dot at dist(Validate_1.s,Validate_2.n)*0.75 heading 180 from Validate_1.s

arrow <- from State_validate.nw to Validate_1.e
arrow <- from State_validate.sw to Validate_2.e

State_admin: box "admin" at boxwid*2 heading -90 from State_isadmin
arrow -> "yes" above from State_isadmin.w to State_admin.e

State_client: box "client" at boxwid*2 heading -90 from State_isclient
arrow -> "yes" above from State_isclient.w to State_client.e

State_datastore: box "datastore" rad 0.3*boxht at boxwid*2 heading -90 from State_router
arrow -> "delay" above from State_router.w to State_datastore.e
linerad = 0.5cm
arrow from State_datastore.w left then up even with Reader_3 then right to Reader_3.w

Route_1: box "router" at dist(State_start, State_introspection) heading -135 from State_router
Route_2: box "router" at dist(State_start, State_introspection) heading 135 from State_router
Route_dot_1: dot at dist(Route_1.e,Route_2.w)*0.25 heading 90 from Route_1.e
Route_dot_2: dot at dist(Route_1.e,Route_2.w)*0.50 heading 90 from Route_1.e
Route_dot_3: dot at dist(Route_1.e,Route_2.w)*0.75 heading 90 from Route_1.e

arrow <- from State_router.sw to Route_1.n
arrow <- from State_router.se to Route_2.n

Writer_1: box "writer/" "cla" at dist(State_start, State_introspection) heading 70 from State_writer.ne
Writer_2: box "writer/" "cla" at dist(State_start, State_introspection) heading 110 from State_writer.se
Writer_dot_1: dot at dist(Writer_1.s,Writer_2.n)*0.25 heading 180 from Writer_1.s
Writer_dot_2: dot at dist(Writer_1.s,Writer_2.n)*0.50 heading 180 from Writer_1.s
Writer_dot_3: dot at dist(Writer_1.s,Writer_2.n)*0.75 heading 180 from Writer_1.s

arrow -> right from Writer_1.e
arrow -> right from Writer_2.e
arrow -> from State_writer.ne to Writer_1.w
arrow -> from State_writer.se to Writer_2.w

K: [
box "module" height boxht*0.66
box "phase" rad 0.1*boxwid height boxht*0.66 at boxht heading 180 from previous
] at boxht*4 heading 180 from Introspection_2
K_border: box thin width K.width+0.5cm height K.height+0.5cm at K.center
K_caption: text "[ key ]" with .s at 0.1cm above K_border.n




The Zefina Service consists of a Main Loop of states, each with a collection of modules.

A state represents a phase of a bundles lifetime. The modules provide functionality and the means for a state to do work. Also note that the above diagram represents the "happy path" of the bundle's lifetime. If there is a problem with a bundle at any point, the path of the bundle will be very different.


Main Loop

The Main Loop is populated by one or more threads. Each thread will take a bundle from reception to delivery. Threads will also periodically do some house keeping activities.


Introspection

During the Introspection state, Zefina will perform various activities. The goal of these activities is to maintain the health and operation of Zefina.

Activity

The Introspection state uses the Activity Modules. Examples of some possible Activities include:

  • State Reporting ?
  • Performance Adjustments?
    • Give some queues higher priority due to getting full?
  • Write memory snapshots to disk?
  • Memory Defragmenting?

Activities will occur periodically and not continuously.

Note: Only one thread is allowed to execute the Activities.


Reader

Threads will wait in the Reader state for bundle to be provided by the one of Reader Modules. If no bundle comes in after a period of time, a thread will perform Introspection.

Reader/CLA

A Reader Module will receive bundles and make them available to the Main Loop. Each Reader Module can be dynamically loaded and unloaded.

Zefina supports zero or more Reader Modules and each Reader Module is specialized to the device that it uses. Examples of Reader Modules and their devices are:

  • TCP/IP4
  • UDP/IP4
  • Pipe (POSIX Filesystem Pipes)

Note: There is no requirement that there must be a matching Reader and Writer.

Reader/Client

Zefina also has a Reader/Client Module dedicated for registered clients. Clients communicate with the Zefina Service via a separate interface. This Reader/Client Module will convert data from the interface into bundles to be processed by the Main Loop.

Reader/DataStore

Sometimes a bundle can not be sent immediately and are placed in a queue. When a bundle is ready to be processed, the Reader/DataStore Module will make the bundle available to the Main Loop.

Ideas

Multi-Queue Priority (Solution?)

  • Process
    • The thread will call the reader's "get bundle".
    • The reader's "get bundle" function will
    • select the "best" bundle from each queue
    • select the "best" bundle from the collection
  • What is "best"?
    • bundle lifetime/expire
    • queue capacity (0.0 ... 1.0)
    • best = (now - expire) * (capacity + 0.5)

Validate

After a thread has bundle from the Reader, that bundle will be validated by the Validator Modules. All the loaded Validator Modules will ensure the bundle is in good health.

Validator

Each Validator Modules is responsible for validating only one aspect of a bundle. These validator checks should be simple and do not depend on any specific order of modules.

Example Validator Modules:

  • CRC8
  • CRC16
  • DTN
  • IPN

Is Admin?

When the thread brings the bundle to Is Admin?, the bundle will be checked if Zefina (The BP Agent) is the destination. If it is, Admin Module module will process the bundle.

Admin

The Adimn Module module of the Zefina Service provides a means of querying current status as well as requesting some action to be performed.


Is Client?

When the thread brings the bundle to Is Client?, the bundle will be checked if a registered client is the destination. If it is, the Client Module module will process the bundle to pass the data to the registered client.

Client

The Client Module module of the Zefina Service provides communication to registered clients. Communication with registered clients does not use the Writers because Zefina does not send bundles to the clients. Instead, a specialized communication interface is used.


Route

The Route state is where the thread learns which BP Agent will be the next hop location of the bundle.

The Router Modules are arranged in priority order. Based on the Route state configuration:

  • only the first module will determine the route
  • each module can determine the route, stopping with the first successful module
  • all modules provide a route, if possible, and the Route state selects one

Router

The Router Modules determine the best next hop for the bundle. An example of a Router Module:

  • CGR

Writer

The Writer state will use the results of the Route state to determine which Writer Module will take the bundle.

Writer/CLA

A Writer Module will send a bundle out to the next BP Agent towards the bundle's destination. Each Writer Module can be dynamically loaded and unloaded.

Zefina supports zero or more Writer Modules and each Writer Module is specialized to the device that it uses. Examples of Writer Modules and their devices are:

  • TCP/IP4
  • UDP/IP4
  • Pipe (POSIX Filesystem Pipes)

Each Writer Module has a queue which contains outgoing bundles.

Every Writer Module also has a thread that take bundles out of its queue and sends the bundle out.

Note: There is no requirement that there must be a matching Reader and Writer.