ndnSIM学习(一)——安装ndnSIM踩坑:克隆ndnSIM时git无法访问(连接超时)的解决方案

前言

今天装网络仿真软件 ndnSIM ,我用的 Ubuntu20.04 ,装的版本是 ndnSIM2.8 ,把所有踩过的坑说一遍吧。

按照官方的教程https://ndnsim.net/current/getting-started.htmlUbuntu20.04 的安装代码应当为

sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python3-setuptools castxml

sudo apt install gir1.2-goocanvas-2.0 gir1.2-gtk-3.0 libgirepository1.0-dev python3-dev python3-gi python3-gi-cairo python3-pip python3-pygraphviz python3-pygccxml
sudo pip3 install kiwi

mkdir ndnSIM
cd ndnSIM
git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM

cd <ns-3-folder>
./waf configure --enable-examples
./waf

然而遇到了很多问题,让我们跟着问题一步一步地来解决吧。

下载速度过慢

一开始 apt install 下载很慢,这是因为没有使用镜像源。这里使用清华镜像源,参考链接https://blog.csdn.net/dou3516/article/details/108196179

git clone过慢甚至无法访问

解决方案:使用github的镜像,如用镜像 https://github.com.cnpmjs.org/ (或者 https://hub.fastgit.org/ )代替 https://github.com/ ,示例代码:

sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python3-setuptools castxml

sudo apt install gir1.2-goocanvas-2.0 gir1.2-gtk-3.0 libgirepository1.0-dev python3-dev python3-gi python3-gi-cairo python3-pip python3-pygraphviz python3-pygccxml
sudo pip3 install kiwi

mkdir ndnSIM
cd ndnSIM
git clone https://github.com.cnpmjs.org/named-data-ndnSIM/ns-3-dev.git ns-3
git clone https://github.com.cnpmjs.org/named-data-ndnSIM/pybindgen.git pybindgen
git clone --recursive https://github.com.cnpmjs.org/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM

cd <ns-3-folder>
./waf configure --enable-examples
./waf

–recursice参数导致子模块无法使用git镜像

此时还会遇到一个问题,因为文章开头倒数第5行代码 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM 采用了 --recursive 递归下载子文件。然而递归下载时,又会使用 https://github.com/ 了,没有镜像加速,就会报这样的错

正克隆到 '/home/ndn/ndnSIM/ns-3/src/ndnSIM/NFD'...
fatal: 无法访问 'https://github.com/named-data-ndnSIM/NFD/':GnuTLS recv error (-54): Error in the pull function.
fatal: 无法克隆 'https://github.com/named-data-ndnSIM/NFD' 到子模组路径 '/home/ndn/ndnSIM/ns-3/src/ndnSIM/NFD'
克隆 'NFD' 失败。按计划重试
正克隆到 '/home/ndn/ndnSIM/ns-3/src/ndnSIM/ndn-cxx'...
fatal: 无法访问 'https://github.com/named-data-ndnSIM/ndn-cxx/':Failed to connect to github.com port 443: 拒绝连接
fatal: 无法克隆 'https://github.com/named-data-ndnSIM/ndn-cxx' 到子模组路径 '/home/ndn/ndnSIM/ns-3/src/ndnSIM/ndn-cxx'
克隆 'ndn-cxx' 失败。按计划重试
正克隆到 '/home/ndn/ndnSIM/ns-3/src/ndnSIM/NFD'...
fatal: 无法访问 'https://github.com/named-data-ndnSIM/NFD/':Failed to connect to github.com port 443: 拒绝连接
fatal: 无法克隆 'https://github.com/named-data-ndnSIM/NFD' 到子模组路径 '/home/ndn/ndnSIM/ns-3/src/ndnSIM/NFD'
第二次尝试克隆 'NFD' 失败,退出

而实际上,子文件就只有 ndn-cxxNFD ,所以我们可以手动用镜像下载。具体而言,就是把代码 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM 更改为

git clone https://github.com.cnpmjs.org/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
git clone https://github.com.cnpmjs.org/named-data-ndnSIM/NFD ns-3/src/ndnSIM/NFD
git clone https://github.com.cnpmjs.org/named-data-ndnSIM/ndn-cxx ns-3/src/ndnSIM/ndn-cxx

完整代码——

sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python3-setuptools castxml

sudo apt install gir1.2-goocanvas-2.0 gir1.2-gtk-3.0 libgirepository1.0-dev python3-dev python3-gi python3-gi-cairo python3-pip python3-pygraphviz python3-pygccxml
sudo pip3 install kiwi

mkdir ndnSIM
cd ndnSIM
git clone https://github.com.cnpmjs.org/named-data-ndnSIM/ns-3-dev.git ns-3
git clone https://github.com.cnpmjs.org/named-data-ndnSIM/pybindgen.git pybindgen
git clone https://github.com.cnpmjs.org/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
git clone https://github.com.cnpmjs.org/named-data-ndnSIM/NFD ns-3/src/ndnSIM/NFD
git clone https://github.com.cnpmjs.org/named-data-ndnSIM/ndn-cxx ns-3/src/ndnSIM/ndn-cxx

cd <ns-3-folder>
./waf configure --enable-examples
./waf

No module named ‘openssl’

这个问题很离谱,网上找不到靠谱的解决方案。按照链接http://www.04007.cn/article/478.html尝试了,然而 import OpenSSLimport ssl 都可以,就是 import openssl 搞不定。报错如下

Traceback (most recent call last):
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Scripting.py", line 119, in waf_entry_point
    run_commands()
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Scripting.py", line 178, in run_commands
    parse_options()
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Scripting.py", line 158, in parse_options
    ctx.execute()
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Options.py", line 198, in execute
    super(OptionsContext,self).execute()
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 85, in execute
    self.recurse([os.path.dirname(g_module.root_path)])
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
    user_function(self)
  File "/home/ndn/ndnSIM/ns-3/wscript", line 256, in options
    opt.recurse('src')
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
    user_function(self)
  File "/home/ndn/ndnSIM/ns-3/src/wscript", line 51, in options
    opt.recurse(module, mandatory=False)
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
    user_function(self)
  File "/home/ndn/ndnSIM/ns-3/src/ndnSIM/wscript", line 20, in options
    opt.load(['doxygen', 'sphinx_build', 'compiler-features', 'sqlite3', 'openssl'],
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 80, in load
    module=load_tool(t,path,with_sys_path=with_sys_path)
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 373, in load_tool
    __import__(tool)
ModuleNotFoundError: No module named 'openssl'

查看了下 OpenSSL 的位置,原来在 ~/anaconda3/lib/python3.8/site-packages/OpenSSL 。虽然不知道OpenSSL和openssl是不是一个玩意,但实在是没有别的办法了,只能自欺欺人改名了。

cp -r ~/anaconda3/lib/python3.8/site-packages/OpenSSL ~/anaconda3/lib/python3.8/site-packages/openssl

然后还是失败,报错信息如下

Traceback (most recent call last):
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Scripting.py", line 119, in waf_entry_point
    run_commands()
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Scripting.py", line 182, in run_commands
    ctx=run_command(cmd_name)
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Scripting.py", line 173, in run_command
    ctx.execute()
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Configure.py", line 85, in execute
    super(ConfigurationContext,self).execute()
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 85, in execute
    self.recurse([os.path.dirname(g_module.root_path)])
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
    user_function(self)
  File "/home/ndn/ndnSIM/ns-3/wscript", line 491, in configure
    conf.recurse('src')
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
    user_function(self)
  File "/home/ndn/ndnSIM/ns-3/src/wscript", line 59, in configure
    conf.recurse(module, mandatory=False)
  File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
    user_function(self)
  File "/home/ndn/ndnSIM/ns-3/src/ndnSIM/wscript", line 33, in configure
    conf.check_openssl(mandatory=True, use='OPENSSL', atleast_version=0x10001000)
AttributeError: 'ConfigurationContext' object has no attribute 'check_openssl'

在root用户目录下执行 grep -rl "check_openssl" ./ ,找不到 check_openssl 函数在哪,无奈之下,只能掩耳盗铃,注释掉 /home/ndn/ndnSIM/ns-3/src/ndnSIM/wscriptconf.check_openssl(mandatory=True, use='OPENSSL', atleast_version=0x10001000)

然后还遇到了一顿问题,我选择了放弃,并且按照上述流程,新建了一个叫做 newndnSIM 的文件夹,然后重新执行了那一串 git clone ,然后莫名其妙地编译成功了。我也懒得纠结到底是啥原因了,能用就行。

11月10日的更新:解决可视化visualizer打不开的问题

破案了!破案了!终于知道为什么 PyViz 安装不上了!我之前一直用不了 --vis 可视化,无论怎么 pip installconda install 都不行。于是我放弃了可视化。

今天,一个偶然的机会,我又开了一个虚拟机,然后这次我没装 Anaconda ,直接装的 Ubuntu18.04 。自带的 Python 版本是 2.7 ,结果发现 ndnSIM 说我的 Python 版本是 3.6 。一查,发现 Ubuntu 自带两个版本的 Python ,我 pip 永远是在给 Python2 进行 pip ,于是安装 pip3 命令,解决可视化问题!芜湖!

  • 4
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
根据引用\[3\]中的官方教程,安装ndnSIM在Ubuntu 20.04上需要执行以下步骤: 1. 打开终端,执行以下命令安装必要的依赖项: ``` sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python3-setuptools castxml sudo apt install gir1.2-goocanvas-2.0 gir1.2-gtk-3.0 libgirepository1.0-dev python3-dev python3-gi python3-gi-cairo python3-pip python3-pygraphviz python3-pygccxml ``` 2. 安装kiwi,执行以下命令: ``` sudo pip3 install kiwi ``` 3. 创建一个名为ndnSIM的文件夹,并进入该文件夹: ``` mkdir ndnSIM cd ndnSIM ``` 4. 克隆ns-3-dev、pybindgen和ndnSIM的仓库: ``` git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM ``` 5. 进入ns-3文件夹,并执行以下命令进行配置和编译: ``` cd ns-3 ./waf configure --enable-examples ./waf ``` 这样,你就可以在Ubuntu 20.04上成功安装ndnSIM了。请注意,这些步骤是根据官方教程提供的信息编写的,确保你的系统满足所有的依赖项,并按照步骤进行操作。 #### 引用[.reference_title] - *1* [在Ubuntu安装ndnSIM](https://blog.csdn.net/qq_44001007/article/details/107575203)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [ndnSIM学习(一)——安装ndnSIM克隆ndnSIMgit无法访问连接超时)的解决方案](https://blog.csdn.net/MamiyaHasaki/article/details/120578299)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值