fix: cleanup for onboarding
This commit is contained in:
69
scratch/modulated-cca.cc
Normal file
69
scratch/modulated-cca.cc
Normal file
@@ -0,0 +1,69 @@
|
||||
#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<ModulatedCCA> app1 = DynamicCast<ModulatedCCA>(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<ModulatedCCA>(app.Get(0))->GetTotalTx() << " bytes.");
|
||||
Simulator::Destroy();
|
||||
return 0;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
// This file contains the implementation of the functions declared in the
|
||||
// corresponding header file.
|
||||
|
||||
#include "scratch-subdir-additional-header.h"
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
std::string
|
||||
ScratchSubdirGetMessage()
|
||||
{
|
||||
return "Scratch Subdir";
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
// This header does not provide much functionality but is meant to demonstrate how,
|
||||
// in a scratch subdirectory, one can create new programs that are implemented
|
||||
// in multiple files and headers.
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
/**
|
||||
* Get a message from the subdir.
|
||||
*
|
||||
* \return The message from the subdir
|
||||
*/
|
||||
std::string ScratchSubdirGetMessage();
|
||||
|
||||
} // namespace ns3
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
// This example shows how to create new simulations that are implemented in
|
||||
// multiple files and headers. The structure of this simulation project
|
||||
// is as follows:
|
||||
//
|
||||
// scratch/
|
||||
// | subdir/
|
||||
// | | - scratch-subdir.cc // Main simulation file
|
||||
// | | - scratch-subdir-additional-header.h // Additional header
|
||||
// | | - scratch-subdir-additional-header.cc // Additional header implementation
|
||||
//
|
||||
// This file contains the main() function, which calls an external function
|
||||
// defined in the "scratch-subdir-additional-header.h" header file and
|
||||
// implemented in "scratch-subdir-additional-header.cc".
|
||||
|
||||
#include "scratch-subdir-additional-header.h"
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE("ScratchSubdir");
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
std::string message = ScratchSubdirGetMessage();
|
||||
NS_LOG_UNCOND(message);
|
||||
|
||||
Simulator::Run();
|
||||
Simulator::Destroy();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user