#include "ns3/core-module.h" #include "ns3/common-module.h" #include "ns3/node-module.h" #include "ns3/mobility-module.h" #include "ns3/contrib-module.h" #include "ns3/helper-module.h" #include "ns3/uan-module.h" #include "ns3/basic-energy-source-helper.h" #include "ns3/acoustic-modem-energy-model-helper.h" #include "ns3/acoustic-modem-energy-model.h" #include #include #include #include #include using namespace ns3; uint32_t m_dataRate = 80; uint32_t m_depth = 70; uint32_t m_boundary = 1000; UanHelper uan; int run () { std::set setClusters; uan.SetMac ("ns3::UanMacAloha"); NodeContainer nc = NodeContainer (); nc.Create (2); //Ptr prop = CreateObjectWithAttributes (); Ptr prop = CreateObjectWithAttributes (); Ptr channel = CreateObjectWithAttributes ("PropagationModel", PointerValue (prop)); //Create net device and nodes with UanHelper NetDeviceContainer devices = uan.Install (nc, channel); uan.EnableAscii (std::cout, devices); MobilityHelper mobility; Ptr pos = CreateObject (); pos->Add (Vector (0, 0, m_depth)); pos->Add (Vector (0, m_boundary, m_depth)); mobility.SetPositionAllocator (pos); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (nc); Ptr packet = Create (); devices.Get (0)->Send(packet, UanAddress::GetBroadcast (), 0); Simulator::Run (); return 0; } int main (int argc, char **argv) { std::string perModel = "ns3::UanPhyPerGenDefault"; std::string sinrModel = "ns3::UanPhyCalcSinrDefault"; ObjectFactory obf; obf.SetTypeId (perModel); Ptr per = obf.Create (); obf.SetTypeId (sinrModel); Ptr sinr = obf.Create (); UanTxMode mode; mode = UanTxModeFactory::CreateMode (UanTxMode::FSK, m_dataRate, m_dataRate, 12000, m_dataRate, 2, "Default mode"); UanModesList myModes; myModes.AppendMode (mode); uan.SetPhy ("ns3::UanPhyGen", "PerModel", PointerValue (per), "SinrModel", PointerValue (sinr), "SupportedModes", UanModesListValue (myModes), "TxPower", DoubleValue(190)); //Son dB m_boundary = atoi (argv[1]); run (); per = 0; sinr = 0; }