#include <vpr/md/SIM/Network/NetworkLine.h>
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) |
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.
| 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 }
| 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().
| double vpr::sim::NetworkLine::getLength | ( | ) | const [inline] |
| void vpr::sim::NetworkLine::setLength | ( | const double | miles | ) | [inline] |
| double vpr::sim::NetworkLine::getCapacity | ( | ) | const [inline] |
| void vpr::sim::NetworkLine::setCapacity | ( | const double | Mbps | ) | [inline] |
| double vpr::sim::NetworkLine::getPropagationDelay | ( | ) | const [inline] |
| 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().
| 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 }
1.5.1