This commit is contained in:
Gustavo J. A. M. Carneiro
2012-01-04 18:14:05 +00:00
3 changed files with 46 additions and 5 deletions

View File

@@ -256,11 +256,48 @@ Ipv4ClickRouting::GetClickInstanceFromSimNode (simclick_node_t *simnode)
return m_clickInstanceFromSimNode[simnode];
}
struct timeval
Ipv4ClickRouting::GetTimevalFromNow () const
{
struct timeval curtime;
uint64_t remainder = 0;
curtime.tv_sec = Simulator::Now ().GetSeconds ();
curtime.tv_usec = Simulator::Now ().GetMicroSeconds () % 1000000;
switch (Simulator::Now ().GetResolution())
{
case Time::NS:
remainder = Simulator::Now ().GetNanoSeconds () % 1000;
break;
case Time::PS:
remainder = Simulator::Now ().GetPicoSeconds () % 1000000;
break;
case Time::FS:
remainder = Simulator::Now ().GetFemtoSeconds () % 1000000000;
break;
default:
break;
}
if (remainder)
{
++curtime.tv_usec;
if (curtime.tv_usec == 1000000)
{
++curtime.tv_sec;
curtime.tv_usec = 0;
}
}
return curtime;
}
void
Ipv4ClickRouting::RunClickEvent ()
{
m_simNode->curtime.tv_sec = Simulator::Now ().GetSeconds ();
m_simNode->curtime.tv_usec = Simulator::Now ().GetMicroSeconds () % 1000000;
m_simNode->curtime = GetTimevalFromNow ();
NS_LOG_DEBUG ("RunClickEvent at " << m_simNode->curtime.tv_sec << " " <<
m_simNode->curtime.tv_usec << " " << Simulator::Now ());
simclick_click_run (m_simNode);
@@ -311,8 +348,7 @@ void
Ipv4ClickRouting::SendPacketToClick (int ifid, int ptype, const unsigned char* data, int len)
{
NS_LOG_FUNCTION (this << ifid);
m_simNode->curtime.tv_sec = Simulator::Now ().GetSeconds ();
m_simNode->curtime.tv_usec = Simulator::Now ().GetMicroSeconds () % 1000000;
m_simNode->curtime = GetTimevalFromNow ();
// Since packets in ns-3 don't have global Packet ID's and Flow ID's, we
// feed dummy values into pinfo. This avoids the need to make changes in the Click code

View File

@@ -180,6 +180,11 @@ private:
*/
void AddSimNodeToClickMapping ();
/**
* \brief Get current simulation time as a timeval
*/
struct timeval GetTimevalFromNow () const;
/**
* \brief This method has to be scheduled everytime Click calls SIMCLICK_SCHEDULE
*/

View File

@@ -500,7 +500,7 @@ def sigint_hook(signal, frame):
# and use that result.
#
def read_waf_config():
for line in open(".lock-wafbuild", "rt"):
for line in open(".lock-waf_" + sys.platform + "_build", "rt"):
if line.startswith("out_dir ="):
key, val = line.split('=')
out_dir = eval(val.strip())