33 #include "IPAddressResolver.h"
52 for (uint32_t i = 0; i <
dim; ++i)
60 for (uint32_t i = 0; i <
dim; ++i)
77 for (
int i = 0; i < this->
getDim(); i++) {
78 if (abs(this->
coords[i] - temp->
coords[i]) > 0.00000001){
90 uint32_t sendQueueLength,
106 cChannelType* typeRx,
107 cChannelType* typeTx,
108 uint32_t sendQueueLength,
111 cModule* udpModule = node->getSubmodule(
"udp");
114 cModule* tcpModule = node->getSubmodule(
"tcp", 0);
123 cDatarateChannel* tempRx =
dynamic_cast<cDatarateChannel*
>(typeRx->create(
"temp"));
124 cDatarateChannel* tempTx =
dynamic_cast<cDatarateChannel*
>(typeTx->create(
"temp"));
144 double sum_of_squares = 0;
149 return sqrt(sum_of_squares);
156 if ((pow(1 -
tx.
errorRate, msg->getByteLength() * 8) <= uniform(0, 1)) ||
157 (pow(1 - dest.
rx.
errorRate, msg->getByteLength() * 8) <= uniform(0, 1))) {
158 msg->setBitError(
true);
161 simtime_t now = simTime();
162 simtime_t bandwidthDelay = ((msg->getByteLength() * 8) /
tx.
bandwidth);
163 simtime_t newTxFinished = std::max(
tx.
finished, now) + bandwidthDelay;
167 EV <<
"[SimpleNodeEntry::calcDelay()]\n"
168 <<
" Send queue overrun"
169 <<
"\n newTxFinished = fmax(txFinished, now) + bandwidthDelay"
170 <<
"\n newTxFinished = " << newTxFinished
172 <<
"\n now = " << now
173 <<
"\n bandwidthDelay = " << bandwidthDelay
174 <<
"\n (newTxFinished > now + txMaxQueueTime) == true"
182 simtime_t destBandwidthDelay = (msg->getByteLength() * 8) / dest.
rx.
bandwidth;
183 simtime_t coordDelay = 0.001 * (*
this - dest);
196 simtime_t now = simTime();
197 simtime_t bandwidthDelay = ((msg->getByteLength() * 8) /
rx.
bandwidth);
199 bandwidthDelay, now);
203 EV <<
"[SimpleNodeEntry::calcAccessRouterDelay()]\n"
204 <<
" Access router send queue overrun"
205 <<
"\n newRxFinished = fmax(rxFinished + accessDelay + bandwidthDelay, now)"
206 <<
"\n newRxFinished = " << newRxFinished
208 <<
"\n now = " << now
209 <<
"\n bandwidthDelay = " << bandwidthDelay
210 <<
"\n (newRxFinished > now + rxMaxQueueTime) == true"
218 std::cout <<
"RouterDelay: " <<
rx.
finished - now << std::endl;
227 char delaystring[35];
228 sprintf(delaystring,
"%.30f", SIMTIME_DBL(oldDelay));
231 uint8_t hashOverDelays[20];
233 sha1.
Update((uint8_t*)delaystring, 32);
238 unsigned int decimalhash = 0;
239 for (
int i = 0; i < 4; i++) {
240 decimalhash += (
unsigned int) hashOverDelays[i] * (2 << (8*(3 - i) - 1));
244 double fraction = (double) decimalhash / (
unsigned int) ((2 << 31) - 1);
247 char sign = (decimalhash % 2 == 0) ? 1 : -1;
251 double errorRatio = 0;
255 errorRatio = pow((1.0 - pow(fraction, 1.0/14.0)), 1.0/2.03) + 0.04;
260 errorRatio = pow((1.0 - pow(fraction, 1.0/50.0)), 1.0/1.95) + 0.105;
265 errorRatio = pow((1.0 - pow(fraction, 1.0/23.0)), 1.0/1.96) + 0.02;
266 std::cout <<
"ErrorRatio: " << errorRatio << std::endl;
280 errorRatio = (errorRatio > 0.6) ? 0.6 : errorRatio;
282 return (oldDelay + sign * errorRatio * oldDelay);
287 std::ostringstream str;