1、hdr_cmn,位于文件:/ns-allinone-2.34/ns-2.34/common/packet.h,570行
struct hdr_cmn {
enum dir_t { DOWN= -1, NONE= 0, UP= 1 };
packet_t ptype_; // 包类型,84行开始
int size_; // simulated packet size
int uid_; // unique id
int error_; // error flag
int errbitcnt_; // # of corrupted bits jahn
int fecsize_;
double ts_; // timestamp: for q-delay measurement
int iface_; // receiving interface (label)
dir_t direction_; // direction: 0=none, 1=up, -1=down
// source routing
char src_rt_valid;
double ts_arr_; // Required by Marker of JOBS
//Monarch extn begins
nsaddr_t prev_hop_; // IP addr of forwarding hop
nsaddr_t next_hop_; // next hop for this packet
int addr_type_; // type of next_hop_ addr
nsaddr_t last_hop_; // for tracing on multi-user channels
// AOMDV patch
int aomdv_salvage_count_;
// called if pkt can't obtain media or isn't ack'd. not called if
// droped by a queue
FailureCallback xmit_failure_;
void *xmit_failure_data_;
int xmit_reason_;
#define XMIT_REASON_RTS 0x01
#define XMIT_REASON_ACK 0x02
// filled in by GOD on first transmission, used for trace analysis
int num_forwards_; // how many times this pkt was forwarded
int opt_num_forwards_; // optimal #forwards
// Monarch extn ends;
// tx time for this packet in sec
double txtime_;
inline double& txtime() { return(txtime_); }
static int offset_; // offset for this header
inline static int& offset() { return offset_; }
inline static hdr_cmn* access(const Packet* p) {
return (hdr_cmn*) p->access(offset_);
}
inline packet_t& ptype() { return (ptype_); }
inline int& size() { return (size_); }
inline int& uid() { return (uid_); }
inline int& error() { return error_; }
inline int& errbitcnt() {return errbitcnt_; }
inline int& fecsize() {return fecsize_; }
inline double& timestamp() { return (ts_); }
inline int& iface() { return (iface_); }
inline dir_t& direction() { return (direction_); }
// monarch_begin
inline nsaddr_t& next_hop() { return (next_hop_); }
inline int& addr_type() { return (addr_type_); }
inline int& num_forwards() { return (num_forwards_); }
inline int& opt_num_forwards() { return (opt_num_forwards_); }
//monarch_end
ModulationScheme mod_scheme_;
inline ModulationScheme& mod_scheme() { return (mod_scheme_); }
};
2、hdr_ip,位于文件:/ns-allinone-2.34/ns-2.34/common/ip.h,58行
struct hdr_ip {
ns_addr_t src_;
ns_addr_t dst_;
int ttl_;
// u_int16_t sport_;
// u_int16_t dport_;
int fid_;
int prio_;
static int offset_;
inline static int& offset() { return offset_; }
inline static hdr_ip* access(const Packet* p) {
return (hdr_ip*) p->access(offset_);
}
ns_addr_t& src() { return (src_); }
nsaddr_t& saddr() { return (src_.addr_); }
int32_t& sport() { return src_.port_;}
ns_addr_t& dst() { return (dst_); }
nsaddr_t& daddr() { return (dst_.addr_); }
int32_t& dport() { return dst_.port_;}
int& ttl() { return (ttl_); }
int& flowid() { return (fid_); }
int& prio() { return (prio_); }
};