INET Framework for OMNeT++/OMNEST
inet::visualizer::PacketDropVisualizerBase Class Referenceabstract

#include <PacketDropVisualizerBase.h>

Inheritance diagram for inet::visualizer::PacketDropVisualizerBase:
inet::visualizer::VisualizerBase inet::visualizer::PacketDropCanvasVisualizer inet::visualizer::PacketDropOsgVisualizer

Classes

class  PacketDropVisualization
 

Public Member Functions

virtual ~PacketDropVisualizerBase ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signal, cObject *object, cObject *details) override
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleParameterChange (const char *name) override
 
virtual void refreshDisplay () const override
 
virtual void subscribe ()
 
virtual void unsubscribe ()
 
virtual const PacketDropVisualizationcreatePacketDropVisualization (cModule *module, cPacket *packet) const =0
 
virtual void addPacketDropVisualization (const PacketDropVisualization *packetDropVisualization)
 
virtual void removePacketDropVisualization (const PacketDropVisualization *packetDropVisualization)
 
virtual void removeAllPacketDropVisualizations ()
 
virtual void setAlpha (const PacketDropVisualization *packetDropVisualization, double alpha) const =0
 
- Protected Member Functions inherited from inet::visualizer::VisualizerBase
virtual int numInitStages () const override
 
virtual Coord getPosition (const cModule *networkNode) const
 
virtual Coord getContactPosition (const cModule *networkNode, const Coord &fromPosition, const char *contactMode, double contactSpacing) const
 
virtual InterfaceEntrygetInterfaceEntry (cModule *networkNode, cModule *module) const
 

Protected Attributes

std::vector< const PacketDropVisualization * > packetDropVisualizations
 
Parameters
bool displayPacketDrops = false
 
NetworkNodeFilter nodeFilter
 
InterfaceFilter interfaceFilter
 
PacketFilter packetFilter
 
const char * icon = nullptr
 
cFigure::Color iconTintColor
 
double iconTintAmount = NaN
 
cFigure::Font labelFont
 
cFigure::Color labelColor
 
const char * fadeOutMode = nullptr
 
double fadeOutTime = NaN
 
double fadeOutAnimationSpeed = NaN
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Constructor & Destructor Documentation

inet::visualizer::PacketDropVisualizerBase::~PacketDropVisualizerBase ( )
virtual
45 {
46  for (auto packetDrop : packetDropVisualizations)
47  delete packetDrop->packet;
49  unsubscribe();
50 }
virtual void unsubscribe()
Definition: PacketDropVisualizerBase.cc:127
std::vector< const PacketDropVisualization * > packetDropVisualizations
Definition: PacketDropVisualizerBase.h:64
bool displayPacketDrops
Definition: PacketDropVisualizerBase.h:50

Member Function Documentation

void inet::visualizer::PacketDropVisualizerBase::addPacketDropVisualization ( const PacketDropVisualization packetDropVisualization)
protectedvirtual

Reimplemented in inet::visualizer::PacketDropCanvasVisualizer.

Referenced by inet::visualizer::PacketDropCanvasVisualizer::addPacketDropVisualization(), and receiveSignal().

161 {
162  packetDropVisualizations.push_back(packetDropVisualization);
163 }
std::vector< const PacketDropVisualization * > packetDropVisualizations
Definition: PacketDropVisualizerBase.h:64
virtual const PacketDropVisualization* inet::visualizer::PacketDropVisualizerBase::createPacketDropVisualization ( cModule *  module,
cPacket *  packet 
) const
protectedpure virtual
void inet::visualizer::PacketDropVisualizerBase::handleParameterChange ( const char *  name)
overrideprotectedvirtual
76 {
77  if (name != nullptr) {
78  if (!strcmp(name, "nodeFilter"))
79  nodeFilter.setPattern(par("nodeFilter"));
80  else if (!strcmp(name, "interfaceFilter"))
81  interfaceFilter.setPattern(par("interfaceFilter"));
82  else if (!strcmp(name, "packetFilter"))
83  packetFilter.setPattern(par("packetFilter"));
85  }
86 }
virtual void removeAllPacketDropVisualizations()
Definition: PacketDropVisualizerBase.cc:170
void setPattern(const char *pattern)
Definition: NetworkNodeFilter.cc:24
NetworkNodeFilter nodeFilter
Definition: PacketDropVisualizerBase.h:51
void setPattern(const char *pattern)
Definition: InterfaceFilter.cc:24
PacketFilter packetFilter
Definition: PacketDropVisualizerBase.h:53
InterfaceFilter interfaceFilter
Definition: PacketDropVisualizerBase.h:52
void setPattern(const char *pattern)
Definition: PacketFilter.cc:24
void inet::visualizer::PacketDropVisualizerBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::VisualizerBase.

Reimplemented in inet::visualizer::PacketDropOsgVisualizer, and inet::visualizer::PacketDropCanvasVisualizer.

Referenced by inet::visualizer::PacketDropCanvasVisualizer::initialize().

53 {
55  if (!hasGUI()) return;
56  if (stage == INITSTAGE_LOCAL) {
57  displayPacketDrops = par("displayPacketDrops");
58  nodeFilter.setPattern(par("nodeFilter"));
59  interfaceFilter.setPattern(par("interfaceFilter"));
60  packetFilter.setPattern(par("packetFilter"));
61  icon = par("icon");
62  iconTintAmount = par("iconTintAmount");
63  if (iconTintAmount != 0)
64  iconTintColor = cFigure::Color(par("iconTintColor"));
65  labelFont = cFigure::parseFont(par("labelFont"));
66  labelColor = cFigure::Color(par("labelColor"));
67  fadeOutMode = par("fadeOutMode");
68  fadeOutTime = par("fadeOutTime");
69  fadeOutAnimationSpeed = par("fadeOutAnimationSpeed");
71  subscribe();
72  }
73 }
const char * fadeOutMode
Definition: PacketDropVisualizerBase.h:59
double iconTintAmount
Definition: PacketDropVisualizerBase.h:56
void setPattern(const char *pattern)
Definition: NetworkNodeFilter.cc:24
cFigure::Font labelFont
Definition: PacketDropVisualizerBase.h:57
NetworkNodeFilter nodeFilter
Definition: PacketDropVisualizerBase.h:51
double fadeOutTime
Definition: PacketDropVisualizerBase.h:60
virtual void subscribe()
Definition: PacketDropVisualizerBase.cc:113
void setPattern(const char *pattern)
Definition: InterfaceFilter.cc:24
cFigure::Color iconTintColor
Definition: PacketDropVisualizerBase.h:55
virtual void initialize(int stage) override
Definition: VisualizerBase.cc:29
PacketFilter packetFilter
Definition: PacketDropVisualizerBase.h:53
const char * icon
Definition: PacketDropVisualizerBase.h:54
Local initializations.
Definition: InitStages.h:35
InterfaceFilter interfaceFilter
Definition: PacketDropVisualizerBase.h:52
void setPattern(const char *pattern)
Definition: PacketFilter.cc:24
Color
Definition: DiffservUtil.h:30
cFigure::Color labelColor
Definition: PacketDropVisualizerBase.h:58
bool displayPacketDrops
Definition: PacketDropVisualizerBase.h:50
double fadeOutAnimationSpeed
Definition: PacketDropVisualizerBase.h:61
void inet::visualizer::PacketDropVisualizerBase::receiveSignal ( cComponent *  source,
simsignal_t  signal,
cObject *  object,
cObject *  details 
)
overridevirtual
144 {
145  Enter_Method_Silent();
148 #ifdef WITH_ETHERNET
150 #endif // WITH_ETHERNET
151  ) {
152  auto packet = check_and_cast<cPacket *>(object);
153  if (packetFilter.matches(packet))
154  addPacketDropVisualization(createPacketDropVisualization(check_and_cast<cModule*>(source), packet->dup()));
155  }
156  else
157  throw cRuntimeError("Unknown signal");
158 }
static simsignal_t packetFromLowerDroppedSignal
Definition: LayeredProtocolBase.h:34
PacketFilter packetFilter
Definition: PacketDropVisualizerBase.h:53
bool matches(const cPacket *packet) const
Definition: PacketFilter.cc:29
static simsignal_t dropPkFromHLIfaceDownSignal
Definition: EtherMACBase.h:192
static simsignal_t packetFromUpperDroppedSignal
Definition: LayeredProtocolBase.h:30
static simsignal_t dropPkByQueueSignal
Signal with packet when dropped it.
Definition: PassiveQueueBase.h:55
virtual void addPacketDropVisualization(const PacketDropVisualization *packetDropVisualization)
Definition: PacketDropVisualizerBase.cc:160
static simsignal_t dropPkIfaceDownSignal
Definition: EtherMACBase.h:191
virtual const PacketDropVisualization * createPacketDropVisualization(cModule *module, cPacket *packet) const =0
void inet::visualizer::PacketDropVisualizerBase::refreshDisplay ( ) const
overrideprotectedvirtual

Reimplemented in inet::visualizer::PacketDropCanvasVisualizer.

Referenced by inet::visualizer::PacketDropCanvasVisualizer::refreshDisplay().

89 {
90  AnimationPosition currentAnimationPosition;
91  std::vector<const PacketDropVisualization *> removedPacketDropVisualizations;
92  for (auto packetDrop : packetDropVisualizations) {
93  double delta;
94  if (!strcmp(fadeOutMode, "simulationTime"))
95  delta = (currentAnimationPosition.getSimulationTime() - packetDrop->packetDropAnimationPosition.getSimulationTime()).dbl();
96  else if (!strcmp(fadeOutMode, "animationTime"))
97  delta = currentAnimationPosition.getAnimationTime() - packetDrop->packetDropAnimationPosition.getAnimationTime();
98  else if (!strcmp(fadeOutMode, "realTime"))
99  delta = currentAnimationPosition.getRealTime() - packetDrop->packetDropAnimationPosition.getRealTime();
100  else
101  throw cRuntimeError("Unknown fadeOutMode: %s", fadeOutMode);
102  if (delta > fadeOutTime)
103  removedPacketDropVisualizations.push_back(packetDrop);
104  else
105  setAlpha(packetDrop, 1 - delta / fadeOutTime);
106  }
107  for (auto packetDrop : removedPacketDropVisualizations) {
108  const_cast<PacketDropVisualizerBase *>(this)->removePacketDropVisualization(packetDrop);
109  delete packetDrop;
110  }
111 }
const char * fadeOutMode
Definition: PacketDropVisualizerBase.h:59
double fadeOutTime
Definition: PacketDropVisualizerBase.h:60
virtual void removePacketDropVisualization(const PacketDropVisualization *packetDropVisualization)
Definition: PacketDropVisualizerBase.cc:165
std::vector< const PacketDropVisualization * > packetDropVisualizations
Definition: PacketDropVisualizerBase.h:64
virtual void setAlpha(const PacketDropVisualization *packetDropVisualization, double alpha) const =0
void inet::visualizer::PacketDropVisualizerBase::removeAllPacketDropVisualizations ( )
protectedvirtual

Referenced by handleParameterChange().

171 {
172  for (auto packetDropVisualization : packetDropVisualizations) {
173  removePacketDropVisualization(packetDropVisualization);
174  delete packetDropVisualization;
175  }
176 }
virtual void removePacketDropVisualization(const PacketDropVisualization *packetDropVisualization)
Definition: PacketDropVisualizerBase.cc:165
std::vector< const PacketDropVisualization * > packetDropVisualizations
Definition: PacketDropVisualizerBase.h:64
void inet::visualizer::PacketDropVisualizerBase::removePacketDropVisualization ( const PacketDropVisualization packetDropVisualization)
protectedvirtual

Reimplemented in inet::visualizer::PacketDropCanvasVisualizer.

Referenced by refreshDisplay(), removeAllPacketDropVisualizations(), and inet::visualizer::PacketDropCanvasVisualizer::removePacketDropVisualization().

166 {
168 }
void remove(std::vector< T > &v, const A &a)
Definition: stlutils.h:91
std::vector< const PacketDropVisualization * > packetDropVisualizations
Definition: PacketDropVisualizerBase.h:64
virtual void inet::visualizer::PacketDropVisualizerBase::setAlpha ( const PacketDropVisualization packetDropVisualization,
double  alpha 
) const
protectedpure virtual
void inet::visualizer::PacketDropVisualizerBase::subscribe ( )
protectedvirtual

Referenced by initialize().

114 {
115  auto subscriptionModule = getModuleFromPar<cModule>(par("subscriptionModule"), this);
116  subscriptionModule->subscribe(LayeredProtocolBase::packetFromLowerDroppedSignal, this);
117  subscriptionModule->subscribe(LayeredProtocolBase::packetFromUpperDroppedSignal, this);
118  subscriptionModule->subscribe(PassiveQueueBase::dropPkByQueueSignal, this);
119 #ifdef WITH_ETHERNET
120  subscriptionModule->subscribe(EtherMACBase::dropPkIfaceDownSignal, this);
121  subscriptionModule->subscribe(EtherMACBase::dropPkFromHLIfaceDownSignal, this);
122 #endif // WITH_ETHERNET
123  subscriptionModule->subscribe(NF_PACKET_DROP, this);
124 
125 }
static simsignal_t packetFromLowerDroppedSignal
Definition: LayeredProtocolBase.h:34
static simsignal_t dropPkFromHLIfaceDownSignal
Definition: EtherMACBase.h:192
simsignal_t NF_PACKET_DROP
Definition: NotifierConsts.cc:33
static simsignal_t packetFromUpperDroppedSignal
Definition: LayeredProtocolBase.h:30
static simsignal_t dropPkByQueueSignal
Signal with packet when dropped it.
Definition: PassiveQueueBase.h:55
static simsignal_t dropPkIfaceDownSignal
Definition: EtherMACBase.h:191
void inet::visualizer::PacketDropVisualizerBase::unsubscribe ( )
protectedvirtual

Referenced by ~PacketDropVisualizerBase().

128 {
129  // NOTE: lookup the module again because it may have been deleted first
130  auto subscriptionModule = getModuleFromPar<cModule>(par("subscriptionModule"), this, false);
131  if (subscriptionModule != nullptr) {
132  subscriptionModule->unsubscribe(LayeredProtocolBase::packetFromLowerDroppedSignal, this);
133  subscriptionModule->unsubscribe(LayeredProtocolBase::packetFromUpperDroppedSignal, this);
134  subscriptionModule->unsubscribe(PassiveQueueBase::dropPkByQueueSignal, this);
135 #ifdef WITH_ETHERNET
136  subscriptionModule->unsubscribe(EtherMACBase::dropPkIfaceDownSignal, this);
137  subscriptionModule->unsubscribe(EtherMACBase::dropPkFromHLIfaceDownSignal, this);
138 #endif // WITH_ETHERNET
139  subscriptionModule->unsubscribe(NF_PACKET_DROP, this);
140  }
141 }
static simsignal_t packetFromLowerDroppedSignal
Definition: LayeredProtocolBase.h:34
static simsignal_t dropPkFromHLIfaceDownSignal
Definition: EtherMACBase.h:192
simsignal_t NF_PACKET_DROP
Definition: NotifierConsts.cc:33
static simsignal_t packetFromUpperDroppedSignal
Definition: LayeredProtocolBase.h:30
static simsignal_t dropPkByQueueSignal
Signal with packet when dropped it.
Definition: PassiveQueueBase.h:55
static simsignal_t dropPkIfaceDownSignal
Definition: EtherMACBase.h:191

Member Data Documentation

bool inet::visualizer::PacketDropVisualizerBase::displayPacketDrops = false
protected
double inet::visualizer::PacketDropVisualizerBase::fadeOutAnimationSpeed = NaN
protected
const char* inet::visualizer::PacketDropVisualizerBase::fadeOutMode = nullptr
protected

Referenced by initialize(), and refreshDisplay().

double inet::visualizer::PacketDropVisualizerBase::fadeOutTime = NaN
protected

Referenced by initialize(), and refreshDisplay().

const char* inet::visualizer::PacketDropVisualizerBase::icon = nullptr
protected
double inet::visualizer::PacketDropVisualizerBase::iconTintAmount = NaN
protected
cFigure::Color inet::visualizer::PacketDropVisualizerBase::iconTintColor
protected
InterfaceFilter inet::visualizer::PacketDropVisualizerBase::interfaceFilter
protected
cFigure::Color inet::visualizer::PacketDropVisualizerBase::labelColor
protected
cFigure::Font inet::visualizer::PacketDropVisualizerBase::labelFont
protected
NetworkNodeFilter inet::visualizer::PacketDropVisualizerBase::nodeFilter
protected
PacketFilter inet::visualizer::PacketDropVisualizerBase::packetFilter
protected

The documentation for this class was generated from the following files: