ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

A NetAnim example for ns3

2022-06-13 22:03:29  阅读:189  来源: 互联网

标签:NetAnim anim netanim brite debug ns3 example lns3.25


http://installfights.blogspot.com/2016/08/a-netanim-example-for-ns3.html

 

August 30, 2016 NetAnim is a GUI for ns3 (like visualizer). The last version 3.107 comes with ns3-allinone-3.25. To compile it follow these commands:

#Install required software
sudo apt-get install mercurial qt4-dev-tools

#Download netanim from mercurial
hg clone http://code.nsnam.org/netanim

#or use it from ns3-allinone-3.25
cd netanim-3.107

make clean
qmake NetAnim.pro  (For MAC Users: qmake -spec macx-g++ NetAnim.pro)
make 

./NetAnim

To generate an xml file compatible with netanim, you must add the following lines to your simulation file.

// netanim headers
  #include "ns3/netanim-module.h"

// file's name to run on netanim
  std::string animFile = "example.xml" ; 

  AnimationInterface anim (animFile);

// background image. Starts on 0,0, the image is not resized (scale 1,1) and the image has no transparency (alpha channel is one).
  anim.SetBackgroundImage("potential_google_fiber_cities.png",0,0,1,1,1);

// Set position of node 0 in the layout
  anim.SetConstantPosition(nodes.Get(0),115,63);
// Set description of node 0
  anim.UpdateNodeDescription (0, "Portland");
// Set size of node 0
  anim.UpdateNodeSize (0,10, 10);
// Set color of node 0 (R,G,B). In this case, color is blue.
  anim.UpdateNodeColor (0, 0, 0, 255);

  anim.SetConstantPosition(nodes.Get(1),83,219);
  anim.UpdateNodeDescription (1, "San Jose");
  anim.UpdateNodeSize (1, 10, 10);
// Set color of node 1 (R,G,B). In this case, color is green.
  anim.UpdateNodeColor (1, 0, 255, 0);

  anim.SetConstantPosition(nodes.Get(2),249,178);
  anim.UpdateNodeDescription (4, "Salt Lake City");
  anim.UpdateNodeSize (2, 10, 10);
// Set color of node 2 (R,G,B). In this case, color is red.
  anim.UpdateNodeColor (2, 255, 0, 0);


 

 



Maybe, when you'll execute your simulation you'll get this error:

undefined reference to `ns3::AnimationInterface::AnimationInterface(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
undefined reference to `ns3::AnimationInterface::~AnimationInterface()'
collect2: error: ld returned 1 exit status

Waf: Leaving directory `ns-allinone-3.25/ns-3.25/build'
Build failed
 -> task in 'brite-generic-example' failed (exit status 1): 
{task 139687142658192: cxxprogram brite-generic-example.cc.1.o -> ns3.25-brite-generic-example-debug}
['/usr/bin/g++', '-pthread', '-pthread', '-Wl,--enable-new-dtags', '-Wl,-rpath,/usr/lib/openmpi/lib', '-pthread', 'src/brite/examples/brite-generic-example.cc.1.o', '-o', '/home/dragonx/Downloads/ns-allinone-3.25/ns-3.25/build/src/brite/examples/ns3.25-brite-generic-example-debug', '-Wl,-rpath,/usr/lib/openmpi/lib', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-Wl,--no-as-needed', '-L.', '-L/usr/lib/openmpi/lib', '-L/home/dragonx/Downloads/ns-allinone-3.25/BRITE', '-lns3.25-brite-debug', '-lns3.25-nix-vector-routing-debug', '-lns3.25-applications-debug', '-lns3.25-internet-debug', '-lns3.25-bridge-debug', '-lns3.25-point-to-point-debug', '-lns3.25-mpi-debug', '-lns3.25-traffic-control-debug', '-lns3.25-config-store-debug', '-lns3.25-network-debug', '-lns3.25-stats-debug', '-lns3.25-core-debug', '-lrt', '-lgsl', '-lgslcblas', '-lm', '-lsqlite3', '-lmpi_cxx', '-lmpi', '-lbrite', '-ldl', '-lgtk-x11-2.0', '-lgdk-x11-2.0', '-lpangocairo-1.0', '-latk-1.0', '-lcairo', '-lgdk_pixbuf-2.0', '-lgio-2.0', '-lpangoft2-1.0', '-lpango-1.0', '-lgobject-2.0', '-lglib-2.0', '-lfontconfig', '-lfreetype', '-lxml2']

To solve it, you must Add 'netanim' to your wscript or move your simulation file to your scratch folder.
An extract of BRITE wscript as example:

obj = bld.create_ns3_program('brite-generic-example', ['netanim','brite', 'internet', 'point-to-point', 'nix-vector-routing', 'applications'])

   obj.source = 'brite-generic-example.cc'  

标签:NetAnim,anim,netanim,brite,debug,ns3,example,lns3.25
来源: https://www.cnblogs.com/ztguang/p/16372456.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有