00001 /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ 00002 /* 00003 * Copyright (c) 1997 Regents of the University of California. 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 1. Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * 3. All advertising materials mentioning features or use of this software 00015 * must display the following acknowledgement: 00016 * This product includes software developed by the Computer Systems 00017 * Engineering Group at Lawrence Berkeley Laboratory. 00018 * 4. Neither the name of the University nor of the Laboratory may be used 00019 * to endorse or promote products derived from this software without 00020 * specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00023 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00025 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00028 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00029 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00031 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00032 * SUCH DAMAGE. 00033 * 00034 * Ported from CMU/Monarch's code 00035 * 00036 * $Header: /nfs/jade/vint/CVSROOT/ns-2/imep/imep_spec.h,v 1.3 2000/09/01 03:04:10 haoboy Exp $ 00037 */ 00038 00039 #ifndef __imep_spec_h__ 00040 #define __imep_spec_h__ 00041 00042 #include <sys/types.h> 00043 00044 // ********************************************************************** 00045 #ifdef COMMENT_ONLY 00046 00047 The Internet MANET Encapsulation Protocol (IMEP) consists of five 00048 different mechanisms: 00049 Link/Connection Status Sensing 00050 Control Message Aggregation 00051 Broadcast Reliability 00052 Network-layer Address Resolution 00053 Security Authentication 00054 00055 04AUG98 - jgb - For now, I am going to implement the first three mechanisms 00056 as the last two are not really necessary for the present 00057 simulation work. 00058 00059 #endif /* COMMENT_ONLY */ 00060 00061 00062 // ********************************************************************** 00063 // Link/Connection Status Sensing 00064 00065 00066 // IMEP may be configured to run in the following "connection 00067 // notification" modes. 00068 #define MODE_BIDIRECTIONAL 0x01 00069 #define MODE_UNIDIRECTIONAL 0x02 00070 00071 // Link status 00072 #define LINK_DOWN 0x00 00073 #define LINK_IN 0x01 00074 #define LINK_OUT 0x02 00075 #define LINK_BI (LINK_IN | LINK_OUT) 00076 00077 // XXX - The values for these constants are not specified by the IMEP draft. 00078 #define BEACON_PERIOD 1.0 // seconds 00079 #define BEACON_JITTER 0.010 // seconds 00080 #define MAX_BEACON_TIME (BEACON_PERIOD * 3) 00081 00082 // ********************************************************************** 00083 // Control Message Aggregation 00084 00085 // XXX - The values for these constants are not specified by the IMEP draft. 00086 #define MAX_TRANSMIT_WAIT_TIME_LOWP 0.250 // seconds 00087 #define MIN_TRANSMIT_WAIT_TIME_LOWP 0.150 00088 #define MAX_TRANSMIT_WAIT_TIME_HIGHP 0.010 // seconds 00089 #define MIN_TRANSMIT_WAIT_TIME_HIGHP 0.000 00090 00091 // ********************************************************************** 00092 // Broadcast Reliability 00093 #define RETRANS_PERIOD 0.500 // seconds 00094 #define MAX_REXMITS 2 00095 #define MAX_RETRANS_TIME (RETRANS_PERIOD * (MAX_REXMITS + 1)) 00096 00097 00098 // ********************************************************************** 00099 // Protocol Message Format 00100 00101 struct hdr_imep { 00102 u_int8_t imep_version : 4; 00103 u_int8_t imep_block_flags : 4; 00104 u_int16_t imep_length; 00105 00106 // Header access methods 00107 static int offset_; // required by PacketHeaderManager 00108 inline static int& offset() { return offset_; } 00109 inline static hdr_imep* access(const Packet* p) { 00110 return (hdr_imep*) p->access(offset_); 00111 } 00112 }; 00113 00114 /* hdr_imep actually takes 4 bytes, not 3, b/c we aren't packing the 00115 two bitfields into 1 byte */ 00116 00117 #define IMEP_VERSION_0 0x00 00118 #define IMEP_VERSION IMEP_VERSION_0 00119 #define BLOCK_FLAG_ACK 0x08 00120 #define BLOCK_FLAG_HELLO 0x04 00121 #define BLOCK_FLAG_OBJECT 0x02 00122 #define BLOCK_FLAG_UNUSED 0x01 00123 00124 /* I'd rather not deal with alignment issues in this code, so I've 00125 just padded out the IMEP structs to be word aligned. The sizes of 00126 packets will be slightly inflated, but the packet formats in the IMEP 00127 draft are really odd --- I can't imagine anyone actually implementing them, 00128 and they'd need to be padded out or redone in real life. -dam */ 00129 00130 struct imep_ack { 00131 u_int8_t ack_seqno; 00132 u_int8_t r1; 00133 u_int16_t r2; 00134 u_int32_t ack_ipaddr; 00135 }; 00136 00137 struct imep_ack_block { 00138 u_int8_t ab_num_acks; 00139 u_int8_t r1; 00140 u_int16_t r2; 00141 char ab_ack_list[0]; // placeholder 00142 }; 00143 00144 struct imep_hello { 00145 u_int32_t hello_ipaddr; 00146 }; 00147 00148 struct imep_hello_block { 00149 u_int8_t hb_num_hellos; 00150 u_int8_t r1; 00151 u_int16_t r2; 00152 char hb_hello_list[0]; // placeholder 00153 }; 00154 00155 struct imep_object { 00156 u_int16_t o_length; 00157 // The IMEP spec uses the first bit to determine if this field 00158 // is 8 or 16 bits. I fix its length at 16 bits to keep 00159 // things simple. 00160 char o_data[0]; 00161 }; 00162 00163 struct imep_object_block { 00164 u_int8_t ob_sequence; 00165 u_int8_t ob_protocol_type : 4; 00166 u_int8_t ob_num_objects : 7; 00167 u_int8_t ob_num_responses : 5; 00168 char ob_object_list[0]; // placeholder 00169 }; 00170 00171 #define PROTO_RESERVED 0x00 00172 #define PROTO_NARP 0x01 00173 #define PROTO_RNARP 0x01 00174 #define PROTO_TORA 0x02 00175 00176 // The "response list" follows the "object list" in an IMEP packet. 00177 struct imep_response { 00178 u_int32_t resp_ipaddr; 00179 }; 00180 00181 #endif /* __imep_spec_h__ */
1.4.6