3

I am developing an energy based routing protocol in which a node has to know its available neighbours, so that it can get the energy details of the neighbour nodes and decide its next hop.

a) How to find available neighbours for a node?

b) Among the use of PDU and RemoteGetParamReq, which method suits well to retrieve energy of neighbour nodes?

Bonifacio2
  • 3,405
  • 6
  • 34
  • 54

1 Answers1

1

a) If you are writing your own agent, you could send a broadcast frame to query neighbors, and have your agent on the neighbors respond to the frame with a random backoff (to avoid MAC collisions). An alternative hack could be to use the RouteDisoveryReq (see https://unetstack.net/svc-31-rdp.html) with the to address set to a non-existent node. This will cause all 1-hop neighbors to re-broadcast your route discovery request, and you will get RouteDiscoveryNtf for each of those neighbors.

Example script demonstrating the hack (rdpdemo.groovy):

// settings
attempts = 1      // try only a single attempt at discovery
phantom = 132     // non-existent node address
timeout = 10000   // 10 second timeout

println 'Starting discovery...'
n = []                        // collect list of neighbors
rdp << new RouteDiscoveryReq(to: phantom, count: attempts)
while (ntf = receive(RouteDiscoveryNtf, timeout)) {
  println("  Discovered neighbor: ${ntf.nextHop}")
  n << ntf.nextHop            // add neighbor to list
}
n = n.unique()                // remove duplicates
println("Neighbors: ${n}")

Example run (simulation samples/rt/3-node-network.groovy on node 3):

> rdpdemo
Starting discovery...
  Discovered neighbor: 1
  Discovered neighbor: 2
Neighbors: [1, 2]
>

b) The answer to this depends on how you expose your energy information. If you expose it as a parameter, you can use the RemoteGetParamReq to get it. But if you are already implementing some protocol in your agent, it is easy enough to have a specific PDU to convey the information.

Mandar Chitre
  • 2,110
  • 6
  • 14
  • Sir I used `RouteDiscoveryReq` to know 1-hop neighbors for a node, but here in order to receive multiple RouteDiscoveryNtf coming from multiple neighbors I am using receive() method in a for loop and trying to store nextHop value in an array using `getNextHop()` which is giving error. How can I store nextHop values in array? because, further I am trying to use `RemoteGetParamReq` to fetch remaining energy, which is exposed as parameter of PHY agent. Also both RouteDiscoveryReq and RemoteGetParamReq consumes energy in querying details. **Please suggest me an better approach with example code** – AKHILRAJ V GADAGKAR Jul 19 '19 at 09:05
  • I have updated the answer above to include code example of how to use `RouteDiscoveryReq` to find neighbors. You are right that the route discovery and parameter get themselves will consume energy and should be sparingly used in a energy-sensitive application. You could consider "snooping" on neighbors to hear their transmissions and estimate their energies if you can't afford the energy consumed in asking them. You could also collect neighbor information that way, except neighbors who happen to be quiet. – Mandar Chitre Jul 20 '19 at 06:17
  • Thank you sir. your code worked for knowing neighbors, further I tried using `RemoteGetParamReq` to fetch energy of node 2 which is neighbor of node 1 but I am not getting it, as request returns `FAILURE`. I have exposed energy parameter with `phy` agent from my extended modem file (`MyHalfDuplexModem.groovy`) where I have added my energy modelling, and in that, I have also defined `getParameterList()` method ,which returns all enumerations required for `HalfDuplexModem` plus my customized modem. I think the `get()` method is unable to locate the file where I have defined my enumeration. – AKHILRAJ V GADAGKAR Jul 23 '19 at 06:26
  • Your Groovy or class files must be in the class path. Usually a `classes` folder in the UnetSim root folder is in the class path, and so consider putting your class/Groovy files there. – Mandar Chitre Jul 26 '19 at 05:13