Documentation ¶
Overview ¶
Package core represents a bundle node's router and contains both the bundle protocol agent and application agent.
Here be dragons.
Index ¶
- type AdministrativeRecord
- type AdministrativeRecordTypeCode
- type ApplicationAgent
- type BundlePack
- func (bp *BundlePack) AddConstraint(c Constraint)
- func (bp BundlePack) HasConstraint(c Constraint) bool
- func (bp BundlePack) HasConstraints() bool
- func (bp BundlePack) HasReceiver() bool
- func (bp BundlePack) ID() string
- func (bp *BundlePack) PurgeConstraints()
- func (bp *BundlePack) RemoveConstraint(c Constraint)
- func (bp BundlePack) String() string
- func (bp *BundlePack) UpdateBundleAge() (uint, error)
- type BundleStatusItem
- type Constraint
- type Core
- func (c *Core) Close()
- func (c *Core) HasEndpoint(endpoint bundle.EndpointID) (state bool)
- func (c *Core) RegisterApplicationAgent(agent ApplicationAgent)
- func (c *Core) RegisterConvergence(conv cla.Convergence)
- func (c *Core) RemoveConvergence(conv cla.Convergence)
- func (c *Core) RestartConvergence(conv cla.Convergence)
- func (c *Core) SendBundle(bndl *bundle.Bundle)
- func (c *Core) SendStatusReport(bp BundlePack, status StatusInformationPos, reason StatusReportReason)
- func (c *Core) SetRoutingAlgorithm(routing RoutingAlgorithm)
- type EpidemicRouting
- type IdKeeper
- type NoStore
- type RoutingAlgorithm
- type SimpleRESTAppAgent
- type SimpleRESTRequest
- type SimpleRESTRequestResponse
- type SimpleRESTResponse
- type SimpleStore
- func (store *SimpleStore) Close() error
- func (store *SimpleStore) KnowsBundle(bp BundlePack) bool
- func (store *SimpleStore) Push(bp BundlePack) error
- func (store *SimpleStore) Query(sel func(BundlePack) bool) (bps []BundlePack, err error)
- func (store *SimpleStore) QueryId(bundleId string) (bp BundlePack, err error)
- func (store *SimpleStore) QueryPending() (bps []BundlePack, err error)
- type StatusInformationPos
- type StatusReport
- type StatusReportReason
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdministrativeRecord ¶
type AdministrativeRecord struct { TypeCode AdministrativeRecordTypeCode Content StatusReport // contains filtered or unexported fields }
AdministrativeRecord is a application data unit used for administrative records. There is only one kind of Administrative Record definded today: the Bundle Status Report. Therefore the Content field is currently of the StatusReport type. Otherwise the CBOR en- and decoding would have been done by hand. So this becomes work for future me.
func NewAdministrativeRecord ¶
func NewAdministrativeRecord(typeCode AdministrativeRecordTypeCode, content StatusReport) AdministrativeRecord
NewAdministrativeRecord generates a new Administrative Record based on the given parameters.
func NewAdministrativeRecordFromCbor ¶
func NewAdministrativeRecordFromCbor(data []byte) (ar AdministrativeRecord, err error)
NewAdministrativeRecordFromCbor creates a new AdministrativeRecord from a given byte array.
func (AdministrativeRecord) String ¶
func (ar AdministrativeRecord) String() string
func (AdministrativeRecord) ToCanonicalBlock ¶
func (ar AdministrativeRecord) ToCanonicalBlock() bundle.CanonicalBlock
ToCanonicalBlock creates a canonical block, containing this administrative record. The surrounding bundle _must_ have a set AdministrativeRecordPayload bundle processing control flag.
type AdministrativeRecordTypeCode ¶
type AdministrativeRecordTypeCode uint
AdministrativeRecordTypeCode specifies the type of an AdministrativeRecord. However, currently the Bundle Status Report is the only known type.
const ( // BundleStatusReportTypeCode is the Bundle Status Report's type code, used in // its parent Administrative Record. BundleStatusReportTypeCode AdministrativeRecordTypeCode = 1 )
func (AdministrativeRecordTypeCode) String ¶
func (artc AdministrativeRecordTypeCode) String() string
type ApplicationAgent ¶
type ApplicationAgent interface { // EndpointID returns this ApplicationAgent's (unique) endpoint ID. EndpointID() bundle.EndpointID // Deliver delivers a received bundle to this ApplicationAgent. This bundle // may contain an application specific payload or an administrative record. Deliver(bp BundlePack) error }
ApplicationAgent is an interface which describes application agent, which can both receive and transmit bundles in interaction with the Core.
type BundlePack ¶
type BundlePack struct { Bundle *bundle.Bundle Receiver bundle.EndpointID Timestamp time.Time Constraints map[Constraint]bool }
BundlePack is a set of a bundle, it's creation or reception time stamp and a set of constraints used in the process of delivering this bundle.
func NewBundlePack ¶
func NewBundlePack(b *bundle.Bundle) BundlePack
NewBundlePack returns a BundlePack for the given bundle.
func NewRecBundlePack ¶
func NewRecBundlePack(b cla.RecBundle) BundlePack
NewRecBundlePack returns a new BundlePack based on a RecBundle, which contains a receiving CLA.
func QueryAll ¶
func QueryAll(store Store) []BundlePack
QueryAll is a helper function for Stores and queries all bundle packs.
func QueryFromStatusReport ¶
func QueryFromStatusReport(store Store, sr StatusReport) []BundlePack
QueryFromStatusReport returns all (hopefully <= 1) bundles related to the given StatusReport.
func (*BundlePack) AddConstraint ¶
func (bp *BundlePack) AddConstraint(c Constraint)
AddConstraint adds the given constraint.
func (BundlePack) HasConstraint ¶
func (bp BundlePack) HasConstraint(c Constraint) bool
HasConstraint returns true if the given constraint contains.
func (BundlePack) HasConstraints ¶
func (bp BundlePack) HasConstraints() bool
HasConstraints returns true if any constraint exists.
func (BundlePack) HasReceiver ¶
func (bp BundlePack) HasReceiver() bool
HasReceiver returns true if this BundlePack has a Receiver value.
func (*BundlePack) PurgeConstraints ¶
func (bp *BundlePack) PurgeConstraints()
PurgeConstraints removes all constraints, except LocalEndpoint.
func (*BundlePack) RemoveConstraint ¶
func (bp *BundlePack) RemoveConstraint(c Constraint)
RemoveConstraint removes the given constraint.
func (BundlePack) String ¶
func (bp BundlePack) String() string
func (*BundlePack) UpdateBundleAge ¶
func (bp *BundlePack) UpdateBundleAge() (uint, error)
UpdateBundleAge updates the bundle's Bundle Age block based on its reception timestamp, if such a block exists.
type BundleStatusItem ¶
BundleStatusItem represents the a bundle status item, as used as an element in the bundle status information array of each Bundle Status Report.
func NewBundleStatusItem ¶
func NewBundleStatusItem(asserted bool) BundleStatusItem
NewBundleStatusItem returns a new BundleStatusItem, indicating an optional assertion - givenas asserted -, but no status time request.
func NewTimeReportingBundleStatusItem ¶
func NewTimeReportingBundleStatusItem(time bundle.DtnTime) BundleStatusItem
NewTimeReportingBundleStatusItem returns a new BundleStatusItem, indicating both a positive assertion and a requested status time report.
func (*BundleStatusItem) CodecDecodeSelf ¶
func (bsi *BundleStatusItem) CodecDecodeSelf(dec *codec.Decoder)
func (BundleStatusItem) CodecEncodeSelf ¶
func (bsi BundleStatusItem) CodecEncodeSelf(enc *codec.Encoder)
func (BundleStatusItem) String ¶
func (bsi BundleStatusItem) String() string
type Constraint ¶
type Constraint int
Constraint is a retention constraint as defined in the subsections of the fifth chapter of draft-ietf-dtn-bpbis-13.
const ( // DispatchPending is assigned to a bundle if its dispatching is pending. DispatchPending Constraint = iota // ForwardPending is assigned to a bundle if its forwarding is pending. ForwardPending Constraint = iota // ReassemblyPending is assigned to a fragmented bundle if its reassembly is // pending. ReassemblyPending Constraint = iota // Contraindicated is assigned to a bundle if it could not be delivered and // was moved to the contraindicated stage. This Constraint was not defined // in draft-ietf-dtn-bpbis-13, but seemed reasonable for this implementation. Contraindicated Constraint = iota // LocalEndpoint is assigned to a bundle after delivery to a local endpoint. // This constraint demands storage until the endpoint removes this constraint. LocalEndpoint Constraint = iota )
func (Constraint) String ¶
func (c Constraint) String() string
type Core ¶
type Core struct { Agents []ApplicationAgent InspectAllBundles bool NodeId bundle.EndpointID // contains filtered or unexported fields }
Core is the inner core of our DTN which handles transmission, reception and reception of bundles.
func NewCore ¶
NewCore creates and returns a new Core. A SimpleStore will be created or used at the given path. The inspectAllBundles flag indicates if all administrative records - next to the bundles addressed to this node - should be inspected. This allows bundle deletion for forwarding bundles.
func (*Core) Close ¶
func (c *Core) Close()
Close shuts the Core down and notifies all bounded ConvergenceReceivers to also close the connection.
func (*Core) HasEndpoint ¶
func (c *Core) HasEndpoint(endpoint bundle.EndpointID) (state bool)
HasEndpoint returns true if the given endpoint ID is assigned either to an application or a CLA governed by this Application Agent.
func (*Core) RegisterApplicationAgent ¶
func (c *Core) RegisterApplicationAgent(agent ApplicationAgent)
RegisterApplicationAgent adds a new ApplicationAgent to this Core's list.
func (*Core) RegisterConvergence ¶
func (c *Core) RegisterConvergence(conv cla.Convergence)
RegisterConvergence registeres a CLA on this Core. This could be a ConvergenceReceiver, ConvergenceSender or even both.
func (*Core) RemoveConvergence ¶
func (c *Core) RemoveConvergence(conv cla.Convergence)
RemoveConvergence removes a Convergence. It should have been `Close()`ed before.
func (*Core) RestartConvergence ¶
func (c *Core) RestartConvergence(conv cla.Convergence)
RestartConvergence stops and restarts a Convergence.
func (*Core) SendBundle ¶
SendBundle transmits an outbounding bundle.
func (*Core) SendStatusReport ¶
func (c *Core) SendStatusReport(bp BundlePack, status StatusInformationPos, reason StatusReportReason)
SendStatusReport creates a new status report in response to the given BundlePack and transmits it.
func (*Core) SetRoutingAlgorithm ¶
func (c *Core) SetRoutingAlgorithm(routing RoutingAlgorithm)
SetRoutingAlgorithm overwrites the used RoutingAlgorithm, which defaults to EpidemicRouting.
type EpidemicRouting ¶
type EpidemicRouting struct {
// contains filtered or unexported fields
}
EpidemicRouting is an implementation of a RoutingAlgorithm and behaves in a flooding-based epidemic way.
func NewEpidemicRouting ¶
func NewEpidemicRouting(c *Core) EpidemicRouting
NewEpidemicRouting creates a new EpidemicRouting RoutingAlgorithm interacting with the given Core.
func (EpidemicRouting) NotifyIncoming ¶
func (er EpidemicRouting) NotifyIncoming(bp BundlePack)
NotifyIncoming tells the EpidemicRouting about new bundles. In our case, the PreviousNodeBlock will be inspected.
func (EpidemicRouting) ReportFailure ¶
func (er EpidemicRouting) ReportFailure(bp BundlePack, sender cla.ConvergenceSender)
func (EpidemicRouting) SenderForBundle ¶
func (er EpidemicRouting) SenderForBundle(bp BundlePack) (css []cla.ConvergenceSender, del bool)
SenderForBundle returns the Core's ConvergenceSenders.
type IdKeeper ¶
type IdKeeper struct {
// contains filtered or unexported fields
}
IdKeeper keeps track of the creation timestamp's sequence number for outbounding bundles.
type NoStore ¶
type NoStore struct{}
NoStore is a dummy implemention of the Store interface which represents, as the name indicates, no store whatsoever. Push will produce log messages and Query has no functionality at all.
func (NoStore) KnowsBundle ¶
func (_ NoStore) KnowsBundle(_ BundlePack) bool
func (NoStore) Push ¶
func (_ NoStore) Push(bp BundlePack) error
func (NoStore) Query ¶
func (_ NoStore) Query(_ func(BundlePack) bool) ([]BundlePack, error)
type RoutingAlgorithm ¶
type RoutingAlgorithm interface { // NotifyIncoming notifies this RoutingAlgorithm about incoming bundles. // Whether the algorithm acts on this information or ignores it, is both a // design and implementation decision. NotifyIncoming(bp BundlePack) // SenderForBundle returns an array of ConvergenceSender for a requested // bundle. Furthermore the finished flags indicates if this BundlePack should // be deleted afterwards. // The CLA selection is based on the algorithm's design. SenderForBundle(bp BundlePack) (sender []cla.ConvergenceSender, delete bool) // ReportFailure notifies the RoutingAlgorithm about a failed transmission to // a previously selected CLA. Compare: SenderForBundle. ReportFailure(bp BundlePack, sender cla.ConvergenceSender) }
RoutingAlgorithm is an interface to specify routing algorithms for delay-tolerant networks. An implementation might store a reference to a Core struct to refer the ConvergenceSenders.
type SimpleRESTAppAgent ¶
type SimpleRESTAppAgent struct {
// contains filtered or unexported fields
}
SimpleRESTAppAgent is an implementation of an ApplicationAgent, useable through simple HTTP requests for bundle creation and reception.
The /fetch/ endpoint can be queried through a simple HTTP GET request and will return all received bundles. Those are removed from the store afterwards.
The /send/ endpoint can be queried through a HTTP POST request with JSON data. The payload must be base64 encoded.
curl -d "{\"Destination\":\"dtn:foobar\", \"Payload\":\"`base64 <<< "hello world"`\"}" http://localhost:8080/send/
Would create an outbounding bundle with a "hello" payload, addressed to an endpoint named "dtn:foobar".
func NewSimpleRESTAppAgent ¶
func NewSimpleRESTAppAgent(endpointID bundle.EndpointID, c *Core, addr string) (aa *SimpleRESTAppAgent)
NewSimpleRESTAppAgent creates a new SimpleRESTAppAgent for the given endpoint, Core and bound to the address.
func (*SimpleRESTAppAgent) Deliver ¶
func (aa *SimpleRESTAppAgent) Deliver(bp BundlePack) error
Deliver delivers a received bundle to this SimpleRESTAppAgent. This bundle may contain an application specific payload or an administrative record.
func (*SimpleRESTAppAgent) EndpointID ¶
func (aa *SimpleRESTAppAgent) EndpointID() bundle.EndpointID
EndpointID returns this SimpleRESTAppAgent's (unique) endpoint ID.
type SimpleRESTRequest ¶
SimpleRESTRequest is the data structure used for outbounding bundles, requested through the SimpleRESTAppAgent.
type SimpleRESTRequestResponse ¶
type SimpleRESTRequestResponse struct {
Error string
}
SimpleRESTRequestResponse is the response, sent to a SimpleRESTRequest.
type SimpleRESTResponse ¶
type SimpleRESTResponse struct { Destination string SourceNode string ControlFlags string Timestamp [2]string Payload []byte }
SimpleRESTResponse is the data structure used for incoming bundles, handled through the SimpleRESTAppAgent.
func NewSimpleRESTReponseFromBundle ¶
func NewSimpleRESTReponseFromBundle(b *bundle.Bundle) SimpleRESTResponse
NewSimpleRESTReponseFromBundle creates a new SimpleRESTResponse for a bundle.
type SimpleStore ¶
type SimpleStore struct {
// contains filtered or unexported fields
}
SimpleStore is an implemention of the Store interface which serializes the bundle packs to a file. Both Lock and Query are safed with a mutex, should making this Store kind of thread-safe.
func NewSimpleStore ¶
func NewSimpleStore(directory string) (store *SimpleStore, err error)
NewSimpleStore creates a SimpleStore.
func (*SimpleStore) Close ¶
func (store *SimpleStore) Close() error
func (*SimpleStore) KnowsBundle ¶
func (store *SimpleStore) KnowsBundle(bp BundlePack) bool
func (*SimpleStore) Push ¶
func (store *SimpleStore) Push(bp BundlePack) error
func (*SimpleStore) Query ¶
func (store *SimpleStore) Query(sel func(BundlePack) bool) (bps []BundlePack, err error)
func (*SimpleStore) QueryId ¶
func (store *SimpleStore) QueryId(bundleId string) (bp BundlePack, err error)
func (*SimpleStore) QueryPending ¶
func (store *SimpleStore) QueryPending() (bps []BundlePack, err error)
type StatusInformationPos ¶
type StatusInformationPos int
StatusInformationPos describes the different bundle status information entries. Each bundle status report must contain at least the following bundle status items.
const ( // ReceivedBundle is the first bundle status information entry, indicating // the reporting node received this bundle. ReceivedBundle StatusInformationPos = 0 // ForwardedBundle is the second bundle status information entry, indicating // the reporting node forwarded this bundle. ForwardedBundle StatusInformationPos = 1 // DeliveredBundle is the third bundle status information entry, indicating // the reporting node delivered this bundle. DeliveredBundle StatusInformationPos = 2 // DeletedBundle is the fourth bundle status information entry, indicating // the reporting node deleted this bundle. DeletedBundle StatusInformationPos = 3 )
func (StatusInformationPos) String ¶
func (sip StatusInformationPos) String() string
type StatusReport ¶
type StatusReport struct { StatusInformation []BundleStatusItem ReportReason StatusReportReason SourceNode bundle.EndpointID Timestamp bundle.CreationTimestamp // contains filtered or unexported fields }
StatusReport is the bundle status report, used in an administrative record.
func NewStatusReport ¶
func NewStatusReport(bndl bundle.Bundle, statusItem StatusInformationPos, reason StatusReportReason, time bundle.DtnTime) StatusReport
NewStatusReport creates a bundle status report for the given bundle and StatusInformationPos, which creates the right bundle status item. The bundle status report reason code will be used and the bundle status item gets the given timestamp.
func (StatusReport) StatusInformations ¶
func (sr StatusReport) StatusInformations() (sips []StatusInformationPos)
StatusInformations returns an array of available StatusInformationPos.
func (StatusReport) String ¶
func (sr StatusReport) String() string
type StatusReportReason ¶
type StatusReportReason uint
StatusReportReason is the bundle status report reason code, which is used as the second element of the bundle status report array.
const ( // NoInformation is the "No additional information" bundle status report // reason code. NoInformation StatusReportReason = 0 // LifetimeExpired is the "Lifetime expired" bundle status report reason code. LifetimeExpired StatusReportReason = 1 // ForwardUnidirectionalLink is the "Forwarded over unidirectional link" // bundle status report reason code. ForwardUnidirectionalLink StatusReportReason = 2 // TransmissionCanceled is the "Transmission canceled" bundle status report // reason code. TransmissionCanceled StatusReportReason = 3 // DepletedStorage is the "Depleted storage" bundle status report reason code. DepletedStorage StatusReportReason = 4 // DestEndpointUnintelligible is the "Destination endpoint ID unintelligible" // bundle status report reason code. DestEndpointUnintelligible StatusReportReason = 5 // NoRouteToDestination is the "No known route to destination from here" // bundle status report reason code. NoRouteToDestination StatusReportReason = 6 // NoNextNodeContact is the "No timely contact with next node on route" bundle // status report reason code. NoNextNodeContact StatusReportReason = 7 // BlockUnintelligible is the "Block unintelligible" bundle status report // reason code. BlockUnintelligible StatusReportReason = 8 // HopLimitExceeded is the "Hop limit exceeded" bundle status report reason // code. HopLimitExceeded StatusReportReason = 9 )
func (StatusReportReason) String ¶
func (srr StatusReportReason) String() string
type Store ¶
type Store interface { // Push inserts or update the given bundle pack. Each bundle pack is // identified by the stored bundle's combination of sender, creation timestamp // and optionally fragmentation. // An error will be returned, if something failed. This is mostly an // implemention specific matter. Push(bp BundlePack) error // Query returns all bundle packs satisfying the given selection function. // Some convenience function, starting with "Query", are existing in the // core package. Query(func(BundlePack) bool) ([]BundlePack, error) // QueryId returns a bundle pack for the given bundle ID. QueryId(bundleId string) (BundlePack, error) // QueryPending queries those bundle packs,which could not be delivered // previously, but are complete (not fragmented). QueryPending() ([]BundlePack, error) // KnowsBundle checks if an entry with the BundlePack's ID exists. KnowsBundle(BundlePack) bool // Close closes the store. Close() error }
Store is an interface for a bundle storage.