struct hdr_cmn


//对ns2中的hdr_cmn头 ,源码进行注解
//源码来源于http://www.cs.mun.ca/~yzchen/code/ns-2.33/packet_8h_source.html
 struct hdr_cmn {       enum dir_t { DOWN= -1, NONE= 0, UP= 1 
        packet_t ptype_;        // packet type (see above)
00570         int             size_;          // simulated packet size
00571         int             uid_;           // unique id
00572         int             error_;         // error flag
00573         int     errbitcnt_;     // # of corrupted bits jahn
00574         int     fecsize_;
00575         double  ts_;            // timestamp: for q-delay measurement
00576         int             iface_;         // receiving interface (label)
00577         dir_t   direction_;     // direction: 0=none, 1=up, -1=down
00578         // source routing
00579         char    src_rt_valid;
00580         double  ts_arr_; // Required by Marker of JOBS
00581 
00582         //Monarch extn begins
00583         nsaddr_t prev_hop_;     // IP addr of forwarding hop
00584         nsaddr_t next_hop_;             // next hop for this packet
00585         int      addr_type_;    // type of next_hop_ addr
00586         nsaddr_t last_hop_;     // for tracing on multi-user channels
00587 
00588         // called if pkt can't obtain media or isn't ack'd. not called if
00589         // dropped by a queue
00590         FailureCallback xmit_failure_;
00591         void *xmit_failure_data_;
00592 
00593         /*
00594          * MONARCH wants to know if the MAC layer is passing this back because
00595          * it could not get the RTS through or because it did not receive
00596          * an ACK.
00597          */
00598         int     xmit_reason_;
00599         #define XMIT_REASON_RTS 0x01
00600         #define XMIT_REASON_ACK 0x02
00601 
00602         // filled in by GOD on first transmission, used for trace analysis
00603         int num_forwards_;              // how many times this pkt was forwarded
00604         int opt_num_forwards_;  // optimal #forwards
00605         // Monarch extn ends;
00606 
00607         // tx time for this packet in sec
00608         double txtime_;
00609         inline double& txtime() { return(txtime_); }
00610 
00611         static int offset_;     // offset for this header
00612         inline static int& offset() { return offset_; }
00613         inline static hdr_cmn* access(const Packet* p) {
00614                 return (hdr_cmn*) p->access(offset_);
00615         }
00616 
00617         /* per-field member functions */
00618         inline packet_t& ptype() { return (ptype_); }
00619         inline int& size() { return (size_); }
00620         inline int& uid() { return (uid_); }
00621         inline int& error() { return error_; }
00622         inline int& errbitcnt() {return errbitcnt_; }
00623         inline int& fecsize() {return fecsize_; }
00624         inline double& timestamp() { return (ts_); }
00625         inline int& iface() { return (iface_); }
00626         inline dir_t& direction() { return (direction_); }//方向为UP或者down
00627         // monarch_begin
00628         inline nsaddr_t& next_hop() { return (next_hop_); }//下一跳的地址
00629         inline int& addr_type() { return (addr_type_); }
00630         inline int& num_forwards() { return (num_forwards_); }
00631         inline int& opt_num_forwards() { return (opt_num_forwards_); }
00632         //monarch_end
00633 
00634         ModulationScheme mod_scheme_;
00635         inline ModulationScheme& mod_scheme() { return (mod_scheme_); }
00636 };
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值