Skip to content

Commit

Permalink
RadioMedium: Added sameTransmissionStartTimeCheck parameter.
Browse files Browse the repository at this point in the history
It specifies what should happen if two transmissions start at the same moment.
  • Loading branch information
levy committed Dec 10, 2024
1 parent 51d46fc commit 282b225
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/inet/physicallayer/wireless/common/medium/RadioMedium.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ void RadioMedium::initialize(int stage)
recordReceptionLog = par("recordReceptionLog");
if (recordTransmissionLog || recordReceptionLog)
communicationLog.open();
sameTransmissionStartTimeCheck = par("sameTransmissionStartTimeCheck");
}
else if (stage == INITSTAGE_LAST)
EV_INFO << "Initialized " << getCompleteStringRepresentation() << endl;
Expand Down Expand Up @@ -460,6 +461,25 @@ void RadioMedium::addTransmission(const IRadio *transmitterRadio, const ITransmi
{
Enter_Method("addTransmission");
transmissionCount++;
if (*sameTransmissionStartTimeCheck != 'i') {
int count = 0;
communicationCache->mapTransmissions([&] (const ITransmission *ongoingTransmission) {
if (ongoingTransmission->getStartTime() == transmission->getStartTime()) {
if (*sameTransmissionStartTimeCheck == 'w')
count++;
else
throw cRuntimeError("Another transmission is already started at precisely the same simulation time!\n\n"
"Such exact coincidence is highly unlikely in the real world and typically indicates a configuration issue."
"It suggests that applications or protocols are set up in a way that synchronizes the transmission timing across multiple network nodes."
"This can lead to undesired behavior that is statistically improbable in the real world."
"For instance, two nodes may repeatedly broadcast packets without detecting channel activity, causing interference and preventing successful receptions."
"One way of addressing this, is randomizing the start time parameters of applications or protocols.\n\n"
"If needed, you can disable this check by setting the RadioMedium module's 'sameTransmissionStartTimeCheck' parameter.\n\n");
}
});
if (count != 0)
EV_WARN << "There are " << count << " other transmissions started at precisely the same simulation time" << EV_ENDL;
}
communicationCache->addTransmission(transmission);
simtime_t maxArrivalEndTime = transmission->getEndTime();
communicationCache->mapRadios([&] (const IRadio *receiverRadio) {
Expand Down
4 changes: 4 additions & 0 deletions src/inet/physicallayer/wireless/common/medium/RadioMedium.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ class INET_API RadioMedium : public cSimpleModule, public cListener, public IRad
*/
bool recordTransmissionLog;
bool recordReceptionLog;
/**
* Specifies what should happen if two transmissions start at the same moment
*/
const char *sameTransmissionStartTimeCheck = nullptr;
//@}

/** @name Timer */
Expand Down
2 changes: 2 additions & 0 deletions src/inet/physicallayer/wireless/common/medium/RadioMedium.ned
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ module RadioMedium like IRadioMedium
bool recordTransmissionLog = default(false); // When enabled, the medium writes one line per transmission into the communication log file
bool recordReceptionLog = default(false); // When enabled, the medium writes one line per reception into the communication log file

string sameTransmissionStartTimeCheck @enum("ignore", "warning", "error") = default("error"); // Specifies what should happen if two transmissions start at the same moment

@class(RadioMedium);
@display("i=misc/sun");

Expand Down

0 comments on commit 282b225

Please sign in to comment.