wiki:ClientDesign
  • goal for the hackathon:
    1. requirements
    2. a design
    3. write as much commented code as possible

Requirements:

  • MUST support v6 (RFC3315bis)
  • MUST support all of the following:
    • call a hook
    • add address on its own (if the hook didn't do it)
    • call external script (via hook)
  • MUST use configuration in JSON

maybe

  • MUST support rewriting /etc/resolv.conf (must support rewriting on its own, calling a script, do both, do neither, hook)
  • MUST do hooks
  • SHOULD use bison as parser ?
  • MUST the binaries should be as small as possible (i.e. push as much as realistically possible to hooks)
  • MUST NOT use log4cplus (just a very rudimentary logging)

Class diagram (sort of)

main loop - instantiate Executor, log startup, log shutdown, catch exceptions

Executor

BaseCfgMgr?

  • accesses configuration store, makes contents available

FileCfgMgr? (inherits from BaseCfgMgr?)

  • reads the configuration file, makes contents available

ClientIfaceMgr?, derived from IfaceMgr?

  • uses BaseCfgMgr? interface to access BaseCfgMgr? data (what the users wants us to do)
  • uses IfaceMgr? (what's available in the system)
  • creates an intersection of those two lists. these are the intefaces we can configure;
  • hides send4, send6, receive4, receive6 - uses asyncIO to do the job TODO: this will be migrated to IfaceMgr? once it's mature enough

ClientIface?, derived from Iface

  • represents the network interface that the client is going to control
  • contains the network interface state machine - has methods to

manipulate it.

  • derived from Iface, so already contains all the structures
  • contains a pointer to BaseCfgMgr? structure representing the user

desires

  • the state machine is started when the ClientIface? is created

State Machine

The client moves through a series of states during its execution:

BEGIN:

  • Opens sockets
  • Initialize solicit timer interval
  • Move to SERVER_DISCOVERY

SERVER_DISCOVERY:

  • Initialize list of available servers
  • Move to SEND_SOLICIT

SEND_SOLICIT:

  • If solicit timer not running
    • Start solicit timer (move to SOLICIT_TIMEOUT on timeout)
  • Issue read for advertise (move to ADVERTISE_RECEIVED when response received)
  • Send SOLICIT message

ADVERTISE_RECEIVED:

  • If solicit timer has not expired
    • Add server to list of available servers
    • If server has maximum preference value (255)
      • Cancel solicit timer
      • Move to SEND_REQUEST
  • Move to SEND_SOLICIT

SOLICIT_TIMEOUT:

  • Cancel read for advertise
  • Sort servers in order most to least preferred
  • If some servers are available
    • Select next available server in list,
    • Move to SEND_REQUEST
  • Else
    • Adjust timer interval
    • Move to SERVER_DISCOVERY

SEND_REQUEST:

  • If request timer not running
    • Zero transmission count
    • Start request timer (move to REQUEST_TIMEOUT on timeout)
  • Increment transmission count
  • Send REQUEST
  • Issue read for reply (move to REPLY_RECEIVED when response received)

REQUEST_TIMEOUT:

  • If maximum number of transmissions has been reached
    • If no more servers in the list
      • Cancel read for request
      • Move to SERVER_DISCOVERY
    • Select next server
  • Move to SEND_REQUEST

REPLY_RECEIVED:

  • If address available
    • Cancel request timer
    • Apply non-address configuration (prefixes, options) immediately
    • Move to DUPLICATE_CHECK
  • Else
    • Select next server in list
    • If there is another server
      • Move to SEND_REQUEST
    • Else
      • Move to SERVER_DISCOVERY

DUPLICATE_CHECK:

  • Start a duplicate detection timer (move to DUPLICATE_TIMEOUT on timeout)

DUPLICATE_TIMEOUT:

  • Check kernel state of the addresses
  • If no duplicates
    • Move to CONFIGURED
  • Else
    • Send DECLINE
    • Move to SEND_REQUEST

CONFIGURED:

  • Start T1 timer (move to START_RENEW on timeout)

START_RENEW:

  • Send RENEW message
  • Issue read for response (move to RENEW_COMPLETE on I/O completion)
  • Start retransmission timer (move to RESEND_RENEW on timeout)
  • If T2 timer not running
    • Start T2 timer (move to REBINDING on timeout)

RESEND_RENEW:

  • Increase retransmission time
  • Cancel read for renew response
  • Move to START_RENEW

RENEW_COMPLETE:

  • Cancel retransmission timer
  • Cancel T2 timer
  • If server responded REPLY with status OK
    • Move to CONFIGURED
  • Else
    • Move to SEND_REQUEST

REBINDING:

  • Cancel retransmission timer
  • Cancel read for RENEW response
  • Start the rebinding timer (move to REBINDING_TIMEOUT on timeout)
  • send REBIND to all servers
  • Issue read for response (move to PROCESS_REBINDING on completion)

REBINDING_TIMEOUT:

  • Cancel read for REBINDING response
  • Move to SERVER_DISCOVERY

PROCESS_REBINDING:

  • Cancel rebinding timer
  • If server responded REPLY with status OK
    • Update configuration
    • Update current server
    • Move to CONFIGURED
  • Else
    • If backup server available
      • Select backup server
      • Move to SEND_SOLICIT
    • Else
      • Move to SERVER_DISCOVERY

State Transition Diagram

Client State Diagram

Last modified 4 months ago Last modified on Jul 20, 2017, 2:48:07 PM

Attachments (1)

Download all attachments as: .zip