representation of a single node in the GlobalNodeList More...
#include <SimpleNodeEntry.h>
Classes | |
| struct | Channel |
Public Types | |
| typedef std::pair< simtime_t, bool > | SimpleDelay |
| type for return value of calcDelay() | |
Public Member Functions | |
| ~SimpleNodeEntry () | |
| SimpleNodeEntry (cModule *node, cChannelType *typeRx, cChannelType *typeTx, uint32_t sendQueueLength, uint32_t fieldSize) | |
| Constructor for node entries with 2D random coordinates. | |
| SimpleNodeEntry (cModule *node, cChannelType *typeRx, cChannelType *typeTx, uint32_t sendQueueLength, NodeRecord *nodeRecord, int index) | |
| Constructor for node entries with given n-dim coordinates. | |
| cGate * | getUdpIPv4Gate () const |
| Getter for SimpleUDP ingate. | |
| cGate * | getUdpIPv6Gate () const |
| Getter for SimpleUDP IPv6 ingate. | |
| cGate * | getTcpIPv4Gate () const |
| Getter for SimpleUDP ingate. | |
| cGate * | getTcpIPv6Gate () const |
| Getter for SimpleUDP IPv6 ingate. | |
| SimpleDelay | calcDelay (cPacket *msg, const SimpleNodeEntry &dest, bool faultyDelay=false) |
| Calculates delay between two nodes. | |
| std::string | info () const |
| OMNeT++ info method. | |
| simtime_t | getAccessDelay () const |
| simtime_t | getTxAccessDelay () const |
| simtime_t | getRxAccessDelay () const |
| float | getBandwidth () const |
| float | getTxBandwidth () const |
| float | getRxBandwidth () const |
| float | getErrorRate () const |
| float | getX () const |
| float | getY () const |
| float | getCoords (int dim) const |
| uint8_t | getDim () const |
| int | getRecordIndex () const |
| NodeRecord * | getNodeRecord () const |
Static Public Member Functions | |
| static simtime_t | getFaultyDelay (simtime_t oldDelay) |
| Calculates SHA1 hash over errorfree delay (always the same uniform distributed value), uses this to generate a realistic error distribution and returns the real RTT augmented with this error. | |
Protected Member Functions | |
| float | operator- (const SimpleNodeEntry &entry) const |
| Calculates euclidean distance between two terminals. | |
Protected Attributes | |
| cGate * | UdpIPv4ingate |
| IPv4 ingate of the SimpleUDP module of this terminal. | |
| cGate * | UdpIPv6ingate |
| IPv6 ingate of the SimpleUDP module of this terminal. | |
| cGate * | TcpIPv4ingate |
| IPv4 ingate of the SimpleTCP module of this terminal. | |
| cGate * | TcpIPv6ingate |
| IPv6 ingate of the SimpleTCP module of this terminal. | |
| struct SimpleNodeEntry::Channel | rx |
| struct SimpleNodeEntry::Channel | tx |
| NodeRecord * | nodeRecord |
| int | index |
Friends | |
| std::ostream & | operator<< (std::ostream &out, const SimpleNodeEntry &entry) |
| Stream output. | |
representation of a single node in the GlobalNodeList
Definition at line 59 of file SimpleNodeEntry.h.
| typedef std::pair<simtime_t, bool> SimpleNodeEntry::SimpleDelay |
type for return value of calcDelay()
Definition at line 132 of file SimpleNodeEntry.h.
| SimpleNodeEntry::~SimpleNodeEntry | ( | ) | [inline] |
Definition at line 63 of file SimpleNodeEntry.h.
{
if (index == -1) delete nodeRecord;
}
| SimpleNodeEntry::SimpleNodeEntry | ( | cModule * | node, | |
| cChannelType * | typeRx, | |||
| cChannelType * | typeTx, | |||
| uint32_t | sendQueueLength, | |||
| uint32_t | fieldSize | |||
| ) |
Constructor for node entries with 2D random coordinates.
| node | pointer to new terminal | |
| typeRx | receive access channel of new terminal | |
| typeTx | transmit access channel of new terminal | |
| sendQueueLength | initial send queue size | |
| fieldSize | length of one side of the coordinate space |
Definition at line 66 of file SimpleNodeEntry.cc.
{
assert(NodeRecord::dim == 2);
cModule* udpModule = node->getSubmodule("udp");
UdpIPv4ingate = udpModule->gate("ipIn");
UdpIPv6ingate = udpModule->gate("ipv6In");
cModule* tcpModule = node->getSubmodule("tcp", 0);
if (tcpModule) {
TcpIPv4ingate = tcpModule->gate("ipIn");
TcpIPv6ingate = tcpModule->gate("ipv6In");
}
nodeRecord = new NodeRecord;
index = -1;
//use random values as coordinates
nodeRecord->coords[0] = uniform(0, fieldSize) - fieldSize / 2;
nodeRecord->coords[1] = uniform(0, fieldSize) - fieldSize / 2;
cDatarateChannel* tempRx = dynamic_cast<cDatarateChannel*>(typeRx->create("temp"));
cDatarateChannel* tempTx = dynamic_cast<cDatarateChannel*>(typeTx->create("temp"));
rx.bandwidth = tempRx->par("datarate");
rx.errorRate = tempRx->par("ber");
rx.accessDelay = tempRx->par("delay");
rx.maxQueueTime = 0;
rx.finished = simTime();
tx.bandwidth = tempTx->par("datarate");
tx.errorRate = tempTx->par("ber");
tx.accessDelay = tempTx->par("delay");
tx.maxQueueTime = (sendQueueLength * 8.) / tx.bandwidth;
tx.finished = simTime();
delete tempRx;
delete tempTx;
}
| SimpleNodeEntry::SimpleNodeEntry | ( | cModule * | node, | |
| cChannelType * | typeRx, | |||
| cChannelType * | typeTx, | |||
| uint32_t | sendQueueLength, | |||
| NodeRecord * | nodeRecord, | |||
| int | index | |||
| ) |
Constructor for node entries with given n-dim coordinates.
| node | pointer to new terminal | |
| typeRx | receive access channel of new terminal | |
| typeTx | transmit access channel of new terminal | |
| sendQueueLength | length of the send queue in bytes | |
| nodeRecord | the node's coordinates | |
| index | the position in unusedNodeRecords |
Definition at line 108 of file SimpleNodeEntry.cc.
{
cModule* udpModule = node->getSubmodule("udp");
UdpIPv4ingate = udpModule->gate("ipIn");
UdpIPv6ingate = udpModule->gate("ipv6In");
cModule* tcpModule = node->getSubmodule("tcp", 0);
if (tcpModule) {
TcpIPv4ingate = tcpModule->gate("ipIn");
TcpIPv6ingate = tcpModule->gate("ipv6In");
}
this->nodeRecord = nodeRecord;
this->index = index;
cDatarateChannel* tempRx = dynamic_cast<cDatarateChannel*>(typeRx->create("temp"));
cDatarateChannel* tempTx = dynamic_cast<cDatarateChannel*>(typeTx->create("temp"));
rx.bandwidth = tempRx->par("datarate");
rx.errorRate = tempRx->par("ber");
rx.accessDelay = tempRx->par("delay");
rx.maxQueueTime = 0;
rx.finished = simTime();
tx.bandwidth = tempTx->par("datarate");
tx.errorRate = tempTx->par("ber");
tx.accessDelay = tempTx->par("delay");
tx.maxQueueTime = (sendQueueLength * 8.) / tx.bandwidth;
tx.finished = simTime();
delete tempRx;
delete tempTx;
}
| SimpleNodeEntry::SimpleDelay SimpleNodeEntry::calcDelay | ( | cPacket * | msg, | |
| const SimpleNodeEntry & | dest, | |||
| bool | faultyDelay = false | |||
| ) |
Calculates delay between two nodes.
| msg | pointer to message to get its length for delay calculation and set bit error flag | |
| dest | destination terminal | |
| faultyDelay | violate triangle inequality? |
Definition at line 155 of file SimpleNodeEntry.cc.
Referenced by SimpleUDP::processMsgFromApp(), and SimpleTCPConnection::sendToIP().
{
if ((pow(1 - tx.errorRate, msg->getByteLength() * 8) <= uniform(0, 1)) ||
(pow(1 - dest.rx.errorRate, msg->getByteLength() * 8) <= uniform(0, 1))) {
msg->setBitError(true);
}
simtime_t now = simTime();
simtime_t bandwidthDelay= ((msg->getByteLength() * 8) / tx.bandwidth);
simtime_t newTxFinished = std::max(tx.finished, now) + bandwidthDelay;
// send queue
if ((newTxFinished > now + tx.maxQueueTime) && (tx.maxQueueTime != 0)) {
EV << "[SimpleNodeEntry::calcDelay()]\n"
<< " Send queue overrun"
<< "\n newTxFinished = fmax(txFinished, now) + bandwidthDelay"
<< "\n newTxFinished = " << newTxFinished
<< "\n tx.finished = " << tx.finished
<< "\n now = " << now
<< "\n bandwidthDelay = " << bandwidthDelay
<< "\n (newTxFinished > now + txMaxQueueTime) == true"
<< "\n tx.maxQueueTime = " << tx.maxQueueTime
<< endl;
return SimpleDelay(0, false);
}
tx.finished = newTxFinished;
simtime_t destBandwidthDelay = (msg->getByteLength() * 8) / dest.rx.bandwidth;
simtime_t coordDelay = 0.001 * (*this - dest);
if (faultyDelay)
coordDelay = getFaultyDelay(coordDelay);
return SimpleDelay(tx.finished - now
+ tx.accessDelay
+ coordDelay
+ destBandwidthDelay + dest.rx.accessDelay, true);
}
| simtime_t SimpleNodeEntry::getAccessDelay | ( | ) | const [inline] |
Definition at line 164 of file SimpleNodeEntry.h.
{ return tx.accessDelay; };
| float SimpleNodeEntry::getBandwidth | ( | ) | const [inline] |
Definition at line 170 of file SimpleNodeEntry.h.
| float SimpleNodeEntry::getCoords | ( | int | dim | ) | const [inline] |
Definition at line 179 of file SimpleNodeEntry.h.
Referenced by Nps::coordsReqRpcResponse(), SimpleNcs::init(), and Landmark::initializeApp().
{ return nodeRecord->coords[dim]; };
| uint8_t SimpleNodeEntry::getDim | ( | ) | const [inline] |
Definition at line 180 of file SimpleNodeEntry.h.
Referenced by Nps::coordsReqRpcResponse(), SimpleNcs::init(), and Landmark::initializeApp().
{ return nodeRecord->getDim(); };
| float SimpleNodeEntry::getErrorRate | ( | ) | const [inline] |
Definition at line 175 of file SimpleNodeEntry.h.
| simtime_t SimpleNodeEntry::getFaultyDelay | ( | simtime_t | oldDelay | ) | [static] |
Calculates SHA1 hash over errorfree delay (always the same uniform distributed value), uses this to generate a realistic error distribution and returns the real RTT augmented with this error.
Definition at line 197 of file SimpleNodeEntry.cc.
Referenced by calcDelay().
{
// hash over string of oldDelay
char delaystring[35];
sprintf(delaystring, "%.30f", SIMTIME_DBL(oldDelay));
CSHA1 sha1;
uint8_t hashOverDelays[20];
sha1.Reset();
sha1.Update((uint8_t*)delaystring, 32);
sha1.Final();
sha1.GetHash(hashOverDelays);
// get the hash's first 4 bytes == 32 bits as one unsigned integer
unsigned int decimalhash = 0;
for (int i = 0; i < 4; i++) {
decimalhash += (unsigned int) hashOverDelays[i] * (2 << (8*(3 - i) - 1));
}
// normalize decimal hash value onto 0..1 (decimal number / 2^32-1)
double fraction = (double) decimalhash / (unsigned int) ((2 << 31) - 1);
// flip a coin if faulty rtt is larger or smaller
char sign = (decimalhash % 2 == 0) ? 1 : -1;
// get the error ratio according to the distributions in
// "Network Coordinates in the Wild", Figure 7
double errorRatio = 0;
switch (SimpleUDP::delayFaultTypeMap[SimpleUDP::delayFaultTypeString]) {
case SimpleUDP::delayFaultLiveAll:
// Kumaraswamy, a=2.03, b=14, moved by 0.04 to the right
errorRatio = pow((1.0 - pow(fraction, 1.0/14.0)), 1.0/2.03) + 0.04;
break;
case SimpleUDP::delayFaultLivePlanetlab:
// Kumaraswamy, a=1.95, b=50, moved by 0.105 to the right
errorRatio = pow((1.0 - pow(fraction, 1.0/50.0)), 1.0/1.95) + 0.105;
break;
case SimpleUDP::delayFaultSimulation:
// Kumaraswamy, a=1.96, b=23, moved by 0.02 to the right
errorRatio = pow((1.0 - pow(fraction, 1.0/23.0)), 1.0/1.96) + 0.02;
std::cout << "ErrorRatio: " << errorRatio << std::endl;
break;
default:
break;
}
/*
std::cout << "decimalhash: " << decimalhash << " -- fraction: " << fraction << " -- errorRatio: " << errorRatio << std::endl;
std::cout << SimpleUDP::delayFaultTypeString << " -- " << "old: " << oldDelay << " -- new: " << oldDelay + sign * errorRatio * oldDelay << std::endl;
*/
// If faulty rtt is smaller, set errorRatio to max 0.6
errorRatio = (sign == -1 && errorRatio > 0.6) ? 0.6 : errorRatio;
return oldDelay + sign * errorRatio * oldDelay;
}
| NodeRecord* SimpleNodeEntry::getNodeRecord | ( | ) | const [inline] |
Definition at line 183 of file SimpleNodeEntry.h.
Referenced by SimpleUnderlayConfigurator::migrateNode().
{ return nodeRecord; };
| int SimpleNodeEntry::getRecordIndex | ( | ) | const [inline] |
Definition at line 182 of file SimpleNodeEntry.h.
Referenced by SimpleUnderlayConfigurator::handleTimerEvent(), and SimpleUnderlayConfigurator::migrateNode().
{ return index; };
| simtime_t SimpleNodeEntry::getRxAccessDelay | ( | ) | const [inline] |
Definition at line 167 of file SimpleNodeEntry.h.
Referenced by SimpleNcs::init().
{ return rx.accessDelay; };
| float SimpleNodeEntry::getRxBandwidth | ( | ) | const [inline] |
Definition at line 173 of file SimpleNodeEntry.h.
Referenced by SimpleNcs::init().
| cGate* SimpleNodeEntry::getTcpIPv4Gate | ( | ) | const [inline] |
Getter for SimpleUDP ingate.
Definition at line 119 of file SimpleNodeEntry.h.
Referenced by SimpleTCPConnection::sendToIP().
{
return TcpIPv4ingate;
};
| cGate* SimpleNodeEntry::getTcpIPv6Gate | ( | ) | const [inline] |
Getter for SimpleUDP IPv6 ingate.
Definition at line 129 of file SimpleNodeEntry.h.
Referenced by SimpleTCPConnection::sendToIP().
{
return TcpIPv6ingate;
};
| simtime_t SimpleNodeEntry::getTxAccessDelay | ( | ) | const [inline] |
Definition at line 166 of file SimpleNodeEntry.h.
Referenced by SimpleNcs::init().
{ return tx.accessDelay; };
| float SimpleNodeEntry::getTxBandwidth | ( | ) | const [inline] |
Definition at line 172 of file SimpleNodeEntry.h.
Referenced by SimpleNcs::init().
| cGate* SimpleNodeEntry::getUdpIPv4Gate | ( | ) | const [inline] |
Getter for SimpleUDP ingate.
Definition at line 99 of file SimpleNodeEntry.h.
Referenced by SimpleUnderlayConfigurator::handleTimerEvent(), SimpleUnderlayConfigurator::migrateNode(), SimpleUnderlayConfigurator::preKillNode(), and SimpleUDP::processMsgFromApp().
{
return UdpIPv4ingate;
};
| cGate* SimpleNodeEntry::getUdpIPv6Gate | ( | ) | const [inline] |
Getter for SimpleUDP IPv6 ingate.
Definition at line 109 of file SimpleNodeEntry.h.
Referenced by SimpleUDP::processMsgFromApp().
{
return UdpIPv6ingate;
};
| float SimpleNodeEntry::getX | ( | ) | const [inline] |
Definition at line 177 of file SimpleNodeEntry.h.
Referenced by SimpleUnderlayConfigurator::createNode().
{ return nodeRecord->coords[0]; };
| float SimpleNodeEntry::getY | ( | ) | const [inline] |
Definition at line 178 of file SimpleNodeEntry.h.
Referenced by SimpleUnderlayConfigurator::createNode().
{ return nodeRecord->coords[1]; };
| std::string SimpleNodeEntry::info | ( | ) | const |
OMNeT++ info method.
Definition at line 256 of file SimpleNodeEntry.cc.
{
std::ostringstream str;
str << *this;
return str.str();
}
| float SimpleNodeEntry::operator- | ( | const SimpleNodeEntry & | entry | ) | const [protected] |
Calculates euclidean distance between two terminals.
| entry | destination entry |
Definition at line 145 of file SimpleNodeEntry.cc.
{
double sum_of_squares = 0;
for (uint32_t i = 0; i < nodeRecord->dim; i++) {
sum_of_squares += pow(nodeRecord->coords[i] -
entry.nodeRecord->coords[i], 2);
}
return sqrt(sum_of_squares);
}
| std::ostream& operator<< | ( | std::ostream & | out, | |
| const SimpleNodeEntry & | entry | |||
| ) | [friend] |
Stream output.
| out | output stream | |
| entry | the terminal |
Definition at line 263 of file SimpleNodeEntry.cc.
{
out << "(";
for (uint8_t i = 0; i < NodeRecord::dim; i++) {
out << "dim" << i <<": " << entry.nodeRecord->coords[i];
out << ", ";
}
// out << ", y:" << entry.nodeRecord->coords[1]
out << ")\n[rx]"
<< "\nbandwidth = " << entry.rx.bandwidth
<< ",\ndelay = " << entry.rx.accessDelay
<< ",\nerrorRate = " << entry.rx.errorRate
<< ",\ntxMaxQueueTime = " << entry.rx.maxQueueTime
<< ",\ntxFinished = " << entry.rx.finished;
out << "\n[tx]"
<< "\nbandwidth = " << entry.tx.bandwidth
<< ",\ndelay = " << entry.tx.accessDelay
<< ",\nerrorRate = " << entry.tx.errorRate
<< ",\ntxMaxQueueTime = " << entry.tx.maxQueueTime
<< ",\ntxFinished = " << entry.tx.finished;
return out;
}
int SimpleNodeEntry::index [protected] |
Definition at line 217 of file SimpleNodeEntry.h.
Referenced by getRecordIndex(), SimpleNodeEntry(), and ~SimpleNodeEntry().
NodeRecord* SimpleNodeEntry::nodeRecord [protected] |
Definition at line 216 of file SimpleNodeEntry.h.
Referenced by getCoords(), getDim(), getNodeRecord(), getX(), getY(), operator-(), operator<<(), SimpleNodeEntry(), and ~SimpleNodeEntry().
struct SimpleNodeEntry::Channel SimpleNodeEntry::rx [protected] |
Referenced by calcDelay(), getRxAccessDelay(), getRxBandwidth(), operator<<(), and SimpleNodeEntry().
cGate* SimpleNodeEntry::TcpIPv4ingate [protected] |
IPv4 ingate of the SimpleTCP module of this terminal.
Definition at line 205 of file SimpleNodeEntry.h.
Referenced by getTcpIPv4Gate(), and SimpleNodeEntry().
cGate* SimpleNodeEntry::TcpIPv6ingate [protected] |
IPv6 ingate of the SimpleTCP module of this terminal.
Definition at line 206 of file SimpleNodeEntry.h.
Referenced by getTcpIPv6Gate(), and SimpleNodeEntry().
struct SimpleNodeEntry::Channel SimpleNodeEntry::tx [protected] |
Referenced by calcDelay(), getAccessDelay(), getBandwidth(), getErrorRate(), getTxAccessDelay(), getTxBandwidth(), operator<<(), and SimpleNodeEntry().
cGate* SimpleNodeEntry::UdpIPv4ingate [protected] |
IPv4 ingate of the SimpleUDP module of this terminal.
Definition at line 203 of file SimpleNodeEntry.h.
Referenced by getUdpIPv4Gate(), and SimpleNodeEntry().
cGate* SimpleNodeEntry::UdpIPv6ingate [protected] |
IPv6 ingate of the SimpleUDP module of this terminal.
Definition at line 204 of file SimpleNodeEntry.h.
Referenced by getUdpIPv6Gate(), and SimpleNodeEntry().
1.7.1