Rate Control stops being used during simulation.

305 views
Skip to first unread message

Rúben Queirós

unread,
Jun 1, 2023, 11:40:56 AM6/1/23
to ns-3-users
Hello all,

I have been doing ns-3 experiments for a while, with special focus on the development of new rate control mechanisms for Wi-Fi. However, i would like your assistance to guide me through the problems I am facing recently.

For a bit of context:

I developed a simple scenario with 2 nodes. They are initially placed close to each other, one remains static throughout the simulation duration (60seconds) and the other moves with constant velocity until link quality is extremely low (simulation finishes by then). IEEE802.11n is used (20Ch. BW, SISO, long GI), AdhocWifiMac, YansWifiPhy, Friis propagation loss model with NistErrorRate, etc. For traffic generation UDP is used, saturating the link (data rate = 70Mbps)  (Not sure if more details are necessary)

When I run this scenario with IdealWifiManager, what is observed is that MCS 7 down to 0 are used throughout the duration of the simulation (as it was expected).

When I run my custom Rate Control algorithm, (which is heavily based on ConstantRateWifiManager) I configure MCS0 during the whole simulation. This also works as expected because the throughput remains the same for the total sim duration.

However, if I randomly update the MCS index (lets say, 10 times per second), the simulation starts working as intended and at ~17 seconds simulation time, the rate control mechanism "stops being used".

What i have found so far:
  Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::OnOffApplication/Tx",MakeCallback (&checkingPACKET)); // is called throughout the whole simulation
  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::AdhocWifiMac/MacTx",MakeCallback (&checkingPACKET));// is called throughout the whole simulation
  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::AdhocWifiMac/MacTxDrop",MakeCallback (&checkingPACKET)); //never happened
 
  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxEnd",MakeCallback (&checkingPACKET)); // is called in the beginning, but stops afterwards
I'm not sure where to look from here.
Any suggestions?

Rúben Queirós

unread,
Jun 1, 2023, 2:20:07 PM6/1/23
to ns-3-users
After reducing the simulation time and using WifiHelper::EnableLogComponents();
This is the loop that repeats itself:

+3.700416164s 0 [link=0][mac=00:00:00:00:00:01] No frames available for transmission
+3.700416164s 0 [link=0][mac=00:00:00:00:00:01] No frame transmitted
+3.700416164s 0 [mac=00:00:00:00:00:01] QosTxop:NotifyChannelReleased(0x55f9c94ea320, 0)
+3.700416164s 0 [mac=00:00:00:00:00:01] Txop:NotifyChannelReleased(0x55f9c94ea320, 0)
+3.700416164s 0 [mac=00:00:00:00:00:01] Txop:GenerateBackoff(0x55f9c94ea320, 0)
+3.700416164s 0 [mac=00:00:00:00:00:01] Txop:StartBackoffNow(0x55f9c94ea320, 13, 0)
+3.700416164s 0 [mac=00:00:00:00:00:01] start backoff=13 slots
+3.700416164s 0 WifiMacQueue:WipeAllExpiredMpdus(0x55f9c94ea410)
+3.700416164s 0 WifiMacQueue:ExtractAllExpiredMpdus(0x55f9c94ea410)
+3.700416164s 0 WifiMacQueue:PeekFirstAvailable(0x55f9c94ea410, 0, 0)
+3.700416164s 0 WifiMacQueue:ExtractExpiredMpdus(0x55f9c94ea410)
+3.700416164s 0 [mac=00:00:00:00:00:01] QosTxop:HasFramesToTransmit(0x55f9c94ea320, 1)
+3.700416164s 0 [link=0] ChannelAccessManager:DoRestartAccessTimeoutIfNeeded(0x55f9c93b3240)
+3.700416164s 0 [link=0] Access timeout needed: 0
+3.700416164s 0 [mac=00:00:00:00:00:01] Txop:RequestAccess(0x55f9c94ea320, 0)
+3.700416164s 0 [link=0] ChannelAccessManager:RequestAccess(0x55f9c93b3240, 0x55f9c94ea320)
+3.700416164s 0 WifiPhy:NotifyChannelAccessRequested(0x55f9c94e8b40)
+3.700416164s 0 [link=0] ChannelAccessManager:GetAccessGrantStart(0x55f9c93b3240)
+3.700416164s 0 [link=0] access grant start=+3.05012e+09ns, rx access start=+3.05012e+09ns, busy access start=+3.0501e+09ns, tx access start=+3.05007e+09ns, nav access start=+10000ns
+3.700416164s 0 [mac=00:00:00:00:00:01] Txop:UpdateBackoffSlotsNow(0x55f9c94ea320, 0, +3.70044e+09ns, 0)
+3.700416164s 0 [mac=00:00:00:00:00:01] update slots=0 slots, backoff=13
+3.700416164s 0 [link=0] ChannelAccessManager:UpdateBackoff(0x55f9c93b3240)
+3.700416164s 0 [link=0] ChannelAccessManager:GetBackoffStartFor(0x55f9c93b3240, 0x55f9c94e9a10)
+3.700416164s 0 [link=0] ChannelAccessManager:GetAccessGrantStart(0x55f9c93b3240)
+3.700416164s 0 [link=0] access grant start=+3.05012e+09ns, rx access start=+3.05012e+09ns, busy access start=+3.0501e+09ns, tx access start=+3.05007e+09ns, nav access start=+10000ns
+3.700416164s 0 [link=0] Backoff start: +3.05016e+06us
+3.700416164s 0 [link=0] dcf 0 dec backoff slots=0
+3.700416164s 0 [mac=00:00:00:00:00:01] Txop:UpdateBackoffSlotsNow(0x55f9c94e9a10, 0, +3.05016e+09ns, 0)
+3.700416164s 0 [mac=00:00:00:00:00:01] update slots=0 slots, backoff=0
+3.700416164s 0 [link=0] ChannelAccessManager:GetBackoffStartFor(0x55f9c93b3240, 0x55f9c94e9d30)
+3.700416164s 0 [link=0] ChannelAccessManager:GetAccessGrantStart(0x55f9c93b3240)
+3.700416164s 0 [link=0] access grant start=+3.05012e+09ns, rx access start=+3.05012e+09ns, busy access start=+3.0501e+09ns, tx access start=+3.05007e+09ns, nav access start=+10000ns
+3.700416164s 0 [link=0] Backoff start: +3.05016e+06us
+3.700416164s 0 [link=0] dcf 1 dec backoff slots=0
+3.700416164s 0 [mac=00:00:00:00:00:01] Txop:UpdateBackoffSlotsNow(0x55f9c94e9d30, 0, +3.05016e+09ns, 0)
+3.700416164s 0 [mac=00:00:00:00:00:01] update slots=0 slots, backoff=0
+3.700416164s 0 [link=0] ChannelAccessManager:GetBackoffStartFor(0x55f9c93b3240, 0x55f9c94ea320)
+3.700416164s 0 [link=0] ChannelAccessManager:GetAccessGrantStart(0x55f9c93b3240)
+3.700416164s 0 [link=0] access grant start=+3.05012e+09ns, rx access start=+3.05012e+09ns, busy access start=+3.0501e+09ns, tx access start=+3.05007e+09ns, nav access start=+10000ns
+3.700416164s 0 [link=0] Backoff start: +3.70044e+06us
+3.700416164s 0 [link=0] ChannelAccessManager:GetBackoffStartFor(0x55f9c93b3240, 0x55f9c94eb090)
+3.700416164s 0 [link=0] ChannelAccessManager:GetAccessGrantStart(0x55f9c93b3240)
+3.700416164s 0 [link=0] access grant start=+3.05012e+09ns, rx access start=+3.05012e+09ns, busy access start=+3.0501e+09ns, tx access start=+3.05007e+09ns, nav access start=+10000ns
+3.700416164s 0 [link=0] Backoff start: +3.05026e+06us
+3.700416164s 0 [link=0] dcf 3 dec backoff slots=0
+3.700416164s 0 [mac=00:00:00:00:00:01] Txop:UpdateBackoffSlotsNow(0x55f9c94eb090, 0, +3.05026e+09ns, 0)
+3.700416164s 0 [mac=00:00:00:00:00:01] update slots=0 slots, backoff=0
+3.700416164s 0 [mac=00:00:00:00:00:01] Txop:NotifyAccessRequested(0x55f9c94ea320, 0)
+3.700416164s 0 [link=0] ChannelAccessManager:DoGrantDcfAccess(0x55f9c93b3240)
+3.700416164s 0 [link=0] ChannelAccessManager:GetBackoffEndFor(0x55f9c93b3240, 0x55f9c94ea320)
+3.700416164s 0 [link=0] ChannelAccessManager:GetBackoffStartFor(0x55f9c93b3240, 0x55f9c94ea320)
+3.700416164s 0 [link=0] ChannelAccessManager:GetAccessGrantStart(0x55f9c93b3240)
+3.700416164s 0 [link=0] access grant start=+3.05012e+09ns, rx access start=+3.05012e+09ns, busy access start=+3.0501e+09ns, tx access start=+3.05007e+09ns, nav access start=+10000ns
+3.700416164s 0 [link=0] Backoff start: +3.70044e+06us
+3.700416164s 0 [link=0] Backoff end: +3.7007e+06us
+3.700416164s 0 [link=0] ChannelAccessManager:DoRestartAccessTimeoutIfNeeded(0x55f9c93b3240)
+3.700416164s 0 [link=0] ChannelAccessManager:GetBackoffEndFor(0x55f9c93b3240, 0x55f9c94ea320)
+3.700416164s 0 [link=0] ChannelAccessManager:GetBackoffStartFor(0x55f9c93b3240, 0x55f9c94ea320)
+3.700416164s 0 [link=0] ChannelAccessManager:GetAccessGrantStart(0x55f9c93b3240)
+3.700416164s 0 [link=0] access grant start=+3.05012e+09ns, rx access start=+3.05012e+09ns, busy access start=+3.0501e+09ns, tx access start=+3.05007e+09ns, nav access start=+10000ns
+3.700416164s 0 [link=0] Backoff start: +3.70044e+06us
+3.700416164s 0 [link=0] Backoff end: +3.7007e+06us
+3.700416164s 0 [link=0] Access timeout needed: 1
+3.700416164s 0 [link=0] expected backoff end=+3.7007e+09ns
+3.700696164s 0 [link=0] ChannelAccessManager:AccessTimeout(0x55f9c93b3240)
+3.700696164s 0 [link=0] ChannelAccessManager:UpdateBackoff(0x55f9c93b3240)
+3.700696164s 0 [link=0] ChannelAccessManager:GetBackoffStartFor(0x55f9c93b3240, 0x55f9c94e9a10)
+3.700696164s 0 [link=0] ChannelAccessManager:GetAccessGrantStart(0x55f9c93b3240)
+3.700696164s 0 [link=0] access grant start=+3.05012e+09ns, rx access start=+3.05012e+09ns, busy access start=+3.0501e+09ns, tx access start=+3.05007e+09ns, nav access start=+10000ns
+3.700696164s 0 [link=0] Backoff start: +3.05016e+06us
+3.700696164s 0 [link=0] dcf 0 dec backoff slots=0
+3.700696164s 0 [mac=00:00:00:00:00:01] Txop:UpdateBackoffSlotsNow(0x55f9c94e9a10, 0, +3.05016e+09ns, 0)
+3.700696164s 0 [mac=00:00:00:00:00:01] update slots=0 slots, backoff=0
+3.700696164s 0 [link=0] ChannelAccessManager:GetBackoffStartFor(0x55f9c93b3240, 0x55f9c94e9d30)
+3.700696164s 0 [link=0] ChannelAccessManager:GetAccessGrantStart(0x55f9c93b3240)
+3.700696164s 0 [link=0] access grant start=+3.05012e+09ns, rx access start=+3.05012e+09ns, busy access start=+3.0501e+09ns, tx access start=+3.05007e+09ns, nav access start=+10000ns
+3.700696164s 0 [link=0] Backoff start: +3.05016e+06us
+3.700696164s 0 [link=0] dcf 1 dec backoff slots=0
+3.700696164s 0 [mac=00:00:00:00:00:01] Txop:UpdateBackoffSlotsNow(0x55f9c94e9d30, 0, +3.05016e+09ns, 0)
+3.700696164s 0 [mac=00:00:00:00:00:01] update slots=0 slots, backoff=0
+3.700696164s 0 [link=0] ChannelAccessManager:GetBackoffStartFor(0x55f9c93b3240, 0x55f9c94ea320)
+3.700696164s 0 [link=0] ChannelAccessManager:GetAccessGrantStart(0x55f9c93b3240)
+3.700696164s 0 [link=0] access grant start=+3.05012e+09ns, rx access start=+3.05012e+09ns, busy access start=+3.0501e+09ns, tx access start=+3.05007e+09ns, nav access start=+10000ns
+3.700696164s 0 [link=0] Backoff start: +3.70044e+06us
+3.700696164s 0 [link=0] dcf 2 dec backoff slots=13
+3.700696164s 0 [mac=00:00:00:00:00:01] Txop:UpdateBackoffSlotsNow(0x55f9c94ea320, 13, +3.7007e+09ns, 0)
+3.700696164s 0 [mac=00:00:00:00:00:01] update slots=13 slots, backoff=0
+3.700696164s 0 [link=0] ChannelAccessManager:GetBackoffStartFor(0x55f9c93b3240, 0x55f9c94eb090)
+3.700696164s 0 [link=0] ChannelAccessManager:GetAccessGrantStart(0x55f9c93b3240)
+3.700696164s 0 [link=0] access grant start=+3.05012e+09ns, rx access start=+3.05012e+09ns, busy access start=+3.0501e+09ns, tx access start=+3.05007e+09ns, nav access start=+10000ns
+3.700696164s 0 [link=0] Backoff start: +3.05026e+06us
+3.700696164s 0 [link=0] dcf 3 dec backoff slots=0
+3.700696164s 0 [mac=00:00:00:00:00:01] Txop:UpdateBackoffSlotsNow(0x55f9c94eb090, 0, +3.05026e+09ns, 0)
+3.700696164s 0 [mac=00:00:00:00:00:01] update slots=0 slots, backoff=0
+3.700696164s 0 [link=0] ChannelAccessManager:DoGrantDcfAccess(0x55f9c93b3240)
+3.700696164s 0 [link=0] ChannelAccessManager:GetBackoffEndFor(0x55f9c93b3240, 0x55f9c94ea320)
+3.700696164s 0 [link=0] ChannelAccessManager:GetBackoffStartFor(0x55f9c93b3240, 0x55f9c94ea320)
+3.700696164s 0 [link=0] ChannelAccessManager:GetAccessGrantStart(0x55f9c93b3240)
+3.700696164s 0 [link=0] access grant start=+3.05012e+09ns, rx access start=+3.05012e+09ns, busy access start=+3.0501e+09ns, tx access start=+3.05007e+09ns, nav access start=+10000ns
+3.700696164s 0 [link=0] Backoff start: +3.7007e+06us
+3.700696164s 0 [link=0] Backoff end: +3.7007e+06us
+3.700696164s 0 [link=0] dcf 2 needs access. backoff expired. access granted. slots=0
+3.700696164s 0 [link=0][mac=00:00:00:00:00:01] QosFrameExchangeManager:StartTransmission(0x55f9c93c2480, 0x55f9c94ea320, 20)
+3.700696164s 0 [link=0][mac=00:00:00:00:00:01] QosFrameExchangeManager:StartTransmission(0x55f9c93c2480, 0x55f9c94ea320, +0ns)
+3.700696164s 0 [link=0][mac=00:00:00:00:00:01] HtFrameExchangeManager:StartFrameExchange(0x55f9c93c2480, 0x55f9c94ea320, +9.22337e+18ns, 1)
+3.700696164s 0 [link=0][mac=00:00:00:00:00:01] HtFrameExchangeManager:GetBar(0x55f9c93c2480, 0, 0, 0)
+3.700696164s 0 [mac=00:00:00:00:00:01] Txop:GetWifiMacQueue(0x55f9c94ea320)
+3.700696164s 0 WifiMacQueue:WipeAllExpiredMpdus(0x55f9c94ea410)
+3.700696164s 0 WifiMacQueue:ExtractAllExpiredMpdus(0x55f9c94ea410)
+3.700696164s 0 WifiMacQueue:PeekByQueueId(0x55f9c94ea410, 0)
+3.700696164s 0 WifiMacQueue:ExtractExpiredMpdus(0x55f9c94ea410)
+3.700696164s 0 The queue is empty
+3.700696164s 0 [mac=00:00:00:00:00:01] QosTxop:PeekNextMpdu(0x55f9c94ea320, 0, 8, ff:ff:ff:ff:ff:ff, 0)
+3.700696164s 0 WifiMacQueue:PeekFirstAvailable(0x55f9c94ea410, 0, 0)
+3.700696164s 0 WifiMacQueue:ExtractExpiredMpdus(0x55f9c94ea410)
+3.700696164s 0 MacTxMiddle:PeekNextSequenceNumberFor(0x55f9c943e0b0)
+3.700696164s 0 WifiRemoteStationManager:LookupState(0x55f9c94e93a0, 00:00:00:00:00:02)
+3.700696164s 0 WifiRemoteStationManager::LookupState returning existing state
+3.700696164s 0 BlockAckManager:GetAgreementAsOriginator(0x55f9c94ea690, 00:00:00:00:00:02, 0)
+3.700696164s 0 [mac=00:00:00:00:00:01] Packet beyond the end of the current transmit window
+3.700696164s 0 [link=0][mac=00:00:00:00:00:01] No frames available for transmission
+3.700696164s 0 [link=0][mac=00:00:00:00:00:01] No frame transmitted
+3.700696164s 0 [mac=00:00:00:00:00:01] QosTxop:NotifyChannelReleased(0x55f9c94ea320, 0)
+3.700696164s 0 [mac=00:00:00:00:00:01] Txop:NotifyChannelReleased(0x55f9c94ea320, 0)
+3.700696164s 0 [mac=00:00:00:00:00:01] Txop:GenerateBackoff(0x55f9c94ea320, 0)
+3.700696164s 0 [mac=00:00:00:00:00:01] Txop:StartBackoffNow(0x55f9c94ea320, 8, 0)

Tom Henderson

unread,
Jun 1, 2023, 5:23:07 PM6/1/23
to ns-3-...@googlegroups.com
I am not sure what you mean that the rate control stops being used. The
rate control should be consulted when there is a new frame to send. One
cause of rate control not being used is that there is no longer any new
traffic to send-- is that the case? Or are you seeing frames being sent
but the rate control not being involved in selecting their WifiTxVector
(which I don't think could be the case)?

- Tom
> --
> Posting to this group should follow these guidelines
> https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
> <https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting>
> ---
> You received this message because you are subscribed to the Google
> Groups "ns-3-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ns-3-users+...@googlegroups.com
> <mailto:ns-3-users+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ns-3-users/a1087812-99eb-4b97-9a49-2074928b5458n%40googlegroups.com <https://groups.google.com/d/msgid/ns-3-users/a1087812-99eb-4b97-9a49-2074928b5458n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Rúben Queirós

unread,
Jun 1, 2023, 6:57:03 PM6/1/23
to ns-3-users
The traffic is permanently being generated during the whole simulation. I can confirm that with the following trace

Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::OnOffApplication/Tx",MakeCallback (&checkingPACKET)); // is called throughout the whole simulation

and i see the frames being sent with the following trace
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::AdhocWifiMac/MacTx",MakeCallback (&checkingPACKET));// is called throughout the whole simulation
A packet has been received from higher layers and is being processed in preparation for queueing for transmission.

The WifiTxVector is being selected in the beginning of the simulation. but it stops afterwards, same with the following trace:

  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxEnd",MakeCallback (&checkingPACKET)); // is called in the beginning, but stops afterwards

Perhaps the frames are getting stuck somewhere in the Mac Queueing... but im not sure how to check that. or why would such thing happen.

Tom Henderson

unread,
Jun 1, 2023, 7:09:55 PM6/1/23
to ns-3-...@googlegroups.com
try tracing WifiRemoteStationManager::MacTxFinalDataFailed and see if this event corresponds to when you no longer see transmissions.  My guess is that the destination becomes blocked somehow due to failures. However, I am not very up to date on the current WifiMac and how/whether this could happen.

- Tom
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/acc8209b-3f4d-4248-bae0-1821cb0ef2e0n%40googlegroups.com.


Rúben Queirós

unread,
Jun 2, 2023, 12:36:57 PM6/2/23
to ns-3-users
I did and i can confirm that both MacTxFinalDataFailed and MacTxDataFailed traces are both being called prior to this "bug". I can also tell you that after the final MacTxFinalDataFailed event,  MacTxDataFailed  event occurs 3 times.

In the meantime, i found out that disabling AdhocWifiMac frame aggregation fixes this bug. This makes me believe that there is some issue with the frame aggregation or queueing. However, I don't see how adapting the ConstantRateWifiManager could impact those methods happening in a higher level of the protocol stack.

Still on this matter, I am not having success connecting to any trace of the WifiMacQueue class.
I am currently using the string (replacing the wildcards with the respective node Ids and Device Ids is also not working for me):
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/Txop/Queue/PacketsInQueue"

and getting the error:

msg="Could not connect callback to /NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/Txop/Queue/PacketsInQueue", +0.000000000s -1 file=/home/rmq/workspace/ns-3-dev/src/core/model/config.cc, line=980
NS_FATAL, terminating
terminate called without an active exception
Command 'build/scratch/fw-phd/ns3.38-sim-default --simSeed=1' died with <Signals.SIGABRT: 6>.

Tom Henderson

unread,
Jun 2, 2023, 1:01:08 PM6/2/23
to ns-3-...@googlegroups.com
My guess is that there is a failure in the block ack agreement at some
point and the destination becomes blocked and the simulation never recovers.

Possibly related, although reported to be fixed:
https://gitlab.com/nsnam/ns-3-dev/-/issues/595

Can you provide a working testcase, that runs on ns-3-dev, of the problem?

- Tom


On 6/2/23 09:36, Rúben Queirós wrote:
> I did and i can confirm that both *MacTxFinalDataFailed* and
> *MacTxDataFailed* traces are both being called prior to this "bug". I
> can also tell you that after the final *MacTxFinalDataFailed* event,
> *MacTxDataFailed*  event occurs 3 times.
>
> In the meantime, i found out that disabling *AdhocWifiMac* frame
> aggregation fixes this bug. This makes me believe that there is some
> issue with the frame aggregation or queueing. However, I don't see how
> adapting the *ConstantRateWifiManager *could impact those methods
> happening in a higher level of the protocol stack.
>
> Still on this matter, I am not having success connecting to any trace of
> the *WifiMacQueue* class.
> I am currently using the string (replacing the wildcards with the
> respective node Ids and Device Ids is also not working for me):
> *"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/Txop/Queue/PacketsInQueue"*
>> https://groups.google.com/d/msgid/ns-3-users/a1087812-99eb-4b97-9a49-2074928b5458n%40googlegroups.com <https://groups.google.com/d/msgid/ns-3-users/a1087812-99eb-4b97-9a49-2074928b5458n%40googlegroups.com> <https://groups.google.com/d/msgid/ns-3-users/a1087812-99eb-4b97-9a49-2074928b5458n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ns-3-users/a1087812-99eb-4b97-9a49-2074928b5458n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>>
>> --
>> Posting to this group should follow these guidelines
>> https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
>> <https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting>
>> ---
>> You received this message because you are subscribed to the Google
>> Groups "ns-3-users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to ns-3-users+...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ns-3-users/acc8209b-3f4d-4248-bae0-1821cb0ef2e0n%40googlegroups.com <https://groups.google.com/d/msgid/ns-3-users/acc8209b-3f4d-4248-bae0-1821cb0ef2e0n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
>
> --
> Posting to this group should follow these guidelines
> https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
> <https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting>
> ---
> You received this message because you are subscribed to the Google
> Groups "ns-3-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ns-3-users+...@googlegroups.com
> <mailto:ns-3-users+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ns-3-users/580e7aea-9363-4e29-b6ce-4560bf2ef86en%40googlegroups.com <https://groups.google.com/d/msgid/ns-3-users/580e7aea-9363-4e29-b6ce-4560bf2ef86en%40googlegroups.com?utm_medium=email&utm_source=footer>.

Rúben Queirós

unread,
Jun 2, 2023, 5:32:52 PM6/2/23
to ns-3-users
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
#include "ns3/propagation-loss-model.h"
#include "ns3/internet-module.h"
#include "ns3/log.h"
#include <iostream>
#include <cstring>
#include <string>

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("bug");

uint64_t rxByteCounter=0, oldRxByteCounter=0;

std::vector<std::string> htDataRates = {"HtMcs0", "HtMcs1", "HtMcs2", "HtMcs3", "HtMcs4", "HtMcs5", "HtMcs6", "HtMcs7"};

void ChangeMCS ()
{
    Ptr<UniformRandomVariable> random_num = CreateObject<UniformRandomVariable> ();
    uint32_t dataRateId = random_num->GetInteger(0, 7);

    std::string newDataRate = htDataRates.at (dataRateId);
    Config::Set ("/NodeList/1/DeviceList/0/$ns3::WifiNetDevice/"
                   "RemoteStationManager/$ns3::ConstantRateWifiManager/DataMode",
                   StringValue (newDataRate));
    Config::Set ("/NodeList/1/DeviceList/0/$ns3::WifiNetDevice/"
                   "RemoteStationManager/$ns3::ConstantRateWifiManager/ControlMode",
                   StringValue (newDataRate));
    NS_LOG_UNCOND("New MCS: " << newDataRate);
    Simulator::Schedule(Seconds(0.1), &ChangeMCS);
}

void ThroughputMonitor ()
{
    double throughput = ((rxByteCounter - oldRxByteCounter) * 8) / (1e6 * 0.1);
    oldRxByteCounter = rxByteCounter;

    NS_LOG_UNCOND("SimTime: " << Simulator::Now().GetSeconds() <<
                    " | Throughput: " << throughput << " Mbit/0.1s");
   
    Simulator::Schedule(Seconds(0.1), &ThroughputMonitor);
}

void ReceivedPacket(Ptr<const Packet> packet)
{
    rxByteCounter += packet->GetSize();
}

int main(int argc, char** argv)
{
    // To trigger bug, randomMCS, FrameAggregation and ConstantRate need to be true.
    // Any other combination works well:
    // Ideal with or without frame aggregation works well
    // Constant rate (without randomMCS) and with or without frame aggregation works well
    // the combination of the three is what makes it trigger the bug.

    // ---- CONFIGURATION VARIABLES ---
    bool RandomMCS = true;
    bool FrameAggregation = true;
    bool ConstantRate = true; //alternative is IdealWifiManager
    // ---- CONFIGURATION VARIABLES ---
    double duration = 15;
    std::string udpDataRate = "70Mbps"; // saturated link


    SeedManager::SetSeed(1);
    SeedManager::SetRun(1);
    NodeContainer adhocNodes;
    adhocNodes.Create(2);


    WifiHelper wifi;
    wifi.SetStandard (WIFI_STANDARD_80211n);
    if(ConstantRate)
    {
        std::string initialDataRate = htDataRates.at (0);
        wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
                                    "DataMode", StringValue(initialDataRate),
                                    "ControlMode", StringValue(initialDataRate));
    }
    else
    {
        wifi.SetRemoteStationManager("ns3::IdealWifiManager");
    }

    YansWifiChannelHelper wifiChannel;
    wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
    wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel", "Frequency", DoubleValue(5180*1e6));
   
    YansWifiPhyHelper wifiPhy;
    wifiPhy.SetChannel( wifiChannel.Create()) ;
    wifiPhy.Set("ChannelSettings", StringValue("{36, 20, BAND_5GHZ, 0}"));
    wifiPhy.Set("RxGain", DoubleValue(0));
    wifiPhy.Set ("TxGain", DoubleValue(0) );
    wifiPhy.Set ("TxPowerStart", DoubleValue(20) );
    wifiPhy.Set ("TxPowerEnd", DoubleValue(20) );
    wifiPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
 
    WifiMacHelper wifiMac;
    if(!FrameAggregation)
    {
        wifiMac.SetType ("ns3::AdhocWifiMac",
                "VO_MaxAmsduSize", UintegerValue (0),
                "VI_MaxAmsduSize", UintegerValue (0),
                "BE_MaxAmsduSize", UintegerValue (0),
                "BK_MaxAmsduSize", UintegerValue (0),
                "VO_MaxAmpduSize", UintegerValue (0),
                "VI_MaxAmpduSize", UintegerValue (0),
                "BE_MaxAmpduSize", UintegerValue (0),
                "BK_MaxAmpduSize", UintegerValue (0));
    }
    else
    {
        wifiMac.SetType ("ns3::AdhocWifiMac");
    }
       
    NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, adhocNodes.Get (0));
    devices.Add (wifi.Install (wifiPhy, wifiMac, adhocNodes.Get (1)));
   
    //Set RSSI Threshold for preamble detection
    Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PreambleDetectionModel/$ns3::ThresholdPreambleDetectionModel/MinimumRssi", DoubleValue(-94));
   
    //Summary: Nodes start 10 meters away from each other
    //by the time the simulation finishes, they are 1000 meters away.
    MobilityHelper mobility;
    Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
    positionAlloc->Add (Vector (0.0, 0.0, 0.0)); //node 0 Sink node
    positionAlloc->Add (Vector (10.0, 0.0, 0.0)); //node 1 Sender node
    mobility.SetPositionAllocator (positionAlloc);
    mobility.SetMobilityModel ("ns3::WaypointMobilityModel"); //constant position mobility model for the two (static) nodes
    mobility.Install (adhocNodes);
    Ptr<WaypointMobilityModel> mob_model =
      DynamicCast<WaypointMobilityModel> (NodeList::GetNode (1)->GetObject<MobilityModel> ());
   
    Waypoint w1 = (Waypoint (Seconds (1), Vector (10, 0, 0)));
    Waypoint w2 = (Waypoint (Seconds (duration), Vector (1000, 0, 0)));
    mob_model->AddWaypoint (w1);
    mob_model->AddWaypoint (w2);

 
    //install internet stack and assign IP addresses for the nodes
    InternetStackHelper internet;
    internet.Install (adhocNodes);
 
    Ipv4AddressHelper ipv4;
    NS_LOG_INFO ("Assign IP Addresses.");
    ipv4.SetBase ("10.0.0.0", "255.255.255.0");
    Ipv4InterfaceContainer interfaces = ipv4.Assign (devices);

    ApplicationContainer apps;

    PacketSinkHelper rx ("ns3::UdpSocketFactory", InetSocketAddress(Ipv4Address::GetAny(), 9));
    apps.Add(rx.Install(adhocNodes.Get(0))); //node 0 is the Sink

    OnOffHelper tx ("ns3::UdpSocketFactory", interfaces.GetAddress (0));
    tx.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"));
    tx.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
    tx.SetAttribute ("PacketSize", UintegerValue (1400));
    tx.SetAttribute ("DataRate", DataRateValue (DataRate (udpDataRate)));
   
    AddressValue remoteAddress (InetSocketAddress (interfaces.GetAddress (0), 9)); //Points to RX
    tx.SetAttribute ("Remote", remoteAddress);
   
    apps.Add(tx.Install (adhocNodes.Get (1)));
   
    Config::ConnectWithoutContext("/NodeList/0/DeviceList/0/$ns3::WifiNetDevice/Mac/MacRx", MakeCallback(&ReceivedPacket));

    apps.Start (Seconds (1));
    apps.Stop (Seconds (duration));

    Simulator::Schedule(Seconds(1), &ThroughputMonitor);
    if(RandomMCS && ConstantRate)
        Simulator::Schedule(Seconds(1), &ChangeMCS);

    Simulator::Stop (Seconds(duration));
    Simulator::Run ();
    Simulator::Destroy();

    return 0;
}

Rúben Queirós

unread,
Jun 2, 2023, 5:35:58 PM6/2/23
to ns-3-users
For some context, I left three booleans that could help in the debug.
Bool RandomMCS calls a function that Changes the ConstantRate MCS randomly, triggering the faulty behaviour

However, for it to work, (Bool) FrameAggregation must also be turned on, as well the (Bool) ConstantRate rate control being used.

Tom Henderson

unread,
Jun 2, 2023, 8:17:58 PM6/2/23
to Rúben Queirós, ns-3-users
Thank you for creating a test case; I opened issue 915 to track this:

https://gitlab.com/nsnam/ns-3-dev/-/issues/915

- Tom

On 6/2/23 14:35, Rúben Queirós wrote:
> For some context, I left three booleans that could help in the debug.
> *Bool RandomMCS *calls a function that Changes the ConstantRate MCS
> randomly, triggering the faulty behaviour
>
> However, for it to work, *(Bool) *FrameAggregation must also be turned
> on, as well the *(Bool) *ConstantRate rate control being used.
>
>

王小胜

unread,
Dec 10, 2024, 5:13:24 AM12/10/24
to ns-3-users
Hi Tom, can you help me with the following issues?
0.0212143 UE IMSI 1: connected to CellId 1 with RNTI 1 context 0
msg="Could not connect callback to /NodeList/*/DeviceList/*/$ns3::LteNetDevice/$ns3::LteEnbNetDevice/LteEnbRrc/UeMap/1/DataRadioBearerMap/*/LtePdcp/TxPDUtrace", +0.121214285s 4 file=../src/core/model/config.cc, line=906

terminate called without an active exception
#include <string>
#include "ns3/lte-helper.h"
#include "ns3/epc-helper.h"
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/internet-module.h"
#include "ns3/mobility-module.h"
#include "ns3/lte-module.h"
#include "ns3/applications-module.h"
#include "ns3/point-to-point-helper.h"
#include "ns3/config-store.h"
#include "ns3/netanim-module.h"
#include "ns3/wifi-module.h"
//#include "ns3/gtk-config-store.h"
#include "/data/user/wangtengsheng/ns3/ns3_wifi/ns3-mmwave-5.0/src/lte/model/lwa-tag.h"
#include "/data/user/wangtengsheng/ns3/ns3_wifi/ns3-mmwave-5.0/src/lte/model/pdcp-lcid.h"
#include "/data/user/wangtengsheng/ns3/ns3_wifi/ns3-mmwave-5.0/src/lte/model/lwalwip-header.h"
using namespace ns3;
std::map<uint16_t, Ptr<Socket>> lwaSocketMap;
std::map<std::string, Ptr<Socket>> contextSocketMap;
// function for lwa/lwip packet handling transmitted through the LtePdcp::DoTransmitPdcpSdu
void LtePdcpLwaHandler (LteRlcSapProvider::TransmitPdcpPduParameters params){

  //NS_LOG_DEBUG("rnti : " << params.rnti);

  // copy incoming packet
  Ptr<Packet> currentPacket = params.pdcpPdu->Copy();

  // remove headers to get sequence number and include lwa/lwip header
  //wifi接收到的数据包
  LtePdcpHeader pdcpHeader;
  currentPacket->RemoveHeader (pdcpHeader);
  Ipv4Header ipHeader;
  currentPacket->RemoveHeader (ipHeader);
  TcpHeader tcpHeader;
  currentPacket->RemoveHeader (tcpHeader);

  // add headers again
  currentPacket->AddHeader (tcpHeader);
  currentPacket->AddHeader (ipHeader);
  currentPacket->AddHeader (pdcpHeader);

  // read lwa tags added by pdcp layer and add lwa information
  // as separate header to data packets (won't be removed when transmitting
  // packets via API)
  LwaTag   lwaTag;
  PdcpLcid lcidTag;
  uint32_t lcid=0;
  uint32_t bid=0;
  LwaLwipHeader lwaLwipHeader;

  // tag to copy the logical channel id of the frame
  if(currentPacket->FindFirstMatchingByteTag (lcidTag)){
      lcid = lcidTag.Get();
      bid = lcid - 2;
  }
  lwaLwipHeader.SetBearerId (bid);

  // packet handling for lwa packets
  if (currentPacket->PeekPacketTag(lwaTag)){
      //copy the status of LWA activation (LTE, Split, swtiched)
      lwaLwipHeader.SetLwaActivate (lwaTag.Get());
      // add lwa lwip header
      currentPacket->AddHeader (lwaLwipHeader);
      lwaSocketMap.find(params.rnti)->second->Send(currentPacket);
    //NS_LOG_DEBUG ("LWA: Sent packet with PDCP Sequence Number " << pdcpHeader.GetSequenceNumber());
  }
}
// assign callback function to the pdcp object
// NOTE: object is created after bearer release which is after attach procedure
static void
Callback_LtePDCPTX
(uint16_t rnti){
  std::string rntiPath = "/NodeList/*/DeviceList/*/$ns3::LteNetDevice/$ns3::LteEnbNetDevice/LteEnbRrc/UeMap/" + std::to_string(rnti) + "/DataRadioBearerMap/*/LtePdcp/TxPDUtrace";
 Config::ConnectWithoutContext (rntiPath, MakeCallback (&LtePdcpLwaHandler));
}

  void NotifyConnectionEstablishedUe (
              std::string context,
                        uint64_t imsi,
                        uint16_t cellId,
                        uint16_t rnti)
  {
    std::cout << Simulator::Now ().GetSeconds ()
              << " UE IMSI " << imsi
              << ": connected to CellId " << cellId
              << " with RNTI " << rnti
        << " context " << context
              << std::endl;
    // create socket on lwaap socket to enable transmission of lwa packets
  /*
            Ptr<Socket> lwaapTxSocket = Socket::CreateSocket (lwaapNode, tid);
            lwaapTxSocket->Bind ();
            lwaapTxSocket->Connect (InetSocketAddress (Ipv4Address::ConvertFrom(wifiIpInterfaces.GetAddress (i+1)), 9));
            lwaapTxSocket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ());
            lwaapTxSocket->SetAllowBroadcast (true);

            //TODO: temporary fix assuming rnti=i+1
            lwaSocketMap.insert(std::pair<uint16_t, Ptr<Socket>>(i+1, lwaapTxSocket));
        NS_LOG_INFO("STA Socket bound " << i+1);
  */
 
    lwaSocketMap.insert(std::pair<uint16_t, Ptr<Socket>>(rnti, contextSocketMap.find(context)->second));
    Simulator::Schedule(MilliSeconds(100), &Callback_LtePDCPTX, rnti);
  }


/**
 * Sample simulation script for LTE+EPC. It instantiates several eNodeB,
 * attaches one UE per eNodeB starts a flow for each UE to  and from a remote host.
 * It also  starts yet another flow between each UE pair.
 */

NS_LOG_COMPONENT_DEFINE ("EpcFirstExample");

int
main (int argc, char *argv[])
{
  uint16_t numberOfNodes = 1;
  Time simTime = MilliSeconds (11000);
  double distance = 40.0;
  Time interPacketInterval = MilliSeconds (10);
    // MTU size for P2P link between EnB and Wifi AP
  double xwLwaLinkMtuSize=1500;
  //delay of p2p link
  std::string xwLwaLinkDelay="0ms";
  //data rate of p2p link
  std::string xwLwaLinkDataRate="100Mbps";
  // Command line arguments
  CommandLine cmd;
  cmd.AddValue ("numberOfNodes", "Number of eNodeBs + UE pairs", numberOfNodes);
  cmd.AddValue ("simTime", "Total duration of the simulation", simTime);
  cmd.AddValue ("distance", "Distance between eNBs [m]", distance);
  cmd.AddValue ("interPacketInterval", "Inter packet interval", interPacketInterval);
  cmd.Parse(argc, argv);


  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
  Ptr<PointToPointEpcHelper>  epcHelper = CreateObject<PointToPointEpcHelper> ();
  lteHelper->SetEpcHelper (epcHelper);

  ConfigStore inputConfig;
  inputConfig.ConfigureDefaults();

  // parse again so you can override default values from the command line
  cmd.Parse(argc, argv);

  Ptr<Node> pgw = epcHelper->GetPgwNode ();
 
   // Create a single RemoteHost
  NodeContainer remoteHostContainer;
  remoteHostContainer.Create (1);
  Ptr<Node> remoteHost = remoteHostContainer.Get (0);
  InternetStackHelper internet;
  internet.Install (remoteHostContainer);

  // Create the Internet
  PointToPointHelper p2ph;
  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
  p2ph.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (10)));
  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
  Ipv4AddressHelper ipv4h;
  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
  // interface 0 is localhost, 1 is the p2p device
 // Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);

  Ipv4StaticRoutingHelper ipv4RoutingHelper;
  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);


 
    NodeContainer ueNodes, enbNodes, wifiApNodes, wifiStaNodes;
    enbNodes.Create(numberOfNodes);
    ueNodes.Create(numberOfNodes);
    wifiApNodes.Create(1);
    wifiStaNodes.Add(ueNodes); // LTE 用户设备同时作为 Wi-Fi STA


    // Configure Wi-Fi
    WifiHelper wifiHelper;
    YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();
    YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
    wifiPhy.SetChannel(wifiChannel.Create());

    WifiMacHelper wifiMac;
    Ssid ssid = Ssid("LteWifiNetwork");

    wifiMac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
    NetDeviceContainer wifiApDevs = wifiHelper.Install(wifiPhy, wifiMac, wifiApNodes);

    wifiMac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
   NetDeviceContainer wifiStaDevs = wifiHelper.Install(wifiPhy, wifiMac, wifiStaNodes);

 
  // start call back 100ms before datageneration
  // uint32_t callbackStartMs = uint32_t (3 * 1000 - 100);
  // Simulator::Schedule (MilliSeconds(callbackStartMs),&Callback_LtePDCPTX);
  // Install Mobility Model
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
    // 分配 eNB 和 UE 的位置,距离不超过 30
    for (uint16_t i = 0; i < numberOfNodes; i++)
    {
        positionAlloc->Add(Vector(10.0 * i+10, 10.0 * i, 0.0)); // eNB 位置
        positionAlloc->Add(Vector(10.0 * i, 10.0 * i + 10.0, 0.0)); // 对应 UE 位置
        positionAlloc->Add(Vector(10.0 * i+40, 10.0 * i+10, 0.0)); // remoteHost 位置
        positionAlloc->Add(Vector(10.0 * i+10, 10.0 * i+20, 0.0)); // wifiAp 位置
       

    }
  MobilityHelper mobility;
  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
  mobility.SetPositionAllocator(positionAlloc);
  mobility.Install(enbNodes);
  mobility.Install(ueNodes);
  mobility.Install(remoteHostContainer);
  mobility.Install(wifiApNodes);

  // Install LTE Devices to the nodes
  NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNodes);
  NetDeviceContainer ueLteDevs = lteHelper->InstallUeDevice (ueNodes);

  // Install the IP stack on the UEs
  internet.Install (ueNodes);
   internet.Install(wifiApNodes);
  Ipv4InterfaceContainer ueIpIface;
  ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteDevs));
  // Assign IP address to UEs, and install applications
  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
    {
      Ptr<Node> ueNode = ueNodes.Get (u);
      // Set the default gateway for the UE
      Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
      ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
      // ueStaticRouting->AddNetworkRouteTo(Ipv4Address("192.168.1.0"),Ipv4Mask("255.255.255.0"),)
    }


 // Assign IP addresses for Wi-Fi
    ipv4h.SetBase("192.168.1.0", "255.255.255.0");
  // Ipv4InterfaceContainer wifiApInterfaces = ipv4h.Assign(wifiApDevs);
  // Ipv4InterfaceContainer wifiStaInterfaces = ipv4h.Assign(wifiStaDevs);
  Ipv4InterfaceContainer wifiIpInterfaces;
                         wifiIpInterfaces.Add (ipv4h.Assign (wifiApDevs));
                         wifiIpInterfaces.Add (ipv4h.Assign (wifiStaDevs));
    // Configure Applications
    // create p2p helper for LWA/Xw link
  PointToPointHelper p2pHelpXw;
                     p2pHelpXw.SetDeviceAttribute ("DataRate", StringValue (xwLwaLinkDataRate));
                     p2pHelpXw.SetChannelAttribute ("Delay", StringValue (xwLwaLinkDelay));
                     p2pHelpXw.SetDeviceAttribute ("Mtu", UintegerValue (xwLwaLinkMtuSize));

  // create lwaap node
  // NodeContainer lwaNode;
  Ptr<Node> lwaapNode = CreateObject<Node> ();
  // lwaNode.Add(lwaapNode);
  Names::Add("LWAAP", lwaapNode);
  // install p2p net devices to create parallel lwa and lwip links
  NetDeviceContainer xwLwaDevices  = p2pHelpXw.Install (lwaapNode, wifiApNodes.Get(0));
  xwLwaDevices.Add(p2pHelpXw.Install (lwaapNode, wifiApNodes.Get(0)));

  // install ip stack on additional nodes
  internet.Install(lwaapNode);

  // assign ip adresses to lwa / lwip links
  Ipv4AddressHelper XwAddress;
  XwAddress.SetBase ("20.1.2.0", "255.255.255.0");
  Ipv4InterfaceContainer xwLwaIpInterfaces = XwAddress.Assign (xwLwaDevices);
  Ptr<ListPositionAllocator> positionAlloclwa = CreateObject<ListPositionAllocator> ();
  mobility.SetPositionAllocator(positionAlloclwa);
  positionAlloclwa->Add(Vector(10.0 +10, 15, 0.0)); // lwa 位置
  MobilityHelper Lwamobility;
  Lwamobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
  mobility.SetPositionAllocator(positionAlloclwa);
  mobility.Install(lwaapNode);
  lteHelper->AttachToClosestEnb(ueLteDevs, enbLteDevs);
    // Attach one UE per eNodeB
  for (uint16_t i = 0; i < numberOfNodes; i++)
    {
      // lteHelper->Attach (ueLteDevs.Get(i), enbLteDevs.Get(i));
      // side effect: the default EPS bearer will be activated
      Ptr<LteUeNetDevice> ueDev = ueLteDevs.Get(i)->GetObject<LteUeNetDevice> ();
      Ptr<LteUeRrc> ueRrc = ueDev->GetRrc ();
       
      ueRrc->TraceConnect("ConnectionEstablished", std::to_string(i), MakeCallback(&NotifyConnectionEstablishedUe));

      //创建UDP套接字
      TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
      Ptr<Socket> lwaapTxSocket = Socket::CreateSocket (lwaapNode, tid);
      lwaapTxSocket->Bind ();
      lwaapTxSocket->Connect (InetSocketAddress (Ipv4Address::ConvertFrom(wifiIpInterfaces.GetAddress (i+1)), 9));
      lwaapTxSocket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ());
      lwaapTxSocket->SetAllowBroadcast (true);

      //TODO: temporary fix assuming rnti=i+1
      contextSocketMap.insert(std::pair<std::string, Ptr<Socket>>(std::to_string(i+1), lwaapTxSocket));
     
      //创建接收wifiSta->UE套接字
      Ptr<Socket> staRxSocket = Socket::CreateSocket (ueNodes.Get(i), tid);
      staRxSocket->Bind (InetSocketAddress (Ipv4Address::GetAny(), 9));
      ueRrc->m_staRxSocket = staRxSocket;
    }


  // Install and start applications on UEs and remote host
  uint16_t dlPort = 1100;
  ApplicationContainer clientApps;
  ApplicationContainer serverApps;
  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
    {
     
          PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
          serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get(u)));

          UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort);
          dlClient.SetAttribute ("Interval", TimeValue (interPacketInterval));
          dlClient.SetAttribute ("MaxPackets", UintegerValue (1000000));
          clientApps.Add (dlClient.Install (remoteHost));
    }

  serverApps.Start (Seconds (1));
  clientApps.Start (Seconds (10));
    AnimationInterface anim("lte-wifi-distribution.xml");

    anim.UpdateNodeDescription(remoteHost, "RemoteHost");
    anim.UpdateNodeColor(remoteHost, 0, 0, 255);
    anim.UpdateNodeDescription(pgw, "PGW");
    anim.UpdateNodeColor(pgw, 0, 0, 255);
    anim.UpdateNodeDescription(lwaapNode, "LWAAP");
    anim.UpdateNodeColor(lwaapNode, 0, 0, 255);
    for (uint32_t i = 0; i < wifiApNodes.GetN(); ++i)
    {
        anim.UpdateNodeDescription(wifiApNodes.Get(i), "WiFi-AP");
        anim.UpdateNodeColor(wifiApNodes.Get(i), 255, 0, 0);
    }

    for (uint32_t i = 0; i < enbNodes.GetN(); ++i)
    {
        anim.UpdateNodeDescription(enbNodes.Get(i), "eNB");
        anim.UpdateNodeColor(enbNodes.Get(i), 0, 255, 0);
    }

    for (uint32_t i = 0; i < ueNodes.GetN(); ++i)
    {
        anim.UpdateNodeDescription(ueNodes.Get(i), "UE");
        anim.UpdateNodeColor(ueNodes.Get(i), 0, 255, 255);
    }
  //lteHelper->EnableTraces ();
  // Uncomment to enable PCAP tracing
  //p2ph.EnablePcapAll("lena-simple-epc");
  // lteHelper->EnableDlPhyTraces ();
  lteHelper->EnablePdcpTraces();

  Simulator::Stop (simTime);
  Simulator::Run ();

  /*GtkConfigStore config;
  config.ConfigureAttributes();*/

  Simulator::Destroy ();
  return 0;
}

Tom Henderson

unread,
Dec 10, 2024, 8:47:04 AM12/10/24
to ns-3-...@googlegroups.com
Most likely, your trace path is wrong in some way. Try connecting to
'TxPDU' instead of 'TxPDUtrace'.

王小胜

unread,
Dec 10, 2024, 8:42:38 PM12/10/24
to ns-3-users
'TxPDUtrace' is my custom source
1.png
If I connect to 'TxPDU', it shows a callback function mismatch because it's not the source I'm trying to trace.The following error message is displayed

msg="Incompatible types. (feed to "c++filt -t" if needed)
got=CallbackImpl<void,ns3::LteRlcSapProvider::TransmitPdcpPduParameters>
expected=CallbackImpl<void,unsigned short,unsigned char,unsigned int>", +0.121214285s 4 file=./ns3/callback.h, line=1582
+0.121214285s 4 file=./ns3/traced-callback.h, line=140

terminate called without an active exception

Tom Henderson

unread,
Dec 11, 2024, 10:23:35 AM12/11/24
to ns-3-...@googlegroups.com, 王小胜
I dug up an old reply that I had on a similar question a couple of years
ago. It could be the mentioned wildcard issue; it might be consistent
with the errors you are seeing.

https://groups.google.com/g/ns-3-users/c/RZaYwz18pvg

On 12/10/24 17:42, 王小胜 wrote:
> 'TxPDUtrace' is my custom source
> --
> Posting to this group should follow these guidelines
> https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
> <https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting>
> ---
> You received this message because you are subscribed to the Google
> Groups "ns-3-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ns-3-users+...@googlegroups.com
> <mailto:ns-3-users+...@googlegroups.com>.
> To view this discussion visit
> https://groups.google.com/d/msgid/ns-3-users/1706fbde-bed8-45b7-b4f4-e101da33d643n%40googlegroups.com <https://groups.google.com/d/msgid/ns-3-users/1706fbde-bed8-45b7-b4f4-e101da33d643n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages