|
WSF
|
#include <WsfCommProtocolAdHoc.hpp>


Public Member Functions | |
| ProtocolAdHoc (const WsfScenario &aScenario) | |
| ProtocolAdHoc (const ProtocolAdHoc &aSrc) | |
| ~ProtocolAdHoc () override=default | |
| Public Member Functions inherited from wsf::comm::router::ProtocolInterface | |
| ProtocolInterface ()=default | |
| ~ProtocolInterface () override=default | |
| const char * | GetScriptClassName () const override |
| WsfStringId | GetComponentName () const override final |
| bool | Initialize (double aSimTime) override |
| bool | ProcessInput (UtInput &aInput) override |
| bool | operator< (const ProtocolInterface &aRhs) const |
| virtual bool | Receive (double aSimTime, const Address &aReceivingInterface, Message &aMessage, bool &aOverrideForward) |
| virtual void | PerfectNetworkAdded (double aSimTime, Network *aNetworkPtr) |
| virtual void | PerfectNetworkRemoved (double aSimTime, Network *aNetworkPtr) |
| virtual void | PerfectCommEnabled (double aSimTime, Comm *aCommPtr) |
| virtual void | PerfectCommDisabled (double aSimTime, Comm *aCommPtr) |
| virtual void | PerfectConnectionEnabled (double aSimTime, const Address &aSourceAddress, const Address &aDestinationAddress) |
| virtual void | PerfectConnectionDisabled (double aSimTime, const Address &aSourceAddress, const Address &aDestinationAddress) |
| Public Member Functions inherited from wsf::comm::router::RouterComponent | |
| RouterComponent ()=default | |
| ~RouterComponent () override=default | |
| Router * | GetRouter () const |
| WsfSimulation * | GetSimulation () const |
| NetworkManager * | GetNetworkManager () const |
| virtual void | PendingStart () |
| virtual bool | Initialize (double aSimTime) |
| virtual bool | Initialize2 (double aSimTime) |
| virtual bool | PreInitialize (double aSimTime) |
| virtual bool | ProcessInput (UtInput &aInput) |
| Public Member Functions inherited from WsfComponentT< Router > | |
| WsfComponentT () | |
| WsfComponentT & | operator= (const WsfComponentT &) noexcept |
| ~WsfComponentT () override=default | |
| virtual void | ComponentParentChanged (ParentType *aParentPtr) |
| ParentType * | GetComponentParent () const |
| void | SetComponentParent (ParentType *aParentPtr) |
| Public Member Functions inherited from WsfComponent | |
| virtual | ~WsfComponent ()=default |
| virtual int | GetComponentInitializationOrder () const |
| template<typename T> | |
| bool | QueryInterfaceT (T *&aRolePtr) |
| bool | ComponentHasRole (int aRole) |
| Returns true if the component has the specified role. | |
| virtual void | PreInput () |
| Public Member Functions inherited from WsfObject | |
| WsfObject () | |
| This is the constructor for the WsfObject class. | |
| ~WsfObject () override | |
| This is the destructor for the WsfObject class. | |
| const char * | GetScriptClassName () const override |
| const std::string & | GetType () const |
| WsfStringId | GetTypeId () const |
| Get the string ID of the 'type' of the object. | |
| void | SetType (WsfStringId aType) |
| const std::string & | GetBaseType () const |
| WsfStringId | GetBaseTypeId () const |
| const TypeList & | GetTypeList () const |
| bool | IsA_TypeOf (WsfStringId aType) const |
| WsfObject & | operator= (const WsfObject &aRhs) |
| Assignment operator. | |
| template<typename T> | |
| void | Serialize (T &aBuff) |
| For XIO (de)serialization. | |
| const std::string & | GetName () const |
| WsfStringId | GetNameId () const |
| void | SetName (WsfStringId aName) |
Static Public Member Functions | |
| static ProtocolAdHoc * | Find (const Router &aParent) |
| static ProtocolAdHoc * | FindOrCreate (Router &aParent) |
Router push notifications | |
These methods, from the ProtocolInterface, are called by the router when truth based network state data has been indicated to the router via the network manager. These methods will schedule any potential delays/events for the corresponding knowledge to propagate for this protocol.
| |
| void | PerfectCommAdded (double aSimTime, Comm *aCommPtr) override |
| void | PerfectCommRemoved (double aSimTime, Comm *aCommPtr) override |
| void | PerfectConnectionAdded (double aSimTime, const Address &aSourceAddress, const Address &aDestinationAddress) override |
| void | PerfectConnectionRemoved (double aSimTime, const Address &aSourceAddress, const Address &aDestinationAddress) override |
| bool | ValidNetwork (const Address &aAddress) const |
| void | InitializeState () |
Required ProtocolInterface interface. | |
| WsfComponent * | CloneComponent () const override |
| const int * | GetComponentRoles () const override |
| void * | QueryInterface (int aRole) override |
| int | GetPriority () const override |
| ProtocolAdHoc * | Clone () const override |
| bool | Send (double aSimTime, Router::SendData &aData) override |
| std::vector< Address > | Routing (double aSimTime, const Address &aSendingInterface, size_t &aHopNumber, double &aCost, const Message &aMessage) override |
| const char * | GetScriptClassName () const override |
| bool | Initialize (double aSimTime) override |
| bool | ProcessInput (UtInput &aInput) override |
| void | Setup () override |
Graph methods | |
| bool | ShouldPropagateTruth () const override |
| graph::Graph * | GetGraph () const override |
Script method overload execution methods | |
These methods execute the user defined script corresponding with the network state notification. | |
| void | ExecuteOnCommAdded (double aSimTime, const Address &aComm) |
| void | ExecuteOnCommRemoved (double aSimTime, const Address &aComm) |
| void | ExecuteOnConnectionAdded (double aSimTime, const Address &aSourceAddress, const Address &aDestinationAddress) |
| void | ExecuteOnConnectionRemoved (double aSimTime, const Address &aSourceAddress, const Address &aDestinationAddress) |
| Address | ExecuteOnMessageRouting (double aSimTime, const Address &aInterface, const Message &aMessage) |
Additional Inherited Members | |
| Public Types inherited from WsfComponentT< Router > | |
| typedef Router | ParentType |
| This is needed to support the WsfComponentList template. | |
| Public Types inherited from WsfObject | |
| typedef std::vector< WsfStringId > | TypeList |
| The list of types returned by GetTypeList. | |
| WsfObject (const WsfObject &aSrc) | |
| Copy constructor (for Clone()). | |
Class ProtocolAdHoc provides a router protocol for usage in generic ad-hoc routing, or simply for generic script based routing protocol capabilities.
In general, ad-hoc routing protocols vary greatly and often are highly customizable in the rules used to determine routing and connectivity. Concerns exist that often aren't applicable in other use cases, such as power consumption, network congestion, or unique security concerns. As such, this protocol provides the ability to the user to directly define these rules, to the extent that they are needed or can be modeled within AFSIM using the scripting language. This provides a highly customizable router protocol with basic infrastructure, such that each can be customized specific to the analysis and use case. This also allows users to modify the protocol behavior to the maximum extent possible without requiring code based development or changes where general behaviors are sufficient and a high level of fidelity is not required, as typical in the common AFSIM mission level simulation usage.
Several pre-defined methods are associated with this routing protocol for definition by the user. Definition of these script methods allow the user to dictate the protocol behavior in these instances.
While most ad-hoc protocols do not require routers in the traditional sense, they do provide routing capabilities. As such, this protocol is provided as a router protocol. The definitions associated with this protocol define every interface associated with the router, which may not be intended behavior. In such cases, users may simply associate routers with comm interfaces on a one-to-one basis.
| wsf::comm::router::ProtocolAdHoc::ProtocolAdHoc | ( | const WsfScenario & | aScenario | ) |
Referenced by Clone(), CloneComponent(), Find(), FindOrCreate(), ProtocolAdHoc(), and ~ProtocolAdHoc().
| wsf::comm::router::ProtocolAdHoc::ProtocolAdHoc | ( | const ProtocolAdHoc & | aSrc | ) |
References ProtocolAdHoc(), and wsf::comm::router::ProtocolInterface::ProtocolInterface().
|
overridedefault |
References ProtocolAdHoc().
|
overridevirtual |
Return a copy of this object. Must be implemented by all derived types. If cloning is impossible, a WsfUncloneableException should be thrown.
Implements wsf::comm::router::ProtocolInterface.
References ProtocolAdHoc().
|
overridevirtual |
Clones a component. May return null if component does not support clone.
Implements wsf::comm::router::ProtocolInterface.
References ProtocolAdHoc().
| void wsf::comm::router::ProtocolAdHoc::ExecuteOnCommAdded | ( | double | aSimTime, |
| const Address & | aComm ) |
| void wsf::comm::router::ProtocolAdHoc::ExecuteOnCommRemoved | ( | double | aSimTime, |
| const Address & | aComm ) |
| Address wsf::comm::router::ProtocolAdHoc::ExecuteOnMessageRouting | ( | double | aSimTime, |
| const Address & | aInterface, | ||
| const Message & | aMessage ) |
References wsf::comm::router::RouterComponent::GetRouter().
Referenced by Routing().
|
static |
References WsfComponentList::GetComponent(), wsf::comm::router::Router::GetComponents(), and ProtocolAdHoc().
Referenced by FindOrCreate().
|
static |
|
overridevirtual |
Returns a zero-terminated array of component roles. Note that the array should be in decreasing order of specificity and should generally the inheritance hierarchy. The first entry should be the components 'primary' role. For example a sensor would do the following:
Implements wsf::comm::router::ProtocolInterface.
References cWSF_COMPONENT_COMM_ROUTER_PROTOCOL, cWSF_COMPONENT_COMM_ROUTER_PROTOCOL_AD_HOC, and cWSF_COMPONENT_NULL.
|
inlineoverridevirtual |
Implements wsf::comm::router::ProtocolInterface.
Referenced by Routing().
|
overridevirtual |
Required query for protocol priority. Protocols are evaluated in order based on their assigned priorities. A lower value indicates a higher priority.
Implements wsf::comm::router::ProtocolInterface.
References wsf::comm::cAD_HOC.
|
inlineoverride |
|
overridevirtual |
Perform phase 1 initialization. This is called by WsfPlatform::Initialize() during phase 1 initialization of the platform. The component should complete validation of input data that could not be done by ProcessInput, as well as any other functions to prepare for simulation use (subject to the next paragraph).
The order in which components are initialized is defined by GetComponentInitializationOrder. In general a component implementation of this method should not be dependent on the state of another component, i.e.: it should not assume that the other components Initialize() method has been called. If such a dependency exists one should use Initialize2() if possible, or specify a value GetComponentInitializationOrder to force things to initialize in a particular order.
| aSimTime | The current simulation time. |
Reimplemented from WsfComponent.
References wsf::comm::router::RouterComponent::GetRouter(), wsf::comm::router::RouterComponent::GetSimulation(), and ok.
| void wsf::comm::router::ProtocolAdHoc::InitializeState | ( | ) |
A helper function for initialization. This copies truth state at simulation start to this protocol.
References wsf::comm::NetworkManager::GetAddressesInNetwork(), WsfSimulation::GetCommNetworkManager(), wsf::comm::NetworkManager::GetGraph(), wsf::comm::graph::Graph::GetIncomingNodeEdges(), wsf::comm::router::Router::GetInterfaces(), wsf::comm::graph::Graph::GetOutgoingNodeEdges(), wsf::comm::router::RouterComponent::GetRouter(), and wsf::comm::router::RouterComponent::GetSimulation().
Referenced by Setup().
|
overridevirtual |
Reimplemented from wsf::comm::router::ProtocolInterface.
References WsfSimulation::AddEvent(), ExecuteOnCommAdded(), wsf::comm::Comm::GetAddress(), wsf::comm::router::RouterComponent::GetSimulation(), and ValidNetwork().
|
overridevirtual |
Reimplemented from wsf::comm::router::ProtocolInterface.
References WsfSimulation::AddEvent(), ExecuteOnCommRemoved(), wsf::comm::Comm::GetAddress(), wsf::comm::router::RouterComponent::GetSimulation(), and ValidNetwork().
|
overridevirtual |
Reimplemented from wsf::comm::router::ProtocolInterface.
References WsfSimulation::AddEvent(), ExecuteOnConnectionAdded(), wsf::comm::router::RouterComponent::GetSimulation(), and ValidNetwork().
|
overridevirtual |
Reimplemented from wsf::comm::router::ProtocolInterface.
References WsfSimulation::AddEvent(), ExecuteOnConnectionRemoved(), wsf::comm::router::RouterComponent::GetSimulation(), and ValidNetwork().
|
overridevirtual |
Evaluate the current input command and determine if it is one processed by the component. The component should get the current command from the input stream and determine if it is one that it recognizes. If it does not recognize the command then it should leave the command in the input stream and return false. If it does recognize the command then it should process the command and return true. If invalid arguments are encountered then it should throw an exception.
| aInput | The input stream. |
| UtInput::ExceptionBase | if an invalid input was encountered. |
Reimplemented from WsfComponent.
References WsfObject::GetName(), and WsfObject::GetType().
|
overridevirtual |
Requests a component's role interface. A component can support one or more roles.
| aRole | The role whose interface is to be returned. |
Implements wsf::comm::router::ProtocolInterface.
References cWSF_COMPONENT_COMM_ROUTER_PROTOCOL, cWSF_COMPONENT_COMM_ROUTER_PROTOCOL_AD_HOC, and wsf::comm::router::ProtocolInterface::ProtocolInterface().
|
overridevirtual |
The routing method is used by the router to determine the route based on the protocol defined routing algorithm. A return of an empty vector indicates that no path was found. The router will utilize any of its available interfaces to find a valid path.
Short circuit immediately if the incremented number of hops (possible due to recursive calls) exceeds the allowable number of hops set by the originating router call.
If the user has a custom routing algorithm via script, and wants to route, it will return the next hop as an address. In such cases, simply return the next hop.
If the custom routing script was defined, but a next hop was not provided, the user does not want this message forwarded.
Implements wsf::comm::router::ProtocolInterface.
References ExecuteOnMessageRouting(), wsf::comm::graph::Graph::FindPath(), GetGraph(), wsf::comm::router::RouterComponent::GetRouter(), and wsf::comm::Message::SourceMessage().
Referenced by Send().
|
overridevirtual |
Special case in this protocol for user defined next hop.
Reimplemented from wsf::comm::router::ProtocolInterface.
References wsf::comm::Comm::GetAddress(), wsf::comm::router::Router::SendData::GetMessages(), wsf::comm::router::Router::SendData::GetXmtr(), Routing(), and wsf::comm::router::Router::SendData::SetAbortProcessing().
|
overridevirtual |
Reimplemented from wsf::comm::router::RouterComponent.
References InitializeState().
|
inlineoverridevirtual |
Implements wsf::comm::router::ProtocolInterface.
| bool wsf::comm::router::ProtocolAdHoc::ValidNetwork | ( | const Address & | aAddress | ) | const |
A helper method to filter incoming updates. In this implementation, the only changes to network state that are tracked are those for interfaces that share a network with any of the interfaces on this router. Returns true if the address is one that we currently track.
References WsfSimulation::GetCommNetworkManager(), wsf::comm::router::Router::GetInterfaces(), wsf::comm::NetworkManager::GetNetwork(), wsf::comm::router::RouterComponent::GetRouter(), and wsf::comm::router::RouterComponent::GetSimulation().
Referenced by PerfectCommAdded(), PerfectCommRemoved(), PerfectConnectionAdded(), and PerfectConnectionRemoved().