--- a/RELEASE_NOTES Thu Oct 16 23:08:16 2014 +0900
+++ b/RELEASE_NOTES Thu Oct 16 23:08:36 2014 +0900
@@ -20,7 +20,7 @@
Bugs fixed
----------
--
+- Bug 2009 - update code for RandomVariable deprecation
Release dce-1.4
===============
--- a/example/ccnx/dce-wifi-ccnx.cc Thu Oct 16 23:08:16 2014 +0900
+++ b/example/ccnx/dce-wifi-ccnx.cc Thu Oct 16 23:08:36 2014 +0900
@@ -35,7 +35,6 @@
#include "ns3/dce-module.h"
#include "ns3/rectangle.h"
-#include "ns3/random-variable.h"
--- a/helper/dce-manager-helper.cc Thu Oct 16 23:08:16 2014 +0900
+++ b/helper/dce-manager-helper.cc Thu Oct 16 23:08:36 2014 +0900
@@ -5,7 +5,7 @@
#include "task-scheduler.h"
#include "task-manager.h"
#include "loader-factory.h"
-#include "ns3/random-variable.h"
+#include "ns3/random-variable-stream.h"
#include "ns3/uinteger.h"
#include "ns3/string.h"
#include "ns3/config.h"
@@ -24,8 +24,6 @@
namespace ns3 {
-UniformVariable g_firstPid;
-
NS_OBJECT_ENSURE_REGISTERED (DceManagerHelper);
TypeId
@@ -111,7 +109,8 @@
taskManager->SetScheduler (scheduler);
taskManager->SetDelayModel (delay);
- manager->SetAttribute ("FirstPid", UintegerValue (g_firstPid.GetInteger (0, 0xffff)));
+ Ptr<UniformRandomVariable> uv = CreateObject<UniformRandomVariable> ();
+ manager->SetAttribute ("FirstPid", UintegerValue (uv->GetInteger (0, 0xffff)));
Ptr<Node> node = *i;
node->AggregateObject (taskManager);
node->AggregateObject (loader);
--- a/model/dce-manager.cc Thu Oct 16 23:08:16 2014 +0900
+++ b/model/dce-manager.cc Thu Oct 16 23:08:36 2014 +0900
@@ -39,6 +39,7 @@
#include "ns3/ptr.h"
#include "ns3/uinteger.h"
#include "ns3/boolean.h"
+#include "ns3/double.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/enum.h"
#include "file-usage.h"
@@ -349,7 +350,9 @@
process->stdinFilename = stdinfilename;
//"seeding" random variable
- process->rndVarible = UniformVariable (0, RAND_MAX);
+ process->rndVariable = CreateObject<UniformRandomVariable> ();
+ process->rndVariable->SetAttribute ("Min", DoubleValue (0));
+ process->rndVariable->SetAttribute ("Max", DoubleValue (RAND_MAX));
process->nodeId = UtilsGetNodeId ();
@@ -638,7 +641,9 @@
clone->penvp = thread->process->penvp;
//"seeding" random variable
- clone->rndVarible = UniformVariable (0, RAND_MAX);
+ clone->rndVariable = CreateObject<UniformRandomVariable> ();
+ clone->rndVariable->SetAttribute ("Min", DoubleValue (0));
+ clone->rndVariable->SetAttribute ("Max", DoubleValue (RAND_MAX));
m_processes[clone->pid] = clone;
Thread *cloneThread = CreateThread (clone);
--- a/model/dce-node-context.cc Thu Oct 16 23:08:16 2014 +0900
+++ b/model/dce-node-context.cc Thu Oct 16 23:08:36 2014 +0900
@@ -25,6 +25,7 @@
#include "ns3/node.h"
#include "ns3/node-list.h"
#include "ns3/names.h"
+#include "ns3/double.h"
#include "utils.h"
#include <string.h>
#include "process.h"
@@ -51,8 +52,10 @@
}
DceNodeContext::DceNodeContext ()
{
- m_randomCtx = NormalVariable (0, 2 ^ 32 - 1);
- m_rndBuffer = m_randomCtx.GetInteger ();
+ m_randomCtx = CreateObject<NormalRandomVariable> ();
+ m_randomCtx->SetAttribute ("Mean", DoubleValue (0));
+ m_randomCtx->SetAttribute ("Variance", DoubleValue (2 ^ 32 - 1));
+ m_rndBuffer = m_randomCtx->GetInteger ();
m_rndOffset = 0;
}
@@ -127,7 +130,7 @@
if (m_rndOffset >= 4)
{
m_rndOffset = 0;
- m_rndBuffer = m_randomCtx.GetInteger ();
+ m_rndBuffer = m_randomCtx->GetInteger ();
}
return v;
}
--- a/model/dce-node-context.h Thu Oct 16 23:08:16 2014 +0900
+++ b/model/dce-node-context.h Thu Oct 16 23:08:36 2014 +0900
@@ -27,7 +27,7 @@
#include "ns3/traced-callback.h"
#include "ns3/simulator.h"
#include <sys/utsname.h>
-#include "ns3/random-variable.h"
+#include "ns3/random-variable-stream.h"
extern "C" struct Libc;
@@ -62,7 +62,7 @@
std::string m_release;
std::string m_version;
std::string m_hardId;
- RandomVariable m_randomCtx;
+ Ptr<RandomVariableStream> m_randomCtx;
uint32_t m_rndBuffer;
uint8_t m_rndOffset;
};
--- a/model/dce.cc Thu Oct 16 23:08:16 2014 +0900
+++ b/model/dce.cc Thu Oct 16 23:08:36 2014 +0900
@@ -30,7 +30,6 @@
#include "ns3/log.h"
#include "ns3/simulator.h"
#include "ns3/names.h"
-#include "ns3/random-variable.h"
#include "ns3/ipv4-l3-protocol.h"
#include "socket-fd-factory.h"
@@ -330,12 +329,12 @@
long int dce_random (void)
{
Thread *current = Current ();
- return current->process->rndVarible.GetInteger ();
+ return current->process->rndVariable->GetInteger ();
}
int dce_rand (void)
{
Thread *current = Current ();
- return current->process->rndVarible.GetInteger ();
+ return current->process->rndVariable->GetInteger ();
}
unsigned short int * dce_seed48 (unsigned short int seed16v[3])
{
--- a/model/kernel-socket-fd-factory.cc Thu Oct 16 23:08:16 2014 +0900
+++ b/model/kernel-socket-fd-factory.cc Thu Oct 16 23:08:36 2014 +0900
@@ -17,9 +17,10 @@
#include "ns3/log.h"
#include "ns3/string.h"
#include "ns3/double.h"
+#include "ns3/pointer.h"
#include "ns3/node.h"
#include "ns3/net-device.h"
-#include "ns3/random-variable.h"
+#include "ns3/random-variable-stream.h"
#include "ns3/event-id.h"
#include "ns3/simulator.h"
#include "ns3/mac48-address.h"
@@ -78,9 +79,9 @@
MakeDoubleAccessor (&KernelSocketFdFactory::m_rate),
MakeDoubleChecker<double> ())
.AddAttribute ("RanVar", "The decision variable attached to this error model.",
- RandomVariableValue (UniformVariable (0.0, 1.0)),
- MakeRandomVariableAccessor (&KernelSocketFdFactory::m_ranvar),
- MakeRandomVariableChecker ())
+ StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
+ MakePointerAccessor (&KernelSocketFdFactory::m_ranvar),
+ MakePointerChecker<RandomVariableStream> ())
;
return tid;
}
@@ -91,6 +92,7 @@
m_logFile (0)
{
TypeId::LookupByNameFailSafe ("ns3::LteUeNetDevice", &m_lteUeTid);
+ m_variable = CreateObject<UniformRandomVariable> ();
}
KernelSocketFdFactory::~KernelSocketFdFactory ()
@@ -137,7 +139,7 @@
KernelSocketFdFactory::Malloc (struct SimKernel *kernel, unsigned long size)
{
KernelSocketFdFactory *self = (KernelSocketFdFactory *)kernel;
- if (self->m_ranvar.GetValue () < self->m_rate)
+ if (self->m_ranvar->GetValue () < self->m_rate)
{
NS_LOG_DEBUG ("return null");
// Inject fault
@@ -256,7 +258,7 @@
} u;
for (uint8_t i = 0; i < sizeof (u.buffer); i++)
{
- u.buffer[i] = self->m_variable.GetInteger (0,255);
+ u.buffer[i] = self->m_variable->GetInteger (0,255);
}
return u.v;
}
--- a/model/kernel-socket-fd-factory.h Thu Oct 16 23:08:16 2014 +0900
+++ b/model/kernel-socket-fd-factory.h Thu Oct 16 23:08:36 2014 +0900
@@ -4,7 +4,7 @@
#include "socket-fd-factory.h"
#include "task-manager.h"
#include "ns3/net-device.h"
-#include "ns3/random-variable.h"
+#include "ns3/random-variable-stream.h"
#include <sys/socket.h>
#include <vector>
#include <string>
@@ -142,11 +142,11 @@
std::vector<std::pair<Ptr<NetDevice>,struct SimDevice *> > m_devices;
std::list<Task *> m_kernelTasks;
- UniformVariable m_variable;
+ Ptr<UniformRandomVariable> m_variable;
KingsleyAlloc *m_alloc;
std::vector<Ptr<KernelDeviceStateListener> > m_listeners;
double m_rate;
- RandomVariable m_ranvar;
+ Ptr<RandomVariableStream> m_ranvar;
uint16_t m_pid;
TypeId m_lteUeTid;
};
--- a/model/process-delay-model.cc Thu Oct 16 23:08:16 2014 +0900
+++ b/model/process-delay-model.cc Thu Oct 16 23:08:36 2014 +0900
@@ -19,6 +19,8 @@
*/
#include "process-delay-model.h"
#include "ns3/log.h"
+#include "ns3/string.h"
+#include "ns3/pointer.h"
#include <sys/time.h>
#include <time.h>
@@ -45,9 +47,9 @@
.SetParent<ProcessDelayModel> ()
.AddConstructor<RandomProcessDelayModel> ()
.AddAttribute ("Variable", "Pick the process delay at random.",
- RandomVariableValue (ConstantVariable (0.0)),
- MakeRandomVariableAccessor (&RandomProcessDelayModel::m_variable),
- MakeRandomVariableChecker ())
+ StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"),
+ MakePointerAccessor (&RandomProcessDelayModel::m_variable),
+ MakePointerChecker<RandomVariableStream> ())
;
return tid;
}
@@ -57,8 +59,9 @@
}
void
-RandomProcessDelayModel::SetVariable (RandomVariable variable)
+RandomProcessDelayModel::SetVariable (Ptr<RandomVariableStream> variable)
{
+ m_variable = variable;
}
void
@@ -68,7 +71,7 @@
Time
RandomProcessDelayModel::RecordEnd (void)
{
- return Seconds (m_variable.GetValue ());
+ return Seconds (m_variable->GetValue ());
}
NS_OBJECT_ENSURE_REGISTERED (TimeOfDayProcessDelayModel);
--- a/model/process-delay-model.h Thu Oct 16 23:08:16 2014 +0900
+++ b/model/process-delay-model.h Thu Oct 16 23:08:36 2014 +0900
@@ -21,7 +21,7 @@
#define PROCESS_DELAY_MODEL_H
#include "ns3/object.h"
-#include "ns3/random-variable.h"
+#include "ns3/random-variable-stream.h"
#include "ns3/nstime.h"
namespace ns3 {
@@ -42,13 +42,13 @@
RandomProcessDelayModel ();
- void SetVariable (RandomVariable variable);
+ void SetVariable (Ptr<RandomVariableStream> variable);
virtual void RecordStart (void);
virtual Time RecordEnd (void);
private:
- RandomVariable m_variable;
+ Ptr<RandomVariableStream> m_variable;
};
class TimeOfDayProcessDelayModel : public ProcessDelayModel
--- a/model/process.h Thu Oct 16 23:08:16 2014 +0900
+++ b/model/process.h Thu Oct 16 23:08:36 2014 +0900
@@ -31,7 +31,7 @@
#include "ns3/event-id.h"
#include "ns3/nstime.h"
#include "unix-fd.h"
-#include "ns3/random-variable.h"
+#include "ns3/random-variable-stream.h"
class KingsleyAlloc;
@@ -188,7 +188,7 @@
// lifetime due to weirdness in the posix API.
std::vector<void *> allocated;
//random variable for rand and random implementation
- RandomVariable rndVarible;
+ Ptr<RandomVariableStream> rndVariable;
// srand48 seed
struct drand48_data seed48Current;
// Current umask
--- a/myscripts/ccn-tap-vlc/dce-ccn-vlc.cc Thu Oct 16 23:08:16 2014 +0900
+++ b/myscripts/ccn-tap-vlc/dce-ccn-vlc.cc Thu Oct 16 23:08:36 2014 +0900
@@ -154,7 +154,7 @@
NetDeviceContainer devices = csma.Install (nodes);
Ptr<RateErrorModel> em = CreateObjectWithAttributes<RateErrorModel> (
- "RanVar", RandomVariableValue (UniformVariable (0., 1.)),
+ "RanVar", StringValue ("ns3::UniformRandomVariable[Min=0.|Max=1.]"),
"ErrorRate", DoubleValue (0.00001));
// devices.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (em));