OMNeT++ Simulation Library
6.0.3
|
#include <cdataratechannel.h>
A transmission channel model that supports propagation delay, transmission duration computed from a data rate or given explicitly, and a simple error model with based on bit error rate (BER) and packet error rate (PER). The above parameters can be supplied via NED or explicit setter methods.
This class is a transmission channel, i.e. its isTransmissionChannel() method returns true. There can be at most one transmission channel in a connection path.
The treatment of packets depends on the mode setting. In mode=SINGLE, at most one transmission can be active at any given time, and overlapping transmissions are not permitted. In mode=MULTI, multiple concurrent transmissions are allowed, with consistency checking (transmission updates must refer to existing and active transmissions). The UNCHECKED mode is the low-overhead version of MULTI: the channel does not keep track of ongoing transmissions, so there are no consistency checks, and certain functionality is unavailable (e.g. the channel does not emit channelBusy signals).
Non-packet messages are let through at any time, after applying propagation delay only. They do not interfere with ongoing transmissions in any way.
By default, transmission duration is computed from the packet bit length and the channel datarate. The channel datarate is optional; if it is missing, the packet duration needs to be specified explicitly in the send() call (see SendOptions). If both datarate and explicit duration are present, the explicit duration takes precedence.
Allowing to override the duration is useful for a few cases: to account for certain parts in the frame (preamble, padding, PHY-layer header with different datarate, etc.) and for aborting at arbitrary time (for example at a fractional bit time).
The channel supports updating the ongoing transmission (see SendOptions). Duration and remainingDuration are optional, as long as the missing one(s) can be computed from the others. For example, duration can be computed as the elapsed transmission time plus remainingDuration (unless in UNCHECKED mode, when the channel doesn't keep the needed information around). Sanity checks (e.g. duration/remainingDuration cannot be negative, duration >= remainingDuration, etc.) are included.
Public Types | |
enum | Mode { SINGLE, MULTI, UNCHECKED } |
Public Member Functions | |
Redefined cObject member functions. | |
virtual std::string | str () const override |
Setting and getting channel parameters. | |
virtual bool | isTransmissionChannel () const override |
virtual void | setMode (Mode mode) |
virtual void | setDelay (double d) |
virtual void | setDatarate (double d) |
virtual void | setBitErrorRate (double d) |
virtual void | setPacketErrorRate (double d) |
virtual void | setDisabled (bool d) |
virtual Mode | getMode () const |
virtual simtime_t | getDelay () const |
virtual double | getDatarate () const |
virtual double | getBitErrorRate () const |
virtual double | getPacketErrorRate () const |
virtual bool | isDisabled () const override |
Transmission state. | |
virtual double | getNominalDatarate () const override |
virtual simtime_t | calculateDuration (cMessage *msg) const override |
virtual simtime_t | getTransmissionFinishTime () const override |
virtual bool | isBusy () const override |
virtual void | forceTransmissionFinishTime (simtime_t t) override |
Implementation methods | |
virtual void | initialize () override |
virtual Result | processMessage (cMessage *msg, const SendOptions &options, simtime_t t) override |
Public Member Functions inherited from cChannel | |
virtual void | finalizeParameters () override |
cChannel (const char *name=nullptr) | |
virtual | ~cChannel () |
virtual void | callInitialize () override |
virtual bool | callInitialize (int stage) override |
virtual void | callFinish () override |
virtual ComponentKind | getComponentKind () const override |
virtual cModule * | getParentModule () const override |
cChannelType * | getChannelType () const |
virtual cProperties * | getProperties () const override |
virtual cGate * | getSourceGate () const |
Public Member Functions inherited from cComponent | |
cComponent (const char *name=nullptr) | |
virtual | ~cComponent () |
virtual void | forEachChild (cVisitor *v) override |
const cComponent * | getThisPtr () const |
virtual void | setDisplayName (const char *name) |
virtual const char * | getDisplayName () const |
virtual cComponentType * | getComponentType () const |
cSimulation * | getSimulation () const |
int | getId () const |
virtual const char * | getNedTypeName () const |
virtual std::string | getNedTypeAndFullName () const |
virtual std::string | getNedTypeAndFullPath () const |
bool | isModule () const |
bool | isChannel () const |
virtual cModule * | getSystemModule () const |
virtual cModule * | getModuleByPath (const char *path) const |
virtual cModule * | findModuleByPath (const char *path) const |
virtual int | getNumParams () const |
virtual cPar & | par (int k) |
const cPar & | par (int k) const |
virtual cPar & | par (const char *parname) |
const cPar & | par (const char *parname) const |
virtual int | findPar (const char *parname) const |
bool | hasPar (const char *s) const |
virtual cRNG * | getRNG (int k) const |
virtual uint32_t | intrand (uint32_t r, int rng=0) const |
virtual double | dblrand (int rng=0) const |
virtual double | uniform (double a, double b, int rng=0) const |
virtual SimTime | uniform (SimTime a, SimTime b, int rng=0) const |
virtual double | exponential (double mean, int rng=0) const |
virtual SimTime | exponential (SimTime mean, int rng=0) const |
virtual double | normal (double mean, double stddev, int rng=0) const |
virtual SimTime | normal (SimTime mean, SimTime stddev, int rng=0) const |
virtual double | truncnormal (double mean, double stddev, int rng=0) const |
virtual SimTime | truncnormal (SimTime mean, SimTime stddev, int rng=0) const |
virtual double | gamma_d (double alpha, double theta, int rng=0) const |
virtual double | beta (double alpha1, double alpha2, int rng=0) const |
virtual double | erlang_k (unsigned int k, double mean, int rng=0) const |
virtual double | chi_square (unsigned int k, int rng=0) const |
virtual double | student_t (unsigned int i, int rng=0) const |
virtual double | cauchy (double a, double b, int rng=0) const |
virtual double | triang (double a, double b, double c, int rng=0) const |
virtual double | lognormal (double m, double w, int rng=0) const |
virtual double | weibull (double a, double b, int rng=0) const |
virtual double | pareto_shifted (double a, double b, double c, int rng=0) const |
virtual int | intuniform (int a, int b, int rng=0) const |
virtual int | intuniformexcl (int a, int b, int rng=0) const |
virtual int | bernoulli (double p, int rng=0) const |
virtual int | binomial (int n, double p, int rng=0) const |
virtual int | geometric (double p, int rng=0) const |
virtual int | negbinomial (int n, double p, int rng=0) const |
virtual int | poisson (double lambda, int rng=0) const |
virtual void | subscribe (simsignal_t signalID, cIListener *listener) |
virtual void | subscribe (const char *signalName, cIListener *listener) |
virtual void | unsubscribe (simsignal_t signalID, cIListener *listener) |
virtual void | unsubscribe (const char *signalName, cIListener *listener) |
virtual bool | isSubscribed (simsignal_t signalID, cIListener *listener) const |
virtual bool | isSubscribed (const char *signalName, cIListener *listener) const |
virtual std::vector< simsignal_t > | getLocalListenedSignals () const |
virtual std::vector< cIListener * > | getLocalSignalListeners (simsignal_t signalID) const |
virtual bool | hasGUI () const |
virtual cDisplayString & | getDisplayString () const |
virtual void | setDisplayString (const char *dispstr) |
virtual void | bubble (const char *text) const |
virtual std::string | resolveResourcePath (const char *fileName) const |
virtual void | recordScalar (const char *name, double value, const char *unit=nullptr) |
virtual void | recordScalar (const char *name, SimTime value, const char *unit=nullptr) |
virtual void | recordStatistic (cStatistic *stats, const char *unit=nullptr) |
virtual void | recordStatistic (const char *name, cStatistic *stats, const char *unit=nullptr) |
virtual void | emit (simsignal_t signalID, bool b, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, double d, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, const SimTime &t, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, const char *s, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, cObject *obj, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, const cObject *obj, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, char c, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, unsigned char c, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, short i, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, unsigned short i, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, int i, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, unsigned int i, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, long i, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, unsigned long i, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, long long i, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, unsigned long long i, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, float f, cObject *details=nullptr) |
virtual void | emit (simsignal_t signalID, long double d, cObject *details=nullptr) |
bool | mayHaveListeners (simsignal_t signalID) const |
bool | hasListeners (simsignal_t signalID) const |
Public Member Functions inherited from cSoftOwner | |
cSoftOwner (const char *name=nullptr, bool namepooling=true) | |
virtual | ~cSoftOwner () |
virtual bool | isSoftOwner () const override |
int | getNumOwnedObjects () const |
cOwnedObject * | getOwnedObject (int k) |
Public Member Functions inherited from cNoncopyableOwnedObject | |
cNoncopyableOwnedObject (const char *name=nullptr, bool namepooling=true) | |
virtual cNoncopyableOwnedObject * | dup () const override |
Public Member Functions inherited from cOwnedObject | |
cOwnedObject () | |
cOwnedObject (const char *name, bool namepooling=true) | |
cOwnedObject (const cOwnedObject &obj) | |
virtual | ~cOwnedObject () |
cOwnedObject & | operator= (const cOwnedObject &o) |
virtual cObject * | getOwner () const override |
virtual bool | isOwnedObject () const override |
Public Member Functions inherited from cNamedObject | |
cNamedObject () | |
cNamedObject (const char *name, bool namepooling=true) | |
cNamedObject (const cNamedObject &obj) | |
virtual | ~cNamedObject () |
cNamedObject & | operator= (const cNamedObject &o) |
virtual void | setName (const char *s) |
virtual const char * | getName () const override |
virtual void | setNamePooling (bool b) |
virtual bool | getNamePooling () |
Public Member Functions inherited from cObject | |
cObject () | |
cObject (const cObject &other)=default | |
virtual | ~cObject () |
virtual const char * | getClassName () const |
bool | isName (const char *s) const |
virtual const char * | getFullName () const |
virtual std::string | getFullPath () const |
virtual std::string | getClassAndFullName () const |
virtual std::string | getClassAndFullPath () const |
const cObject * | getThisPtr () const |
virtual std::ostream & | printOn (std::ostream &os) const |
cObject * | findObject (const char *name, bool deep=true) |
virtual cClassDescriptor * | getDescriptor () const |
void | copyNotSupported () const |
Protected Member Functions | |
virtual void | handleParameterChange (const char *parname) override |
virtual void | finish () override |
Protected Member Functions inherited from cComponent | |
virtual void | initialize (int stage) |
virtual int | numInitStages () const |
virtual void | refreshDisplay () const |
virtual void | preDelete (cComponent *root) |
Protected Member Functions inherited from cSoftOwner | |
virtual void | take (cOwnedObject *obj) override |
virtual void | drop (cOwnedObject *obj) override |
Protected Member Functions inherited from cObject | |
void | dropAndDelete (cOwnedObject *obj) |
Constructors, destructor | |
cDatarateChannel (const char *name=nullptr) | |
virtual | ~cDatarateChannel () |
static cDatarateChannel * | create (const char *name) |
Additional Inherited Members | |
Static Public Member Functions inherited from cComponent | |
static simsignal_t | registerSignal (const char *name) |
static const char * | getSignalName (simsignal_t signalID) |
Static Public Member Functions inherited from cOwnedObject | |
static long | getTotalObjectCount () |
static long | getLiveObjectCount () |
static void | resetObjectCounters () |
static cSoftOwner * | getOwningContext () |
enum Mode |
Channel operating mode
Enumerator | |
---|---|
SINGLE | Allow a single transmission at a time. |
MULTI | Allow multiple concurrent transmissions, with consistency checks. |
UNCHECKED | Allow multiple concurrent transmissions, with low overhead. In this mode, the channel does not keep track of ongoing transmissions, so there are no consistency checks, the isBusy() and getTransmissionFinishTime() methods are not supported, and the channel does not emit channelBusy signals. |
|
explicit |
Constructor. This is only for internal purposes, and should not be used when creating channels dynamically; use the create() factory method instead.
|
inlinevirtual |
Destructor.
|
overrideprotectedvirtual |
This method is called by the simulation kernel to notify the module or channel that the value of an existing parameter has changed. Redefining this method allows simple modules and channels to be react on parameter changes, for example by re-reading the value. This default implementation does nothing.
Notification is initially disabled until all parameters have been set up, that is, until finalizeParameters() is invoked on this component. However, notifications are enabled while the component goes through (single or multi-stage) initialization. When implementing handleParameterChange(), one must keep in mind that the component may not have been fully initialized at the time of the call (e.g. may not have gone through all init stages yet).
One must be extremely careful when changing parameters from inside handleParameterChange(), to avoid creating infinite notification loops.
Note: before OMNeT++ version 6.0, handleParameterChange() was disabled during the whole initialization process, and handleParameterChange(nullptr) was called after the last stage of the initialization. This is no longer so in version 6.0 or later.
Reimplemented from cComponent.
|
overrideprotectedvirtual |
Finish hook. finish() is called after end of simulation if it terminated without error. This default implementation does nothing.
Reimplemented from cComponent.
|
static |
Utility function for dynamic channel creation. Equivalent to cChannelType::getDatarateChannelType()->create(name)
.
|
overridevirtual |
|
inlineoverridevirtual |
Returns true.
Implements cChannel.
|
virtual |
Sets the operating mode. Switching operating mode during simulation (when the channel is in use) is not allowed.
|
virtual |
Sets the propagation delay of the channel, in seconds.
|
virtual |
Sets the data rate of the channel, in bit/second.
|
virtual |
Sets the bit error rate (BER) of the channel.
|
virtual |
Sets the packet error rate (PER) of the channel.
|
virtual |
Disables or enables the channel.
|
inlinevirtual |
Returns the operating mode.
|
inlinevirtual |
Returns the propagation delay of the channel, in seconds. This method is equivalent to reading the "delay" parameter, via par("delay").
|
inlinevirtual |
Returns the data rate of the channel, in bit/second. This method is equivalent to reading the "datarate" parameter, via par("datarate"). This value affects the transmission time of messages sent through the channel.
|
inlinevirtual |
Returns the bit error rate (BER) of the channel. This method is equivalent to reading the "ber" parameter, via par("ber"). When a message sent through the channel suffers at least one bit error, its bit error flag will be set.
|
inlinevirtual |
Returns the packet error rate (PER) of the channel. This method is equivalent to reading the "per" parameter, via par("per"). When a message is sent through the channel, its bit error flag will be set with this probability.
|
inlineoverridevirtual |
Returns whether the channel is disabled. This method is equivalent to reading the "disabled" parameter, via par("disabled"). A disabled channel discards all messages sent on it.
Reimplemented from cChannel.
|
inlineoverridevirtual |
Same as getDatarate().
Implements cChannel.
Returns the message length in bits divided by the datarate.
Note that processMessage() does NOT call this method, so in order to change the duration computation algorithm via subclassing you need to redefine both this and processMessage().
Implements cChannel.
|
overridevirtual |
Returns the simulation time all transmissions will finish on the (sender side) of the channel. If there is no ongoing transmission, the result is undefined but less or equal the current simulation time.
This method is unsupported (throws exception) in the UNCHECKED mode.
Implements cChannel.
|
overridevirtual |
Returns whether the sender gate is currently transmitting, ie. whether transmissionFinishTime() is greater than the current simulation time.
This method is unsupported (throws exception) in the UNCHECKED mode.
Reimplemented from cChannel.
|
overridevirtual |
DEPRECATED METHOD. It is only provided for backward compatibility with OMNeT++ 5.x.
This method forcibly overwrites the finish time of the current transmission in the channel. It is a crude device that allows implementing aborting transmissions. Models using this method should be migrated to the transmission update API.
Reimplemented from cChannel.
|
overridevirtual |
Initialization.
Reimplemented from cComponent.
|
overridevirtual |
Performs bit error rate, delay and transmission time modelling.
Implements cChannel.