A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns2-mobility-helper-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 INRIA
4  * 2009,2010 Contributors
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Contributors: Thomas Waldecker <twaldecker@rocketmail.com>
21  * Martín Giachino <martin.giachino@gmail.com>
22  *
23  * Brief description: Implementation of a ns2 movement trace file reader.
24  *
25  * This implementation is based on the ns2 movement documentation of ns2
26  * as described in http://www.isi.edu/nsnam/ns/doc/node174.html
27  *
28  * Valid trace files use the following ns2 statements:
29  *
30  * $node set X_ x1
31  * $node set Y_ y1
32  * $node set Z_ z1
33  * $ns at $time $node setdest x2 y2 speed
34  * $ns at $time $node set X_ x1
35  * $ns at $time $node set Y_ Y1
36  * $ns at $time $node set Z_ Z1
37  *
38  */
39 
40 #include <algorithm>
41 #include "ns3/log.h"
42 #include "ns3/simulator.h"
43 #include "ns3/node-list.h"
44 #include "ns3/node.h"
45 #include "ns3/constant-velocity-mobility-model.h"
46 #include "ns3/test.h"
47 #include "ns3/node-container.h"
48 #include "ns3/names.h"
49 #include "ns3/config.h"
50 #include "ns3/ns2-mobility-helper.h"
51 
52 NS_LOG_COMPONENT_DEFINE ("ns2-mobility-helper-test-suite");
53 
54 namespace ns3 {
55 
56 // -----------------------------------------------------------------------------
57 // Testing
58 // -----------------------------------------------------------------------------
59 bool AreVectorsEqual (Vector const & actual, Vector const & limit, double tol)
60 {
61  if (actual.x > limit.x + tol || actual.x < limit.x - tol)
62  {
63  return false;
64  }
65  if (actual.y > limit.y + tol || actual.y < limit.y - tol)
66  {
67  return false;
68  }
69  if (actual.z > limit.z + tol || actual.z < limit.z - tol)
70  {
71  return false;
72  }
73  return true;
74 }
75 
84 {
85 public:
88  {
89  std::string node;
93 
94  ReferencePoint (std::string const & id, Time t, Vector const & p, Vector const & v)
95  : node (id),
96  time (t),
97  pos (p),
98  vel (v)
99  {
100  }
102  bool operator< (ReferencePoint const & o) const
103  {
104  return (time < o.time);
105  }
106  };
114  Ns2MobilityHelperTest (std::string const & name, Time timeLimit, uint32_t nodes = 1)
115  : TestCase (name),
116  m_timeLimit (timeLimit),
117  m_nodeCount (nodes),
118  m_nextRefPoint (0)
119  {
120  }
123  {
124  }
126  void SetTrace (std::string const & trace)
127  {
128  m_trace = trace;
129  }
132  {
133  m_reference.push_back (r);
134  }
136  void AddReferencePoint (const char * id, double sec, Vector const & p, Vector const & v)
137  {
138  AddReferencePoint (ReferencePoint (id, Seconds (sec), p, v));
139  }
140 
141 private:
145  uint32_t m_nodeCount;
147  std::string m_trace;
149  std::vector<ReferencePoint> m_reference;
153  std::string m_traceFile;
154 
155 private:
157  bool WriteTrace ()
158  {
159  m_traceFile = CreateTempDirFilename ("Ns2MobilityHelperTest.tcl");
160  std::ofstream of (m_traceFile.c_str ());
161  NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (of.is_open (), true, "Need to write tmp. file");
162  of << m_trace;
163  of.close ();
164  return false; // no errors
165  }
167  void CreateNodes ()
168  {
170  nodes.Create (m_nodeCount);
171  for (uint32_t i = 0; i < m_nodeCount; ++i)
172  {
173  std::ostringstream os;
174  os << i;
175  Names::Add (os.str (), nodes.Get (i));
176  }
177  }
180  {
181  std::stable_sort (m_reference.begin (), m_reference.end ());
182  while (m_nextRefPoint < m_reference.size () && m_reference[m_nextRefPoint].time == Seconds (0))
183  {
185  Ptr<Node> node = Names::Find<Node> (rp.node);
186  NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL (node, 0, "Can't find node with id " << rp.node);
188  NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL (mob, 0, "Can't find mobility for node " << rp.node);
189 
190  double tol = 0.001;
191  NS_TEST_EXPECT_MSG_EQ (AreVectorsEqual (mob->GetPosition (), rp.pos, tol), true, "Initial position mismatch for node " << rp.node);
192  NS_TEST_EXPECT_MSG_EQ (AreVectorsEqual (mob->GetVelocity (), rp.vel, tol), true, "Initial velocity mismatch for node " << rp.node);
193 
194  m_nextRefPoint++;
195  }
196  return IsStatusFailure ();
197  }
199  void CourseChange (std::string context, Ptr<const MobilityModel> mobility)
200  {
201  Time time = Simulator::Now ();
202  Ptr<Node> node = mobility->GetObject<Node> ();
203  NS_ASSERT (node);
204  std::string id = Names::FindName (node);
205  NS_ASSERT (!id.empty ());
206  Vector pos = mobility->GetPosition ();
207  Vector vel = mobility->GetVelocity ();
208 
209  NS_TEST_EXPECT_MSG_LT (m_nextRefPoint, m_reference.size (), "Not enough reference points");
210  if (m_nextRefPoint >= m_reference.size ())
211  {
212  return;
213  }
214 
215  ReferencePoint const & ref = m_reference [m_nextRefPoint++];
216  NS_TEST_EXPECT_MSG_EQ (time, ref.time, "Time mismatch");
217  NS_TEST_EXPECT_MSG_EQ (id, ref.node, "Node ID mismatch at time " << time.GetSeconds () << " s");
218 
219  double tol = 0.001;
220  NS_TEST_EXPECT_MSG_EQ (AreVectorsEqual (pos, ref.pos, tol), true, "Position mismatch at time " << time.GetSeconds () << " s for node " << id);
221  NS_TEST_EXPECT_MSG_EQ (AreVectorsEqual (vel, ref.vel, tol), true, "Velocity mismatch at time " << time.GetSeconds () << " s for node " << id);
222  }
223 
224  void DoSetup ()
225  {
226  CreateNodes ();
227  }
228 
229  void DoTeardown ()
230  {
231  Names::Clear ();
232  if (std::remove (m_traceFile.c_str ()))
233  {
234  NS_LOG_ERROR ("Failed to delete file " << m_traceFile);
235  }
237  }
238 
240  void DoRun ()
241  {
242  NS_TEST_ASSERT_MSG_EQ (m_trace.empty (), false, "Need trace");
243  NS_TEST_ASSERT_MSG_EQ (m_reference.empty (), false, "Need reference");
244 
245  if (WriteTrace ())
246  {
247  return;
248  }
249  Ns2MobilityHelper mobility (m_traceFile);
250  mobility.Install ();
251  if (CheckInitialPositions ())
252  {
253  return;
254  }
255  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
258  Simulator::Run ();
259  }
260 };
261 
264 {
265 public:
266  Ns2MobilityHelperTestSuite () : TestSuite ("mobility-ns2-trace-helper", UNIT)
267  {
268  SetDataDir (NS_TEST_SOURCEDIR);
269 
270  // to be used as temporary variable for test cases.
271  // Note that test suite takes care of deleting all test cases.
272  Ns2MobilityHelperTest * t (0);
273 
274  // Initial position
275  t = new Ns2MobilityHelperTest ("initial position", Seconds (1));
276  t->SetTrace ("$node_(0) set X_ 1.0\n"
277  "$node_(0) set Y_ 2.0\n"
278  "$node_(0) set Z_ 3.0\n"
279  );
280  t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
282 
283  // Check parsing comments, empty lines and no EOF at the end of file
284  t = new Ns2MobilityHelperTest ("comments", Seconds (1));
285  t->SetTrace ("# comment\n"
286  "\n\n" // empty lines
287  "$node_(0) set X_ 1.0 # comment \n"
288  "$node_(0) set Y_ 2.0 ### \n"
289  "$node_(0) set Z_ 3.0 # $node_(0) set Z_ 3.0\n"
290  "#$node_(0) set Z_ 100 #"
291  );
292  t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
294 
295  // Simple setdest. Arguments are interpreted as x, y, speed by default
296  t = new Ns2MobilityHelperTest ("simple setdest", Seconds (10));
297  t->SetTrace ("$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"");
298  // id t position velocity
299  t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
300  t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5, 0, 0));
301  t->AddReferencePoint ("0", 6, Vector (25, 0, 0), Vector (0, 0, 0));
303 
304  // Several set and setdest. Arguments are interpreted as x, y, speed by default
305  t = new Ns2MobilityHelperTest ("square setdest", Seconds (6));
306  t->SetTrace ("$node_(0) set X_ 0.0\n"
307  "$node_(0) set Y_ 0.0\n"
308  "$ns_ at 1.0 \"$node_(0) setdest 5 0 5\"\n"
309  "$ns_ at 2.0 \"$node_(0) setdest 5 5 5\"\n"
310  "$ns_ at 3.0 \"$node_(0) setdest 0 5 5\"\n"
311  "$ns_ at 4.0 \"$node_(0) setdest 0 0 5\"\n"
312  );
313  // id t position velocity
314  t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
315  t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5, 0, 0));
316  t->AddReferencePoint ("0", 2, Vector (5, 0, 0), Vector (0, 0, 0));
317  t->AddReferencePoint ("0", 2, Vector (5, 0, 0), Vector (0, 5, 0));
318  t->AddReferencePoint ("0", 3, Vector (5, 5, 0), Vector (0, 0, 0));
319  t->AddReferencePoint ("0", 3, Vector (5, 5, 0), Vector (-5, 0, 0));
320  t->AddReferencePoint ("0", 4, Vector (0, 5, 0), Vector (0, 0, 0));
321  t->AddReferencePoint ("0", 4, Vector (0, 5, 0), Vector (0, -5, 0));
322  t->AddReferencePoint ("0", 5, Vector (0, 0, 0), Vector (0, 0, 0));
324 
325  // Copy of previous test case but with the initial positions at
326  // the end of the trace rather than at the beginning.
327  //
328  // Several set and setdest. Arguments are interpreted as x, y, speed by default
329  t = new Ns2MobilityHelperTest ("square setdest (initial positions at end)", Seconds (6));
330  t->SetTrace ("$ns_ at 1.0 \"$node_(0) setdest 15 10 5\"\n"
331  "$ns_ at 2.0 \"$node_(0) setdest 15 15 5\"\n"
332  "$ns_ at 3.0 \"$node_(0) setdest 10 15 5\"\n"
333  "$ns_ at 4.0 \"$node_(0) setdest 10 10 5\"\n"
334  "$node_(0) set X_ 10.0\n"
335  "$node_(0) set Y_ 10.0\n"
336  );
337  // id t position velocity
338  t->AddReferencePoint ("0", 0, Vector (10, 10, 0), Vector (0, 0, 0));
339  t->AddReferencePoint ("0", 1, Vector (10, 10, 0), Vector (5, 0, 0));
340  t->AddReferencePoint ("0", 2, Vector (15, 10, 0), Vector (0, 0, 0));
341  t->AddReferencePoint ("0", 2, Vector (15, 10, 0), Vector (0, 5, 0));
342  t->AddReferencePoint ("0", 3, Vector (15, 15, 0), Vector (0, 0, 0));
343  t->AddReferencePoint ("0", 3, Vector (15, 15, 0), Vector (-5, 0, 0));
344  t->AddReferencePoint ("0", 4, Vector (10, 15, 0), Vector (0, 0, 0));
345  t->AddReferencePoint ("0", 4, Vector (10, 15, 0), Vector (0, -5, 0));
346  t->AddReferencePoint ("0", 5, Vector (10, 10, 0), Vector (0, 0, 0));
348 
349  // Scheduled set position
350  t = new Ns2MobilityHelperTest ("scheduled set position", Seconds (2));
351  t->SetTrace ("$ns_ at 1.0 \"$node_(0) set X_ 10\"\n"
352  "$ns_ at 1.0 \"$node_(0) set Z_ 10\"\n"
353  "$ns_ at 1.0 \"$node_(0) set Y_ 10\"");
354  // id t position velocity
355  t->AddReferencePoint ("0", 1, Vector (10, 0, 0), Vector (0, 0, 0));
356  t->AddReferencePoint ("0", 1, Vector (10, 0, 10), Vector (0, 0, 0));
357  t->AddReferencePoint ("0", 1, Vector (10, 10, 10), Vector (0, 0, 0));
359 
360  // Malformed lines
361  t = new Ns2MobilityHelperTest ("malformed lines", Seconds (2));
362  t->SetTrace ("$node() set X_ 1 # node id is not present\n"
363  "$node # incoplete line\"\n"
364  "$node this line is not correct\n"
365  "$node_(0) set X_ 1 # line OK \n"
366  "$node_(0) set Y_ 2 # line OK \n"
367  "$node_(0) set Z_ 3 # line OK \n"
368  "$ns_ at \"$node_(0) setdest 4 4 4\" # time not present\n"
369  "$ns_ at 1 \"$node_(0) setdest 2 2 1 \" # line OK \n");
370  // id t position velocity
371  t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
372  t->AddReferencePoint ("0", 1, Vector (1, 2, 3), Vector (1, 0, 0));
373  t->AddReferencePoint ("0", 2, Vector (2, 2, 3), Vector (0, 0, 0));
375 
376  // Non possible values
377  t = new Ns2MobilityHelperTest ("non possible values", Seconds (2));
378  t->SetTrace ("$node_(0) set X_ 1 # line OK \n"
379  "$node_(0) set Y_ 2 # line OK \n"
380  "$node_(0) set Z_ 3 # line OK \n"
381  "$node_(-22) set Y_ 3 # node id not correct\n"
382  "$node_(3.3) set Y_ 1111 # node id not correct\n"
383  "$ns_ at sss \"$node_(0) setdest 5 5 5\" # time is not a number\n"
384  "$ns_ at 1 \"$node_(0) setdest 2 2 1\" # line OK \n"
385  "$ns_ at 1 \"$node_(0) setdest 2 2 -1\" # negative speed is not correct\n"
386  "$ns_ at 1 \"$node_(0) setdest 2 2 sdfs\" # speed is not a number\n"
387  "$ns_ at 1 \"$node_(0) setdest 2 2 s232dfs\" # speed is not a number\n"
388  "$ns_ at 1 \"$node_(0) setdest 233 2.. s232dfs\" # more than one non numbers\n"
389  "$ns_ at -12 \"$node_(0) setdest 11 22 33\" # time should not be negative\n");
390  // id t position velocity
391  t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
392  t->AddReferencePoint ("0", 1, Vector (1, 2, 3), Vector (1, 0, 0));
393  t->AddReferencePoint ("0", 2, Vector (2, 2, 3), Vector (0, 0, 0));
395 
396  // More than one node
397  t = new Ns2MobilityHelperTest ("few nodes, combinations of set and setdest", Seconds (10), 3);
398  t->SetTrace ("$node_(0) set X_ 1.0\n"
399  "$node_(0) set Y_ 2.0\n"
400  "$node_(0) set Z_ 3.0\n"
401  "$ns_ at 1.0 \"$node_(1) setdest 25 0 5\"\n"
402  "$node_(2) set X_ 0.0\n"
403  "$node_(2) set Y_ 0.0\n"
404  "$ns_ at 1.0 \"$node_(2) setdest 5 0 5\"\n"
405  "$ns_ at 2.0 \"$node_(2) setdest 5 5 5\"\n"
406  "$ns_ at 3.0 \"$node_(2) setdest 0 5 5\"\n"
407  "$ns_ at 4.0 \"$node_(2) setdest 0 0 5\"\n");
408  // id t position velocity
409  t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
410  t->AddReferencePoint ("1", 0, Vector (0, 0, 0), Vector (0, 0, 0));
411  t->AddReferencePoint ("1", 1, Vector (0, 0, 0), Vector (5, 0, 0));
412  t->AddReferencePoint ("1", 6, Vector (25, 0, 0), Vector (0, 0, 0));
413  t->AddReferencePoint ("2", 0, Vector (0, 0, 0), Vector (0, 0, 0));
414  t->AddReferencePoint ("2", 1, Vector (0, 0, 0), Vector (5, 0, 0));
415  t->AddReferencePoint ("2", 2, Vector (5, 0, 0), Vector (0, 0, 0));
416  t->AddReferencePoint ("2", 2, Vector (5, 0, 0), Vector (0, 5, 0));
417  t->AddReferencePoint ("2", 3, Vector (5, 5, 0), Vector (0, 0, 0));
418  t->AddReferencePoint ("2", 3, Vector (5, 5, 0), Vector (-5, 0, 0));
419  t->AddReferencePoint ("2", 4, Vector (0, 5, 0), Vector (0, 0, 0));
420  t->AddReferencePoint ("2", 4, Vector (0, 5, 0), Vector (0, -5, 0));
421  t->AddReferencePoint ("2", 5, Vector (0, 0, 0), Vector (0, 0, 0));
423 
424  // Test for Speed == 0, that acts as stop the node.
425  t = new Ns2MobilityHelperTest ("setdest with speed cero", Seconds (10));
426  t->SetTrace ("$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"\n"
427  "$ns_ at 7.0 \"$node_(0) setdest 11 22 0\"\n");
428  // id t position velocity
429  t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
430  t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5, 0, 0));
431  t->AddReferencePoint ("0", 6, Vector (25, 0, 0), Vector (0, 0, 0));
432  t->AddReferencePoint ("0", 7, Vector (25, 0, 0), Vector (0, 0, 0));
434 
435 
436  // Test negative positions
437  t = new Ns2MobilityHelperTest ("test negative positions", Seconds (10));
438  t->SetTrace ("$node_(0) set X_ -1.0\n"
439  "$node_(0) set Y_ 0\n"
440  "$ns_ at 1.0 \"$node_(0) setdest 0 0 1\"\n"
441  "$ns_ at 2.0 \"$node_(0) setdest 0 -1 1\"\n");
442  // id t position velocity
443  t->AddReferencePoint ("0", 0, Vector (-1, 0, 0), Vector (0, 0, 0));
444  t->AddReferencePoint ("0", 1, Vector (-1, 0, 0), Vector (1, 0, 0));
445  t->AddReferencePoint ("0", 2, Vector (0, 0, 0), Vector (0, 0, 0));
446  t->AddReferencePoint ("0", 2, Vector (0, 0, 0), Vector (0, -1, 0));
447  t->AddReferencePoint ("0", 3, Vector (0, -1, 0), Vector (0, 0, 0));
449 
450  // Sqare setdest with values in the form 1.0e+2
451  t = new Ns2MobilityHelperTest ("Foalt numbers in 1.0e+2 format", Seconds (6));
452  t->SetTrace ("$node_(0) set X_ 0.0\n"
453  "$node_(0) set Y_ 0.0\n"
454  "$ns_ at 1.0 \"$node_(0) setdest 1.0e+2 0 1.0e+2\"\n"
455  "$ns_ at 2.0 \"$node_(0) setdest 1.0e+2 1.0e+2 1.0e+2\"\n"
456  "$ns_ at 3.0 \"$node_(0) setdest 0 1.0e+2 1.0e+2\"\n"
457  "$ns_ at 4.0 \"$node_(0) setdest 0 0 1.0e+2\"\n");
458  // id t position velocity
459  t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
460  t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (100, 0, 0));
461  t->AddReferencePoint ("0", 2, Vector (100, 0, 0), Vector (0, 0, 0));
462  t->AddReferencePoint ("0", 2, Vector (100, 0, 0), Vector (0, 100, 0));
463  t->AddReferencePoint ("0", 3, Vector (100, 100, 0), Vector (0, 0, 0));
464  t->AddReferencePoint ("0", 3, Vector (100, 100, 0), Vector (-100, 0, 0));
465  t->AddReferencePoint ("0", 4, Vector (0, 100, 0), Vector (0, 0, 0));
466  t->AddReferencePoint ("0", 4, Vector (0, 100, 0), Vector (0, -100, 0));
467  t->AddReferencePoint ("0", 5, Vector (0, 0, 0), Vector (0, 0, 0));
469  t = new Ns2MobilityHelperTest ("Bug 1219 testcase", Seconds (16));
470  t->SetTrace ("$node_(0) set X_ 0.0\n"
471  "$node_(0) set Y_ 0.0\n"
472  "$ns_ at 1.0 \"$node_(0) setdest 0 10 1\"\n"
473  "$ns_ at 6.0 \"$node_(0) setdest 0 -10 1\"\n"
474  );
475  // id t position velocity
476  t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
477  t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (0, 1, 0));
478  t->AddReferencePoint ("0", 6, Vector (0, 5, 0), Vector (0, -1, 0));
479  t->AddReferencePoint ("0", 16, Vector (0, -10, 0), Vector (0, 0, 0));
481  t = new Ns2MobilityHelperTest ("Bug 1059 testcase", Seconds (16));
482  t->SetTrace ("$node_(0) set X_ 10.0\r\n"
483  "$node_(0) set Y_ 0.0\r\n"
484  );
485  // id t position velocity
486  t->AddReferencePoint ("0", 0, Vector (10, 0, 0), Vector (0, 0, 0));
488  t = new Ns2MobilityHelperTest ("Bug 1301 testcase", Seconds (16));
489  t->SetTrace ("$node_(0) set X_ 10.0\n"
490  "$node_(0) set Y_ 0.0\n"
491  "$ns_ at 1.0 \"$node_(0) setdest 10 0 1\"\n"
492  );
493  // id t position velocity
494  // Moving to the current position must change nothing. No NaN
495  // speed must be.
496  t->AddReferencePoint ("0", 0, Vector (10, 0, 0), Vector (0, 0, 0));
498 
499  t = new Ns2MobilityHelperTest ("Bug 1316 testcase", Seconds (1000));
500  t->SetTrace ("$node_(0) set X_ 350.00000000000000\n"
501  "$node_(0) set Y_ 50.00000000000000\n"
502  "$ns_ at 50.00000000000000 \"$node_(0) setdest 400.00000000000000 50.00000000000000 1.00000000000000\"\n"
503  "$ns_ at 150.00000000000000 \"$node_(0) setdest 400.00000000000000 150.00000000000000 4.00000000000000\"\n"
504  "$ns_ at 300.00000000000000 \"$node_(0) setdest 250.00000000000000 150.00000000000000 3.00000000000000\"\n"
505  "$ns_ at 350.00000000000000 \"$node_(0) setdest 250.00000000000000 50.00000000000000 1.00000000000000\"\n"
506  "$ns_ at 600.00000000000000 \"$node_(0) setdest 250.00000000000000 1050.00000000000000 2.00000000000000\"\n"
507  "$ns_ at 900.00000000000000 \"$node_(0) setdest 300.00000000000000 650.00000000000000 2.50000000000000\"\n"
508  );
509  t->AddReferencePoint ("0", 0.000, Vector (350.000, 50.000, 0.000), Vector (0.000, 0.000, 0.000));
510  t->AddReferencePoint ("0", 50.000, Vector (350.000, 50.000, 0.000), Vector (1.000, 0.000, 0.000));
511  t->AddReferencePoint ("0", 100.000, Vector (400.000, 50.000, 0.000), Vector (0.000, 0.000, 0.000));
512  t->AddReferencePoint ("0", 150.000, Vector (400.000, 50.000, 0.000), Vector (0.000, 4.000, 0.000));
513  t->AddReferencePoint ("0", 175.000, Vector (400.000, 150.000, 0.000), Vector (0.000, 0.000, 0.000));
514  t->AddReferencePoint ("0", 300.000, Vector (400.000, 150.000, 0.000), Vector (-3.000, 0.000, 0.000));
515  t->AddReferencePoint ("0", 350.000, Vector (250.000, 150.000, 0.000), Vector (0.000, 0.000, 0.000));
516  t->AddReferencePoint ("0", 350.000, Vector (250.000, 150.000, 0.000), Vector (0.000, -1.000, 0.000));
517  t->AddReferencePoint ("0", 450.000, Vector (250.000, 50.000, 0.000), Vector (0.000, 0.000, 0.000));
518  t->AddReferencePoint ("0", 600.000, Vector (250.000, 50.000, 0.000), Vector (0.000, 2.000, 0.000));
519  t->AddReferencePoint ("0", 900.000, Vector (250.000, 650.000, 0.000), Vector (2.500, 0.000, 0.000));
520  t->AddReferencePoint ("0", 920.000, Vector (300.000, 650.000, 0.000), Vector (0.000, 0.000, 0.000));
522 
523  }
525 
526 
527 } // namespace ns3
Ns2MobilityHelperTest(std::string const &name, Time timeLimit, uint32_t nodes=1)
Create new test case.
double x
x coordinate of vector
Definition: vector.h:49
void AddReferencePoint(ReferencePoint const &r)
Add next reference point.
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
A suite of tests to run.
Definition: test.h:1025
Every test case is supposed to:
#define NS_ASSERT(condition)
Definition: assert.h:64
static void Run(void)
Run the simulation until one of:
Definition: simulator.cc:157
Vector GetPosition(void) const
size_t m_nextRefPoint
Next reference point to be checked.
void DoTeardown()
Implementation to do any local setup required for this TestCase.
encapsulates test code
Definition: test.h:849
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:728
#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not...
Definition: test.h:592
a 3d vector
Definition: vector.h:31
Vector GetVelocity(void) const
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr obj.
Definition: names.cc:616
tuple nodes
Definition: first.py:25
Keep track of the current position and velocity of an object.
double GetSeconds(void) const
Definition: nstime.h:274
bool AreVectorsEqual(Vector const &actual, Vector const &limit, double tol)
void Install(void) const
Read the ns2 trace file and configure the movement patterns of all nodes contained in the global ns3:...
static void Clear(void)
Clear the list of objects associated with names.
Definition: names.cc:679
Helper class which can read ns-2 movement files and configure nodes mobility.
make Callback use a separate empty type
Definition: empty.h:8
void CourseChange(std::string context, Ptr< const MobilityModel > mobility)
Listen for course change events.
std::string node
node ID as string, e.g. "1"
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:244
std::string m_traceFile
TMP trace file name.
ns3::Ns2MobilityHelperTestSuite g_ns2TransmobilityHelperTestSuite
void CreateNodes()
Create and name nodes.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1238
void DoSetup()
Implementation to do any local setup required for this TestCase.
NS_LOG_COMPONENT_DEFINE("ns2-mobility-helper-test-suite")
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
Definition: simulator.cc:121
keep track of a set of node pointers.
bool IsStatusFailure(void) const
Definition: test.cc:324
double y
y coordinate of vector
Definition: vector.h:53
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:173
ReferencePoint(std::string const &id, Time t, Vector const &p, Vector const &v)
Fast test.
Definition: test.h:857
bool WriteTrace()
Dump NS-2 trace to tmp file.
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
Definition: simulator.cc:165
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
std::string CreateTempDirFilename(std::string filename)
Definition: test.cc:296
A network Node.
Definition: node.h:55
std::string m_trace
Trace as string.
void SetDataDir(std::string directory)
Definition: test.cc:337
uint32_t m_nodeCount
Number of nodes used in the test.
static std::string FindName(Ptr< Object > object)
Given a pointer to an object, look to see if that object has a name associated with it and...
Definition: names.cc:665
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
Definition: test.h:729
#define NS_LOG_ERROR(msg)
Definition: log.h:271
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:191
bool CheckInitialPositions()
Check that all initial positions are correct.
This test suite implements a Unit Test.
Definition: test.h:1035
bool operator<(ReferencePoint const &o) const
Sort by timestamp.
Ptr< T > GetObject(void) const
Definition: object.h:361
void AddReferencePoint(const char *id, double sec, Vector const &p, Vector const &v)
Sugar.
void SetTrace(std::string const &trace)
Set NS-2 trace to read as single large string (don't forget to add \n and quote "'s) ...
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:137
std::vector< ReferencePoint > m_reference
Reference mobility.
double z
z coordinate of vector
Definition: vector.h:57