org-arl / unet-contrib

Unet user contributions
BSD 3-Clause "New" or "Revised" License
11 stars 15 forks source link

Sending a Datagram on ReliableLink without setting Reliability to true causes the DatagramNtf to not be generated in Unet3 #18

Closed shortstheory closed 5 years ago

shortstheory commented 5 years ago

My agent:

class DummyAgent extends UnetAgent {
    void startup() {

        def link = agentForService Services.LINK
        def phy = agentForService Services.PHYSICAL
        subscribe link
        subscribe phy
    }
    Message processRequest(Message msg) {
        return msg
    }

    void processMessage(Message msg) {
      if (msg instanceof RxFrameNtf) {
        println "Received RFN"
      } else if (msg instanceof DatagramNtf) {
        println "Received DNtf"
      }
    }
}

My simulation script:

simulate  {
  node '1', address: 1, location: [0, 0, 0], shell: true, stack: { container ->
    container.add 'da', new DummyAgent()
    container.add 'link', new ReliableLink()
    container.add 'router', new org.arl.unet.net.Router()
  }
  node '3', address: 3, location: [1*1000.m, 0, 0], shell: 5000, stack: { container ->
    container.add 'da', new DummyAgent()
    container.add 'link', new ReliableLink()
    container.add 'router', new Router()
  }
}

If I type link << new org.arl.unet.DatagramReq(to: 3, reliability: true) on the shell, I get the following output on the log:

1551100259643|INFO|DummyAgent@28:println|Received RFN
1551100259670|INFO|DummyAgent@28:println|Receiveid DNtf

However, on link << new org.arl.unet.DatagramReq(to: 3), I only get:

1551100830138|INFO|DummyAgent@20:println|Received RFN

No notification is received for the DatagramNtf. This also occurs when I send link << new org.arl.unet.DatagramReq(to: 3, reliability: false). However, in Unet 1.4, I get both the RFN and DNtf notifications even when reliability is unset/set to false.

shortstheory commented 5 years ago

Unet 3 short-circuits by not including the RL headers when Reliability is not required. This causes the RxFrameNtf to be generated without the DatagramNtf in such cases. Hence, this issue is not a bug, but expected behaviour.