fix us/ns handling
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 04 Sep 2006 13:18:16 +0200
changeset 38 8ca1b9b1d3a9
parent 37 af78cb75be51
child 39 fc6ce16b47e1
fix us/ns handling
src/simulator/simulator.cc
src/simulator/time.cc
src/simulator/time.h
utils/bench-simulator.cc
--- a/src/simulator/simulator.cc	Mon Sep 04 13:14:39 2006 +0200
+++ b/src/simulator/simulator.cc	Mon Sep 04 13:18:16 2006 +0200
@@ -141,7 +141,7 @@
 {
 	assert (!m_events->is_empty ());
 	Scheduler::EventKey next_key = m_events->peek_next_key ();
-	return AbsTimeUs (next_key.m_ns);
+	return Time::abs_ns (next_key.m_ns);
 }
 
 
--- a/src/simulator/time.cc	Mon Sep 04 13:14:39 2006 +0200
+++ b/src/simulator/time.cc	Mon Sep 04 13:18:16 2006 +0200
@@ -114,6 +114,33 @@
 	return Time ();
 }
 
+class AbsTimeS : public Time {
+public:
+	AbsTimeS (double s);
+};
+class AbsTimeUs : public Time {
+public:
+	AbsTimeUs (uint64_t us);
+};
+class RelTimeS : public Time {
+public:
+	RelTimeS (double s);
+};
+class RelTimeUs : public Time {
+public:
+	RelTimeUs (uint64_t us);
+};
+
+class NowTime : public Time {
+public:
+	NowTime ();
+};
+
+class DestroyTime : public Time {
+public:
+	DestroyTime ();
+};
+
 
 AbsTimeS::AbsTimeS (double s)
 	: Time ((uint64_t)(int64_t)(s * 1000000000.0))
--- a/src/simulator/time.h	Mon Sep 04 13:14:39 2006 +0200
+++ b/src/simulator/time.h	Mon Sep 04 13:18:16 2006 +0200
@@ -49,32 +49,6 @@
 	bool m_is_destroy;
 };
 
-class AbsTimeS : public Time {
-public:
-	AbsTimeS (double s);
-};
-class AbsTimeUs : public Time {
-public:
-	AbsTimeUs (uint64_t us);
-};
-class RelTimeS : public Time {
-public:
-	RelTimeS (double s);
-};
-class RelTimeUs : public Time {
-public:
-	RelTimeUs (uint64_t us);
-};
-
-class NowTime : public Time {
-public:
-	NowTime ();
-};
-
-class DestroyTime : public Time {
-public:
-	DestroyTime ();
-};
 
 }; // namespace ns3
 
--- a/utils/bench-simulator.cc	Mon Sep 04 13:14:39 2006 +0200
+++ b/utils/bench-simulator.cc	Mon Sep 04 13:18:16 2006 +0200
@@ -55,8 +55,8 @@
 	double data;
 	while (!input.eof ()) {
 		if (input >> data) {
-			uint64_t us = (uint64_t) (data * 1000000);
-			m_distribution.push_back (us);
+			uint64_t ns = (uint64_t) (data * 1000000000);
+			m_distribution.push_back (ns);
 		} else {
 			input.clear ();
 			std::string line;
@@ -73,7 +73,7 @@
 	time.start ();
 	for (std::vector<uint64_t>::const_iterator i = m_distribution.begin ();
 	     i != m_distribution.end (); i++) {
-		Simulator::schedule (AbsTimeUs (*i), &Bench::cb, this);
+		Simulator::schedule (Time::abs_ns (*i), &Bench::cb, this);
 	}
 	init = time.end ();
 
@@ -103,9 +103,9 @@
 		m_current = m_distribution.begin ();
 	}
 	if (g_debug) {
-		std::cerr << "event at " << Simulator::now ().s () << std::endl;
+		std::cerr << "event at " << Simulator::now ().s () << "s" << std::endl;
 	}
-	Simulator::schedule (AbsTimeUs (*m_current), &Bench::cb, this);
+	Simulator::schedule (Time::abs_ns (*m_current), &Bench::cb, this);
 	m_current++;
 	m_n++;
 }