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 |