From 261dc3b45ad5402f1064367436ae04326ec42405 Mon Sep 17 00:00:00 2001 From: Mitch Watrous Date: Mon, 20 Aug 2012 19:08:45 -0700 Subject: [PATCH] Replace more instances of RandomVariable with RandomVariableStream --- examples/stats/wifi-example-apps.cc | 9 +++++---- examples/stats/wifi-example-apps.h | 2 +- examples/wireless/wifi-adhoc.cc | 4 ++-- examples/wireless/wifi-blockack.cc | 4 ++-- examples/wireless/wifi-hidden-terminal.cc | 4 ++-- src/click/examples/nsclick-raw-wlan.cc | 4 ++-- src/click/examples/nsclick-simple-lan.cc | 4 ++-- src/csma-layout/examples/csma-star.cc | 4 ++-- src/mesh/model/flame/flame-protocol.cc | 1 - src/mpi/examples/nms-p2p-nix-distributed.cc | 4 ++-- src/mpi/examples/simple-distributed.cc | 4 ++-- src/nix-vector-routing/examples/nms-p2p-nix.cc | 10 +++++----- src/openflow/examples/openflow-switch.cc | 6 +++--- src/tap-bridge/examples/tap-wifi-dumbbell.cc | 4 ++-- 14 files changed, 32 insertions(+), 32 deletions(-) diff --git a/examples/stats/wifi-example-apps.cc b/examples/stats/wifi-example-apps.cc index 9c222009a..ea5fb6dd0 100644 --- a/examples/stats/wifi-example-apps.cc +++ b/examples/stats/wifi-example-apps.cc @@ -62,9 +62,9 @@ Sender::GetTypeId (void) MakeUintegerAccessor (&Sender::m_numPkts), MakeUintegerChecker(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 ()) .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 (); 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); } diff --git a/examples/stats/wifi-example-apps.h b/examples/stats/wifi-example-apps.h index 653a17599..f7e9ae612 100644 --- a/examples/stats/wifi-example-apps.h +++ b/examples/stats/wifi-example-apps.h @@ -53,7 +53,7 @@ private: uint32_t m_pktSize; Ipv4Address m_destAddr; uint32_t m_destPort; - RandomVariable m_interval; + Ptr m_interval; uint32_t m_numPkts; Ptr m_socket; diff --git a/examples/wireless/wifi-adhoc.cc b/examples/wireless/wifi-adhoc.cc index d4958c204..4ab2da6ee 100644 --- a/examples/wireless/wifi-adhoc.cc +++ b/examples/wireless/wifi-adhoc.cc @@ -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)); diff --git a/examples/wireless/wifi-blockack.cc b/examples/wireless/wifi-blockack.cc index 42db10b9c..62ae61c31 100644 --- a/examples/wireless/wifi-blockack.cc +++ b/examples/wireless/wifi-blockack.cc @@ -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); diff --git a/examples/wireless/wifi-hidden-terminal.cc b/examples/wireless/wifi-hidden-terminal.cc index f03443d4c..0a5c2449c 100644 --- a/examples/wireless/wifi-hidden-terminal.cc +++ b/examples/wireless/wifi-hidden-terminal.cc @@ -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")); diff --git a/src/click/examples/nsclick-raw-wlan.cc b/src/click/examples/nsclick-raw-wlan.cc index ec2b867da..410a013e5 100644 --- a/src/click/examples/nsclick-raw-wlan.cc +++ b/src/click/examples/nsclick-raw-wlan.cc @@ -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; diff --git a/src/click/examples/nsclick-simple-lan.cc b/src/click/examples/nsclick-simple-lan.cc index 61b58821e..8e4622850 100644 --- a/src/click/examples/nsclick-simple-lan.cc +++ b/src/click/examples/nsclick-simple-lan.cc @@ -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; diff --git a/src/csma-layout/examples/csma-star.cc b/src/csma-layout/examples/csma-star.cc index 3f20b9455..658770556 100644 --- a/src/csma-layout/examples/csma-star.cc +++ b/src/csma-layout/examples/csma-star.cc @@ -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; diff --git a/src/mesh/model/flame/flame-protocol.cc b/src/mesh/model/flame/flame-protocol.cc index e900a1973..7f4bc60ce 100644 --- a/src/mesh/model/flame/flame-protocol.cc +++ b/src/mesh/model/flame/flame-protocol.cc @@ -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"); diff --git a/src/mpi/examples/nms-p2p-nix-distributed.cc b/src/mpi/examples/nms-p2p-nix-distributed.cc index 690669be1..bf228fc89 100644 --- a/src/mpi/examples/nms-p2p-nix-distributed.cc +++ b/src/mpi/examples/nms-p2p-nix-distributed.cc @@ -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) diff --git a/src/mpi/examples/simple-distributed.cc b/src/mpi/examples/simple-distributed.cc index f1245814f..54ecc3ec9 100644 --- a/src/mpi/examples/simple-distributed.cc +++ b/src/mpi/examples/simple-distributed.cc @@ -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) diff --git a/src/nix-vector-routing/examples/nms-p2p-nix.cc b/src/nix-vector-routing/examples/nms-p2p-nix.cc index d69c5f55e..7ad0eb62f 100644 --- a/src/nix-vector-routing/examples/nms-p2p-nix.cc +++ b/src/nix-vector-routing/examples/nms-p2p-nix.cc @@ -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 urng = CreateObject (); 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)); diff --git a/src/openflow/examples/openflow-switch.cc b/src/openflow/examples/openflow-switch.cc index 72d83c407..2e71f130f 100644 --- a/src/openflow/examples/openflow-switch.cc +++ b/src/openflow/examples/openflow-switch.cc @@ -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 diff --git a/src/tap-bridge/examples/tap-wifi-dumbbell.cc b/src/tap-bridge/examples/tap-wifi-dumbbell.cc index cda61c9b2..b4c45db7b 100644 --- a/src/tap-bridge/examples/tap-wifi-dumbbell.cc +++ b/src/tap-bridge/examples/tap-wifi-dumbbell.cc @@ -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));