ns2中结构体定义

2024-01-25 12:18
文章标签 定义 结构 ns2

本文主要是介绍ns2中结构体定义,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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_); }
};

这篇关于ns2中结构体定义的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/643236

相关文章

Vite 打包目录结构自定义配置小结

《Vite打包目录结构自定义配置小结》在Vite工程开发中,默认打包后的dist目录资源常集中在asset目录下,不利于资源管理,本文基于Rollup配置原理,本文就来介绍一下通过Vite配置自定义... 目录一、实现原理二、具体配置步骤1. 基础配置文件2. 配置说明(1)js 资源分离(2)非 JS 资

Java集合中的链表与结构详解

《Java集合中的链表与结构详解》链表是一种物理存储结构上非连续的存储结构,数据元素的逻辑顺序的通过链表中的引用链接次序实现,文章对比ArrayList与LinkedList的结构差异,详细讲解了链表... 目录一、链表概念与结构二、当向单链表的实现2.1 准备工作2.2 初始化链表2.3 打印数据、链表长

创建springBoot模块没有目录结构的解决方案

《创建springBoot模块没有目录结构的解决方案》2023版IntelliJIDEA创建模块时可能出现目录结构识别错误,导致文件显示异常,解决方法为选择模块后点击确认,重新校准项目结构设置,确保源... 目录创建spChina编程ringBoot模块没有目录结构解决方案总结创建springBoot模块没有目录

SpringBoot利用树形结构优化查询速度

《SpringBoot利用树形结构优化查询速度》这篇文章主要为大家详细介绍了SpringBoot利用树形结构优化查询速度,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录一个真实的性能灾难传统方案为什么这么慢N+1查询灾难性能测试数据对比核心解决方案:一次查询 + O(n)算法解决

Django中的函数视图和类视图以及路由的定义方式

《Django中的函数视图和类视图以及路由的定义方式》Django视图分函数视图和类视图,前者用函数处理请求,后者继承View类定义方法,路由使用path()、re_path()或url(),通过in... 目录函数视图类视图路由总路由函数视图的路由类视图定义路由总结Django允许接收的请求方法http

Oracle查询表结构建表语句索引等方式

《Oracle查询表结构建表语句索引等方式》使用USER_TAB_COLUMNS查询表结构可避免系统隐藏字段(如LISTUSER的CLOB与VARCHAR2同名字段),这些字段可能为dbms_lob.... 目录oracle查询表结构建表语句索引1.用“USER_TAB_COLUMNS”查询表结构2.用“a

MySQL中的索引结构和分类实战案例详解

《MySQL中的索引结构和分类实战案例详解》本文详解MySQL索引结构与分类,涵盖B树、B+树、哈希及全文索引,分析其原理与优劣势,并结合实战案例探讨创建、管理及优化技巧,助力提升查询性能,感兴趣的朋... 目录一、索引概述1.1 索引的定义与作用1.2 索引的基本原理二、索引结构详解2.1 B树索引2.2

如何使用Maven创建web目录结构

《如何使用Maven创建web目录结构》:本文主要介绍如何使用Maven创建web目录结构的问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录创建web工程第一步第二步第三步第四步第五步第六步第七步总结创建web工程第一步js通过Maven骨架创pytho

Python循环结构全面解析

《Python循环结构全面解析》循环中的代码会执行特定的次数,或者是执行到特定条件成立时结束循环,或者是针对某一集合中的所有项目都执行一次,这篇文章给大家介绍Python循环结构解析,感兴趣的朋友跟随... 目录for-in循环while循环循环控制语句break语句continue语句else子句嵌套的循

CSS Anchor Positioning重新定义锚点定位的时代来临(最新推荐)

《CSSAnchorPositioning重新定义锚点定位的时代来临(最新推荐)》CSSAnchorPositioning是一项仍在草案中的新特性,由Chrome125开始提供原生支持需... 目录 css Anchor Positioning:重新定义「锚定定位」的时代来了! 什么是 Anchor Pos