vpr::sim::NetworkLine Class Reference

A container class for the little collection of properties that are assigned to edges (network lines) in the network graph. More...

#include <vpr/md/SIM/Network/NetworkLine.h>

List of all members.

Public Types

enum  LineDirection { FORWARD, REVERSE }
enum  NetworkType { LAN, MAN, WAN, LOOPBACK }

Public Member Functions

 NetworkLine ()
 Default constructor.
 NetworkLine (const double miles, const double Mbps, const double delay, const std::string &netType, const vpr::Uint8 netID, const std::string &netIP)
int getWeight () const
 Returns a value designating the "weight" of this line (edge) in the network (graph).
double getLength () const
 Returns the length in miles of this network line.
void setLength (const double miles)
double getCapacity () const
void setCapacity (const double Mbps)
double getPropagationDelay () const
vpr::Interval getWireAccessTime (const vpr::Uint32 bits) const
 Calculates the amount of time needed to put the given number of bits on the wire.
const std::string & getNetworkAddressString () const
vpr::Interval getBitTransmissionTime () const
 Calculates the amount of time required to get a single bit down the wire.
void calculateMessageEventTimes (vpr::sim::MessagePtr msg, const vpr::Interval &curTime, const LineDirection direction)
void addMessage (vpr::sim::MessagePtr msg, const LineDirection direction)
void removeActiveMessages (const vpr::SocketImplSIM *sock, std::vector< vpr::Interval > &eventTimes, const LineDirection direction)
vpr::ReturnStatus getArrivedMessage (const vpr::Interval &eventTime, vpr::sim::MessagePtr &msg, const LineDirection direction)


Detailed Description

A container class for the little collection of properties that are assigned to edges (network lines) in the network graph.

Grouping them into a class this way makes it easier for developers to manage the BGL property stuff, and it makes it easier for users to query and update properties. This class must be default constrible, assignable, and copy constructible.

Definition at line 73 of file NetworkLine.h.


Member Enumeration Documentation

enum vpr::sim::NetworkLine::LineDirection

Enumerator:
FORWARD 
REVERSE 

Definition at line 76 of file NetworkLine.h.

00077    {
00078       FORWARD,
00079       REVERSE
00080    };

enum vpr::sim::NetworkLine::NetworkType

Enumerator:
LAN 
MAN 
WAN 
LOOPBACK 

Definition at line 82 of file NetworkLine.h.

00083    {
00084       LAN,
00085       MAN,
00086       WAN,
00087       LOOPBACK
00088    };


Constructor & Destructor Documentation

vpr::sim::NetworkLine::NetworkLine (  )  [inline]

Default constructor.

Definition at line 93 of file NetworkLine.h.

00094       : mLength(0.0f)
00095       , mCapacity(0.0f)
00096       , mDelay(0.0f)
00097       , mNetworkType(LAN)
00098       , mNetworkID(0)
00099       , mNetworkIP(0)
00100       , mLatency(0.0f)
00101    {
00102       /* Do nothing. */ ;
00103    }

vpr::sim::NetworkLine::NetworkLine ( const double  miles,
const double  Mbps,
const double  delay,
const std::string &  netType,
const vpr::Uint8  netID,
const std::string &  netIP 
)

Definition at line 56 of file NetworkLine.cpp.

References LAN, LOOPBACK, MAN, and WAN.

00059    : mLength(miles)
00060    , mCapacity(Mbps)
00061    , mDelay(delay)
00062    , mNetworkID(netID)
00063    , mNetworkIP(0)
00064    , mNetworkIPStr(netIP)
00065 {
00066    // 5 is the approximate number of microseconds it takes light to move
00067    // one mile (i.e., 5 usec/mile).
00068    mLatency = 5.0f * miles;
00069 
00070    if ( netType.compare("WAN") == 0 )
00071    {
00072       mNetworkType = NetworkLine::WAN;
00073    }
00074    else if ( netType.compare("MAN") == 0 )
00075    {
00076       mNetworkType = NetworkLine::MAN;
00077    }
00078    else if ( netType.compare("LAN") == 0 )
00079    {
00080       mNetworkType = NetworkLine::LAN;
00081    }
00082    else
00083    {
00084       mNetworkType = NetworkLine::LOOPBACK;
00085    }
00086 }


Member Function Documentation

int vpr::sim::NetworkLine::getWeight (  )  const [inline]

Returns a value designating the "weight" of this line (edge) in the network (graph).

Currently, the weight of this edge is its length cast to an integer (the round-off error is acceptable).

Definition at line 114 of file NetworkLine.h.

Referenced by vpr::sim::NetworkGraph::construct().

00115    {
00116       return (int) mLength;
00117    }

double vpr::sim::NetworkLine::getLength (  )  const [inline]

Returns the length in miles of this network line.

Definition at line 122 of file NetworkLine.h.

00123    {
00124       return mLength;
00125    }

void vpr::sim::NetworkLine::setLength ( const double  miles  )  [inline]

Definition at line 127 of file NetworkLine.h.

00128    {
00129       mLength  = miles;
00130       mLatency = 5.0f * miles;
00131    }

double vpr::sim::NetworkLine::getCapacity (  )  const [inline]

Definition at line 133 of file NetworkLine.h.

00134    {
00135       return mCapacity;
00136    }

void vpr::sim::NetworkLine::setCapacity ( const double  Mbps  )  [inline]

Definition at line 138 of file NetworkLine.h.

00139    {
00140       mCapacity = Mbps;
00141    }

double vpr::sim::NetworkLine::getPropagationDelay (  )  const [inline]

Definition at line 143 of file NetworkLine.h.

00144    {
00145       return mLatency;
00146    }

vpr::Interval vpr::sim::NetworkLine::getWireAccessTime ( const vpr::Uint32  bits  )  const [inline]

Calculates the amount of time needed to put the given number of bits on the wire.

Definition at line 152 of file NetworkLine.h.

References vpr::Interval::Usec.

00153    {
00154       // This gets the number of microseconds required to transmit the given
00155       // number of bits.  This works because mCapacity is measured in
00156       // _megabits_ per second but the given argument is simply bits.
00157       double microsec = ((double) bits / mCapacity);
00158 
00159       // Round up since vpr::Interval objects deal in whole numbers.
00160       double time = ceil(microsec);
00161 
00162       return vpr::Interval((vpr::Uint32) time, vpr::Interval::Usec);
00163    }

const std::string& vpr::sim::NetworkLine::getNetworkAddressString (  )  const [inline]

Definition at line 165 of file NetworkLine.h.

Referenced by vpr::sim::Controller::processNextEvent(), and vpr::sim::SocketManager::sendMessage().

00166    {
00167       return mNetworkIPStr;
00168    }

vpr::Interval vpr::sim::NetworkLine::getBitTransmissionTime (  )  const [inline]

Calculates the amount of time required to get a single bit down the wire.

Definition at line 174 of file NetworkLine.h.

References vpr::Interval::Usec.

00175    {
00176       // Round up since vpr::Interval objects deal in whole numbers.
00177       return vpr::Interval((vpr::Uint32) ceil(getPropagationDelay()),
00178                            vpr::Interval::Usec);
00179    }

void vpr::sim::NetworkLine::calculateMessageEventTimes ( vpr::sim::MessagePtr  msg,
const vpr::Interval curTime,
const LineDirection  direction 
) [inline]

Definition at line 181 of file NetworkLine.h.

Referenced by vpr::sim::SocketManager::sendMessage().

00184    {
00185       switch (direction)
00186       {
00187          case FORWARD:
00188             calculateMessageEventTimes(msg, curTime, mForwardLineQueue);
00189             break;
00190          case REVERSE:
00191             calculateMessageEventTimes(msg, curTime, mReverseLineQueue);
00192             break;
00193       }
00194    }

void vpr::sim::NetworkLine::addMessage ( vpr::sim::MessagePtr  msg,
const LineDirection  direction 
) [inline]

Definition at line 199 of file NetworkLine.h.

Referenced by vpr::sim::SocketManager::sendMessage().

00200    {
00201       switch (direction)
00202       {
00203          case FORWARD:
00204             addMessageToQueue(msg, mForwardLineQueue);
00205             break;
00206          case REVERSE:
00207             addMessageToQueue(msg, mReverseLineQueue);
00208             break;
00209       }
00210    }

void vpr::sim::NetworkLine::removeActiveMessages ( const vpr::SocketImplSIM sock,
std::vector< vpr::Interval > &  eventTimes,
const LineDirection  direction 
) [inline]

Definition at line 212 of file NetworkLine.h.

Referenced by vpr::sim::Controller::flushPath().

00215    {
00216       switch (direction)
00217       {
00218          case FORWARD:
00219             removeMessagesFromQueue(sock, eventTimes, mForwardLineQueue);
00220             break;
00221          case REVERSE:
00222             removeMessagesFromQueue(sock, eventTimes, mReverseLineQueue);
00223             break;
00224       }
00225    }

vpr::ReturnStatus vpr::sim::NetworkLine::getArrivedMessage ( const vpr::Interval eventTime,
vpr::sim::MessagePtr msg,
const LineDirection  direction 
) [inline]

Definition at line 229 of file NetworkLine.h.

Referenced by vpr::sim::Controller::processNextEvent().

00232    {
00233       vpr::ReturnStatus status;
00234 
00235       if ( direction == FORWARD )
00236       {
00237          status = getArrivedMessageFromQueue(eventTime, msg, mForwardLineQueue);
00238       }
00239       else
00240       {
00241          status = getArrivedMessageFromQueue(eventTime, msg, mReverseLineQueue);
00242       }
00243 
00244       return status;
00245    }


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:56:12 2007 for VR Juggler Portable Runtime by  doxygen 1.5.1