Replace more instances of RandomVariable with RandomVariableStream

This commit is contained in:
Mitch Watrous
2012-08-20 19:08:45 -07:00
parent da1cf74f90
commit 261dc3b45a
14 changed files with 32 additions and 32 deletions

View File

@@ -62,9 +62,9 @@ Sender::GetTypeId (void)
MakeUintegerAccessor (&Sender::m_numPkts),
MakeUintegerChecker<uint32_t>(1))
.AddAttribute ("Interval", "Delay between transmissions.",
RandomVariableValue (ConstantVariable (0.5)),
MakeRandomVariableAccessor (&Sender::m_interval),
MakeRandomVariableChecker ())
StringValue ("ns3::ConstantRandomVariable[Constant=0.5]"),
MakePointerAccessor (&Sender::m_interval),
MakePointerChecker <RandomVariableStream>())
.AddTraceSource ("Tx", "A new packet is created and is sent",
MakeTraceSourceAccessor (&Sender::m_txTrace))
;
@@ -75,6 +75,7 @@ Sender::GetTypeId (void)
Sender::Sender()
{
NS_LOG_FUNCTION_NOARGS ();
m_interval = CreateObject<ConstantRandomVariable> ();
m_socket = 0;
}
@@ -139,7 +140,7 @@ void Sender::SendPacket ()
m_txTrace (packet);
if (++m_count < m_numPkts) {
m_sendEvent = Simulator::Schedule (Seconds (m_interval.GetValue ()),
m_sendEvent = Simulator::Schedule (Seconds (m_interval->GetValue ()),
&Sender::SendPacket, this);
}

View File

@@ -53,7 +53,7 @@ private:
uint32_t m_pktSize;
Ipv4Address m_destAddr;
uint32_t m_destPort;
RandomVariable m_interval;
Ptr<ConstantRandomVariable> m_interval;
uint32_t m_numPkts;
Ptr<Socket> m_socket;

View File

@@ -143,8 +143,8 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
socket.SetProtocol (1);
OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket));
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (250)));
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=250]"));
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
onoff.SetAttribute ("DataRate", DataRateValue (DataRate (60000000)));
onoff.SetAttribute ("PacketSize", UintegerValue (2000));

View File

@@ -121,8 +121,8 @@ int main (int argc, char const* argv[])
DataRate dataRate ("1Mb/s");
OnOffHelper onOff ("ns3::UdpSocketFactory", Address (InetSocketAddress (apIf.GetAddress (0), port)));
onOff.SetAttribute ("DataRate", DataRateValue (dataRate));
onOff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (0.01)));
onOff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (8)));
onOff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=0.01]"));
onOff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=8]"));
onOff.SetAttribute ("PacketSize", UintegerValue (50));
ApplicationContainer staApps = onOff.Install (sta);

View File

@@ -100,8 +100,8 @@ void experiment (bool enableCtsRts)
uint16_t cbrPort = 12345;
OnOffHelper onOffHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address ("10.0.0.2"), cbrPort));
onOffHelper.SetAttribute ("PacketSize", UintegerValue (200));
onOffHelper.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
onOffHelper.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
onOffHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
onOffHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
// flow 1: node 0 -> node 1
onOffHelper.SetAttribute ("DataRate", StringValue ("3000000bps"));

View File

@@ -120,8 +120,8 @@ int main (int argc, char *argv[])
recvapp.Stop (Seconds (10.0));
OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address ());
onOffHelper.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
onOffHelper.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
onOffHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
onOffHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
ApplicationContainer appcont;

View File

@@ -75,8 +75,8 @@ int main (int argc, char *argv[])
recvapp.Stop (Seconds (10.0));
OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address ());
onOffHelper.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
onOffHelper.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
onOffHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
onOffHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
ApplicationContainer appcont;

View File

@@ -178,8 +178,8 @@ main (int argc, char *argv[])
// Create OnOff applications to send TCP to the hub, one on each spoke node.
//
OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address ());
onOffHelper.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
onOffHelper.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
onOffHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
onOffHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
ApplicationContainer spokeApps;

View File

@@ -30,7 +30,6 @@
#include "ns3/wifi-net-device.h"
#include "ns3/mesh-point-device.h"
#include "ns3/mesh-wifi-interface-mac.h"
#include "ns3/random-variable.h"
NS_LOG_COMPONENT_DEFINE ("FlameProtocol");

View File

@@ -391,9 +391,9 @@ main (int argc, char *argv[])
Config::SetDefault ("ns3::OnOffApplication::MaxBytes",
UintegerValue (nBytes));
Config::SetDefault ("ns3::OnOffApplication::OnTime",
RandomVariableValue (ConstantVariable (1)));
StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
Config::SetDefault ("ns3::OnOffApplication::OffTime",
RandomVariableValue (ConstantVariable (0)));
StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
if (single)

View File

@@ -226,9 +226,9 @@ main (int argc, char *argv[])
{
OnOffHelper clientHelper ("ns3::UdpSocketFactory", Address ());
clientHelper.SetAttribute
("OnTime", RandomVariableValue (ConstantVariable (1)));
("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
clientHelper.SetAttribute
("OffTime", RandomVariableValue (ConstantVariable (0)));
("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
ApplicationContainer clientApps;
for (uint32_t i = 0; i < 4; ++i)

View File

@@ -440,7 +440,7 @@ main (int argc, char *argv[])
StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (512));
UniformVariable urng;
Ptr<UniformRandomVariable> urng = CreateObject<UniformRandomVariable> ();
int r1;
double r2;
for (int z = 0; z < nCN; ++z)
@@ -463,8 +463,8 @@ main (int argc, char *argv[])
nodes_net2LAN[z][i][j].Get (0));
sinkApp.Start (Seconds (0.0));
// Sources
r1 = 2 + (int)(4 * urng.GetValue ());
r2 = 10 * urng.GetValue ();
r1 = 2 + (int)(4 * urng->GetValue ());
r2 = 10 * urng->GetValue ();
OnOffHelper client ("ns3::TcpSocketFactory", Address ());
AddressValue remoteAddress (InetSocketAddress (
ifs2LAN[z][i][j].GetAddress (0), 9999));
@@ -487,8 +487,8 @@ main (int argc, char *argv[])
nodes_net3LAN[z][i][j].Get (0));
sinkApp.Start (Seconds (0.0));
// Sources
r1 = 2 + (int)(4 * urng.GetValue ());
r2 = 10 * urng.GetValue ();
r1 = 2 + (int)(4 * urng->GetValue ());
r2 = 10 * urng->GetValue ();
OnOffHelper client ("ns3::TcpSocketFactory", Address ());
AddressValue remoteAddress (InetSocketAddress (
ifs3LAN[z][i][j].GetAddress (0), 9999));

View File

@@ -157,9 +157,9 @@ main (int argc, char *argv[])
uint16_t port = 9; // Discard port (RFC 863)
OnOffHelper onoff ("ns3::UdpSocketFactory",
Address (InetSocketAddress (Ipv4Address ("10.1.1.2"), port)));
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
Address (InetSocketAddress (Ipv4Address ("10.1.1.2"), port]"));
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0)));
ApplicationContainer app = onoff.Install (terminals.Get (0));
// Start the application

View File

@@ -207,8 +207,8 @@ main (int argc, char *argv[])
//
uint16_t port = 9; // Discard port (RFC 863)
OnOffHelper onoff ("ns3::UdpSocketFactory", InetSocketAddress (interfaces.GetAddress (1), port));
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
ApplicationContainer apps = onoff.Install (nodesLeft.Get (3));
apps.Start (Seconds (1.0));