#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) | |
Constructor. | |
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 | getBandwith () |
float | getErrorRate () |
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 | |
float | x |
x-coordinate | |
float | y |
y-coordinate | |
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 | |
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 | |||
) |
Constructor.
node | pointer to new terminal | |
type | access channel of new terminal |
00036 { 00037 ingate = node->submodule("udp")->gate("network_in"); 00038 00039 x = uniform(0, fieldSize); 00040 y = uniform(0, fieldSize); 00041 00042 cBasicChannel* temp = dynamic_cast<cBasicChannel*>(type->create("temp")); 00043 00044 bandwidth = temp->datarate(); 00045 errorRate = temp->error(); 00046 accessDelay = temp->delay(); 00047 00048 txMaxQueueTime = ((float)sendQueueLength * 8) / bandwidth; 00049 txFinished = simulation.simTime(); // 0? 00050 00051 delete temp; 00052 }
cGate* SimpleNodeEntry::getGate | ( | ) | const [inline] |
static void SimpleNodeEntry::setFieldSize | ( | uint | size | ) | [inline, static] |
Setter for maximum coordinate.
size | maximum coordinate |
00067 { 00068 fieldSize = size; 00069 };
static void SimpleNodeEntry::setSendQueueLength | ( | uint | length | ) | [inline, static] |
Setter for send queue length.
length | send queue length |
00077 { 00078 sendQueueLength = length; 00079 };
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 |
00060 { 00061 if (uniform(0, 1) < errorRate || uniform(0, 1) < dest.errorRate) 00062 return SimpleDelay(0, false); 00063 00064 simtime_t now = simulation.simTime(); 00065 simtime_t bandwidthDelay= ((msg.byteLength() * 8) / bandwidth); 00066 simtime_t newTxFinished = fmax(txFinished, now) + bandwidthDelay; 00067 00068 00069 // send queue 00070 if((newTxFinished > now + txMaxQueueTime) && (txMaxQueueTime != 0)) { 00071 EV << "[SimpleNodeEntry::calcDelay()]\n" 00072 << " Send queue overrun" 00073 << "\n newTxFinished = fmax(txFinished, now) + bandwidthDelay" 00074 << "\n newTxFinished = " << newTxFinished 00075 << "\n txFinished = " << txFinished 00076 << "\n now = " << now 00077 << "\n bandwidthDelay = " << bandwidthDelay 00078 << "\n (newTxFinished > now + txMaxQueueTime) == true" 00079 << "\n txMaxQueueTime = " << txMaxQueueTime 00080 << endl; 00081 return SimpleDelay(0, false); 00082 } 00083 00084 txFinished = newTxFinished; 00085 00086 simtime_t destBandwidthDelay = (msg.byteLength() * 8) / dest.bandwidth; 00087 simtime_t coordDelay = 0.001 * (*this - dest); 00088 00089 return SimpleDelay(txFinished - now 00090 + accessDelay 00091 + coordDelay 00092 + destBandwidthDelay + dest.accessDelay, true); 00093 }
std::string SimpleNodeEntry::info | ( | ) | const |
simtime_t SimpleNodeEntry::getAccessDelay | ( | ) | [inline] |
float SimpleNodeEntry::getBandwith | ( | ) | [inline] |
float SimpleNodeEntry::getErrorRate | ( | ) | [inline] |
float SimpleNodeEntry::operator- | ( | const SimpleNodeEntry & | entry | ) | const [protected] |
std::ostream& operator<< | ( | std::ostream & | out, | |
const SimpleNodeEntry & | entry | |||
) | [friend] |
Stream output.
out | output stream | |
entry | the terminal |
00103 { 00104 out << "(x:" << entry.x << ", y:" << entry.y 00105 << ")\nbandwidth = " << entry.bandwidth 00106 << ",\ndelay = " << entry.accessDelay 00107 << ",\ntxMaxQueueTime = " << entry.txMaxQueueTime 00108 << ",\ntxFinished = " << entry.txFinished; 00109 00110 return out; 00111 }
cGate* SimpleNodeEntry::ingate [protected] |
ingate of the SimpleUDP module of this terminal
float SimpleNodeEntry::x [protected] |
x-coordinate
float SimpleNodeEntry::y [protected] |
y-coordinate
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
uint SimpleNodeEntry::fieldSize [static, protected] |
maximum coordinates
uint SimpleNodeEntry::sendQueueLength [static, protected] |
maximum send queue length of overlay terminals in bytes