#include <SimpleNodeEntry.h>
Public Types | |
typedef std::pair< simtime_t, bool > | SimpleDelay |
Setter for maximum coordinate. | |
Public Member Functions | |
~SimpleNodeEntry () | |
SimpleNodeEntry (cModule *node, cChannelType *type, uint fieldSize, uint sendQueueLength) | |
Constructor for use with 2D random coordinates. | |
SimpleNodeEntry (cModule *node, cChannelType *type, uint sendQueueLength, NodeRecord *nodeRecord, int index) | |
Constructor for more than 2 dimensions. | |
cGate * | getGate () const |
Getter for SimpleUDP ingate. | |
SimpleDelay | calcDelay (const SimpleUDPPacket &msg, const SimpleNodeEntry &dest) |
Calculates delay between two nodes. | |
std::string | info () const |
OMNeT++ info method. | |
simtime_t | getAccessDelay () |
float | getBandwidth () |
float | getErrorRate () |
float | getX () |
float | getY () |
int | getRecordIndex () |
NodeRecord * | getNodeRecord () |
Protected Member Functions | |
float | operator- (const SimpleNodeEntry &entry) const |
Calculates eulklidean distance between two terminals. | |
Protected Attributes | |
cGate * | ingate |
ingate of the SimpleUDP module of this terminal | |
simtime_t | txFinished |
send queue finished | |
simtime_t | txMaxQueueTime |
maximum time for packets to be queued | |
simtime_t | accessDelay |
first hop delay | |
double | bandwidth |
bandwidth in access net | |
double | errorRate |
packet loss rate | |
NodeRecord * | nodeRecord |
int | index |
Friends | |
std::ostream & | operator<< (std::ostream &out, const SimpleNodeEntry &entry) |
Stream output. |
typedef std::pair<simtime_t, bool> SimpleNodeEntry::SimpleDelay |
Setter for maximum coordinate.
size | maximum coordinate Setter for send queue length | |
length | send queue length type for return value of calcDelay() |
SimpleNodeEntry::~SimpleNodeEntry | ( | ) | [inline] |
SimpleNodeEntry::SimpleNodeEntry | ( | cModule * | node, | |
cChannelType * | type, | |||
uint | fieldSize, | |||
uint | sendQueueLength | |||
) |
Constructor for use with 2D random coordinates.
node | pointer to new terminal | |
type | access channel of new terminal | |
fieldSize | length of one side of the coordinate space | |
sendQueueLength | initial send queue size |
00070 { 00071 ingate = node->submodule("udp")->gate("network_in"); 00072 00073 nodeRecord = new NodeRecord(2); 00074 index = -1; 00075 00076 //use random values as coordinates 00077 nodeRecord->coords[0] = uniform(0, fieldSize) - fieldSize / 2; 00078 nodeRecord->coords[1] = uniform(0, fieldSize) - fieldSize / 2; 00079 00080 cBasicChannel* temp = dynamic_cast<cBasicChannel*>(type->create("temp")); 00081 00082 bandwidth = temp->datarate(); 00083 errorRate = temp->error(); 00084 accessDelay = temp->delay(); 00085 00086 txMaxQueueTime = ((float)sendQueueLength * 8) / bandwidth; 00087 txFinished = simulation.simTime(); 00088 00089 delete temp; 00090 }
SimpleNodeEntry::SimpleNodeEntry | ( | cModule * | node, | |
cChannelType * | type, | |||
uint | sendQueueLength, | |||
NodeRecord * | nodeRecord, | |||
int | index | |||
) |
Constructor for more than 2 dimensions.
node | pointer to new terminal | |
type | access channel of new terminal | |
sendQueueLength | length of the send queue in bytes | |
nodeRecord | the node's coordinates | |
index | the position in unusedNodeRecords |
00096 { 00097 ingate = node->submodule("udp")->gate("network_in"); 00098 00099 00100 //this->nodeRecord = new NodeRecord(nodeRecord); 00101 this->nodeRecord = nodeRecord; 00102 this->index = index; 00103 00104 cBasicChannel* temp = dynamic_cast<cBasicChannel*>(type->create("temp")); 00105 00106 bandwidth = temp->datarate(); 00107 errorRate = temp->error(); 00108 accessDelay = temp->delay(); 00109 00110 txMaxQueueTime = ((float)sendQueueLength * 8) / bandwidth; 00111 txFinished = simulation.simTime(); 00112 00113 delete temp; 00114 }
cGate* SimpleNodeEntry::getGate | ( | ) | const [inline] |
Getter for SimpleUDP ingate.
Referenced by SimpleNetConfigurator::handleTimerEvent(), SimpleNetConfigurator::migrateNode(), SimpleNetConfigurator::preKillNode(), and SimpleUDP::processMsgFromApp().
00093 { 00094 return ingate; 00095 };
SimpleNodeEntry::SimpleDelay SimpleNodeEntry::calcDelay | ( | const SimpleUDPPacket & | msg, | |
const SimpleNodeEntry & | dest | |||
) |
Calculates delay between two nodes.
msg | reference to message to get its length for delay calculation, | |
dest | destination terminal |
Referenced by SimpleUDP::processMsgFromApp().
00127 { 00128 if ((pow(1 - errorRate, msg.byteLength() * 8) <= uniform(0, 1)) 00129 || (pow(1 - dest.errorRate, msg.byteLength() * 8) <= uniform(0, 1))) { 00130 00131 return SimpleDelay(0, false); 00132 } 00133 00134 simtime_t now = simulation.simTime(); 00135 simtime_t bandwidthDelay= ((msg.byteLength() * 8) / bandwidth); 00136 simtime_t newTxFinished = fmax(txFinished, now) + bandwidthDelay; 00137 00138 // send queue 00139 if ((newTxFinished > now + txMaxQueueTime) && (txMaxQueueTime != 0)) { 00140 EV << "[SimpleNodeEntry::calcDelay()]\n" 00141 << " Send queue overrun" 00142 << "\n newTxFinished = fmax(txFinished, now) + bandwidthDelay" 00143 << "\n newTxFinished = " << newTxFinished 00144 << "\n txFinished = " << txFinished 00145 << "\n now = " << now 00146 << "\n bandwidthDelay = " << bandwidthDelay 00147 << "\n (newTxFinished > now + txMaxQueueTime) == true" 00148 << "\n txMaxQueueTime = " << txMaxQueueTime 00149 << endl; 00150 return SimpleDelay(0, false); 00151 } 00152 00153 txFinished = newTxFinished; 00154 00155 simtime_t destBandwidthDelay = (msg.byteLength() * 8) / dest.bandwidth; 00156 simtime_t coordDelay = 0.001 * (*this - dest); 00157 00158 return SimpleDelay(txFinished - now 00159 + accessDelay 00160 + coordDelay 00161 + destBandwidthDelay + dest.accessDelay, true); 00162 }
std::string SimpleNodeEntry::info | ( | ) | const |
simtime_t SimpleNodeEntry::getAccessDelay | ( | ) | [inline] |
float SimpleNodeEntry::getBandwidth | ( | ) | [inline] |
float SimpleNodeEntry::getErrorRate | ( | ) | [inline] |
float SimpleNodeEntry::getX | ( | ) | [inline] |
float SimpleNodeEntry::getY | ( | ) | [inline] |
int SimpleNodeEntry::getRecordIndex | ( | ) | [inline] |
Referenced by SimpleNetConfigurator::handleTimerEvent(), and SimpleNetConfigurator::migrateNode().
00154 { return index; };
NodeRecord* SimpleNodeEntry::getNodeRecord | ( | ) | [inline] |
float SimpleNodeEntry::operator- | ( | const SimpleNodeEntry & | entry | ) | const [protected] |
Calculates eulklidean distance between two terminals.
entry | destination entry |
00117 { 00118 double sum_of_squares = 0; 00119 for (uint i = 0; i < nodeRecord->dim; i++) { 00120 sum_of_squares += pow(nodeRecord->coords[i] - 00121 entry.nodeRecord->coords[i], 2); 00122 } 00123 return sqrt(sum_of_squares); 00124 }
std::ostream& operator<< | ( | std::ostream & | out, | |
const SimpleNodeEntry & | entry | |||
) | [friend] |
Stream output.
out | output stream | |
entry | the terminal |
00172 { 00173 out << "(x:" << entry.nodeRecord->coords[0] 00174 << ", y:" << entry.nodeRecord->coords[1] 00175 << ")\nbandwidth = " << entry.bandwidth 00176 << ",\ndelay = " << entry.accessDelay 00177 << ",\nerrorRate = " << entry.errorRate 00178 << ",\ntxMaxQueueTime = " << entry.txMaxQueueTime 00179 << ",\ntxFinished = " << entry.txFinished; 00180 00181 return out; 00182 }
cGate* SimpleNodeEntry::ingate [protected] |
simtime_t SimpleNodeEntry::txFinished [protected] |
simtime_t SimpleNodeEntry::txMaxQueueTime [protected] |
maximum time for packets to be queued
Referenced by calcDelay(), operator<<(), and SimpleNodeEntry().
simtime_t SimpleNodeEntry::accessDelay [protected] |
double SimpleNodeEntry::bandwidth [protected] |
bandwidth in access net
Referenced by calcDelay(), getBandwidth(), operator<<(), and SimpleNodeEntry().
double SimpleNodeEntry::errorRate [protected] |
NodeRecord* SimpleNodeEntry::nodeRecord [protected] |
Referenced by getNodeRecord(), getX(), getY(), operator-(), operator<<(), SimpleNodeEntry(), and ~SimpleNodeEntry().
int SimpleNodeEntry::index [protected] |
Referenced by getRecordIndex(), SimpleNodeEntry(), and ~SimpleNodeEntry().