How to use serial forwarder on testbed
How to use the serial forwarder on testbed?
1. To open the serial forwarder on testbed, run the command
forwarder.py -2 -a telosb
2. We can get the packet format used by the serial forwarder in tospacket.py:
byte 0: Delimiter (0x7E)
byte 1: Protocol: ACK (0x43), PACKET_ACK (0x44) or PACKET_NOACK (0x45)
byte 2: Sequence number (omitted if protocol is PACKET_NOACK)
byte 3: Packet type (0x00, omitted if protocol is ACK)
byte 4: Destination high byte (omitted if protocol is ACK)
byte 5: Destination low byte (omitted if protocol is ACK)
byte 6: Source high byte (omitted if protocol is ACK)
byte 7: Source low byte (omitted if protocol is ACK)
byte 8: Payload length (omitted if protocol is ACK)
byte 9: Destination PAN group (omitted if protocol is ACK)
byte 10: Packet AM type (omitted if protocol is ACK)
byte 11 .. n-4: Payload (omitted if protocol is ACK)
byte n-3: CRC-16 low byte
byte n-2: CRC-16 high byte
byte n-1: Delimiter (0x7E)
3. In tinyos standard, the delimiter character is 0x7E, the escape character is 0x7D
4. But we don't need the whole Tos packet as above to use the serial forwarder, the serial forwarder will do a lot of things for us.
5. what we don't need to send to the serial forwarder:
byte 0 and byte n-1: Delimiter(added by serial forwarder server)
byte 1 : Protocol Type(this byte should be given by the serial forwarder server)
byte 2 : Sequence Number(this byte should be given by the serial forwarder server)
byte n-2 and n-3 : the two-byte-CRC is calculated by the serial forwarder
6. Next we will name the packet we sent to the serial forwarder server as local packet, and the packet sent by serial forwarder server to the mote as forward packet
7. The process of using the serial forwarder
7.1 First create a socket, and connect the socket to the server at port 9002