- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 ns2 上工作...在 aodv.cc 中做了一些更改并添加了我自己的一些功能
void nb_traffic_update(int id,struct nb_traffic_stat **nblist,int nid,int flag,int hop_count)
..检测天坑攻击..当我用少量节点运行代码时,我得到了结果,但是当我增加节点数时,我得到了段错误。这是我的 nb_traffic.h 文件
struct nb_traffic_stat
{
int id;
int recvrequest;
int routereply;
int no_of_hops;
//int no_of_updation;
struct nb_traffic_stat *next;
};
struct traffic_stat
{
int id;
struct nb_traffic_stat **list;
struct traffic_stat *next;
};
struct ftraffic_stat
{
int sendrequest;
int routereply;
};
对aodv.cc的修改
struct traffic_stat *tlist=NULL,*ttail=NULL;
void
AODV::recvReply(Packet *p) {
...
if (ih->daddr() == index) { // If I am the original source
.....
nb_traffic_update(index,&nblist,ih->saddr(),1,rp->rp_hop_count);//1 is for receiving the route reply
}
}
void
AODV::recvRequest(Packet *p) {
....
/*after ensuring this is the new routerequest*/
struct hdr_cmn *ch = HDR_CMN(p);
if(ch->num_forwards()==1)
{
nb_traffic_update(index,&nblist,rq->rq_src,0,0);//0 is for receiving the request
}
}
我的邻居路况更新函数
void nb_traffic_update(int id,struct nb_traffic_stat **nblist,int nid,int flag,int hop_count)
{
int n;
//printf("inside nb_traffic_update:%d\n",id);
if(*nblist==NULL)
{
struct nb_traffic_stat *ptr;
ptr=(struct nb_traffic_stat*)malloc(sizeof(struct nb_traffic_stat));
ptr->id=nid;
ptr->next=NULL;
if(flag==0)
{
ptr->recvrequest=1;
ptr->routereply=0;
ptr->no_of_hops=0;
//ptr->no_of_updation=0;
}
else
{
ptr->recvrequest=0;
ptr->routereply=1;
ptr->no_of_hops=hop_count;
//ptr->no_of_updation=1;
}
*nblist=ptr;
struct traffic_stat *sptr;
sptr=tlist;
while(sptr!=NULL&&sptr->id!=id)
{
sptr=sptr->next;
}
assert(sptr!=NULL);
sptr->list=nblist;
}
else
{
int found=0;
struct nb_traffic_stat *tptr,*prevtptr;
tptr=*nblist;
while(tptr!=NULL&&tptr->id<=nid)
{
if(tptr->id==nid)
{
found=1;
break;
}
prevtptr=tptr;
tptr=tptr->next;
}
if(found)
{
if(flag==0)
{
tptr->recvrequest++;
}
else
{
tptr->routereply++;
tptr->no_of_hops=hop_count;
//tptr->no_of_updation++;
}
}
else
{
struct nb_traffic_stat *ptr;
ptr=(struct nb_traffic_stat*)malloc(sizeof(struct nb_traffic_stat));
ptr->id=nid;
if(flag==0)
{
ptr->recvrequest=1;
ptr->routereply=0;
ptr->no_of_hops=0;
//ptr->no_of_updation=0;
}
else
{
ptr->recvrequest=0;
ptr->routereply=1;
ptr->no_of_hops=hop_count;
//ptr->no_of_updation=1;
}
ptr->next=prevtptr->next;
prevtptr->next=ptr;
}
}
}
最佳答案
您没有在 nb_traffic_update(int, nb_traffic_stat**, int, int, int)
函数中检查 nblist
是否为 NULL,这会导致段错误。
同样在条件语句 if (*nblist==NULL)
中,您正在执行:*nblist=ptr;
。这意味着 *NULL = ptr;
可能会导致段错误。
关于c++ - ns2 中的段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15726589/
我只是在几个库中拆分了一个项目。 而且标题中出现了奇怪的错误。 我无法解释自己为什么会这样。 此外,此错误过去仅在FSI.exe中显示 我以为这是因为pb在fsi中加载了dll,但是还有更多。 这可能
我将 Android Studio 更新到 4.2.1 并删除了 jcentor。我在构建项目时收到了这样的警告。我不明白这些 URL 的含义以及如何修复它 映射新 ns http://schemas
在 DNS 响应消息中,我对出现在 Answer Section(包含由 ANCOUNT 编号引用的记录的部分)中的 NS 记录之间的差异感到困惑, 以及出现在 Authority Section 中
我有两个命名空间:第一个是 clojuresque java 中的 gui,第二个是常规 clojure 中的 gui。用户在 gui 中输入值;这些需要在非 gui ns 中“传递”到“设置”值。我
我在这里有一些代码可以使用 python 中的回溯解决 n 个皇后问题。当我运行它时,赔率总是比偶数花费的时间少得多。当 n 达到 20+ 左右时,这一点尤其明显。有人知道为什么是这样吗? impor
因此,我正在使用 Flutter 并在运行应用程序时,在调试控制台中收到如下错误: Warning: Mapping new ns http://schemas.android.com/reposit
当我尝试运行应用程序或重新构建它时,出现以下错误。 (我正在尝试在新的 Android Studio 和 SDK 中运行或重建旧项目) 警告:映射新 ns http://schemas.android
我有一个名为 query_df 的数据框,其中一些列属于 datetime[ns] 数据类型。 我想一次将所有 datetime[ns] 转换为 datetime[ns, UTC]。 到目前为止,这是
我注意到,一些服务提供商正在为其客户的域运行 DNS 服务,其中为该区域设置了 NS 名称,并由权威名称服务器返回(在权限部分/NS 和 SOA 记录中),这些名称与上游服务器(例如 TLD 服务器)
我正在研究 Karatsuba 数字乘法算法的实现,但与大多数使用字符串而不是 BigNumber 或 long 的实现不同。我已经为该问题编写了一个递归解决方案,该解决方案似乎适用于所有 n < 6
我在 Route 53 上注册了一个域。该域指向旧 Route53 路由的一些名称服务器。我现在正在构建我的 Terraform 脚本来创建一个新的 Route53 区域。创建时是否可以设置名称服务器
我想从 dataframe data 读取两列 S1_max 和 S2_max。无论 S1_max 列中存在值,我都想检查每个 S1_max 后面是否有相应的 S2_max 信号。如果是这样,我计算
我正在尝试通过以下方式获取 ns-3-dev 版本: [root@localhost ns-3-allinone]# ./download.py -n ns-3-dev # # Get NS-3 #
我在 pandas 中创建了一个 TimeSeries: In [346]: from datetime import datetime In [347]: dates = [datetime(201
我正在尝试访问 XML http://webservices.ns.nl/ns-api-stations使用 ASIHTTPRequest。但是我现在用的好像不行。它说无法访问主机。所以我假设它在 A
我正在尝试将 mp-olsr(ns 2.29) 添加到 ns 2.34 中,并且在编译时遇到了一些错误。 源代码(甲子乙):http://www.jiaziyi.com/index.php/resea
为什么ns(0.8)或ns(c(0.8))返回NA/NaN/Inf in foreign function call (arg 1) ? ns(c(0.8, 1.0))工作正常,但我想知道为什么只给
我正在创建一个PySpark 3.4.1应用程序在与Python3.11.5对接开发,它应该能够连接到多种类型的数据库通过JDBC连接。我正在测试与本地Oracle数据库的连接,该数据库是我在另一个容
我正在创建一个PySpark 3.4.1应用程序在与Python3.11.5对接开发,它应该能够连接到多种类型的数据库通过JDBC连接。我正在测试与本地Oracle数据库的连接,该数据库是我在另一个容
来自 dns newb 的两个问题: 子域是否可以使用与其父域不同的一组名称服务器? 例如:abc.ca 使用 ns.whatever.com 和 ns2.whatever.com,而 sub.abc
我是一名优秀的程序员,十分优秀!