Hi All,

I am having an issue at the moment regarding packet injection in TOSSIM
using Tymo protocol.

I am using tutorials found at:
http://docs.tinyos.net/index.php/TOSSIM

and using the test code supplied in $TOSROOT/apps/tests/TestTymo

When using the AM components I am able to Inject packets into the network.
Below shows TestAppC.nc, TestC.nc, Test.h, test.py and output.
(Apologies for all the code, I felt it was the easiest way to show the
problem. I hope it is clear)

*****************TestAppC.nc********************************
configuration TestAppC {}

implementation {
  components MainC, TestC as App;
  components new AMReceiverC(AM_MULTIHOP_INJECTION_MSG);
  components ActiveMessageC;

  App.Boot -> MainC.Boot;

  App.Receive -> AMReceiverC;
  App.AMControl -> ActiveMessageC;
  App.Packet -> AMReceiverC;
  App.AMPacket -> AMReceiverC;
}

****************TestC.nc************************************
#include "Test.h"

module TestC{
uses {
    interface Boot;
    interface Receive;
    interface SplitControl as AMControl;
    interface Packet;
    interface AMPacket;
  }
}
implementation {

  event void Boot.booted() {
    call AMControl.start();
    dbg("Boot", "App Booted - Great. \n");
  }

  event void AMControl.startDone(error_t err) {
    if (err == SUCCESS) {
    }
    else {
      call AMControl.start();
    }
  }

  event void AMControl.stopDone(error_t err) {
    // do nothing
  }

  event message_t* Receive.receive(message_t* msg, void* payload, uint8_t
len) {
    dbg("message", "Message: Received Packet of length %hhu.\n", len);
    dbg("message", "Message: My Address is: %hu.\n", call
AMPacket.address());
    if(call AMPacket.address() == call AMPacket.destination(msg)){
       multihop_injection_msg_t* contents =
(multihop_injection_msg_t*)payload;
       dbg("message", "Message: Message Received from %u\n", call
AMPacket.source(msg));
       dbg("message", "Message: Message Contents: %hu.\n",
contents->payload);
    }
  }
}
*******************************Test.h******************************
#ifndef TEST_H
#define TEST_H

typedef nx_struct multihop_injection_msg {
  nx_uint16_t payload;
} multihop_injection_msg_t;

enum {
  AM_MULTIHOP_INJECTION_MSG = 1,
};

#endif

*******************************test.py*****************************
from TOSSIM import *
from MultihopInjectionMsg import *
import sys
import time

t = Tossim([])
r = t.radio()
f = open("topo.txt", "r")
n = 0
.
.
.
.
t.getNode(1).bootAtTime(100001);
t.getNode(2).bootAtTime(200022);
t.getNode(3).bootAtTime(300033);

#Injecting packet to node 3

msg = MultihopInjectionMsg()
msg.set_payload(99);
pkt = t.newPacket();
pkt.setData(msg.data);
pkt.setType(msg.get_amType())
pkt.setDestination(3)

print "AMPacket Type: ", pkt.type();
print "Delivering ", msg, " to node 3 at ", (t.time() + 4000044);
pkt.deliver(3, t.time() + 4000444)

t.runNextEvent();
time = t.time()
while (time + 5000000000 > t.time()):
  print t.time()
  t.runNextEvent()

sys.stderr.write("Finished!\n")
********************************output**********************************8
Creating noise model for  1
Creating noise model for  2
Creating noise model for  3
AMPacket Type:  1
Delivering  Message <MultihopInjectionMsg>
  [payload=0x63]
  to node 3 at  4000044
DEBUG (1): App Booted - Great.
100001
100101
100201
DEBUG (2): App Booted - Great.
200022
200122
200222
DEBUG (3): App Booted - Great.
300033
300133
300233
DEBUG (3): Message: Received Packet of length 2.
DEBUG (3): Message: My Address is: 3.
DEBUG (3): Message: Message Received from 0
DEBUG (3): Message: Message Contents: 99.
4000444
2246193751
2246293772
2246393783
.
.
.
.
Finished!
************************************************************

This is fine, I receive the injected packet correctly.
The Issue occurs when I try to use the tymo components when receiving a
packet.
If I change the wirings in TestAppC.nc and leave the rest unchanged I do not
receive the injected packet

************************TestAppC.nc**************************
configuration TestAppC {}

implementation {
  components MainC, TestC as App, DymoNetworkC;

  App.Boot -> MainC.Boot;

  App.AMControl -> DymoNetworkC;
  App.Packet       -> DymoNetworkC;
  App.AMPacket     -> DymoNetworkC;
  App.Receive      -> DymoNetworkC.Receive[1];
}
***********************output*********************************
Creating noise model for  1
Creating noise model for  2
Creating noise model for  3
AMPacket Type:  1
Delivering  Message <MultihopInjectionMsg>
  [payload=0x63]
  to node 3 at  4000044
DEBUG (1): App Booted - Great.
100001
100101
100201
100301
DEBUG (2): App Booted - Great.
200022
200122
200222
200322
DEBUG (3): App Booted - Great.
300033
300133
300233
300333
4000444
2246193751
2246293772
2246393783
.
.
.
Finished!
******************************************************************
Packet was not received by the node.
I am unsure why I am experiencing this problem. I thought it might have been
a packet type conflict but I think from:
App.Receive      -> DymoNetworkC.Receive[1];
The Receive interface is expecting am packet type 1, and I am injecting a
packet with am packet type 1.

Can anyone shed any light as to why this problem occurs. Im pretty sure Ive
confused something but Im not sure what the problem is.

Thanks,

Dec
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to