WSF
wsf::comm::ProtocolIGMP Class Reference

#include <WsfCommProtocolIGMP.hpp>

Inheritance diagram for wsf::comm::ProtocolIGMP:
Collaboration diagram for wsf::comm::ProtocolIGMP:

Classes

struct  RouteData
 A simple data structure to hold routing data. More...

Public Member Functions

 ProtocolIGMP ()=default
 ~ProtocolIGMP () override=default
Public Member Functions inherited from wsf::comm::ProtocolInterface
 ProtocolInterface ()=default
 ~ProtocolInterface () override=default
const char * GetScriptClassName () const override
WsfStringId GetComponentName () const final
bool Initialize (double aSimTime) override
bool ProcessInput (UtInput &aInput) override
bool operator< (const ProtocolInterface &aRhs) const
virtual ProcessResult ApplicationSend (double aSimTime, size_t aLayerIndex, Message &aMessage)
virtual ProcessResult ApplicationReceive (double aSimTime, size_t aLayerIndex, Message &aMessage)
virtual ProcessResult PresentationSend (double aSimTime, size_t aLayerIndex, Message &aMessage)
virtual ProcessResult PresentationReceive (double aSimTime, size_t aLayerIndex, Message &aMessage)
virtual ProcessResult SessionSend (double aSimTime, size_t aLayerIndex, Message &aMessage)
virtual ProcessResult SessionReceive (double aSimTime, size_t aLayerIndex, Message &aMessage)
virtual ProcessResult TransportSend (double aSimTime, size_t aLayerIndex, Message &aMessage)
virtual ProcessResult TransportReceive (double aSimTime, size_t aLayerIndex, Message &aMessage)
virtual ProcessResult DatalinkSend (double aSimTime, size_t aLayerIndex, Message &aMessage)
virtual ProcessResult DatalinkReceive (double aSimTime, size_t aLayerIndex, Message &aMessage)
virtual ProcessResult PhysicalSend (double aSimTime, size_t aLayerIndex, Message &aMessage)
Public Member Functions inherited from wsf::comm::Component
 Component ()=default
 ~Component () override=default
CommGetComm () const
WsfPlatformGetPlatform () const
WsfSimulationGetSimulation () const
virtual void TurnOn (double aSimTime)
virtual void TurnOff (double aSimTime)
virtual void PendingStart ()
virtual bool Initialize2 (double aSimTime)
virtual bool PreInitialize (double aSimTime)
virtual void AttemptToTransmit (double aSimTime, Result &aResult)
virtual void AttemptToReceive (double aSimTime, Result &aResult)
virtual bool CanInteractWith (const Comm *aXmtrPtr)
virtual bool Receive (double aSimTime, Comm *aXmtrPtr, Message &aMessage)
virtual bool Send (double aSimTime, const WsfMessage &aMessage, const Address &aAddress)
Public Member Functions inherited from WsfComponentT< Comm >
 WsfComponentT ()
WsfComponentToperator= (const WsfComponentT &) noexcept
 ~WsfComponentT () override=default
virtual void ComponentParentChanged (ParentType *aParentPtr)
ParentTypeGetComponentParent () 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 TypeListGetTypeList () const
bool IsA_TypeOf (WsfStringId aType) const
WsfObjectoperator= (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 ProtocolIGMPFind (const Comm &aParent)
static ProtocolIGMPFindOrCreate (Comm &aParent)
static void AttemptToTransmit (Comm &aComm, double aSimTime, Result &aResult)
 Called by model implementations when attempting to send a message.
static void AttemptToReceive (Comm &aComm, double aSimTime, Result &aResult)
 Called by model implementations when attempting to receive a message.
static bool Receive (Comm &aComm, double aSimTime, Comm *aXmtrPtr, Message &aMessage)
static bool Send (Comm &aComm, double aSimTime, const WsfMessage &aMessage, const Address &aAddress)

Leave/Join Group protected methods

These methods are only intended for scenario input processing, prior to initialization. Joining and leaving groups during runtime requires different behaviors.

void JoinGroup (const Address &aAddress)
void LeaveGroup (const Address &aAddress)

Required ProtocolInterface interface.

WsfComponentCloneComponent () const override
const int * GetComponentRoles () const override
void * QueryInterface (int aRole) override
ProtocolPriority GetPriority () const override
ProtocolIGMPClone () const override
void Setup () override
const char * GetScriptClassName () const override
bool Initialize (double aSimTime) override
bool ProcessInput (UtInput &aInput) override

Explicit Protocol Emulation Methods

Note
We don't explicitly model all the network communication for IGMP. These change on the presence of other protocols, the protocol version, etc. We only explicitly send join or leave requests with an associated delay for modelling purposes, as a full implementation would be far more taxing on performance and require a myriad of user defined settings.
Address GetQuerier () const
virtual void LeaveGroup (double aSimTime, const Address &aAddress)
virtual void JoinGroup (double aSimTime, const Address &aAddress)

ProtocolProcess methods

These methods implement the IGMP logic in the interface layers.

ProcessResult NetworkSend (double aSimTime, size_t aLayerIndex, Message &aMessage) override
ProcessResult NetworkReceive (double aSimTime, size_t aLayerIndex, Message &aMessage) override
ProcessResult PhysicalReceive (double aSimTime, size_t aLayerIndex, Message &aMessage) override
std::vector< AddressGetGroups () const
Address GetMessageAddressFromAux (Message &aMessage)

Additional Inherited Members

Public Types inherited from wsf::comm::ProtocolInterface
using ProcessResult = std::pair<bool, bool>
Public Types inherited from WsfComponentT< Comm >
typedef Comm ParentType
 This is needed to support the WsfComponentList template.
Public Types inherited from WsfObject
typedef std::vector< WsfStringIdTypeList
 The list of types returned by GetTypeList.
 WsfObject (const WsfObject &aSrc)
 Copy constructor (for Clone()).

Detailed Description

This protocol is a lightweight implementation of the functionality of the Internet Group Management Protocol (IGMP). Typically, IGMP is a protocol that defines how comm interfaces and routers communicate with each other and determine how to propagate messages to relay joining and leaving multicast groups. This allows routers to have the prerequisite knowledge necessary to know how to route multicast messages.

This implementation uses perfect knowledge, and does not actually generate protocol messaging. It 'cheats' by using multicast data stored in the network manager, and is only intended to resolve addressing. This protocol is provided in this manner to reduce performance overhead and not clutter the simulation with message events when users strictly want multicast messaging without the potential pitfalls of a full, high fidelity implementation.

This protocol does not inherently provide routing capability, and is reliant on the inherent PIM router protocol to provide that service. As such, if PIM is removed from the router, multicast messaging that passes through such a router will fail without an analogue capability.

Constructor & Destructor Documentation

◆ ProtocolIGMP()

wsf::comm::ProtocolIGMP::ProtocolIGMP ( )
default

◆ ~ProtocolIGMP()

wsf::comm::ProtocolIGMP::~ProtocolIGMP ( )
overridedefault

Member Function Documentation

◆ Clone()

ProtocolIGMP * wsf::comm::ProtocolIGMP::Clone ( ) const
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::ProtocolInterface.

References ProtocolIGMP().

Referenced by ~ProtocolIGMP().

◆ CloneComponent()

WsfComponent * wsf::comm::ProtocolIGMP::CloneComponent ( ) const
overridevirtual

Clones a component. May return null if component does not support clone.

Implements wsf::comm::ProtocolInterface.

References ProtocolIGMP().

Referenced by ~ProtocolIGMP().

◆ Find()

ProtocolIGMP * wsf::comm::ProtocolIGMP::Find ( const Comm & aParent)
static

◆ FindOrCreate()

ProtocolIGMP * wsf::comm::ProtocolIGMP::FindOrCreate ( Comm & aParent)
static

◆ GetComponentRoles()

const int * wsf::comm::ProtocolIGMP::GetComponentRoles ( ) const
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:

return roles;
@ cWSF_COMPONENT_SENSOR
A 'sensor' component (WsfSensor).
Definition WsfComponentRoles.hpp:105
@ cWSF_COMPONENT_PLATFORM_PART
The component derives from WsfPlatformPart.
Definition WsfComponentRoles.hpp:98
@ cWSF_COMPONENT_ARTICULATED_PART
The component derives from WsfArticulatedPart.
Definition WsfComponentRoles.hpp:99

Implements wsf::comm::ProtocolInterface.

References cWSF_COMPONENT_COMM, cWSF_COMPONENT_COMM_PROTOCOL, cWSF_COMPONENT_COMM_PROTOCOL_IGMP, and cWSF_COMPONENT_NULL.

Referenced by ~ProtocolIGMP().

◆ GetGroups()

std::vector< Address > wsf::comm::ProtocolIGMP::GetGroups ( ) const
inline

◆ GetMessageAddressFromAux()

Address wsf::comm::ProtocolIGMP::GetMessageAddressFromAux ( Message & aMessage)
protected

◆ GetPriority()

ProtocolPriority wsf::comm::ProtocolIGMP::GetPriority ( ) const
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::ProtocolInterface.

References wsf::comm::cIGMP.

Referenced by ~ProtocolIGMP().

◆ GetQuerier()

◆ GetScriptClassName()

const char * wsf::comm::ProtocolIGMP::GetScriptClassName ( ) const
inlineoverride

◆ Initialize()

bool wsf::comm::ProtocolIGMP::Initialize ( double aSimTime)
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.

Parameters
aSimTimeThe current simulation time.
Returns
true if successful or false if unsuccessful (bad input data, etc.)
Note
This method should NOT add any other components to the platform. This MUST be done in PreInitialize().

Reimplemented from wsf::comm::Component.

References cWSF_COMPONENT_COMM_PROTOCOL_IGMP, wsf::comm::Component::GetComm(), wsf::comm::Comm::GetComponents(), and ok.

◆ JoinGroup() [1/2]

void wsf::comm::ProtocolIGMP::JoinGroup ( const Address & aAddress)
inlineprotected

◆ JoinGroup() [2/2]

◆ LeaveGroup() [1/2]

void wsf::comm::ProtocolIGMP::LeaveGroup ( const Address & aAddress)
protected

◆ LeaveGroup() [2/2]

◆ NetworkReceive()

◆ NetworkSend()

ProtocolIGMP::ProcessResult wsf::comm::ProtocolIGMP::NetworkSend ( double aSimTime,
size_t aLayerIndex,
Message & aMessage )
overridevirtual

Determine if this is a multicast address destination.

If this comm device does has level 0 support, we can't send it.

Set the message destination to null, to avoid any further handling of the message.

Halt processing in the layer, don't send to next layer.

Halt protocol processing, continue to other layers

Don't stop protocol processing, continue to other layers.

Reimplemented from wsf::comm::ProtocolInterface.

References wsf::comm::Address::CheckInAddressRange(), wsf::comm::Comm::cLEVEL_0, wsf::comm::cMulticastRange, wsf::comm::Component::GetComm(), and wsf::comm::Message::SourceMessage().

◆ PhysicalReceive()

ProtocolIGMP::ProcessResult wsf::comm::ProtocolIGMP::PhysicalReceive ( double aSimTime,
size_t aLayerIndex,
Message & aMessage )
overridevirtual

With IGMP, multicast messages not valid for the owning comm are ignored at the physical layer. We listen for those we want, and ignore the rest. If the owning comm is doing routing, then we also must check for dependent hosts who may want this message as well.

This is a multicast address. Check to see if we can receive multicast messages. If not, short circuit.

Halt processing in the layer, don't send to next layer.

Determine if the multicast address is a group we are interested in.

If we made it to this point, the multicast message isn't destined for us. However, if we are a router, we must check if its destined for someone in our network. Note: This is done on the physical layer, as this action is taken via OS level controls and port assignments.

Note: We just pass along the message now. The actual addresses will be resolved in the network layer, and retransmitted there.

Reimplemented from wsf::comm::ProtocolInterface.

References wsf::comm::Address::CheckInAddressRange(), wsf::comm::Comm::cLEVEL_2, wsf::comm::cMulticastRange, wsf::comm::Component::GetComm(), WsfSimulation::GetCommNetworkManager(), WsfPlatformPart::GetSimulation(), and wsf::comm::Message::SourceMessage().

◆ ProcessInput()

bool wsf::comm::ProtocolIGMP::ProcessInput ( UtInput & aInput)
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.

Parameters
aInputThe input stream.
Returns
true if the current command was recognized (and processed), or false if the command was not recognized.
Exceptions
UtInput::ExceptionBaseif an invalid input was encountered.

Reimplemented from wsf::comm::Component.

References JoinGroup(), LeaveGroup(), wsf::comm::Address::ProcessInput(), and WsfRandomVariable::ProcessInput().

◆ QueryInterface()

void * wsf::comm::ProtocolIGMP::QueryInterface ( int aRole)
overridevirtual

Requests a component's role interface. A component can support one or more roles.

Parameters
aRoleThe role whose interface is to be returned.
Returns
A pointer to the object if it supports the indicated role, or 'null' if it does not. Usage: WsfProcessor* procPtrOrNull = (WsfProcessor*)componentPtr->QueryComponentInterface(cWSF_COMPONENT_PROCESSOR);

Implements wsf::comm::ProtocolInterface.

References cWSF_COMPONENT_COMM, cWSF_COMPONENT_COMM_PROTOCOL, cWSF_COMPONENT_COMM_PROTOCOL_IGMP, and wsf::comm::ProtocolInterface::ProtocolInterface().

Referenced by ~ProtocolIGMP().

◆ Setup()

void wsf::comm::ProtocolIGMP::Setup ( )
overridevirtual

The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved