INET Framework for OMNeT++/OMNEST
|
A simple flooding protocol. More...
#include <Flood.h>
Classes | |
class | Bcast |
Public Member Functions | |
Flood () | |
virtual int | numInitStages () const override |
Initialization of omnetpp.ini parameters. More... | |
virtual void | initialize (int) override |
Reads all parameters from the ini file. More... | |
virtual void | finish () override |
Public Member Functions inherited from inet::OperationalBase | |
OperationalBase () | |
Public Member Functions inherited from inet::ILifecycle | |
virtual | ~ILifecycle () |
Public Member Functions inherited from inet::INetworkProtocol | |
virtual | ~INetworkProtocol () |
Protected Types | |
typedef std::list< Bcast > | cBroadcastList |
Protected Member Functions | |
virtual void | handleUpperPacket (cPacket *) override |
Handle messages from upper layer. More... | |
virtual void | handleLowerPacket (cPacket *) override |
Handle messages from lower layer. More... | |
bool | notBroadcasted (FloodDatagram *) |
Checks whether a message was already broadcasted. More... | |
cMessage * | decapsMsg (FloodDatagram *) |
Decapsulates the packet from the received Network packet. More... | |
FloodDatagram * | encapsMsg (cPacket *) |
Encapsulates the received ApplPkt into a NetwPkt and set all needed header fields. More... | |
virtual cObject * | setDownControlInfo (cMessage *const pMsg, const MACAddress &pDestAddr) |
Attaches a "control info" (NetwToMac) structure (object) to the message pMsg. More... | |
Protected Member Functions inherited from inet::NetworkProtocolBase | |
NetworkProtocolBase () | |
virtual void | handleUpperCommand (cMessage *message) override |
virtual void | sendUp (cMessage *message, int transportProtocol) |
virtual void | sendDown (cMessage *message, int interfaceId=-1) |
virtual bool | isUpperMessage (cMessage *message) override |
virtual bool | isLowerMessage (cMessage *message) override |
virtual bool | isInitializeStage (int stage) override |
virtual bool | isNodeStartStage (int stage) override |
virtual bool | isNodeShutdownStage (int stage) override |
Protected Member Functions inherited from inet::LayeredProtocolBase | |
virtual void | handleMessageWhenUp (cMessage *message) override |
virtual void | handleSelfMessage (cMessage *message) |
virtual void | handleLowerCommand (cMessage *message) |
Protected Member Functions inherited from inet::OperationalBase | |
virtual void | handleMessage (cMessage *msg) override |
virtual void | handleMessageWhenDown (cMessage *msg) |
virtual bool | handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override |
Perform one stage of a lifecycle operation. More... | |
virtual bool | handleNodeStart (IDoneCallback *doneCallback) |
virtual bool | handleNodeShutdown (IDoneCallback *doneCallback) |
virtual void | handleNodeCrash () |
virtual void | setOperational (bool isOperational) |
Protected Attributes | |
unsigned long | seqNum = 0 |
Network layer sequence number. More... | |
L3Address | myNetwAddr |
cached variable of my networ address More... | |
int | headerLength = 0 |
Length of the header. More... | |
int | defaultTtl = 0 |
Default time-to-live (ttl) used for this module. More... | |
bool | plainFlooding = false |
Defines whether to use plain flooding or not. More... | |
cBroadcastList | bcMsgs |
List of already broadcasted messages. More... | |
unsigned int | bcMaxEntries = 0 |
Max number of entries in the list of already broadcasted messages. More... | |
simtime_t | bcDelTime |
Time after which an entry for an already broadcasted msg can be deleted. More... | |
long | nbDataPacketsReceived = 0 |
long | nbDataPacketsSent = 0 |
long | nbDataPacketsForwarded = 0 |
long | nbHops = 0 |
Protected Attributes inherited from inet::NetworkProtocolBase | |
ProtocolMapping | protocolMapping |
IInterfaceTable * | interfaceTable |
Protected Attributes inherited from inet::OperationalBase | |
bool | isOperational |
simtime_t | lastChange |
Additional Inherited Members | |
Static Public Attributes inherited from inet::LayeredProtocolBase | |
static simsignal_t | packetSentToUpperSignal = registerSignal("packetSentToUpper") |
static simsignal_t | packetReceivedFromUpperSignal = registerSignal("packetReceivedFromUpper") |
static simsignal_t | packetFromUpperDroppedSignal = registerSignal("packetFromUpperDropped") |
static simsignal_t | packetSentToLowerSignal = registerSignal("packetSentToLower") |
static simsignal_t | packetReceivedFromLowerSignal = registerSignal("packetReceivedFromLower") |
static simsignal_t | packetFromLowerDroppedSignal = registerSignal("packetFromLowerDropped") |
A simple flooding protocol.
This implementation uses plain flooding, i.e. it "remembers" (stores) already broadcasted messages in a list and does not rebroadcast them again, if it gets another copy of that message.
The maximum number of entires for that list can be defined in the .ini file (bcMaxEntries) as well as the time after which an entry is deleted (bcDelTime).
If you prefere a memory-less version you can comment out the
#define PLAINFLOODING
ported to Mixim 2.0 by Theodoros Kapourniotis
|
protected |
|
protected |
|
protected |
Encapsulates the received ApplPkt into a NetwPkt and set all needed header fields.
Referenced by handleUpperPacket().
|
overridevirtual |
|
overrideprotectedvirtual |
Handle messages from lower layer.
Messages from the mac layer will be forwarded to the application only if the are broadcast or destined for this node.
If the arrived message is a broadcast message it is also reflooded only if the tll field is bigger than one. Before the message is handed back to the mac layer the ttl field is reduced by one to account for this hop.
In the case of plain flooding the message will only be processed if there is no corresponding entry in the bcMsgs list (notBroadcasted). Otherwise the message will be deleted.
Implements inet::LayeredProtocolBase.
|
overrideprotectedvirtual |
Handle messages from upper layer.
All messages have to get a sequence number and the ttl filed has to be specified.
Afterwards the messages can be handed to the mac layer. The mac address is set to -1 (broadcast address) because the message is flooded (i.e. has to be send to all neighbors)
In the case of plain flooding the message sequence number and source address has also be stored in the bcMsgs list, so that this message will not be rebroadcasted, if a copy will be flooded back from the neigbouring nodes.
If the maximum number of entries is reached the first (oldest) entry is deleted.
Implements inet::LayeredProtocolBase.
|
overridevirtual |
Reads all parameters from the ini file.
If a parameter is not specified in the ini file a default value will be set.
Reimplemented from inet::NetworkProtocolBase.
|
protected |
Checks whether a message was already broadcasted.
The bcMsgs list is searched for the arrived message.
If the message is in the list, it was already broadcasted and the function returns false.
Concurrently all outdated (older than bcDelTime) are deleted. If the list is full and a new message has to be entered, the oldest entry is deleted.
Referenced by handleLowerPacket().
|
inlineoverridevirtual |
|
protectedvirtual |
Attaches a "control info" (NetwToMac) structure (object) to the message pMsg.
Attaches a "control info" structure (object) to the down message pMsg.
This is most useful when passing packets between protocol layers of a protocol stack, the control info will contain the destination MAC address.
The "control info" object will be deleted when the message is deleted. Only one "control info" structure can be attached (the second setL3ToL2ControlInfo() call throws an error).
pMsg | The message where the "control info" shall be attached. |
pDestAddr | The MAC address of the message receiver. |
Referenced by encapsMsg(), and handleLowerPacket().
|
protected |
Time after which an entry for an already broadcasted msg can be deleted.
Referenced by handleUpperPacket(), initialize(), and notBroadcasted().
|
protected |
Max number of entries in the list of already broadcasted messages.
Referenced by handleUpperPacket(), initialize(), and notBroadcasted().
|
protected |
List of already broadcasted messages.
Referenced by finish(), handleUpperPacket(), and notBroadcasted().
|
protected |
Default time-to-live (ttl) used for this module.
Referenced by handleLowerPacket(), handleUpperPacket(), and initialize().
|
protected |
Length of the header.
Referenced by encapsMsg(), and initialize().
|
protected |
cached variable of my networ address
Referenced by encapsMsg(), and initialize().
|
protected |
Referenced by finish(), handleLowerPacket(), and initialize().
|
protected |
Referenced by finish(), handleLowerPacket(), and initialize().
|
protected |
Referenced by finish(), handleUpperPacket(), and initialize().
|
protected |
Referenced by finish(), handleLowerPacket(), and initialize().
|
protected |
Defines whether to use plain flooding or not.
Referenced by finish(), handleUpperPacket(), initialize(), and notBroadcasted().
|
protected |
Network layer sequence number.
Referenced by handleUpperPacket(), and initialize().