Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(219)

Unified Diff: src/csma/model/backoff.cc

Issue 6448069: replace src/csma usage of RandomVariable with RandomVariableStream
Patch Set: Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/csma/model/backoff.h ('k') | src/csma/model/csma-net-device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/csma/model/backoff.cc
===================================================================
--- a/src/csma/model/backoff.cc
+++ b/src/csma/model/backoff.cc
@@ -19,6 +19,9 @@
*/
#include "backoff.h"
+#include "ns3/log.h"
+
+NS_LOG_COMPONENT_DEFINE ("Backoff");
namespace ns3 {
@@ -29,6 +32,7 @@
m_maxSlots = 1000;
m_ceiling = 10;
m_maxRetries = 1000;
+ m_rng = CreateObject<UniformRandomVariable> ();
ResetBackoffTime ();
}
@@ -40,7 +44,7 @@
m_maxSlots = maxSlots;
m_ceiling = ceiling;
m_maxRetries = maxRetries;
- m_rng = UniformVariable ();
+ m_rng = CreateObject<UniformRandomVariable> ();
}
Time
@@ -64,7 +68,7 @@
maxSlot = m_maxSlots;
}
- uint32_t backoffSlots = (uint32_t)m_rng.GetValue (minSlot, maxSlot);
+ uint32_t backoffSlots = (uint32_t)m_rng->GetValue (minSlot, maxSlot);
Time backoff = Time (backoffSlots * m_slotTime);
return backoff;
@@ -88,4 +92,12 @@
m_numBackoffRetries++;
}
+int64_t
+Backoff::AssignStreams (int64_t stream)
+{
+ NS_LOG_FUNCTION (this << stream);
+ m_rng->SetStream (stream);
+ return 1;
+}
+
} // namespace ns3
« no previous file with comments | « src/csma/model/backoff.h ('k') | src/csma/model/csma-net-device.h » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b