SimpleNodeEntry Class Reference

#include <SimpleNodeEntry.h>

List of all members.


Detailed Description

representation of a single node in the BootstrapOracle

Author:
Bernhard Heep

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 ()
NodeRecordgetNodeRecord ()

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
NodeRecordnodeRecord
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()


Constructor & Destructor Documentation

SimpleNodeEntry::~SimpleNodeEntry (  )  [inline]

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

SimpleNodeEntry::SimpleNodeEntry ( cModule *  node,
cChannelType *  type,
uint  fieldSize,
uint  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
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.

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
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 }


Member Function Documentation

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

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

Calculates delay between two nodes.

Parameters:
msg reference to message to get its length for delay calculation,
dest destination terminal
Returns:
delay in s and boolean value that is false if message should be deleted

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

OMNeT++ info method.

Returns:
infostring
00165 {
00166     std::ostringstream str;
00167     str << *this;
00168     return str.str();
00169 }

simtime_t SimpleNodeEntry::getAccessDelay (  )  [inline]

00144 { return accessDelay; };

float SimpleNodeEntry::getBandwidth (  )  [inline]

00147 { return bandwidth; };

float SimpleNodeEntry::getErrorRate (  )  [inline]

00149 { return errorRate; };

float SimpleNodeEntry::getX (  )  [inline]

Referenced by SimpleNetConfigurator::createNode().

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

float SimpleNodeEntry::getY (  )  [inline]

Referenced by SimpleNetConfigurator::createNode().

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

int SimpleNodeEntry::getRecordIndex (  )  [inline]

NodeRecord* SimpleNodeEntry::getNodeRecord (  )  [inline]

Referenced by SimpleNetConfigurator::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
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 }


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
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 }


Member Data Documentation

cGate* SimpleNodeEntry::ingate [protected]

ingate of the SimpleUDP module of this terminal

Referenced by getGate(), and SimpleNodeEntry().

simtime_t SimpleNodeEntry::txFinished [protected]

send queue finished

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

simtime_t SimpleNodeEntry::txMaxQueueTime [protected]

maximum time for packets to be queued

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

simtime_t SimpleNodeEntry::accessDelay [protected]

first hop delay

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

double SimpleNodeEntry::bandwidth [protected]

bandwidth in access net

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

double SimpleNodeEntry::errorRate [protected]

packet loss rate

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

int SimpleNodeEntry::index [protected]


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

Generated on Fri Sep 19 13:05:08 2008 for ITM OverSim by  doxygen 1.5.5