Skip to content

Commit

Permalink
35 make woss ns3 compatible with cmake build system (#39)
Browse files Browse the repository at this point in the history
* build: added updated CMake files
* fixed example warning
* fixed README instructions
---------
Co-authored-by: Gabriel Ferreira <gabrielcarvfer@gmail.com>
  • Loading branch information
MetalKnight committed Feb 19, 2023
1 parent efe5428 commit cb36444
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 15 deletions.
165 changes: 165 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,165 @@
set(NS3_WITH_WOSS_SOURCE
""
CACHE
PATH
"Path to WOSS source directory, for NS-3 WOSS Integration Framework support"
)
set(NS3_WITH_WOSS_LIBRARY
""
CACHE
PATH
"Path to WOSS library directory, for NS-3 WOSS Integration Framework support"
)

set(NS3_WITH_NETCDF_INSTALL
""
CACHE
PATH
"Path to NetCDF legacy library install, for WOSS Integration Framework support"
)
set(NS3_WITH_NETCDF4_INSTALL
""
CACHE
PATH
"Path to NetCDF4 and HDF5 library install, for WOSS Integration Framework support"
)

set(ENABLE_WOSS
"OFF"
CACHE INTERNAL
"ON if WOSS can be built"
)

find_external_library(
DEPENDENCY_NAME WOSS
LIBRARY_NAME WOSS
HEADER_NAMES
location-definitions.h
woss-manager.h
woss-db-manager.h
SEARCH_PATHS ${NS3_WITH_WOSS_SOURCE}
${NS3_WITH_WOSS_LIBRARY}
PATH_SUFFIXES
/woss
/woss_def
/woss_db
/woss/woss_def
/woss/woss_db
/build
/build/lib
)

set(woss_libraries)

# If we can't find WOSS sources or library, don't process this module
if(NOT
${WOSS_FOUND}
)
message(
${HIGHLIGHTED_STATUS}
"Skipping contrib/woss-ns3"
)
return()
else()
message(STATUS "WOSS library was found: ${WOSS_LIBRARIES}")
set(ENABLE_WOSS
"ON"
CACHE INTERNAL
"ON if woss-ns3 can be built"
)
include_directories(${WOSS_INCLUDE_DIRS})
set(woss_libraries
${WOSS_LIBRARIES}
)
endif()

# Process optional NETCDF libraries
find_external_library(
DEPENDENCY_NAME NETCDF
HEADER_NAMES
netcdf.h
ncFile.h
LIBRARY_NAME netcdf_c++
netcdf
SEARCH_PATHS ${NS3_WITH_NETCDF_INSTALL}
PATH_SUFFIXES
/include
/lib
)

find_external_library(
DEPENDENCY_NAME NETCDF4
HEADER_NAMES
hdf5.h
netcdf.h
ncFile.h
LIBRARY_NAMES
netcdf_c++4
netcdf
hdf5
SEARCH_PATHS ${NS3_WITH_NETCDF4_INSTALL}
PATH_SUFFIXES
/include
/lib
)

set(netcdf_libraries)
if(${NETCDF4_FOUND})
message(STATUS "NETCDF4 was found.")
add_definitions(
-DWOSS_NETCDF_SUPPORT
-DWOSS_NETCDF4_SUPPORT
)
include_directories(${NETCDF4_INCLUDE_DIRS})
set(netcdf_libraries
${NETCDF4_LIBRARIES}
)
else()
if(${NETCDF_FOUND})
message(STATUS "NETCDF was found.")
add_definitions(-DWOSS_NETCDF_SUPPORT)
include_directories(${NETCDF_INCLUDE_DIRS})
set(netcdf_libraries
${NETCDF_LIBRARIES}
)
else()
message(STATUS "NETCDF was not found")
endif()
endif()

add_definitions(
-DNS3_WOSS_SUPPORT
-DWOSS_MULTITHREAD
)

build_lib(
LIBNAME woss-ns3
SOURCE_FILES
model/definitions/woss-location.cc
model/definitions/woss-time-reference.cc
model/definitions/woss-random-generator.cc
model/woss-prop-model.cc
model/woss-channel.cc
model/woss-position-allocator.cc
model/woss-waypoint-mobility-model.cc
helper/woss-helper.cc
HEADER_FILES
model/definitions/woss-location.h
model/definitions/woss-time-reference.h
model/definitions/woss-random-generator.h
model/woss-prop-model.h
model/woss-channel.h
model/woss-position-allocator.h
model/woss-waypoint-mobility-model.h
helper/woss-helper.h
LIBRARIES_TO_LINK
${libnetanim}
${libnetwork}
${libenergy}
${libmobility}
${libuan}
${woss_libraries}
${netcdf_libraries}
TEST_SOURCES test/woss-test.cc
)

31 changes: 18 additions & 13 deletions README.md
Expand Up @@ -3,9 +3,9 @@ WOSS ns3 Integration Framework

This repository aims to introduce WOSS support for ns3 users.

WOSS is a multi-threaded C++ framework that permits the integration of any existing underwater channel simulator that expects environmental data as input and provides as output a channel realization.
Currently, WOSS integrates the Bellhop ray-tracing program.
Thanks to its automation the user only has to specify the location in the world and the time where the simulation should take place. This is done by setting the simulated date and the wanted latitude and longitude of every node involved. The simulator automatically handles the rest (see technical description).
WOSS is a multi-threaded C++ framework that permits the integration of any existing underwater channel simulator that expects environmental data as input and provides as output a channel realization.
Currently, WOSS integrates the Bellhop ray-tracing program.
Thanks to its automation the user only has to specify the location in the world and the time where the simulation should take place. This is done by setting the simulated date and the wanted latitude and longitude of every node involved. The simulator automatically handles the rest (see technical description).
WOSS can be integrated in any network simulator or simulation tool that supports C++.

'woss-ns3' relies on the following libraries:
Expand All @@ -15,16 +15,21 @@ 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 http://telecom.dei.unipd.it/ns/woss/

'woss-ns3' module will be automatically installed by the ns3 app installer, but this feature is not yet complete.

It can also be manually installed:
- by downloading and installing the recommended Acoustic Toolbox library
- with optional NetCDF support, by downloading and installing the recommended HDF5, NetCDF libraries, with NetCDF4 format support
- by downloading and installing the latest WOSS library with optional NetCDF4 and HDF5 support
- by cloning this repository in the `<ns3-dir>/src` path and then running 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
How to install 'woss-ns3' with *waf*:
- 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 `<ns3-dir>/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=<woss_source_path> --with-woss-library=<woss_lib_path> --with-netcdf4-install=<netcdf4_and_hdf5_installed_path> CXXFLAGS="-Wall -Werror -Wno-unused-variable"`
- with no NetCDF support `./waf configure --with-woss-source=<woss_source_path> --with-woss-library=<woss_lib_path>`
- for info on how to install all the required libraries with the suggested paths, please check http://telecom.dei.unipd.it/ns/woss/doxygen/installation.html

*Any issue should be reported via github Issue tracker*.
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=/<woss_source_path> -DNS3_WITH_WOSS_LIBRARY=<woss_lib_path> -DNS3_WITH_NETCDF4_INSTALL=<netcdf4_and_hdf5_installed_path>`
- with no NetCDF support `CXXFLAGS="-Wno-unused-variable" ./ns3 configure --enable-examples --enable-tests -- -DNS3_WITH_WOSS_SOURCE=/<woss_source_path> -DNS3_WITH_WOSS_LIBRARY=<woss_lib_path>`

For info on how to install all the required libraries with the suggested paths, please check http://telecom.dei.unipd.it/ns/woss/doxygen/installation.html

*Any issue should be reported via github Issue tracker or via e-mail to WOSS@guerra-tlc.com*.
15 changes: 15 additions & 0 deletions examples/CMakeLists.txt
@@ -0,0 +1,15 @@
build_lib_example(
NAME woss-aloha-example
SOURCE_FILES woss-aloha-example.cc
HEADER_FILES woss-aloha-example.h
LIBRARIES_TO_LINK
${libnetanim}
${libinternet}
${libmobility}
${libstats}
${libapplications}
${libuan}
${WOSS_LIBRARIES}
${libwoss-ns3}
)

2 changes: 1 addition & 1 deletion examples/woss-aloha-example.cc
Expand Up @@ -85,7 +85,7 @@ Experiment::InitWossHelper (Ptr<WossHelper> wossHelper, Ptr<WossPropModel> wossP
wossHelper->SetAttribute ("BathyDbDebug", BooleanValue (false));
#if defined (WOSS_NETCDF4_SUPPORT)
wossHelper->SetAttribute ("BathyDbGebcoFormat", IntegerValue (4)); // 15 seconds, 2D netcdf format
wossHelper->SetAttribute ("BathyDbCoordFilePath", StringValue (m_databasePath + "/bathymetry/GEBCO_2020.nc"));
wossHelper->SetAttribute ("BathyDbCoordFilePath", StringValue (m_databasePath + "/bathymetry/GEBCO_2022.nc"));
wossHelper->SetAttribute ("SspDbWoaDbType", IntegerValue (1)); // 2013 WOA DB Format
wossHelper->SetAttribute ("SspDbCoordFilePath", StringValue (m_databasePath + "/ssp/WOA2018/WOA2018_SSP_April.nc"));
wossHelper->SetAttribute ("SedimentDbDeck41DbType", IntegerValue (1)); // DECK41 V2 database data format
Expand Down
2 changes: 1 addition & 1 deletion model/woss-channel.cc
Expand Up @@ -116,7 +116,7 @@ WossChannel::TxPacket (Ptr<UanTransducer> src, Ptr<Packet> packet,
{
tempRxMobility = i->first->GetNode ()->GetObject<MobilityModel> ();

NS_ASSERT (tempRxMobility != 0);
NS_ASSERT (tempRxMobility != nullptr);

NS_LOG_DEBUG ("src ptr:" << PeekPointer (src) << "; i->second:" << PeekPointer (i->second));
Expand Down

0 comments on commit cb36444

Please sign in to comment.