Files
2014-06-30 13:58:10 +02:00

82 lines
2.4 KiB
C++

/*
* File: DroppingChannel.cc
* Author: noackrob
* Author: jgaebler
*
* Created on August 26, 2013, 11:31 AM
*/
#include "DroppingChannel.h"
#include <iostream>
#include "cdisplaystring.h"
namespace ubeeme {
namespace moversight {
Register_Class(DroppingChannel);
/**
* @brief Override the OMNET callback to determine the transmission
* finish time for delivered and dropped message reliable.
*/
simtime_t
DroppingChannel::getTransmissionFinishTime() const {
if (this->isDisabled()){
return simTime();
}
else {
return cDatarateChannel::getTransmissionFinishTime();
}
}
/**
* @brief Initialize the channel
*/
void
DroppingChannel::initialize() {
cDatarateChannel::initialize();
this->startTime = int( this->par("startTime"));
}
/**
* @brief Decorates the channel in tkenv.
*/
void
DroppingChannel::updateConnection() {
/**
* @FIXME The connection turns red, only when the msg 'passes' the channel
* It resets to black color immediately after transmission.
*/
cDisplayString& dis = this->getDisplayString();
dis.setTagArg("ls", 0, "red");
}
/**
* @brief OMNET callback, called if a message delivered via that channel.
* This method encapsulates the channel's functionality.
* @param msg The message to process
* @param t The transmission start time
* @param result The transmission results (propagation delay, transmission duration, discard flag) created by the channel
* @see cChannel::processMessage for more details
*/
void
DroppingChannel::processMessage(cMessage *msg, simtime_t t, result_t& result) {
cDatarateChannel::processMessage(msg, t, result);
// drop the message ?
if (t >= startTime) {
// not implemented in tkenv.cc!! so nothing happens.
this->bubble("DROP");
std::cerr<<"DROP packet "<<msg->getFullName()<<"\n";
this->setDisabled(true);
this->updateConnection();
result.discard = true;
return;
}
}
}
}