#include <SimpleNodeEntry.h>
Public Types | |
typedef std::pair < simtime_t, bool > | SimpleDelay |
type for return value of calcDelay() | |
Public Member Functions | |
SimpleNodeEntry (cModule *node, cChannelType *type, uint fieldSize, uint sendQueueLength) | |
Constructor for use with 2D random coordinates. | |
SimpleNodeEntry (cModule *node, cChannelType *type, int dim, double *coords) | |
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 () |
uint | getFieldSize () |
uint | getSendQueueLength () |
Static Public Member Functions | |
static void | setFieldSize (uint size) |
Setter for maximum coordinate. | |
static void | setSendQueueLength (uint length) |
Setter for send queue length. | |
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 | |
float | bandwidth |
bandwidth in access net | |
float | errorRate |
packet loss rate | |
int | dimensions |
number of coordinates each node has | |
double * | coordinates |
array with all coordinates | |
Static Protected Attributes | |
static uint | fieldSize |
maximum coordinates | |
static uint | sendQueueLength |
maximum send queue length of overlay terminals in bytes | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const SimpleNodeEntry &entry) |
Stream output. |
typedef std::pair<simtime_t, bool> SimpleNodeEntry::SimpleDelay |
type for return value of calcDelay()
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 |
00037 { 00038 //uint fieldSize = size; 00039 //uint sendQueueLength = queueLength; 00040 00041 ingate = node->submodule("udp")->gate("network_in"); 00042 00043 dimensions = 2; 00044 coordinates = new double[2]; 00045 00046 //use random values as coordinates 00047 coordinates[0] = uniform(0, fieldSize) - fieldSize / 2; 00048 coordinates[1] = uniform(0, fieldSize) - fieldSize / 2; 00049 00050 cBasicChannel* temp = dynamic_cast<cBasicChannel*>(type->create("temp")); 00051 00052 bandwidth = temp->datarate(); 00053 errorRate = temp->error(); 00054 accessDelay = temp->delay(); 00055 00056 txMaxQueueTime = ((float)sendQueueLength * 8) / bandwidth; 00057 txFinished = simulation.simTime(); // 0? 00058 00059 delete temp; 00060 }
SimpleNodeEntry::SimpleNodeEntry | ( | cModule * | node, | |
cChannelType * | type, | |||
int | dim, | |||
double * | coords | |||
) |
Constructor for more than 2 dimensions.
node | pointer to new terminal | |
type | access channel of new terminal | |
dim | number of dimensions | |
coords | pointer to array with coordinates |
00066 { 00067 ingate = node->submodule("udp")->gate("network_in"); 00068 00069 dimensions = my_dim; 00070 coordinates = new double[dimensions]; 00071 00072 for (int i=0; i<dimensions; i++) { 00073 coordinates[i] = my_coords[i]; 00074 } 00075 00076 cBasicChannel* temp = dynamic_cast<cBasicChannel*>(type->create("temp")); 00077 00078 bandwidth = temp->datarate(); 00079 errorRate = temp->error(); 00080 accessDelay = temp->delay(); 00081 00082 txMaxQueueTime = ((float)sendQueueLength * 8) / bandwidth; 00083 txFinished = simulation.simTime(); // 0? 00084 00085 delete temp; 00086 }
cGate* SimpleNodeEntry::getGate | ( | ) | const [inline] |
static void SimpleNodeEntry::setFieldSize | ( | uint | size | ) | [inline, static] |
Setter for maximum coordinate.
size | maximum coordinate |
00081 { 00082 fieldSize = size; 00083 };
static void SimpleNodeEntry::setSendQueueLength | ( | uint | length | ) | [inline, static] |
Setter for send queue length.
length | send queue length |
00091 { 00092 sendQueueLength = length; 00093 };
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 |
00098 { 00099 if (uniform(0, 1) < errorRate || uniform(0, 1) < dest.errorRate) 00100 return SimpleDelay(0, false); 00101 00102 simtime_t now = simulation.simTime(); 00103 simtime_t bandwidthDelay= ((msg.byteLength() * 8) / bandwidth); 00104 simtime_t newTxFinished = fmax(txFinished, now) + bandwidthDelay; 00105 00106 // send queue 00107 if ((newTxFinished > now + txMaxQueueTime) && (txMaxQueueTime != 0)) { 00108 EV << "[SimpleNodeEntry::calcDelay()]\n" 00109 << " Send queue overrun" 00110 << "\n newTxFinished = fmax(txFinished, now) + bandwidthDelay" 00111 << "\n newTxFinished = " << newTxFinished 00112 << "\n txFinished = " << txFinished 00113 << "\n now = " << now 00114 << "\n bandwidthDelay = " << bandwidthDelay 00115 << "\n (newTxFinished > now + txMaxQueueTime) == true" 00116 << "\n txMaxQueueTime = " << txMaxQueueTime 00117 << endl; 00118 return SimpleDelay(0, false); 00119 } 00120 00121 txFinished = newTxFinished; 00122 00123 simtime_t destBandwidthDelay = (msg.byteLength() * 8) / dest.bandwidth; 00124 simtime_t coordDelay = 0.001 * (*this - dest); 00125 00126 return SimpleDelay(txFinished - now 00127 + accessDelay 00128 + coordDelay 00129 + destBandwidthDelay + dest.accessDelay, true); 00130 }
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] |
uint SimpleNodeEntry::getFieldSize | ( | ) | [inline] |
uint SimpleNodeEntry::getSendQueueLength | ( | ) | [inline] |
float SimpleNodeEntry::operator- | ( | const SimpleNodeEntry & | entry | ) | const [protected] |
Calculates eulklidean distance between two terminals.
entry | destination entry |
00089 { 00090 double sum_of_squares = 0; 00091 for (int i = 0; i < dimensions; i++) { 00092 sum_of_squares += pow(coordinates[i] - entry.coordinates[i], 2); 00093 } 00094 return sqrt(sum_of_squares); 00095 }
std::ostream& operator<< | ( | std::ostream & | out, | |
const SimpleNodeEntry & | entry | |||
) | [friend] |
Stream output.
out | output stream | |
entry | the terminal |
00140 { 00141 out << "(x:" << entry.coordinates[0] << ", y:" << entry.coordinates[1] 00142 << ")\nbandwidth = " << entry.bandwidth 00143 << ",\ndelay = " << entry.accessDelay 00144 << ",\ntxMaxQueueTime = " << entry.txMaxQueueTime 00145 << ",\ntxFinished = " << entry.txFinished; 00146 00147 return out; 00148 }
cGate* SimpleNodeEntry::ingate [protected] |
ingate of the SimpleUDP module of this terminal
simtime_t SimpleNodeEntry::txFinished [protected] |
send queue finished
simtime_t SimpleNodeEntry::txMaxQueueTime [protected] |
maximum time for packets to be queued
simtime_t SimpleNodeEntry::accessDelay [protected] |
first hop delay
float SimpleNodeEntry::bandwidth [protected] |
bandwidth in access net
float SimpleNodeEntry::errorRate [protected] |
packet loss rate
int SimpleNodeEntry::dimensions [protected] |
number of coordinates each node has
double* SimpleNodeEntry::coordinates [protected] |
array with all coordinates
uint SimpleNodeEntry::fieldSize [static, protected] |
maximum coordinates
uint SimpleNodeEntry::sendQueueLength [static, protected] |
maximum send queue length of overlay terminals in bytes