From 748bcc1dc7d18b90e0b9dc862016b9fd45e44426 Mon Sep 17 00:00:00 2001 From: Federico Guerra Date: Fri, 10 Jan 2025 10:34:36 +0100 Subject: [PATCH] fix latest ns-3-dev warnings and issues (#49) * fixed latest warnings and issues * fixed example * fixed woss test * Update README.md --- README.md | 21 ++-- examples/woss-aloha-example.cc | 2 +- helper/woss-helper.cc | 94 +++++++-------- model/woss-channel.cc | 4 +- model/woss-position-allocator.cc | 2 +- test/woss-test.cc | 200 +++++++++++++++---------------- 6 files changed, 159 insertions(+), 164 deletions(-) diff --git a/README.md b/README.md index 2962d45..43e7de2 100644 --- a/README.md +++ b/README.md @@ -15,20 +15,23 @@ WOSS can be integrated in any network simulator or simulation tool that supports Latest WOSS source code, installation instructions and related libraries can be found at https://woss.dei.unipd.it -How to install 'woss-ns3' with *waf*: +How to install 'woss-ns3' with *cmake*: - download and install the recommended Acoustic Toolbox library - with optional NetCDF support, download and install the recommended HDF5, NetCDF libraries, with NetCDF4 format support - download and install the latest WOSS library with optional NetCDF4 and HDF5 support - clone this repository in the `/src` path and then run one of the following: - - NetCDF4 and HDF5 support, *pay attention to the CXXFLAGS inline redefinition due to a unresolved NetCDF-C++4 API warning* `./waf configure ---with-woss-source= --with-woss-library= --with-netcdf4-install= CXXFLAGS="-Wall -Werror -Wno-unused-variable"` - - with no NetCDF support `./waf configure --with-woss-source= --with-woss-library=` - -How to install 'woss-ns3' with *cmake*: -- install the required libraries as in previous instructions -- run one of the following: - - NetCDF4 and HDF5 support, *pay attention to the CXXFLAGS inline redefinition due to a unresolved NetCDF-C++4 API warning* `CXXFLAGS="-Wno-unused-variable" ./ns3 configure --enable-examples --enable-tests -- -DNS3_WITH_WOSS_SOURCE=/ -DNS3_WITH_WOSS_LIBRARY= -DNS3_WITH_NETCDF4_INSTALL=` + - NetCDF4 and HDF5 support, *pay attention to the CXXFLAGS inline redefinition due to a unresolved NetCDF-C++4 API warning* `CXXFLAGS="-Wno-unused-variable" ./ns3 configure --enable-examples --enable-tests -- -DNS3_WITH_WOSS_SOURCE= -DNS3_WITH_WOSS_LIBRARY= -DNS3_WITH_NETCDF4_INSTALL=` - with no NetCDF support `CXXFLAGS="-Wno-unused-variable" ./ns3 configure --enable-examples --enable-tests -- -DNS3_WITH_WOSS_SOURCE=/ -DNS3_WITH_WOSS_LIBRARY=` +- finally run `./ns3 build` + +How to install 'woss-ns3' with *waf* (**OBSOLETE**): +- download and install the recommended Acoustic Toolbox library +- with optional NetCDF support, download and install the recommended HDF5, NetCDF libraries, with NetCDF4 format support +- download and install the latest WOSS library with optional NetCDF4 and HDF5 support +- clone this repository in the `/src` path and then run one of the following: + - NetCDF4 and HDF5 support, *pay attention to the CXXFLAGS inline redefinition due to a unresolved NetCDF-C++4 API warning* `./waf configure --with-woss-source= --with-woss-library= --with-netcdf4-install= CXXFLAGS="-Wall -Werror -Wno-unused-variable"` + - with no NetCDF support `./waf configure --with-woss-source= --with-woss-library=` +- finally run `./waf build` For info on how to install all the required libraries with the suggested paths, please check https://woss.dei.unipd.it/woss/doxygen/installation.html diff --git a/examples/woss-aloha-example.cc b/examples/woss-aloha-example.cc index 932af32..87b5b47 100644 --- a/examples/woss-aloha-example.cc +++ b/examples/woss-aloha-example.cc @@ -247,7 +247,7 @@ Experiment::Run (uint32_t param) Ptr nodeSink = sink.Get (0); Ptr sinkMob = nodeSink->GetObject (); - NS_ASSERT (sinkMob != NULL); + NS_ASSERT (sinkMob != nullptr); for (int cnt = 0; cnt < 5; ++cnt) { diff --git a/helper/woss-helper.cc b/helper/woss-helper.cc index dd1e592..30606ff 100644 --- a/helper/woss-helper.cc +++ b/helper/woss-helper.cc @@ -187,7 +187,7 @@ WossHelper::WossHelper () m_wossRandomGenStream (0), m_randomGenProto (), m_timeRefProto (), - m_defHandler (NULL), + m_defHandler (nullptr), m_resDbCreatorDebug (WH_DEBUG_DEFAULT), m_resDbDebug (WH_DEBUG_DEFAULT), m_resDbUseBinary (true), @@ -195,10 +195,10 @@ WossHelper::WossHelper () m_resDbSpaceSampling (WH_SPACE_SAMPLING_DEFAULT), m_resDbFilePath (WH_STRING_DEFAULT), m_resDbFileName (WH_STRING_DEFAULT), - m_resDbCreatorPressBin (NULL), - m_resDbCreatorPressTxt (NULL), - m_resDbCreatorTimeArrBin (NULL), - m_resDbCreatorTimeArrTxt (NULL), + m_resDbCreatorPressBin (nullptr), + m_resDbCreatorPressTxt (nullptr), + m_resDbCreatorTimeArrBin (nullptr), + m_resDbCreatorTimeArrTxt (nullptr), #if defined (WOSS_NETCDF_SUPPORT) m_sedimDbCreatorDebug (WH_DEBUG_DEFAULT), m_sedimDbDebug (WH_DEBUG_DEFAULT), @@ -208,22 +208,22 @@ WossHelper::WossHelper () m_sedimDbCoordFilePath (WH_STRING_DEFAULT), m_sedimDbMarsdenFilePath (WH_STRING_DEFAULT), m_sedimDbMarsdenOneFilePath (WH_STRING_DEFAULT), - m_sedimDbCreator (NULL), + m_sedimDbCreator (nullptr), m_sspDbCreatorDebug (WH_DEBUG_DEFAULT), m_sspDbDebug (WH_DEBUG_DEFAULT), m_sspDbFilePath (WH_STRING_DEFAULT), #if defined (WOSS_NETCDF4_SUPPORT) m_sspWoaDbType (WH_WOA_DB_TYPE_DEFAULT), #endif // defined (WOSS_NETCDF_SUPPORT) - m_sspDbCreator (NULL), + m_sspDbCreator (nullptr), m_bathyDbCreatorDebug (WH_DEBUG_DEFAULT), m_bathyDbDebug (WH_DEBUG_DEFAULT), m_bathyDbGebcoFormat(WH_GEBCO_FORMAT_DEFAULT), m_bathyDbFilePath (WH_STRING_DEFAULT), - m_bathyDbCreator (NULL), + m_bathyDbCreator (nullptr), #endif // defined (WOSS_NETCDF_SUPPORT) m_wossDbManagerDebug (WH_DEBUG_DEFAULT), - m_wossDbManager (NULL), + m_wossDbManager (nullptr), m_wossCreatorDebug (WH_DEBUG_DEFAULT), m_wossDebug (WH_DEBUG_DEFAULT), m_wossClearWorkDir (true), @@ -255,7 +255,7 @@ WossHelper::WossHelper () m_bellhopArrSyntax (WH_BELLHOP_ARR_SYNTAX_DEFAULT), m_bellhopShdSyntax (WH_BELLHOP_SHD_SYNTAX_DEFAULT), m_simTime (), - m_bellhopCreator (NULL), + m_bellhopCreator (nullptr), m_boxDepth (WH_BOX_DEPTH), m_boxRange (WH_BOX_RANGE), m_wossManagerDebug (WH_DEBUG_DEFAULT), @@ -263,10 +263,10 @@ WossHelper::WossHelper () m_concurrentThreads (WH_CONCURRENT_THREADS_DEFAULT), m_wossManagerSpaceSampling (WH_SPACE_SAMPLING_DEFAULT), m_wossManagerUseMultiThread (false), - m_wossManagerSimple (NULL), - m_wossManagerMulti (NULL), + m_wossManagerSimple (nullptr), + m_wossManagerMulti (nullptr), m_wossTransducerHndlDebug (WH_DEBUG_DEFAULT), - m_wossTransducerHndl (NULL), + m_wossTransducerHndl (nullptr), m_wossControllerDebug (WH_DEBUG_DEFAULT), m_wossController (), m_initialized (false) @@ -287,69 +287,69 @@ WossHelper::DoDispose (void) DeleteWossLocationMap (); - if (m_wossManagerSimple != NULL) + if (m_wossManagerSimple != nullptr) { delete m_wossManagerSimple; } - if (m_wossManagerMulti != NULL) + if (m_wossManagerMulti != nullptr) { delete m_wossManagerMulti; } - if (m_wossTransducerHndl != NULL) + if (m_wossTransducerHndl != nullptr) { delete m_wossTransducerHndl; } - if (m_bellhopCreator != NULL) + if (m_bellhopCreator != nullptr) { delete m_bellhopCreator; } - if (m_wossDbManager != NULL) + if (m_wossDbManager != nullptr) { delete m_wossDbManager; } #if defined (WOSS_NETCDF_SUPPORT) - if (m_bathyDbCreator != NULL) + if (m_bathyDbCreator != nullptr) { delete m_bathyDbCreator; } - if (m_sspDbCreator != NULL) + if (m_sspDbCreator != nullptr) { delete m_sspDbCreator; } - if (m_sedimDbCreator != NULL) + if (m_sedimDbCreator != nullptr) { delete m_sedimDbCreator; } #endif // defined (WOSS_NETCDF_SUPPORT) - if (m_resDbCreatorPressBin != NULL) + if (m_resDbCreatorPressBin != nullptr) { delete m_resDbCreatorPressBin; } - if (m_resDbCreatorPressTxt != NULL) + if (m_resDbCreatorPressTxt != nullptr) { delete m_resDbCreatorPressTxt; } - if (m_resDbCreatorTimeArrBin != NULL) + if (m_resDbCreatorTimeArrBin != nullptr) { delete m_resDbCreatorTimeArrBin; } - if (m_resDbCreatorTimeArrTxt != NULL) + if (m_resDbCreatorTimeArrTxt != nullptr) { delete m_resDbCreatorTimeArrTxt; } - if (m_wossController != NULL) + if (m_wossController != nullptr) { delete m_wossController; } @@ -605,7 +605,7 @@ WossHelper::GetWossLocation ( Ptr< MobilityModel > ptr ) { NS_LOG_FUNCTION (this << ptr); - WossLocation* retValue = NULL; + WossLocation* retValue = nullptr; MLMCIter it = m_locMap.find (PeekPointer (ptr)); @@ -630,7 +630,7 @@ WossHelper::DeleteWossLocationMap (void) { for ( MLMCIter it = m_locMap.begin (); it != m_locMap.end (); ++it ) { - if (it->second != NULL) + if (it->second != nullptr) { delete it->second; } @@ -673,9 +673,9 @@ WossHelper::SetAngles ( const woss::CustomAngles& angles, Ptr tx, { CheckInitialized (); - if ( tx == NULL ) + if ( tx == nullptr ) { - if ( rx == NULL ) + if ( rx == nullptr ) { m_bellhopCreator->setAngles (angles); } @@ -689,7 +689,7 @@ WossHelper::SetAngles ( const woss::CustomAngles& angles, Ptr tx, { WossLocation* txLoc = GetWossLocation ( tx ); - if ( rx == NULL ) + if ( rx == nullptr ) { m_bellhopCreator->eraseAngles ( txLoc ); } @@ -709,9 +709,9 @@ WossHelper::GetAngles ( Ptr tx, Ptr rx ) const { CheckInitialized (); - if ( tx == NULL ) + if ( tx == nullptr ) { - if ( rx == NULL ) + if ( rx == nullptr ) { return m_bellhopCreator->getAngles (); } @@ -725,7 +725,7 @@ WossHelper::GetAngles ( Ptr tx, Ptr rx ) const { WossLocation* txLoc = const_cast (this)->GetWossLocation ( tx ); - if ( rx == NULL ) + if ( rx == nullptr ) { return m_bellhopCreator->getAngles ( txLoc ); } @@ -743,9 +743,9 @@ WossHelper::EraseAngles ( Ptr tx, Ptr rx ) { CheckInitialized (); - if ( tx == NULL ) + if ( tx == nullptr ) { - if ( rx == NULL ) + if ( rx == nullptr ) { m_bellhopCreator->eraseAngles (); } @@ -759,7 +759,7 @@ WossHelper::EraseAngles ( Ptr tx, Ptr rx ) { WossLocation* txLoc = const_cast (this)->GetWossLocation ( tx ); - if ( rx == NULL ) + if ( rx == nullptr ) { m_bellhopCreator->eraseAngles ( txLoc ); } @@ -838,9 +838,9 @@ WossHelper::SetCustomTransducer ( const woss::CustomTransducer& type, PtrsetCustomTransducer (type); } @@ -854,7 +854,7 @@ WossHelper::SetCustomTransducer ( const woss::CustomTransducer& type, Ptr (this)->GetWossLocation ( tx ); - if ( rx == NULL ) + if ( rx == nullptr ) { m_bellhopCreator->setCustomTransducer ( type, txLoc ); } @@ -874,9 +874,9 @@ WossHelper::GetCustomTransducer ( Ptr tx, Ptr rx ) { CheckInitialized (); - if ( tx == NULL ) + if ( tx == nullptr ) { - if ( rx == NULL ) + if ( rx == nullptr ) { return m_bellhopCreator->getCustomTransducer (); } @@ -890,7 +890,7 @@ WossHelper::GetCustomTransducer ( Ptr tx, Ptr rx ) { WossLocation* txLoc = const_cast (this)->GetWossLocation ( tx ); - if ( rx == NULL ) + if ( rx == nullptr ) { return m_bellhopCreator->getCustomTransducer ( txLoc ); } @@ -908,9 +908,9 @@ WossHelper::EraseCustomTransducer ( Ptr tx, Ptr rx { CheckInitialized (); - if ( tx == NULL ) + if ( tx == nullptr ) { - if ( rx == NULL ) + if ( rx == nullptr ) { m_bellhopCreator->eraseCustomTransducer (); } @@ -924,7 +924,7 @@ WossHelper::EraseCustomTransducer ( Ptr tx, Ptr rx { WossLocation* txLoc = const_cast (this)->GetWossLocation ( tx ); - if ( rx == NULL ) + if ( rx == nullptr ) { m_bellhopCreator->eraseCustomTransducer ( txLoc ); } @@ -1286,7 +1286,7 @@ WossHelper::CreateDirectory (const ::std::string& path) NS_LOG_DEBUG ("WossHelper::CreateDirectory () command = " << command); - if (system (NULL)) + if (system (nullptr)) { ret_value = system (command.c_str ()); } diff --git a/model/woss-channel.cc b/model/woss-channel.cc index 1f331d5..9a05870 100644 --- a/model/woss-channel.cc +++ b/model/woss-channel.cc @@ -71,7 +71,7 @@ WossChannel::WossChannel () : UanChannel (), m_channelEqSnrThresDb (WOSS_CHANNEL_SNR_EQ_THRES_DB), // -infinite snr ==> first tap - m_wossPropModel (NULL) + m_wossPropModel (nullptr) { } @@ -87,7 +87,7 @@ WossChannel::DoInitialize (void) m_wossPropModel = DynamicCast< WossPropModel > ( m_prop ); - NS_ASSERT ( m_wossPropModel != NULL ); + NS_ASSERT ( m_wossPropModel != nullptr ); UanChannel::DoInitialize (); } diff --git a/model/woss-position-allocator.cc b/model/woss-position-allocator.cc index 72d1c95..f205c49 100644 --- a/model/woss-position-allocator.cc +++ b/model/woss-position-allocator.cc @@ -113,7 +113,7 @@ WossGridPositionAllocator::GetTypeId (void) MakeDoubleChecker ()) .AddAttribute ("LayoutType", "The type of layout.", EnumValue (ROW_FIRST), - MakeEnumAccessor (&WossGridPositionAllocator::m_layoutType), + MakeEnumAccessor (&WossGridPositionAllocator::m_layoutType), MakeEnumChecker (ROW_FIRST, "RowFirst", COLUMN_FIRST, "ColumnFirst")) ; diff --git a/test/woss-test.cc b/test/woss-test.cc index 73c69e1..7df0bfc 100644 --- a/test/woss-test.cc +++ b/test/woss-test.cc @@ -73,8 +73,8 @@ class WossTest : public TestCase void SendOnePacket (Ptr dev, uint32_t mode); void WossThorpRun(Ptr chan); void DoWossThorpTests(Ptr prop, double ranges[], double windNoise, double shipNoise); - void PktRxOkThorpCallback (std::string trace_str, Ptr< const Packet > pkt, double sinr, UanTxMode mode); - void PktRxOkWossCallback (std::string trace_str, Ptr< const Packet > pkt, double sinr, UanTxMode mode); + void PktRxOkThorpCallback (Ptr< Packet > pkt, double sinr, UanTxMode mode); + void PktRxOkWossCallback (Ptr< Packet > pkt, double sinr, UanTxMode mode); ObjectFactory m_phyFac; uint32_t m_bytesRx; @@ -105,6 +105,8 @@ WossTest::InitWossHelper (Ptr wossProp) m_wossHelper->SetAttribute ("ResDbUseBinary", BooleanValue (false)); m_wossHelper->SetAttribute ("ResDbUseTimeArr", BooleanValue (true)); m_wossHelper->SetAttribute ("ResDbFilePath", StringValue ("./woss-test-output/res-db/")); + m_wossHelper->SetAttribute ("WossBellhopBathyType", StringValue("L")); + m_wossHelper->SetAttribute ("WossBathyWriteMethod", StringValue("D")); if (m_databasePath != "") { @@ -246,115 +248,103 @@ WossTest::DoPhyTests (Ptr prop) } void -WossTest::PktRxOkThorpCallback (std::string trace_str, Ptr< const Packet > pkt, double sinr, UanTxMode mode) +WossTest::PktRxOkThorpCallback (Ptr< Packet > pkt, double sinr, UanTxMode mode) { - std::cout << "PktRxOkThorpCallback: SINR = " << sinr << std::endl; - m_thorpSinr.push_back(sinr); + std::cout << "PktRxOkThorpCallback: SINR = " << sinr << std::endl; + m_thorpSinr.push_back(sinr); } void -WossTest::PktRxOkWossCallback (std::string trace_str, Ptr< const Packet > pkt, double sinr, UanTxMode mode) +WossTest::PktRxOkWossCallback (Ptr< Packet > pkt, double sinr, UanTxMode mode) { - std::cout << "PktRxOkWossCallback: SINR = " << sinr << std::endl; - m_wossSinr.push_back(sinr); + std::cout << "PktRxOkWossCallback: SINR = " << sinr << std::endl; + m_wossSinr.push_back(sinr); } void WossTest::DoWossThorpTests (Ptr prop, double ranges[], double windNoise, double shipNoise) { - // Phy Gen / Default PER / Default SINR - UanModesList mList; - - uint32_t phy_bitrate = 160; - //type, dataRateBps, phyRateSps, cfHz, bwHz, constellationSize, name - UanTxMode mode = UanTxModeFactory::CreateMode (UanTxMode::PSK, //PSK, QAM, FSK, OTHER - phy_bitrate, phy_bitrate/2, 11520, 160, 2, "Default mode"); - - mList.AppendMode (UanTxMode (mode)); - Ptr perDef = CreateObject (); - Ptr sinrDef = CreateObject (); - m_phyFac.SetTypeId ("ns3::UanPhyGen"); - m_phyFac.Set ("PerModel", PointerValue (perDef)); - m_phyFac.Set ("SinrModel", PointerValue (sinrDef)); - m_phyFac.Set ("SupportedModes", UanModesListValue (mList)); - - double depth = 2500; //depth of all nodes (m) - m_sinkCoord = woss::CoordZ(38.1, -130.7, depth); - - //WOSS channel - m_wossHelper->SetCustomBathymetry ("2|0.0|5000.0|10000.0|5000.0", m_sinkCoord); - m_wossHelper->SetCustomSediment ("TestSediment|1560.0|210.0|1.5|0.9|0.8|5000.0"); - m_wossHelper->SetCustomSsp ("2|0|1510|5000|1510"); - - Ptr wossChannel = CreateObject (); - wossChannel->SetAttribute ("PropagationModel", PointerValue (prop)); - wossChannel->SetAttribute ("ChannelEqSnrThresholdDb", DoubleValue (-100.0)); - - - //Thorp channel - double spread_coef = 2.0; - Ptr propThorp = CreateObjectWithAttributes ("SpreadCoef", DoubleValue (spread_coef)); //create the propagation model for the channel - Ptr thorpChannel = CreateObjectWithAttributes ("PropagationModel", PointerValue (propThorp)); //plug prop model (and default noise model) into channel - - Ptr noise_model = CreateObjectWithAttributes ("Wind", DoubleValue (windNoise), "Shipping", DoubleValue(shipNoise)); - thorpChannel->SetNoiseModel(PointerValue(noise_model)); - wossChannel->SetNoiseModel(PointerValue(noise_model)); - - //Create the Thorp nodes - Ptr devt0 = CreateNode (Vector(0, 0, depth), thorpChannel); - Ptr devt1 = CreateNode (Vector(ranges[0], 0, depth), thorpChannel); - Ptr devt2 = CreateNode (Vector(ranges[1], 0, depth), thorpChannel); - Ptr devt3 = CreateNode (Vector(ranges[2], 0, depth), thorpChannel); - - //Create the WOSS nodes - Ptr devw0 = CreateNode (CreateVectorFromCoordZ (m_sinkCoord), wossChannel); - Ptr devw1 = CreateNode (CreateVectorFromCoordZ (woss::CoordZ (woss::Coord::getCoordFromBearing (m_sinkCoord, M_PI / 2.0, ranges[0]), depth)), wossChannel); - Ptr devw2 = CreateNode (CreateVectorFromCoordZ (woss::CoordZ (woss::Coord::getCoordFromBearing (m_sinkCoord, M_PI / 2.0, ranges[1]), depth)), wossChannel); - Ptr devw3 = CreateNode (CreateVectorFromCoordZ (woss::CoordZ (woss::Coord::getCoordFromBearing (m_sinkCoord, M_PI / 2.0, ranges[2]), depth)), wossChannel); - - Simulator::Schedule (Seconds (1.0), &WossTest::SendOnePacket, this, devt0, 0); - Simulator::Schedule (Seconds (10.0), &WossTest::SendOnePacket, this, devw0, 0); - - //Connect RxOk callbacks - Config::Connect ( - "/NodeList/1/DeviceList/0/$ns3::UanNetDevice/Phy/$ns3::UanPhyGen/RxOk", - MakeCallback (&WossTest::PktRxOkThorpCallback, this)); - Config::Connect ( - "/NodeList/2/DeviceList/0/$ns3::UanNetDevice/Phy/$ns3::UanPhyGen/RxOk", - MakeCallback (&WossTest::PktRxOkThorpCallback, this)); - Config::Connect ( - "/NodeList/3/DeviceList/0/$ns3::UanNetDevice/Phy/$ns3::UanPhyGen/RxOk", - MakeCallback (&WossTest::PktRxOkThorpCallback, this)); - - Config::Connect ( - "/NodeList/5/DeviceList/0/$ns3::UanNetDevice/Phy/$ns3::UanPhyGen/RxOk", - MakeCallback (&WossTest::PktRxOkWossCallback, this)); - Config::Connect ( - "/NodeList/6/DeviceList/0/$ns3::UanNetDevice/Phy/$ns3::UanPhyGen/RxOk", - MakeCallback (&WossTest::PktRxOkWossCallback, this)); - Config::Connect ( - "/NodeList/7/DeviceList/0/$ns3::UanNetDevice/Phy/$ns3::UanPhyGen/RxOk", - MakeCallback (&WossTest::PktRxOkWossCallback, this)); - - Simulator::Stop (Seconds (20.0)); - Simulator::Run (); - Simulator::Destroy (); - - //Verify that the transmitted packets are received at all the nodes for both channels - NS_TEST_ASSERT_MSG_EQ(m_thorpSinr.size(), 3, "Not all packets received at Thorp nodes"); - NS_TEST_ASSERT_MSG_EQ(m_wossSinr.size(), 3, "Not all packets received at Woss nodes"); - - //Verify that the SINR matches between Thorp and WOSS for all ranges - std::ostringstream oss; - for(unsigned int i=0;i perDef = CreateObject (); + Ptr sinrDef = CreateObject (); + m_phyFac.SetTypeId ("ns3::UanPhyGen"); + m_phyFac.Set ("PerModel", PointerValue (perDef)); + m_phyFac.Set ("SinrModel", PointerValue (sinrDef)); + m_phyFac.Set ("SupportedModes", UanModesListValue (mList)); + + double depth = 2500; //depth of all nodes (m) + m_sinkCoord = woss::CoordZ(38.1, -130.7, depth); + + //WOSS channel + m_wossHelper->SetCustomBathymetry ("2|0.0|5000.0|10000.0|5000.0", m_sinkCoord); + m_wossHelper->SetCustomSediment ("TestSediment|1560.0|210.0|1.5|0.9|0.8|5000.0"); + m_wossHelper->SetCustomSsp ("2|0|1510|5000|1510"); + + Ptr wossChannel = CreateObject (); + wossChannel->SetAttribute ("PropagationModel", PointerValue (prop)); + wossChannel->SetAttribute ("ChannelEqSnrThresholdDb", DoubleValue (-100.0)); + + + //Thorp channel + double spread_coef = 2.0; + Ptr propThorp = CreateObjectWithAttributes ("SpreadCoef", DoubleValue (spread_coef)); //create the propagation model for the channel + Ptr thorpChannel = CreateObjectWithAttributes ("PropagationModel", PointerValue (propThorp)); //plug prop model (and default noise model) into channel + + Ptr noise_model = CreateObjectWithAttributes ("Wind", DoubleValue (windNoise), "Shipping", DoubleValue(shipNoise)); + thorpChannel->SetNoiseModel(PointerValue(noise_model)); + wossChannel->SetNoiseModel(PointerValue(noise_model)); + + //Create the Thorp nodes + Ptr devt0 = CreateNode (Vector(0, 0, depth), thorpChannel); + Ptr devt1 = CreateNode (Vector(ranges[0], 0, depth), thorpChannel); + Ptr devt2 = CreateNode (Vector(ranges[1], 0, depth), thorpChannel); + Ptr devt3 = CreateNode (Vector(ranges[2], 0, depth), thorpChannel); + + //Create the WOSS nodes + Ptr devw0 = CreateNode (CreateVectorFromCoordZ (m_sinkCoord), wossChannel); + Ptr devw1 = CreateNode (CreateVectorFromCoordZ (woss::CoordZ (woss::Coord::getCoordFromBearing (m_sinkCoord, M_PI / 2.0, ranges[0]), depth)), wossChannel); + Ptr devw2 = CreateNode (CreateVectorFromCoordZ (woss::CoordZ (woss::Coord::getCoordFromBearing (m_sinkCoord, M_PI / 2.0, ranges[1]), depth)), wossChannel); + Ptr devw3 = CreateNode (CreateVectorFromCoordZ (woss::CoordZ (woss::Coord::getCoordFromBearing (m_sinkCoord, M_PI / 2.0, ranges[2]), depth)), wossChannel); + + //Connect RxOk callbacks + devt1->GetPhy()->SetReceiveOkCallback(MakeCallback(&WossTest::PktRxOkThorpCallback, this)); + devt2->GetPhy()->SetReceiveOkCallback(MakeCallback(&WossTest::PktRxOkThorpCallback, this)); + devt3->GetPhy()->SetReceiveOkCallback(MakeCallback(&WossTest::PktRxOkThorpCallback, this)); + + devw1->GetPhy()->SetReceiveOkCallback(MakeCallback(&WossTest::PktRxOkWossCallback, this)); + devw2->GetPhy()->SetReceiveOkCallback(MakeCallback(&WossTest::PktRxOkWossCallback, this)); + devw3->GetPhy()->SetReceiveOkCallback(MakeCallback(&WossTest::PktRxOkWossCallback, this)); + + Simulator::Schedule (Seconds (1.0), &WossTest::SendOnePacket, this, devt0, 0); + Simulator::Schedule (Seconds (10.0), &WossTest::SendOnePacket, this, devw0, 0); + + Simulator::Stop (Seconds (20.0)); + Simulator::Run (); + Simulator::Destroy (); + + //Verify that the transmitted packets are received at all the nodes for both channels + NS_TEST_ASSERT_MSG_EQ(m_thorpSinr.size(), 3, "Not all packets received at Thorp nodes"); + NS_TEST_ASSERT_MSG_EQ(m_wossSinr.size(), 3, "Not all packets received at Woss nodes"); + + //Verify that the SINR matches between Thorp and WOSS for all ranges + std::ostringstream oss; + for(unsigned int i=0;i