#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 |
00035 { 00036 ingate = node->submodule("udp")->gate("network_in"); 00037 00038 x = uniform(0, fieldSize); 00039 y = uniform(0, fieldSize); 00040 00041 cBasicChannel* temp = dynamic_cast<cBasicChannel*>(type->create("temp")); 00042 00043 bandwidth = temp->datarate(); 00044 errorRate = temp->error(); 00045 accessDelay = temp->delay(); 00046 00047 txMaxQueueTime = ((float)sendQueueLength * 8) / bandwidth; 00048 txFinished = simulation.simTime(); // 0? 00049 00050 delete temp; 00051 }
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 |
00059 { 00060 if (uniform(0, 1) < errorRate || uniform(0, 1) < dest.errorRate) 00061 return SimpleDelay(0, false); 00062 00063 simtime_t now = simulation.simTime(); 00064 simtime_t bandwidthDelay= ((msg.byteLength() * 8) / bandwidth); 00065 simtime_t newTxFinished = fmax(txFinished, now) + bandwidthDelay; 00066 00067 // send queue 00068 if((newTxFinished > now + txMaxQueueTime) && (txMaxQueueTime != 0)) { 00069 EV << "(SimpleNodeEntry::calcDelay()) send queue overrun!\n" 00070 << " newTxFinished = fmax(txFinished, now) + bandwidthDelay\n" 00071 << " newTxFinished = " << newTxFinished 00072 << "\n txFinished = " << txFinished 00073 << "\n now = " << now 00074 << "\n bandwidthDelay = " << bandwidthDelay 00075 << "\n (newTxFinished > now + txMaxQueueTime) == true" 00076 << "\n txMaxQueueTime = " << txMaxQueueTime << endl; 00077 00078 return SimpleDelay(0, false); 00079 } 00080 00081 txFinished = newTxFinished; 00082 00083 simtime_t destBandwidthDelay = (msg.byteLength() * 8) / dest.bandwidth; 00084 simtime_t coordDelay = 0.001 * (*this - dest); 00085 00086 return SimpleDelay(txFinished - now 00087 + accessDelay 00088 + coordDelay 00089 + destBandwidthDelay + dest.accessDelay, true); 00090 }
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 |
00100 { 00101 out << "(x:" << entry.x << ", y:" << entry.y 00102 << ")\nbandwidth = " << entry.bandwidth 00103 << ",\ndelay = " << entry.accessDelay 00104 << ",\ntxMaxQueueTime = " << entry.txMaxQueueTime 00105 << ",\ntxFinished = " << entry.txFinished; 00106 00107 return out; 00108 }
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