3

I am using Unetstack software along with Unetpy. I wish to retrieve transmit and recieve notifications when I run .py file which imports Unetpy python library. I followed this tutorial

I am successfully able to connect to the localhost and print values like phy.MTU and so on. When I transmit a packet I also receive a reply saying AGREE on the command prompt.output_of_my_script enter image description here my_script

enter image description here Can you please help me in receiving Txframentf and rxframentf along with data payload.

I have made changes posted in bug reports suggested in this linkeven. Please guide me on how to print notifications for rxframe and txframe. Thank you``

Mr. Roshan
  • 1,777
  • 13
  • 33

2 Answers2

4

Your script is fine until the last line:

print(phy << org_arl_unet_phy.TxFrameNtf())

Here you are trying to send a TxFrameNtf to the physical agent. This does not make sense, as it is the physical agent who sends you such a notification when a transmission is completed.

By the time you reach this line, you should have already received the notification as txntf as long as the transmission was completed within 5 seconds (timeout=5000). To print out the notification, all you need to do is:

print(txntf)

I just tested this against the 3-node-network.groovy sample. I am using unetpy-1.3b5 and fjagepy-1.4.2b3. Here's the modified code:

from unetpy import *
modem = UnetGateway('localhost', 1102)
phy = modem.agentForService(Services.PHYSICAL)
print(phy.MTU)
print(phy.basebandRate)
print(phy << org_arl_unet_phy.TxFrameReq(to=3, data=[1,2,3,4]))
txntf = modem.receive(timeout=5000)
print(txntf)

and the output:

16
4096
AGREE
TxFrameNtf:INFORM[type:1]

You can see that the TxFrameNtf is correctly received.

For reception, you need to subscribe to the agent's notifications and then receive a frame:

modem.subscribe(phy)
rxntf = modem.receive(org_arl_unet_phy.RxFrameNtf, timeout=5000)
print(rxntf)

Assuming you receive a frame within the 5 second timeout specified (in this example, on node 3), this should print out something like:

RxFrameNtf:INFORM[type:CONTROL from:1 to:3 protocol:0 rxTime:34587658 (4 bytes)]
Mandar Chitre
  • 2,110
  • 6
  • 14
  • can you share the link where i can download a unetpy version which has a unetpy version updated with all these bugs? Also please share with me the syntax to print RxFrameNtf and the Ntf.data values on the other node which has received these packets. – Madhuri Madhav Jun 24 '18 at 11:54
  • print(phy << org_arl_unet_phy.RxFrameNtf(type = Physical.CONTROL)) I tried with this code to test for RxFrameNtf, I have been getting none all the time. Also with print(phy< NOT UNDERSTOOD kindly help me – Madhuri Madhav Jun 24 '18 at 12:21
  • The latest `unetpy` version (1.3b5) is released and available via pip. I've edited the response above to show what you get in this version, and to add an example for `RxFrameNtf`. Essentially `RxFrameNtf` is sent by the physical agent and you simply receive it (don't send it using `<<`). For `RangeReq`, you should be sending it to the ranging agent (which you can find using `modem.agentForService(Services.RANGING)`). – Mandar Chitre Jun 26 '18 at 02:08
1

You sent a datagram through some agent that supports the DATAGRAM service. There may be many agents that support this service (not just the physical layer). In any case, that datagram would be received on a different node, and so you wouldn't expect to receive DatagramNtf on the transmitting node.

The RangeReq should yield a RangeNtf if successful, but that might take more than the default receive timeout of 1 second, depending on how far node 2 is. So you might want to try a longer receive timeout to see if you get your notification.

To access the data from payload from the rxntf, you can try print(rxntf.data).

Mandar Chitre
  • 2,110
  • 6
  • 14