sns3 / sns3-satellite

Satellite module for ns-3 simulator
https://www.sns3.org
GNU General Public License v3.0
142 stars 58 forks source link

Failed to build sns3-satellite in ns-3 versions >= 3.31 #27

Closed yeliqseu closed 2 years ago

yeliqseu commented 3 years ago

I managed to installed sns3-satellite on ns-3.29. However, when I tried to install it in a fresh ns-3.33, I got the following errors:

[2950/3305] Compiling contrib/satellite/examples/sat-dama-onoff-sim-tn9.cc
../contrib/satellite/examples/sat-arq-fwd-example.cc: In function ‘int main(int, char**)’:
../contrib/satellite/examples/sat-arq-fwd-example.cc:118:38: error: no matching function for call to ‘Seconds(ns3::Time&)’
  118 |      appStartTime, Seconds (simLength), Seconds (0.001));
      |                                      ^
In file included from ./ns3/command-line.h:28,
                 from ./ns3/core-module.h:25,
                 from ../contrib/satellite/examples/sat-arq-fwd-example.cc:22:
./ns3/nstime.h:1289:13: note: candidate: ‘ns3::Time ns3::Seconds(double)’
 1289 | inline Time Seconds (double value)
      |             ^~~~~~~
./ns3/nstime.h:1289:29: note:   no known conversion for argument 1 from ‘ns3::Time’ to ‘double’
 1289 | inline Time Seconds (double value)
      |                      ~~~~~~~^~~~~
./ns3/nstime.h:1293:13: note: candidate: ‘ns3::Time ns3::Seconds(ns3::int64x64_t)’
 1293 | inline Time Seconds (int64x64_t value)
      |             ^~~~~~~
./ns3/nstime.h:1293:33: note:   no known conversion for argument 1 from ‘ns3::Time’ to ‘ns3::int64x64_t’
 1293 | inline Time Seconds (int64x64_t value)
      |                      ~~~~~~~~~~~^~~~~

It seems that some APIs have changed in ns-3. I then tried to disable all the examples by commenting out

#if (bld.env['ENABLE_EXAMPLES']):
     #    bld.recurse('examples')

in contrib/satellite/wscript. However, I still got the following error:

[3159/3209] Linking build/scratch/scratch-simulator
[3160/3209] Linking build/scratch/subdir/subdir
[3161/3209] Linking build/examples/energy/ns3.33-energy-model-example-debug
[3162/3209] Linking build/examples/energy/ns3.33-energy-model-with-harvesting-example-debug
[3163/3209] Linking build/utils/ns3.33-test-runner-debug
[3164/3209] Linking build/utils/ns3.33-bench-simulator-debug
/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatBaseTraceContainer::INTF_TRACE_DEFAULT_NUMBER_OF_COLUMNS'
/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatConstVariables::SUPERFRAME_SEQUENCE'
/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatBaseTraceContainer::RX_POWER_TRACE_DEFAULT_NUMBER_OF_COLUMNS'
/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatBaseTraceContainer::CSINR_TRACE_DEFAULT_NUMBER_OF_COLUMNS'
/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatBaseTraceContainer::FADING_TRACE_DEFAULT_NUMBER_OF_COLUMNS'
collect2: error: ld returned 1 exit status

/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatBaseTraceContainer::INTF_TRACE_DEFAULT_NUMBER_OF_COLUMNS'
/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatConstVariables::SUPERFRAME_SEQUENCE'
/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatBaseTraceContainer::RX_POWER_TRACE_DEFAULT_NUMBER_OF_COLUMNS'
/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatBaseTraceContainer::CSINR_TRACE_DEFAULT_NUMBER_OF_COLUMNS'
/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatBaseTraceContainer::FADING_TRACE_DEFAULT_NUMBER_OF_COLUMNS'
collect2: error: ld returned 1 exit status

/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatBaseTraceContainer::INTF_TRACE_DEFAULT_NUMBER_OF_COLUMNS'
/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatConstVariables::SUPERFRAME_SEQUENCE'
/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatBaseTraceContainer::RX_POWER_TRACE_DEFAULT_NUMBER_OF_COLUMNS'
/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatBaseTraceContainer::CSINR_TRACE_DEFAULT_NUMBER_OF_COLUMNS'
/usr/bin/ld: lib/libns3.33-satellite-debug.so: undefined reference to `ns3::SatBaseTraceContainer::FADING_TRACE_DEFAULT_NUMBER_OF_COLUMNS'
collect2: error: ld returned 1 exit status

I assume that some ns-3 internal mechanism has changed since ns-3.29. I therefore tried sns3-satellite in all the newer versions, and it seems that the installation can be successful up to ns-3.30.1.

Any idea on how to build it successfully in ns-3.33? Thanks.

yeliqseu commented 2 years ago

I have figured out a workaround to make the module work in ns-3 versions >=3.31:

1, Change all the occurrence of source codes reporting error: no matching function for call to ‘Seconds(ns3::Time&)’ to something like appStartTime, Seconds (simLength.GetSeconds ()), Seconds (0.001));. That is, convert Time objects to double before calling Seconds ().

2, Change all the IsEqual() calls in helper/satellite-helper.cc to the operator "==", because IsEqual() API is deprecated since ns-3.33. For example: - if ( netAddressA.IsEqual (netAddressB)) + if ( netAddressA == netAddressB)

3, Change all the public static variables of class SatBaseTraceContainer (model/satellite-base-trace-container.h) to non-static by removing the static keyword. This will correct the ld error.

The module now compiles correctly in ns-3.35. I think the issue can be closed.

lc837948166 commented 1 year ago

thanks,this is helpful