2

I have two nodes. Address 40 is transmitting a frame to address 10. When I use TxFrameNtf I get that transmission is successful. But node 10 is dropping the frame it seems from trace.nam it seems. I can not figure out why. Here are the Agents that I am using for each node: Node 40:

import org.arl.fjage.Message
import org.arl.unet.*
import org.arl.fjage.*
import org.arl.unet.PDU
import java.util.*
import org.arl.unet.phy.*
import static org.arl.unet.utils.MathUtils.*


class VBF_Agent extends UnetAgent {

  private AgentID phy
  final static int cluster_protocol = Protocol.USER
  private AgentID node
  public int addr

  private final static PDU format = PDU.withFormat
    {
        uint8('source')
        uint16('data')
    }


  void startup() {
      phy = agentForService Services.PHYSICAL    //to communicate between two nodes
      subscribe topic(phy)
      def node = agentForService(Services.NODE_INFO)
      addr = node.Address
      phy[1].powerLevel = 0.dB;

      def datapacket = format.encode(source: addr, data: 51)

    if(addr==40)
      { 
        println "Sending data from source"
        phy << new TxFrameReq(to: Address.BROADCAST, protocol: cluster_protocol, data: datapacket)
      }
  }

  void processMessage(Message msg) {
}

Node 10:

import org.arl.fjage.Message
import org.arl.unet.*
import org.arl.fjage.*
import org.arl.unet.PDU
import java.util.*
import org.arl.unet.phy.*
import static org.arl.unet.utils.MathUtils.*

class VBF_hop extends UnetAgent {

  private AgentID phy
  final static int cluster_protocol = Protocol.USER
  private AgentID node
  public int addr

  void startup() {  
      phy = agentForService Services.PHYSICAL    //to communicate between two nodes
      subscribe topic(phy)
      def node = agentForService(Services.NODE_INFO)
      addr = node.Address
      phy[1].powerLevel = 0.dB
  }

  void processMessage(Message msg) {
    if (msg instanceof RxFrameNtf && msg.protocol == cluster_protocol )      //notfication recieved
      { 
        println "${msg.data} at node ${addr}"
      } 
 } 
}

I don't see the message printed on the screen that data has been received and trace.nam shows that packet was not detected. I have set the transmission power to infinity as you can see.

Instead of TxFrameReq, I used DatagramReq then the data is received by node 10. Is the issue because of improper use of syntax? I am very new to UnetStack and groovy, so I might have missed such problems. Thank you in advance.

notthetup
  • 1,129
  • 9
  • 17
Akriti Anand
  • 166
  • 3
  • 17

1 Answers1

1

Since you have not posted the simulation DSL script, I cannot see what the simulation setup (locations of nodes 10 and 40, channel parameters, etc) are. But your agent codes seem OK (other than the processMessage() on node 40 being incomplete). Do note that, in contrast to your description, you're broadcasting a frame from node 40 and not sending it to node 10. Also, your transmission power is not infinity, but the maximum that the modem supports (0 dB wrt the maximum). But I agree that node 10 should receive the broadcast, as you expect.

There are a few reasons why a frame may be dropped:

  • The range between nodes 10 and 40 is larger than the detection/communication range defined for the channel.
  • The detection probability for the channel may be too low, or the error probability too high.
  • There is a collision, if more than one nodes' transmission overlap at the receiver.

I'd suggest trying with a ProtocolChannelModel, using something like this in the simulation script: ``` import org.arl.unet.sim.channels.*

channel.model = ProtocolChannelModel
channel.communicationRange = 2000.m
channel.detectionRange = 2500.m
channel.interferenceRange = 3000.m
channel.pDetection = 1
channel.pDecoding = 1

``` and ensuring that the distance between nodes 10 and 40 is less than the communicationRange. Do note that the detectionRange and interferenceRange should be more than the communicationRange.

The DatagramReq maps to a TxFrameReq at the physical layer, but automatically selects a frame type (DATA or CONTROL, depending on the version of UnetStack you are using). By setting phy[1].powerLevel, you are only setting the power level for CONTROL channel, so your TxFrameReq would be better off sent with type CONTROL.

If you still have trouble getting this to work, please post excerpts from your simulation script and trace.nam in order to help debug.

Mandar Chitre
  • 2,110
  • 6
  • 14