int
main (int argc, char *argv[])
{
Address serverAddress;
CommandLine cmd;
cmd.AddValue ("useIpv6", "Use Ipv6", useV6);
cmd.Parse (argc, argv);
NS_LOG_INFO ("Create nodes.");
NodeContainer n;
n.Create (4);
InternetStackHelper internet;
internet.Install (n);
NS_LOG_INFO ("Create channels.");
CsmaHelper csma;
csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (10000)));
csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
csma.SetDeviceAttribute ("Mtu", UintegerValue (1400));
NetDeviceContainer d = csma.Install (n);
NS_LOG_INFO ("Assign IP Addresses.");
Ipv4AddressHelper ipv4;
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer i = ipv4.Assign (d);
serverAddress = Address(i.GetAddress (1));
NS_LOG_INFO ("Create Applications.");
uint16_t port = 9; // well-known echo port number
TcpStreamServerHelper server (port);
ApplicationContainer apps = server.Install (n.Get (1));
apps.Start (Seconds (1.0));
apps.Stop (Seconds (10.0));
TcpStreamClientHelper client (serverAddress, port);
apps = client.Install (n.Get (0));
IntegerValue integerValueTemp;
GlobalValue::GetValueByName ("simulationStartTime", integerValueTemp);
apps.Start (MicroSeconds (integerValueTemp.Get ()));
apps.Stop (Seconds (5000.0));
NS_LOG_INFO ("Run Simulation.");
Simulator::Run ();
Simulator::Destroy ();
NS_LOG_INFO ("Done.");
}
Simulator::Schedule (Seconds(7.5), Config::Set, ".../<container name>/<index>/.../<attribute>/<attribute>",
DataRateValue (DataRate (1000))); csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (10000)));
through a path?ns3::CsmaChannel is accessible through the following paths with Config::Set and Config::Connect:
Simulator::Schedule (Seconds(7.5), Config::Set, "/ChannelList/*/$ns3::CsmaChannel/DataRate", DataRateValue (DataRate (100))); There are two basic ways to schedule events, with and without context. What does this mean?
vs.
static void ChangeRate()
{
Config::Set("/ChannelList/*/$ns3::CsmaChannel/DataRate", DataRateValue (DataRate (100)));
return;
}CsmaHelper csma;csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (1300)));Config::Set("/ChannelList/*/$ns3::CsmaChannel/DataRate", DataRateValue (DataRate (1300)));