networking - 更改 MAC 802_3 的 ns2 代码以关闭碰撞检测
问题描述
过去几周我一直在研究 ns2 模拟,需要更改 ns-2.35/mac/mac-802_3.cc 中的实现以关闭碰撞检测。
这是发生碰撞时运行的代码 -
void Mac802_3::collision(Packet *p) {
PRNT_MAC_FUNCS(this);
if (mhIFS_.busy()) mhIFS_.cancel();
double ifstime= netif_->txtime(int((IEEE_8023_JAMSIZE+IEEE_8023_IFS_BITS)/8.0)); //jam time + ifs
mhIFS_.schedule(ifstime);
switch(state_) {
case MAC_SEND:
// If mac trace feature is on generate a collision trace for this packet.
if (trace_)
drop(p);
else
Packet::free(p);
if (mhSend_.busy()) mhSend_.cancel();
if (!mhRetx_.busy()) {
/* schedule retransmissions */
if (!mhRetx_.schedule(ifstime)) {
p= mhRetx_.packet();
hdr_cmn *th = hdr_cmn::access(p);
HDR_CMN(p)->size() -= (ETHER_HDR_LEN + HDR_MAC(p)->padding_);
fprintf(stderr,"BEB limit exceeded:Dropping packet %d\n",th->uid());
fflush(stderr);
drop(p); // drop if backed off far enough
mhRetx_.reset();
}
}
break;
case MAC_RECV:
Packet::free(p);
// more than 2 packets collisions possible
if (mhRecv_.busy()) mhRecv_.cancel();
break;
default:
assert("SHOULD NEVER HAPPEN" == 0);
}
}
我尝试评论 .cancel() 部分以避免在检测到碰撞时取消传输。但这并没有按预期工作,我在网络上的吞吐量为零。有人可以指导我如何实现这一目标吗?
解决方案
推荐阅读
- java - 如何修复 Javadoc 注释有解析错误,详细信息:在解析 JAVADOC_TAG [NonEmptyAtClauseDescription] 时输入“*”没有可行的替代方案
- julia - 需要很长时间的基准测试功能
- sonarqube - Sonarqube 分析总时间/持续时间 [SonnarScanner for Maven]
- android - React Native project error in Android Studio
- python - 使用 BeautifulSoup 查找具有相同类的不同元素
- python - 对于那些包含小于样本大小的值的条件,如何在使用 replace=False 设置条件时获取样本
- javascript - Node JS流重复数据
- django - 与 Django 相关的下拉列表
- reactjs - 映射函数仅映射第一个对象而不映射所有对象。(反应)
- python - python win32com设置office 365 excel用3张打开