23 #include "ns3/simple-device-energy-model.h"
24 #include "ns3/uan-net-device.h"
25 #include "ns3/simulator.h"
26 #include "ns3/packet.h"
28 #include "ns3/uan-helper.h"
29 #include "ns3/basic-energy-source-helper.h"
30 #include "ns3/acoustic-modem-energy-model-helper.h"
31 #include "ns3/acoustic-modem-energy-model.h"
32 #include "ns3/constant-position-mobility-model.h"
33 #include "ns3/uan-channel.h"
34 #include "ns3/uan-noise-model-default.h"
35 #include "ns3/uan-prop-model-ideal.h"
36 #include "ns3/uan-header-common.h"
37 #include "ns3/uan-phy.h"
87 :
TestCase (
"Acoustic Modem energy model test case"),
108 dev->Send (pkt, dev->GetBroadcast (), 0);
112 Simulator::Schedule (
Seconds (10),
120 [[maybe_unused]] uint16_t mode,
121 [[maybe_unused]]
const Address &sender)
133 m_node = CreateObject<Node> ();
138 channel->SetPropagationModel (CreateObject<UanPropModelIdeal> ());
139 channel->SetNoiseModel (noise);
146 uint32_t datarate = devNode->GetPhy ()->GetMode (0).GetDataRateBps ();
152 eh.
Set (
"BasicEnergySourceInitialEnergyJ",
DoubleValue (10000000.0));
157 mobility->SetPosition (Vector (0,0,-500));
177 eh.
Set (
"BasicEnergySourceInitialEnergyJ",
DoubleValue (10000000.0));
182 mobility2->SetPosition (Vector (0,0,0));
200 double consumed1 = src1->GetInitialEnergy () - src1->GetRemainingEnergy ();
205 "Incorrect gateway consumed energy!");
208 double consumed2 = src2->GetInitialEnergy () - src2->GetRemainingEnergy ();
213 "Incorrect node consumed energy!");
215 Simulator::Destroy ();
247 :
TestCase (
"Acoustic Modem energy depletion test case"),
273 dev->Send (pkt, dev->GetBroadcast (), 0);
275 Simulator::Schedule (
Seconds (10),
285 m_node = CreateObject<Node> ();
290 channel->SetPropagationModel (CreateObject<UanPropModelIdeal> ());
291 channel->SetNoiseModel (noise);
304 mobility->SetPosition (Vector (0,0,0));
323 Simulator::Destroy ();
Acoustic Modem Energy Depletion Test Case.
uint32_t m_packetSize
packet size
void SendOnePacket(Ptr< Node > node)
Send one packet function.
void DoRun(void)
Implementation to actually run this TestCase.
AcousticModemEnergyDepletionTestCase()
void DepletionHandler(void)
Depletion handler function.
uint32_t m_callbackCount
callback count
Ptr< Node > m_node
the node
~AcousticModemEnergyDepletionTestCase()
double m_simTime
Simulation time.
Acoustic Modem Energy Test Case.
Ptr< Node > m_gateway
the gateway
double m_simTime
simulation time
uint32_t m_sentPackets
number of sent packets
void SendOnePacket(Ptr< Node > node)
Send one packet function.
bool RxPacket(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
Receive packet function.
void DoRun(void)
Implementation to actually run this TestCase.
~AcousticModemEnergyTestCase()
uint32_t m_packetSize
packet size
uint32_t m_bytesRx
bytes received
AcousticModemEnergyTestCase()
Unit test suite for underwater energy model.
UanEnergyModelTestSuite()
Assign AcousticModemEnergyModel to uan devices.
void SetDepletionCallback(AcousticModemEnergyModel::AcousticModemEnergyDepletionCallback callback)
Sets the callback to be invoked when energy is depleted.
WHOI micro-modem energy model.
a polymophic address class
Creates a BasicEnergySource object.
void Set(std::string name, const AttributeValue &v)
Holds a vector of ns3::DeviceEnergyModel pointers.
Ptr< DeviceEnergyModel > Get(uint32_t i) const
Get the i-th Ptr<DeviceEnergyModel> stored in this container.
DeviceEnergyModelContainer Install(Ptr< NetDevice > device, Ptr< EnergySource > source) const
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Holds a vector of ns3::EnergySource pointers.
EnergySourceContainer Install(Ptr< Node > node) const
virtual void SetReceiveCallback(ReceiveCallback cb)=0
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
UAN configuration helper.
NetDeviceContainer Install(NodeContainer c) const
This method creates a simple ns3::UanChannel (with a default ns3::UanNoiseModelDefault and ns3::UanPr...
Net device for UAN models.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Time Seconds(double value)
Construct a Time in the indicated unit.
void SendOnePacket(Ptr< LrWpanPhy > sender, Ptr< LrWpanPhy > receiver)
Send one packet.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
static UanEnergyModelTestSuite g_uanEnergyModelTestSuite