SimpleNodeEntry Class Reference

#include <SimpleNodeEntry.h>

List of all members.


Detailed Description

representation of a single node in the GlobalNodeList

Author:
Bernhard Heep

Definition at line 55 of file SimpleNodeEntry.h.


Public Types

typedef std::pair< simtime_t,
bool > 
SimpleDelay
 Setter for maximum coordinate.

Public Member Functions

 ~SimpleNodeEntry ()
 SimpleNodeEntry (cModule *node, cChannelType *type, uint32_t fieldSize, uint32_t sendQueueLength)
 Constructor for use with 2D random coordinates.
 SimpleNodeEntry (cModule *node, cChannelType *type, uint32_t sendQueueLength, NodeRecord *nodeRecord, int index)
 Constructor for more than 2 dimensions.
cGate * getGate () const
 Getter for SimpleUDP ingate.
SimpleDelay calcDelay (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.

Member Typedef Documentation

typedef std::pair<simtime_t, bool> SimpleNodeEntry::SimpleDelay

Setter for maximum coordinate.

Parameters:
size maximum coordinate Setter for send queue length
length send queue length type for return value of calcDelay()

Definition at line 95 of file SimpleNodeEntry.h.


Constructor & Destructor Documentation

SimpleNodeEntry::~SimpleNodeEntry (  )  [inline]

Definition at line 59 of file SimpleNodeEntry.h.

00060     {
00061         if (index == -1) delete nodeRecord;
00062     }

SimpleNodeEntry::SimpleNodeEntry ( cModule *  node,
cChannelType *  type,
uint32_t  fieldSize,
uint32_t  sendQueueLength 
)

Constructor for use with 2D random coordinates.

Parameters:
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

Definition at line 62 of file SimpleNodeEntry.cc.

00066 {
00067     ingate = node->getSubmodule("udp")->gate("network_in");
00068 
00069     nodeRecord = new NodeRecord(2);
00070     index = -1;
00071 
00072     //use random values as coordinates
00073     nodeRecord->coords[0] = uniform(0, fieldSize) - fieldSize / 2;
00074     nodeRecord->coords[1] = uniform(0, fieldSize) - fieldSize / 2;
00075 
00076     cDatarateChannel* temp = dynamic_cast<cDatarateChannel*>(type->create("temp"));
00077 
00078     bandwidth = temp->par("datarate");
00079     errorRate = temp->par("ber");
00080     accessDelay = temp->par("delay");
00081 
00082     txMaxQueueTime = ((float)sendQueueLength * 8) / bandwidth;
00083     txFinished = simTime();
00084 
00085     delete temp;
00086 }

SimpleNodeEntry::SimpleNodeEntry ( cModule *  node,
cChannelType *  type,
uint32_t  sendQueueLength,
NodeRecord *  nodeRecord,
int  index 
)

Constructor for more than 2 dimensions.

Parameters:
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

Definition at line 88 of file SimpleNodeEntry.cc.

00092 {
00093     ingate = node->getSubmodule("udp")->gate("network_in");
00094 
00095 
00096     //this->nodeRecord = new NodeRecord(nodeRecord);
00097     this->nodeRecord = nodeRecord;
00098     this->index = index;
00099 
00100     cDatarateChannel* temp = dynamic_cast<cDatarateChannel*>(type->create("temp"));
00101 
00102     bandwidth = temp->par("datarate");
00103     errorRate = temp->par("ber");
00104     accessDelay = temp->par("delay");
00105 
00106     txMaxQueueTime = ((float)sendQueueLength * 8) / bandwidth;
00107     txFinished = simTime();
00108 
00109     delete temp;
00110 }


Member Function Documentation

cGate* SimpleNodeEntry::getGate (  )  const [inline]

Getter for SimpleUDP ingate.

Returns:
the ingate

Definition at line 92 of file SimpleNodeEntry.h.

Referenced by SimpleUnderlayConfigurator::handleTimerEvent(), SimpleUnderlayConfigurator::migrateNode(), SimpleUnderlayConfigurator::preKillNode(), and SimpleUDP::processMsgFromApp().

00093     {
00094         return ingate;
00095     };

SimpleNodeEntry::SimpleDelay SimpleNodeEntry::calcDelay ( SimpleUDPPacket *  msg,
const SimpleNodeEntry &  dest 
)

Calculates delay between two nodes.

Parameters:
msg pointer to message to get its length for delay calculation and set bit error flag
dest destination terminal
Returns:
delay in s and boolean value that is false if message should be deleted

Definition at line 122 of file SimpleNodeEntry.cc.

Referenced by SimpleUDP::processMsgFromApp().

00123 {
00124     if ((pow(1 - errorRate, msg->getByteLength() * 8) <= uniform(0, 1))
00125         || (pow(1 - dest.errorRate, msg->getByteLength() * 8) <= uniform(0, 1))) {
00126         msg->setBitError(true);
00127     }
00128 
00129     simtime_t now = simTime();
00130     simtime_t bandwidthDelay= ((msg->getByteLength() * 8) / bandwidth);
00131     simtime_t newTxFinished = std::max(txFinished, now) + bandwidthDelay;
00132 
00133     // send queue
00134     if ((newTxFinished > now + txMaxQueueTime) && (txMaxQueueTime != 0)) {
00135         EV << "[SimpleNodeEntry::calcDelay()]\n"
00136            << "    Send queue overrun"
00137            << "\n    newTxFinished = fmax(txFinished, now) + bandwidthDelay"
00138            << "\n    newTxFinished = " << newTxFinished
00139            << "\n    txFinished = " << txFinished
00140            << "\n    now = " << now
00141            << "\n    bandwidthDelay = " << bandwidthDelay
00142            << "\n    (newTxFinished > now + txMaxQueueTime) == true"
00143            << "\n    txMaxQueueTime = " << txMaxQueueTime
00144            << endl;
00145         return SimpleDelay(0, false);
00146     }
00147 
00148     txFinished = newTxFinished;
00149 
00150     simtime_t destBandwidthDelay = (msg->getByteLength() * 8) / dest.bandwidth;
00151     simtime_t coordDelay = 0.001 * (*this - dest);
00152 
00153     return SimpleDelay(txFinished - now
00154                        + accessDelay
00155                        + coordDelay
00156                        + destBandwidthDelay + dest.accessDelay, true);
00157 }

std::string SimpleNodeEntry::info (  )  const

OMNeT++ info method.

Returns:
infostring

Definition at line 159 of file SimpleNodeEntry.cc.

00160 {
00161     std::ostringstream str;
00162     str << *this;
00163     return str.str();
00164 }

simtime_t SimpleNodeEntry::getAccessDelay (  )  [inline]

Definition at line 144 of file SimpleNodeEntry.h.

00144 { return accessDelay; };

float SimpleNodeEntry::getBandwidth (  )  [inline]

Definition at line 147 of file SimpleNodeEntry.h.

00147 { return bandwidth; };

float SimpleNodeEntry::getErrorRate (  )  [inline]

Definition at line 149 of file SimpleNodeEntry.h.

00149 { return errorRate; };

float SimpleNodeEntry::getX (  )  [inline]

Definition at line 151 of file SimpleNodeEntry.h.

Referenced by SimpleUnderlayConfigurator::createNode().

00151 { return nodeRecord->coords[0]; };

float SimpleNodeEntry::getY (  )  [inline]

Definition at line 152 of file SimpleNodeEntry.h.

Referenced by SimpleUnderlayConfigurator::createNode().

00152 { return nodeRecord->coords[1]; };

int SimpleNodeEntry::getRecordIndex (  )  [inline]

NodeRecord* SimpleNodeEntry::getNodeRecord (  )  [inline]

Definition at line 155 of file SimpleNodeEntry.h.

Referenced by SimpleUnderlayConfigurator::migrateNode().

00155 { return nodeRecord; };

float SimpleNodeEntry::operator- ( const SimpleNodeEntry &  entry  )  const [protected]

Calculates eulklidean distance between two terminals.

Parameters:
entry destination entry
Returns:
the euklidean distance

Definition at line 112 of file SimpleNodeEntry.cc.

00113 {
00114     double sum_of_squares = 0;
00115     for (uint32_t i = 0; i < nodeRecord->dim; i++) {
00116         sum_of_squares += pow(nodeRecord->coords[i] -
00117                               entry.nodeRecord->coords[i], 2);
00118     }
00119     return sqrt(sum_of_squares);
00120 }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const SimpleNodeEntry &  entry 
) [friend]

Stream output.

Parameters:
out output stream
entry the terminal
Returns:
reference to stream out

Definition at line 166 of file SimpleNodeEntry.cc.

00167 {
00168     out << "(x:" << entry.nodeRecord->coords[0]
00169         << ", y:" << entry.nodeRecord->coords[1]
00170         << ")\nbandwidth = " << entry.bandwidth
00171         << ",\ndelay = " << entry.accessDelay
00172         << ",\nerrorRate = " << entry.errorRate
00173         << ",\ntxMaxQueueTime = " << entry.txMaxQueueTime
00174         << ",\ntxFinished = " << entry.txFinished;
00175 
00176     return out;
00177 }


Member Data Documentation

cGate* SimpleNodeEntry::ingate [protected]

ingate of the SimpleUDP module of this terminal

Definition at line 167 of file SimpleNodeEntry.h.

Referenced by getGate(), and SimpleNodeEntry().

simtime_t SimpleNodeEntry::txFinished [protected]

send queue finished

Definition at line 169 of file SimpleNodeEntry.h.

Referenced by calcDelay(), operator<<(), and SimpleNodeEntry().

simtime_t SimpleNodeEntry::txMaxQueueTime [protected]

maximum time for packets to be queued

Definition at line 170 of file SimpleNodeEntry.h.

Referenced by calcDelay(), operator<<(), and SimpleNodeEntry().

simtime_t SimpleNodeEntry::accessDelay [protected]

first hop delay

Definition at line 171 of file SimpleNodeEntry.h.

Referenced by calcDelay(), getAccessDelay(), operator<<(), and SimpleNodeEntry().

double SimpleNodeEntry::bandwidth [protected]

bandwidth in access net

Definition at line 172 of file SimpleNodeEntry.h.

Referenced by calcDelay(), getBandwidth(), operator<<(), and SimpleNodeEntry().

double SimpleNodeEntry::errorRate [protected]

packet loss rate

Definition at line 173 of file SimpleNodeEntry.h.

Referenced by calcDelay(), getErrorRate(), operator<<(), and SimpleNodeEntry().

int SimpleNodeEntry::index [protected]

Definition at line 176 of file SimpleNodeEntry.h.

Referenced by getRecordIndex(), SimpleNodeEntry(), and ~SimpleNodeEntry().


The documentation for this class was generated from the following files:

Generated on Wed Mar 25 16:32:54 2009 for OverSim by  doxygen 1.5.5