Skip to content

Commit

Permalink
Update supported ns-3 version to 3.40 (#137)
Browse files Browse the repository at this point in the history
+ remove obsolete wscript files
+ fix warnings: deprecated Ptr<T>::Tester*() operator
  • Loading branch information
non-det-alle authored Oct 12, 2023
1 parent e8f7a21 commit a82f2cc
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 185 deletions.
2 changes: 1 addition & 1 deletion NS3-VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release ns-3.29
release ns-3.40
27 changes: 0 additions & 27 deletions examples/wscript

This file was deleted.

4 changes: 2 additions & 2 deletions helper/forwarder-helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ ForwarderHelper::InstallPriv (Ptr<Node> node) const
for (uint32_t i = 0; i < node->GetNDevices (); i++)
{
Ptr<NetDevice> currentNetDevice = node->GetDevice (i);
if (currentNetDevice->GetObject<LoraNetDevice> () != 0)
if (currentNetDevice->GetObject<LoraNetDevice>())
{
Ptr<LoraNetDevice> loraNetDevice =
currentNetDevice->GetObject<LoraNetDevice> ();
app->SetLoraNetDevice (loraNetDevice);
loraNetDevice->SetReceiveCallback (MakeCallback
(&Forwarder::ReceiveFromLora, app));
}
else if (currentNetDevice->GetObject<PointToPointNetDevice> () != 0)
else if (currentNetDevice->GetObject<PointToPointNetDevice> ())
{
Ptr<PointToPointNetDevice> pointToPointNetDevice =
currentNetDevice->GetObject<PointToPointNetDevice> ();
Expand Down
8 changes: 4 additions & 4 deletions helper/lora-helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ NS_LOG_COMPONENT_DEFINE ("LoraHelper");

// Create the PHY
Ptr<LoraPhy> phy = phyHelper.Create (node, device);
NS_ASSERT (phy != 0);
NS_ASSERT (phy);
device->SetPhy (phy);
NS_LOG_DEBUG ("Done creating the PHY");

Expand Down Expand Up @@ -104,7 +104,7 @@ NS_LOG_COMPONENT_DEFINE ("LoraHelper");

// Create the MAC
Ptr<LorawanMac> mac = macHelper.Create (node, device);
NS_ASSERT (mac != 0);
NS_ASSERT (mac);
mac->SetPhy (phy);
NS_LOG_DEBUG ("Done creating the MAC");
device->SetMac (mac);
Expand Down Expand Up @@ -217,10 +217,10 @@ LoraHelper::DoPrintDeviceStatus (NodeContainer endDevices, NodeContainer gateway
{
Ptr<Node> object = *j;
Ptr<MobilityModel> position = object->GetObject<MobilityModel> ();
NS_ASSERT (position != 0);
NS_ASSERT (position);
Ptr<NetDevice> netDevice = object->GetDevice (0);
Ptr<LoraNetDevice> loraNetDevice = netDevice->GetObject<LoraNetDevice> ();
NS_ASSERT (loraNetDevice != 0);
NS_ASSERT (loraNetDevice);
Ptr<ClassAEndDeviceLorawanMac> mac = loraNetDevice->GetMac ()->GetObject<ClassAEndDeviceLorawanMac> ();
int dr = int(mac->GetDataRate ());
double txPower = mac->GetTransmissionPower ();
Expand Down
14 changes: 7 additions & 7 deletions helper/lorawan-mac-helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ LorawanMacHelper::Create (Ptr<Node> node, Ptr<NetDevice> device) const
mac->SetDevice (device);

// If we are operating on an end device, add an address to it
if (m_deviceType == ED_A && m_addrGen != 0)
if (m_deviceType == ED_A && m_addrGen)
{
mac->GetObject<ClassAEndDeviceLorawanMac> ()->SetDeviceAddress (m_addrGen->NextAddress ());
}
Expand Down Expand Up @@ -461,13 +461,13 @@ LorawanMacHelper::SetSpreadingFactorsUp (NodeContainer endDevices, NodeContainer
{
Ptr<Node> object = *j;
Ptr<MobilityModel> position = object->GetObject<MobilityModel> ();
NS_ASSERT (position != 0);
NS_ASSERT (position);
Ptr<NetDevice> netDevice = object->GetDevice (0);
Ptr<LoraNetDevice> loraNetDevice = netDevice->GetObject<LoraNetDevice> ();
NS_ASSERT (loraNetDevice != 0);
NS_ASSERT (loraNetDevice);
Ptr<ClassAEndDeviceLorawanMac> mac =
loraNetDevice->GetMac ()->GetObject<ClassAEndDeviceLorawanMac> ();
NS_ASSERT (mac != 0);
NS_ASSERT (mac);

// Try computing the distance from each gateway and find the best one
Ptr<Node> bestGateway = gateways.Get (0);
Expand Down Expand Up @@ -620,13 +620,13 @@ LorawanMacHelper::SetSpreadingFactorsGivenDistribution (NodeContainer endDevices
{
Ptr<Node> object = *j;
Ptr<MobilityModel> position = object->GetObject<MobilityModel> ();
NS_ASSERT (position != 0);
NS_ASSERT (position);
Ptr<NetDevice> netDevice = object->GetDevice (0);
Ptr<LoraNetDevice> loraNetDevice = netDevice->GetObject<LoraNetDevice> ();
NS_ASSERT (loraNetDevice != 0);
NS_ASSERT (loraNetDevice);
Ptr<ClassAEndDeviceLorawanMac> mac =
loraNetDevice->GetMac ()->GetObject<ClassAEndDeviceLorawanMac> ();
NS_ASSERT (mac != 0);
NS_ASSERT (mac);

double prob = uniformRV->GetValue (0, 1);

Expand Down
4 changes: 2 additions & 2 deletions model/lora-channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ LoraChannel::Send (Ptr< LoraPhy > sender, Ptr< Packet > packet,
// Get the mobility model of the sender
Ptr<MobilityModel> senderMobility = sender->GetMobility ()->GetObject<MobilityModel> ();

NS_ASSERT (senderMobility != 0); // Make sure it's available
NS_ASSERT (senderMobility); // Make sure it's available

NS_LOG_INFO ("Starting cycle over all " << m_phyList.size () << " PHYs");
NS_LOG_INFO ("Sender mobility: " << senderMobility->GetPosition ());
Expand Down Expand Up @@ -151,7 +151,7 @@ LoraChannel::Send (Ptr< LoraPhy > sender, Ptr< Packet > packet,
// Get the id of the destination PHY to correctly format the context
Ptr<NetDevice> dstNetDevice = m_phyList[j]->GetDevice ();
uint32_t dstNode = 0;
if (dstNetDevice != 0)
if (dstNetDevice)
{
NS_LOG_INFO ("Getting node index from NetDevice, since it exists");
dstNode = dstNetDevice->GetNode ()->GetId ();
Expand Down
2 changes: 1 addition & 1 deletion model/lora-frame-header.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ LoraFrameHeader::GetMacCommand ()
std::list< Ptr< MacCommand> >::const_iterator it;
for (it = m_macCommands.begin (); it != m_macCommands.end (); ++it)
{
if ((*it)->GetObject<T> () != 0)
if ((*it)->GetObject<T> ())
{
return (*it)->GetObject<T> ();
}
Expand Down
6 changes: 3 additions & 3 deletions model/lora-net-device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ LoraNetDevice::CompleteConfig (void)
NS_LOG_FUNCTION_NOARGS ();

// Verify we have all the necessary pieces
if (m_mac == 0 || m_phy == 0 || m_node == 0 || m_configComplete)
if (!m_mac || !m_phy || !m_node || m_configComplete)
{
return;
}
Expand All @@ -114,7 +114,7 @@ LoraNetDevice::Send (Ptr<Packet> packet)
NS_LOG_FUNCTION (this << packet);

// Send the packet to the MAC layer, if it exists
NS_ASSERT (m_mac != 0);
NS_ASSERT (m_mac);
m_mac->Send (packet);
}

Expand Down Expand Up @@ -195,7 +195,7 @@ LoraNetDevice::IsLinkUp (void) const
{
NS_LOG_FUNCTION (this);

return m_phy != 0;
return m_phy != nullptr;
}

void
Expand Down
2 changes: 1 addition & 1 deletion model/lora-phy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ LoraPhy::GetMobility (void)

// If there is a mobility model associated to this PHY, take the mobility from
// there
if (m_mobility != 0)
if (m_mobility)
{
return m_mobility;
}
Expand Down
6 changes: 3 additions & 3 deletions model/network-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ NetworkServer::AddGateway (Ptr<Node> gateway, Ptr<NetDevice> netDevice)
for (uint32_t i = 0; i < gateway->GetNDevices (); i++)
{
p2pNetDevice = gateway->GetDevice (i)->GetObject<PointToPointNetDevice> ();
if (p2pNetDevice != 0)
if (p2pNetDevice)
{
// We found a p2pNetDevice on the gateway
break;
Expand All @@ -98,7 +98,7 @@ NetworkServer::AddGateway (Ptr<Node> gateway, Ptr<NetDevice> netDevice)
// Get the gateway's LoRa MAC layer (assumes gateway's MAC is configured as first device)
Ptr<GatewayLorawanMac> gwMac = gateway->GetDevice (0)->GetObject<LoraNetDevice> ()->
GetMac ()->GetObject<GatewayLorawanMac> ();
NS_ASSERT (gwMac != 0);
NS_ASSERT (gwMac);

// Get the Address
Address gatewayAddress = p2pNetDevice->GetAddress ();
Expand Down Expand Up @@ -134,7 +134,7 @@ NetworkServer::AddNode (Ptr<Node> node)
for (uint32_t i = 0; i < node->GetNDevices (); i++)
{
loraNetDevice = node->GetDevice (i)->GetObject<LoraNetDevice> ();
if (loraNetDevice != 0)
if (loraNetDevice)
{
// We found a LoraNetDevice on the node
break;
Expand Down
4 changes: 2 additions & 2 deletions model/one-shot-sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ OneShotSender::StartApplication (void)
NS_LOG_FUNCTION (this);

// Make sure we have a MAC layer
if (m_mac == 0)
if (!m_mac)
{
// Assumes there's only one device
Ptr<LoraNetDevice> loraNetDevice = m_node->GetDevice (0)->GetObject<LoraNetDevice> ();

m_mac = loraNetDevice->GetMac ();
NS_ASSERT (m_mac != 0);
NS_ASSERT (m_mac);
}

// Schedule the next SendPacket event
Expand Down
4 changes: 2 additions & 2 deletions model/periodic-sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ PeriodicSender::StartApplication (void)
NS_LOG_FUNCTION (this);

// Make sure we have a MAC layer
if (m_mac == 0)
if (m_mac)
{
// Assumes there's only one device
Ptr<LoraNetDevice> loraNetDevice = m_node->GetDevice (0)->GetObject<LoraNetDevice> ();

m_mac = loraNetDevice->GetMac ();
NS_ASSERT (m_mac != 0);
NS_ASSERT (m_mac);
}

// Schedule the next SendPacket event
Expand Down
130 changes: 0 additions & 130 deletions wscript

This file was deleted.

0 comments on commit a82f2cc

Please sign in to comment.