Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

m_receiveCallback in Receive function in lora-net-device #150

Closed
chekraF opened this issue Feb 9, 2024 · 4 comments
Closed

m_receiveCallback in Receive function in lora-net-device #150

chekraF opened this issue Feb 9, 2024 · 4 comments
Assignees
Labels

Comments

@chekraF
Copy link

chekraF commented Feb 9, 2024

This instruction generates an error: msg="Attempted to dereference zero pointer". I try to find the problem, and I want to ask why you filled empty empty stuff in ptotocol and address m_receiveCallback (this, packet, 0, Address()); . the callback should not contain th eaddress of the gateway as aparameter?

@non-det-alle
Copy link
Collaborator

non-det-alle commented Feb 9, 2024

This instruction generates an error: msg="Attempted to dereference zero pointer".

This is probably because you are calling m_receiveCallback (i.e., LoraNetDevice::Receive) before setting the callback with LoraNetDevice::SetReceiveCallback. The pointer to the callback function is still zero and so the error message. This way of forwarding packets up the stack is normal practice in ns-3 (compare for instance ns-3's WiFi module).

you filled empty empty stuff in protocol and address m_receiveCallback (this, packet, 0, Address()); .

This is because - in the real world - the LoRaWAN stack (PHY + MAC layers) does not have an actual NetDevice in the traditional network sense. Unfortunately, ns-3 expects you to always have a NetDevice (it is part of the base ns-3 abstractions). As a consequence, in the current implementation packets are just forwarded through the NetDevice object, going from the MAC layer to the Application. We actually have a future proposal to completely remove the NetDevice from the LoRaWAN stack for this reason.

The callback should not contain the address of the gateway as a parameter?

LoRaWAN gateways do not have a LoRaWAN address (i.e., a DevAddr) so, even if it was necessary (it's not, as motivated above), there would be nothing to put there on the LoRaWAN stack side. However, they usually do have an IP for forwarding packets from the LoRaWAN side to a server. This is reflected in the simulation, as they can have a second NetDevice (CSMA for instance) which can store their address and have an implemented version of the callback you mention.

@non-det-alle non-det-alle self-assigned this Feb 9, 2024
@chekraF
Copy link
Author

chekraF commented Feb 9, 2024

The SetReceiveCallback( ...) is already called in the network-server-helper, then at gateway-lorawan-mac-level in GatewayLorawanMac::Receive the Receive( ) function in net-device is called where we find the callback! All these implementation already exist and I didn't modify it ...however it still stopping at lora-net-device. level exactly at m_receiveCallback to generate msg="Attempted to dereference zero pointer error!

@non-det-alle
Copy link
Collaborator

non-det-alle commented Feb 11, 2024

Are you sure the callback in GatewayLorawanMac::Receive is the one giving you problems? Gateways' callbacks are set in forwarder-helper, not in network-server-helper. The callback that gives you problems may be the one set on the gateway's PointToPointNetDevice.

I think I understand where your error is coming from. In your example main file, make sure that NetworkServerHelper::Install is called before ForwarderHelper::Install. This is because the NetworkServerHelper installs a P2P NetDevice on the gateways, which is then needed by ForwarderHelper to set a receive callback for messages going from the server to the gateway through the P2P link. If this condition is not respected, the ForwarderHelper will skip installing the callback and thus your runtime error message.

Ideally this should give a better error message during installation that explains the issue. This is a known problem of the module, and it is already scheduled to be fixed in upcoming releases. Sorry for the inconvenience.

@chekraF
Copy link
Author

chekraF commented Feb 12, 2024

Exactly! Thank you so much for the clarification!! Your indication has resolved the problem! I kindly ask you to keep this kind of remarks in a short tuto with the installation setup! it would be very useful! I was dealing with this error for a whole week!
Thank you again for the instructions.

non-det-alle added a commit that referenced this issue Mar 20, 2024
* Expose p2p connection of gateways to server (#150)

* Expose gw registration to simplify NetworkServerHelper::Install
+ remove NodeContainer install of NetworkServerHelper
+ add P2PGwRegistration_t helper structure to facilitate independent instantiation of P2P and server app

* Directly pass P2PGwRegistration_t to NetworkServerHelper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants