Bug 2024 - Ns2MobilityHelper parsing scheduled events
Ns2MobilityHelper parsing scheduled events
Status: NEW
Product: ns-3
Classification: Unclassified
Component: mobility models
ns-3.21
All All
: P5 normal
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-12-03 13:46 EST by Konstantinos Katsaros
Modified: 2014-12-03 13:46 EST (History)
0 users

See Also:


Attachments
Example Mobility (387 bytes, text/plain)
2014-12-03 13:46 EST, Konstantinos Katsaros
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantinos Katsaros 2014-12-03 13:46:33 EST
Created attachment 1927 [details]
Example Mobility

I have noticed a misbehaviour in the parsing of ns-2 mobility files when there is a scheduled event.

In the example mobility file attached there are 3 nodes. They are given an initial position in the form of 

$node_(1) set Y_ 81.00
$node_(1) set X_ 0.00

Then they are given a destination

$ns_ at 0.0 $node_(1) setdest 0 0 31.00

and after some time they are 'transferred' to another point

$ns_ at 2.6129 $node_(1) set X_ 2400

and given again a new destination

$ns_ at 2.63 $node_(1) setdest 0 0 31.00

This is basically an attempt to create a 'wrap around' in a highway/straight line. Vehicles will move to the left until they reach (0.0) and will be transferred back to the starting point of the highway.

However, the output of the ns2-mobility-trace.cc file (mobility/examples in ns-3 tree) is 

+0.0ns POS: x=2400, y=0, z=0; VEL:-31, y=0, z=0
+2612899999.0ns POS: x=2400, y=0, z=0; VEL:0, y=0, z=0
+2629999999.0ns POS: x=2400, y=0, z=0; VEL:-31, y=0, z=0

which wrongly parses the initial position of node as X=2400 and then again at t=2.613 moved back to X=2400 (as expected).

I think the error is located here but not sure how to fix it. 
last_pos[iNodeId].m_finalPosition = SetSchedPosition (model, at, pr.tokens[5], pr.dvals[6]);


@line 369 ns2-mobility-helper.cc
             /*
               * Scheduled set position
               * line like $ns_ at 4.634906291962 "$node_(0) set X_ 28.675920486450"
               */
              else if (IsSchedSetPos (pr))
                {
                  //                                         time  coordinate   coord value
                  last_pos[iNodeId].m_finalPosition = SetSchedPosition (model, at, pr.tokens[5], pr.dvals[6]);
                  if (last_pos[iNodeId].m_targetArrivalTime > at)
                    {
                      last_pos[iNodeId].m_stopEvent.Cancel ();
                    }
                  last_pos[iNodeId].m_targetArrivalTime = at;
                  last_pos[iNodeId].m_travelStartTime = at;
                  // Log new position
                  NS_LOG_DEBUG ("Positions after parse for node " << iNodeId << " " << nodeId <<
                                " position =" << last_pos[iNodeId].m_finalPosition);
                }
              else
                {
                  NS_LOG_WARN ("Format Line is not correct: " << line << "\n");
                }
            }