I went ahead and refactored the file, let me know if I am at least on the
right track if you guys can, thanks!!
/**
* Header file for the AFDX Protocol under TinyOS
*
* @Author Paimon Sorornejad, 2/9/2011
* @Version 1.0.0
*/
/////////////////////////////////////////////
//// PRE
//// total size: 8 bytes (64 bits)
/////////////////////////////////////////////
typedef nx_struct preamble{
uint64_t value; // 7bit preamble
// 1bit start
} preamble;
////////////////////////////////////////////
//// MAC
//// macDest size: 48 bits
//// macSource size: 48 bits
//// total size: 14 bytes (112 bits)
////////////////////////////////////////////
typedef nx_struct macDest{
static const uint32_t start = 0x03000000;
uint16_t VLI;
} macDest;
typedef nx_struct macSource{
static const uint16_t constField = 0x0200;
static const uint8_t networkStart = 0x00;
uint8_t networkId;
uint8_t equipmentId;
uint8_t interfaceId;
} macSource;
typedef nx_struct macHeader{
macDest dest;
macSource source;
uint16_t type;
} macHeader;
////////////////////////////////////////////
//// IP
//// ipSource size: 32 bits
//// ipDestination size: 32 bits
//// total/ipHeader size: 20 bytes (160 bits)
////////////////////////////////////////////
typedef nx_struct ipSource{
static const uint8_t = 00001010;
uint8_t networkid;
uint8_t equipmentid;
uint8_t partitionid;
} ipSource;
typedef nx_struct ipDestination{
uint16_t start = 0xE0C0;
uint16_t int VLI;
} ipDestination;
typedef nx_struct ipHeader{
uint8_t ip_version;
uint8_t ip_tos;
uint16_t ip_len;
uint16_t ip_id;
uint16_t ip_off;
uint8_t ip_ttl;
uint8_t ip_proto;
uint16_t ip_sum;
ipSource ip_src;
ipDestination ip_dst;
} ipheader;
/////////////////////////////////////////////
//// UDP
//// total size: 8 bytes (64 bits)
/////////////////////////////////////////////
typedef nx_struct udpHeader{
uint16_t source;
uint16_t dest;
uint16_t udplen;
uint16_t udpchk;
} udpHeader;
/////////////////////////////////////////////
//// FULL PACKET
//// AFDXHeader size: 50 bytes
//// AFDXFooter size: 5 bytes
//// total size:
/////////////////////////////////////////////
typedef nx_struct AFDXHeader {
preamble pre;
macHeader mac;
ipHeader ip;
udpHeader udp;
} AFDXHeader;
typedef nx_struct AFDXFooter {
uint8_t sequence;
uint32_t fcs;
} AFDXFooter;
typedef nx_struct AFDXPacket {
AFDXHeader header;
uint8_t data[TOSH_DATA_LENGTH];
AFDXFooter footer;
} AFDXPacket;
Paimon Sorornejad
Email: [email protected] | Cell: 781-205-9876
On Thu, Feb 10, 2011 at 12:45 PM, Paimon Sorornejad
<[email protected]>wrote:
> I actually saw this document out on the help pages. I unfortunately don't
> have access to it here at work, but I will take a look at it when I get
> home. I suppose it will show exactly how they take their structure and
> prepare it for transmission. If anyone else has any tips, please let me
> know.
>
> http://www.tinyos.net/tinyos-2.x/doc/html/tep123.html
> <http://www.tinyos.net/tinyos-2.x/doc/html/tep123.html>
> Paimon Sorornejad
> Email: [email protected] | Cell: 781-205-9876
>
>
> On Wed, Feb 9, 2011 at 10:18 PM, Paimon Sorornejad <[email protected]
> > wrote:
>
>> Hello;
>>
>> As part of my work with TinyOS and a TelosB board, I am looking to
>> implement the AFDX protocol (mainly used in aviation communications). I
>> have defined and structured the packet and was hoping I could get some
>> possible pointers or tips. I haven't really got down to coding the actual
>> TinyOS application or implementation yet, but I have started with my
>> AFDXProtocol.h file which will define the various structures embedded in my
>> packet. I was wondering if someone could take a look at my "AFDXMessage"
>> struct and let me know if I am on the right track. Also, my question is
>> exactly how a packet like this would be transferred. Would the AFDXMessage
>> struct be cast as a message_t as a whole, or will we only be transmitting
>> the data payload? Thanks for the help guys.
>>
>> /**
>> * Header file for the AFDX Protocol under TinyOS
>> *
>> * @Author Paimon Sorornejad, 2/9/2011
>> * @Version 1.0.0
>> */
>>
>> typedef nx_struct preamble{
>> uint8_t value; // 7 preamble + 1 version
>> } preamble;
>>
>> typedef nx_struct macDest{
>> static const uint32_t start = 0x03000000;
>> uint16_t VLI;
>> } macDest;
>>
>> typedef nx_struct macSource{
>> static const uint16_t constField = 0x0200;
>> static const uint8_t networkStart = 0x00;
>> uint8_t networkId;
>> uint8_t equipmentId;
>> uint8_t interfaceId;
>> } macSource;
>>
>> typedef nx_struct macHeader{
>> macDest dest;
>> macSource source;
>> } macHeader;
>>
>> typedef nx_struct ipSource{
>> static const uint8_t = 00001010;
>> uint8_t networkid;
>> uint8_t equipmentid;
>> uint8_t partitionid;
>> } ipSource;
>>
>> typedef nx_struct ipDestination{
>> uint16_t start = 0xE0C0;
>> uint16_t int VLI;
>> } ipDestination;
>>
>> typedef nx_struct ipHeader{
>> uint8_t ip_version;
>> uint8_t ip_tos;
>> uint16_t ip_len;
>> uint16_t ip_id;
>> uint16_t ip_off;
>> uint8_t ip_ttl;
>> uint8_t ip_proto;
>> uint16_t ip_sum;
>> ipSource ip_src;
>> ipDestination ip_dst;
>> } ipheader;
>>
>> typedef nx_struct udpHeader{
>> uint16_t source;
>> uint16_t dest;
>> uint16_t udplen;
>> uint16_t udpchk;
>> } udpHeader;
>>
>> typedef nx_struct sequence{
>> uint8_t value; // 8 bit (1byte)
>> } sequence;
>>
>> typedef nx_struct fcs{
>> uint32_t value; // 32 bit (4byte)
>> } fcs;
>>
>> typedef nx_struct AFDXMessage {
>> preamble pre;
>> macHeader mac;
>> ipHeader ip;
>> udpHeader udp;
>> uint8_t data[TOSH_DATA_LENGTH]
>> sequence seq;
>> fcs fc;
>> } AFDXMessage;
>>
>>
>> Paimon Sorornejad
>> Email: [email protected] | Cell: 781-205-9876
>>
>
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help