00001 /* 00002 Copyright (c) 1997, 1998 Carnegie Mellon University. All Rights 00003 Reserved. 00004 00005 Redistribution and use in source and binary forms, with or without 00006 modification, are permitted provided that the following conditions are met: 00007 00008 1. Redistributions of source code must retain the above copyright notice, 00009 this list of conditions and the following disclaimer. 00010 2. Redistributions in binary form must reproduce the above copyright notice, 00011 this list of conditions and the following disclaimer in the documentation 00012 and/or other materials provided with the distribution. 00013 3. The name of the author may not be used to endorse or promote products 00014 derived from this software without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00017 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00018 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00019 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00020 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00021 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00022 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00023 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00024 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00025 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 00027 The AODV code developed by the CMU/MONARCH group was optimized and tuned by Samir Das and Mahesh Marina, University of Cincinnati. The work was partially done in Sun Microsystems. 00028 */ 00029 00036 #ifndef _MRCL_AODV_PKT_ 00037 #define _MRCL_AODV_PKT_ 00038 00039 #include <mrcl-address.h> 00040 00041 /* ===================================================================== 00042 Packet Formats... 00043 ===================================================================== */ 00044 #define AODVTYPE_HELLO 0x01 00045 #define AODVTYPE_RREQ 0x02 00046 #define AODVTYPE_RREP 0x04 00047 #define AODVTYPE_RERR 0x08 00048 #define AODVTYPE_RREP_ACK 0x10 00049 00050 /* 00051 * AODV Routing Protocol Header Macros 00052 */ 00053 #define HDR_MRCL_AODV(p) ((struct hdr_mrcl_aodv*)hdr_mrcl_aodv::access(p)) 00054 #define HDR_MRCL_AODV_REQUEST(p) ((struct hdr_mrcl_aodv_request*)hdr_mrcl_aodv::access(p)) 00055 #define HDR_MRCL_AODV_REPLY(p) ((struct hdr_mrcl_aodv_reply*)hdr_mrcl_aodv::access(p)) 00056 #define HDR_MRCL_AODV_ERROR(p) ((struct hdr_mrcl_aodv_error*)hdr_mrcl_aodv::access(p)) 00057 #define HDR_MRCL_AODV_RREP_ACK(p) ((struct hdr_mrcl_aodv_rrep_ack*)hdr_mrcl_aodv::access(p)) 00058 00059 00060 /* 00061 * AODV Header 00062 */ 00063 00064 #define AODV_MAX_ERRORS 20 00065 #define AODV_MAX_DST_ERRORS (AODV_MAX_ERRORS * MRCL_ADDRESS_MAX_LEN) 00066 00067 #define AODV_MAX_PKT_LENGTH (AODV_MAX_DST_ERRORS+AODV_MAX_ERRORS*4+10) 00068 00069 struct hdr_mrcl_aodv { 00070 char ah_type; 00071 // char body[AODV_MAX_PKT_LENGTH]; 00072 // Header access methods 00073 static int offset_; // required by PacketHeaderManager 00074 inline static int& offset() { return offset_; } 00075 inline static hdr_mrcl_aodv* access(const Packet* p) { 00076 return (hdr_mrcl_aodv*) p->access(offset_); 00077 } 00078 }; 00079 00080 struct hdr_mrcl_aodv_request { 00081 char rq_type; // Packet Type 00082 char reserved[2]; 00083 char rq_hop_count; // Hop Count 00084 int rq_bcast_id; // Broadcast ID 00085 00086 char rq_dst[MRCL_ADDRESS_MAX_LEN]; // Destination Address 00087 int rq_dst_seqno; // Destination Sequence Number 00088 char rq_src[MRCL_ADDRESS_MAX_LEN]; // Source Address 00089 int rq_src_seqno; // Source Sequence Number 00090 00091 double rq_timestamp; // when REQUEST sent; 00092 // used to compute route discovery latency 00093 00094 inline int size() { 00095 return (3*sizeof(char)+3*sizeof(int)+sizeof(double)+*((int *)rq_dst)+*((int *)rq_src)); 00096 } 00097 }; 00098 00099 struct hdr_mrcl_aodv_reply { 00100 char rp_type; // Packet Type 00101 char reserved[2]; 00102 char rp_hop_count; // Hop Count 00103 char rp_dst[MRCL_ADDRESS_MAX_LEN]; // Destination IP Address 00104 int rp_dst_seqno; // Destination Sequence Number 00105 char rp_src[MRCL_ADDRESS_MAX_LEN]; // Source IP Address 00106 double rp_lifetime; // Lifetime 00107 00108 double rp_timestamp; // when corresponding REQ sent; 00109 // used to compute route discovery latency 00110 00111 inline int size() { 00112 return (3*sizeof(char)+sizeof(int)+2*sizeof(double)+*((int *)rp_dst)+*((int *)rp_src)); 00113 } 00114 00115 }; 00116 00117 struct hdr_mrcl_aodv_error { 00118 char re_type; // Type 00119 char reserved[2]; // Reserved 00120 char DestCount; // DestCount 00121 // List of Unreachable destination IP addresses and sequence numbers 00122 char unreachable_dst[AODV_MAX_DST_ERRORS]; 00123 int unreachable_dst_seqno[AODV_MAX_ERRORS]; 00124 00125 inline int size() { 00126 int sz = DestCount*2*(*((int *)unreachable_dst)) + sizeof(int); 00127 assert(sz > 0); 00128 return sz; 00129 } 00130 00131 }; 00132 00133 struct hdr_mrcl_aodv_rrep_ack { 00134 char rpack_type; 00135 char reserved; 00136 }; 00137 00138 // for size calculation of header-space reservation 00139 union hdr_all_mrcl_aodv { 00140 hdr_mrcl_aodv ah; 00141 hdr_mrcl_aodv_request rreq; 00142 hdr_mrcl_aodv_reply rrep; 00143 hdr_mrcl_aodv_error rerr; 00144 hdr_mrcl_aodv_rrep_ack rrep_ack; 00145 }; 00146 00147 00148 #endif 00149