我想知道如何获取正在处理数据包的节点ID.
我尝试了name(),但它没有给出节点的id,就像跟踪文件中显示的那样,其中显示了数据包跳的源和目的地.在来自format()的跟踪文件中,源和目标可用,但是如何访问它们,这也可能有助于了解当前正在进行哪个节点的处理.
这是关于NS2.有人可以提供一些帮助.
我正在尝试使用ns-allinone-2.35.tar.gz软件包在我的ubuntu 13.10中安装ns2.
起初我得到x11/*目录未找到错误.在完成一些教程并安装以下工具后,帮助我克服了这些问题.
sudo apt-fast install tcl8.5-dev tk8.5-dev
sudo apt-fast install build-essential autoconf automake
sudo apt-fast install perl xgraph libxt-dev libx11-dev libxmu-dev
sudo apt-fast install xorg-dev g++ xgraph
Run Code Online (Sandbox Code Playgroud)
但是,现在我收到以下错误:
linkstate/ls.h:137:58: error: ‘erase’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
void eraseAll() { erase(baseMap::begin(), baseMap::end()); }
^
linkstate/ls.h:137:58: note: declarations in dependent base ‘std::map<int, LsIdSeq, std::less<int>, std::allocator<std::pair<const int, LsIdSeq> > >’ are not found by unqualified lookup
linkstate/ls.h:137:58: …Run Code Online (Sandbox Code Playgroud) 我正在使用“NS2 Simulator”模拟计算机网络。我真的不明白为什么我们应该const char* const* argv使用char *?
我可以用char *它代替吗?关于这个主题有很多质量保证,但我对此感到困惑。请不要将此问题标记为“重复”。const char* const* argv为什么我们在下面的函数中使用?这是c++标准中的规则吗?我可以使用其中一个string或char **代替它吗?
Function Connector::command.
//~ns/common/connector.cc
int Connector::command(int argc, const char*const* argv)
{
Tcl& tcl = Tcl::instance();
...
if (argc == 3) {
if (strcmp(argv[1], "target") == 0) {
...
target_ = (NsObject*)TclObject::lookup(argv[2]);
...
}
...
}
return (NsObject::command(argc, argv));
}
Run Code Online (Sandbox Code Playgroud) 安装时出现以下错误
\n\n在文件中包含来自linkstate/ls.cc:67:0:
linkstate/ls.h: In instantiation of \xe2\x80\x98void LsMap<Key, T>::eraseAll() [with Key = int; T = LsIdSeq]\xe2\x80\x99:\nlinkstate/ls.cc:396:28: required from here\nlinkstate/ls.h:137:58: error: \xe2\x80\x98erase\xe2\x80\x99 was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]\n void eraseAll() { erase(baseMap::begin(), baseMap::end()); }\n ^\nlinkstate/ls.h:137:58: note: declarations in dependent base \xe2\x80\x98std::map<int, LsIdSeq, std::less<int>, std::allocator<std::pair<const int, LsIdSeq> > >\xe2\x80\x99 are not found by unqualified lookup\nlinkstate/ls.h:137:58: note: use \xe2\x80\x98this->erase\xe2\x80\x99 instead\nRun Code Online (Sandbox Code Playgroud)\n\nmake: *** [linkstate/ls.o] Error 1 …
当我在 Linux 终端中写入 $ns 时,它会显示以下消息:
"When configured, ns found the right version of tclsh in /usr/bin/tclsh8.6
but it doesn't seem to be there anymore, so ns will fall back on running the first tclsh in your path. The wrong version of tclsh may break the test suites. Reconfigure and rebuild ns if this is a problem. "
Run Code Online (Sandbox Code Playgroud)
它会导致我正在执行的 TCL 文件出现任何问题吗?我正在使用ns-allinone-2.35.
目前我已经在我的 Linux 电脑上安装了 ns2,当我在终端上运行以下命令时
$ ns sampleprog.tcl
Run Code Online (Sandbox Code Playgroud)
我得到的只是
nam:
Run Code Online (Sandbox Code Playgroud)
应该有一个 nam 弹出窗口打开。我不知道如何解决这个问题,因为我已经安装了 ns2 和 nam。我认为这是因为我更新了我的 Ubuntu 22.04,其中 nam 也更新了,现在与 ns2 版本不兼容。更新之前 nam 工作正常。我应该如何解决这个问题或者可能降低版本?
我尝试更新到最新版本但没有成功。我期待的网络动画窗口没有打开
我在NS 2.29中的Senario有5个节点,每个节点有2个接口,期望节点0和节点4,节点0想要发送数据包到节点4.我使用的协议是AODV,节点类型是无线的
我想算一算
接收数据包/发送数据包
以及不同模拟时间的吞吐量,我想用AWK语言做所有事情.
我不知道如何分享输出文件到undrest和我说的.
输出文件 :
s -t 0.100000000 -Hs 0 -Hd -2 -Ni 0 -Nx 0.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl AGT -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0 -Is 0.0 -Id 4.0 -It cbr -Il 1000 -If 1 -Ii 0 -Iv 32 -Pn cbr -Pi 0 -Pf 0 -Po 0
r -t 0.100000000 -Hs 0 -Hd -2 -Ni 0 -Nx 0.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl RTR -Nw --- …Run Code Online (Sandbox Code Playgroud) 在我的代码中,当XmlSchema只有命名空间attr时,我使用JAXB tranlate对象到xmlstring,我可以得到我想要的.像这样的xml字符串:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FoodSchema xmlns="http://www.something.com/something">
<beverage>water</beverage>
<food>steak</food>
</FoodSchema>
Run Code Online (Sandbox Code Playgroud)
但是当我有xmlns attr时,我得到像这样的xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:FoodSchema xmlns:xsi="h" xmlns:ns2="http://www.something.com/something">
<ns2:beverage>water</ns2:beverage>
<ns2:food>steak</ns2:food>
</ns2:FoodSchema>
Run Code Online (Sandbox Code Playgroud)
代码:package-info.java
@XmlSchema(
namespace="http://www.something.com/something",
elementFormDefault=XmlNsForm.QUALIFIED,
xmlns = { @XmlNs(namespaceURI = "h", prefix = "xsi")})//only this make the result different
package com.test;
import javax.xml.bind.annotation.*;
Run Code Online (Sandbox Code Playgroud)
Food.java
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Food {
private String food;
private String beverage;
public String getFood() {
return food;
}
public void setFood(String food) {
this.food = food;
}
public String getBeverage() {
return …Run Code Online (Sandbox Code Playgroud) 我非常天真地使用NS2并试图在NS2中实现UDP上的CBR.我写了以下代码:
set ns [new Simulator]
set tracefile [open out.tr w]
$ns trace-all $tracefile
set nf [open out.nam w]
$ns namtrace-all $nf
#should be "proc name args body"
#while executing
#"proc finish {}"
proc finish {}
{
global ns tracefile nf
$ns flush-trace
close $nf
close $tracefile
exec nam out.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
$ns simplex-link $n0 $n1 1Mb 10ms DropTail
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
set cbr[new Application/Traffic/CBR]
$cbr …Run Code Online (Sandbox Code Playgroud) set ns [new Simulator]
#open nam file
set nf [open out.nam w]
$ns namtrace-all $nf
#set variables of topology
set lanNodes 5
set link("bandwidth") 5mb
set link("delay") 2ms
set link("queue") DropTail
#define two routers
set router0 [$ns node]
set router1 [$ns node]
#link two routers
$ns duplex-link $router0 $router1 2mb 2ms DropTail
#create and connect nodes with routers
for {set i 0}{$i < $lanNodes}{incr i} {
set n($i) [$ns node]
set n([expr $i+5]) [$ns node]
$ns duplex-link $n($i) $router0 $link("bandwidth") …Run Code Online (Sandbox Code Playgroud) 我正在使用C++语言的NS2.我看到以下代码,我无法理解!!!!
ch->size() += IP_HDR_LEN;
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助...
ns2 ×11
c++ ×3
networking ×3
argv ×1
awk ×1
jaxb ×1
nam ×1
namespaces ×1
operand ×1
simulation ×1
tcl ×1
throughput ×1
ubuntu-13.10 ×1
xml ×1