#include "ns3/modulatedCCA-helper.h" #include "ns3/applications-module.h" #include "ns3/core-module.h" #include "ns3/internet-module.h" #include "ns3/network-module.h" #include "ns3/point-to-point-module.h" #include "ns3/log.h" /** * \file * * Explain here what the example does. */ using namespace ns3; NS_LOG_COMPONENT_DEFINE("ModulatedCCAExample"); int main(int argc, char* argv[]) { bool verbose = true; CommandLine cmd(__FILE__); cmd.AddValue("verbose", "Tell application to log if true", verbose); cmd.Parse(argc, argv); // Setup two nodes NodeContainer nodes; nodes.Create(2); PointToPointHelper pointToPoint; pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps")); pointToPoint.SetChannelAttribute("Delay", StringValue("2ms")); NetDeviceContainer devices; devices = pointToPoint.Install(nodes); InternetStackHelper stack; stack.Install(nodes); Ipv4AddressHelper address; address.SetBase("10.1.1.0", "255.255.255.0"); Ipv4InterfaceContainer interfaces = address.Assign(devices); Ipv4Address serverAddress = interfaces.GetAddress(1); // Create ModulatedCCA ModulatedCCAHelper modulatedCCA(serverAddress); ApplicationContainer app = modulatedCCA.Install(nodes.Get(0)); ModulatedCCA::ModulationConfig config = {ModulatedCCA::ModulationType::SIN, 1.0, 1.0, DataRate("1kbps")}; app.Get(0) -> SetAttribute("Name", StringValue("CCA_1")); Ptr app1 = DynamicCast(app.Get(0)); app1 -> SetConfig(config); DataRate rateA = DataRate("100Mbps"); DataRate rateB = DataRate("1000Mbps"); DataRate rateC = rateA - rateB; app.Start(Seconds(1.0)); app.Stop(Seconds(10.0)); NS_LOG_INFO("Run Simulation."); Simulator::Run(); NS_LOG_UNCOND("Done."); NS_LOG_UNCOND("Total Tx: " << DynamicCast(app.Get(0))->GetTotalTx() << " bytes."); Simulator::Destroy(); return 0; }