NS3之first.cc注解
来源:互联网 发布:hadoop搭建大数据平台 编辑:程序博客网 时间:2024/05/03 07:25
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ //emacs模式,这行告诉源代码使用的预订格式(代码风格)/* * GNU--- * GPL---General Public License许可 * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation; * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *///引入头文件#include "ns3/core-module.h"#include "ns3/network-module.h"#include "ns3/internet-module.h"#include "ns3/point-to-point-module.h"#include "ns3/applications-module.h"using namespace ns3;//使用ns3命名空间NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");//这段代码的作用是向ns-3系统注册一个名为FirstScriptExample的记录组件,只有定义了记录组件才能在仿真脚本中使用Logging系统来定义输出intmain (int argc, char *argv[]){ Time::SetResolution (Time::NS);////设置时间单位为纳秒 //下面两行脚本是用来使2个日志组件生效的,它们被内建在Echo Client和Echo Server的应用中 //这两行代码将UdpEcho应用程序的客户端和服务器端的日志级别设置为“INFO”级 LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); LogComponentEnable ("FirstScriptExample", LOG_LEVEL_INFO); NS_LOG_INFO("Create Simulator");//输出该字符串 //LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_FUNCTION); //LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_FUNCTION); NodeContainer nodes;//创建ns3节点对象 nodes.Create (2);//它们在仿真中代表计算机创建两个节点 PointToPointHelper pointToPoint;//初始化一个PointToPointHelper的对象pointToPoint pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));//DataRate属性值为”5Mbit/s“ //从上层的角度告诉PointToPointHelper对象当创建一个PointToPointNetDevice对象时使用”5Mbit/s“来作为数据速率 pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); //Delay属性告诉PointToPointHelper使用“2ms”作为没一个被创建的点到点信道的传输延迟值 //下面两行代码完成信道和设备的配置 NetDeviceContainer devices; devices = pointToPoint.Install (nodes); //为计算机安装协议栈 InternetStackHelper stack; stack.Install (nodes); Ipv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.0"); Ipv4InterfaceContainer interfaces = address.Assign (devices); UdpEchoServerHelper echoServer (9); ApplicationContainer serverApps = echoServer.Install (nodes.Get (1)); serverApps.Start (Seconds (1.0)); serverApps.Stop (Seconds (10.0)); //下面设置客户端应用层 UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9); echoClient.SetAttribute ("MaxPackets", UintegerValue (1)); echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0))); echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); ApplicationContainer clientApps = echoClient.Install (nodes.Get (0)); clientApps.Start (Seconds (2.0)); clientApps.Stop (Seconds (10.0)); //AsciiTraceHelper ascii;//使用AsciiTraceHelper生成ASCII格式的包 //pointToPoint.EnableAsciiAll(ascii.CreateFileStream("myfirst.tr")); pointToPoint.EnablePcapAll("myfirst");//生成pcap格式的包 Simulator::Run (); Simulator::Destroy (); return 0;}
0 0
- NS3之first.cc注解
- NS3实例分析(2)-- first.cc
- NS3 ipv6例子代码测试和解析之ping6.cc
- NS3 ipv6例子代码测试和解析之test-ipv6.cc
- NS3实例分析(3)-- second.cc
- NS3实例分析(4)-- third.cc
- First.cc分析
- NS3网络仿真(2):first.py
- NS3实例分析(1)-- hello-simulator.cc
- (OK) NS3—NS-3—manet-2015.cc
- NS3 seventh.cc为例说明Probe< 一>
- NS3 seventh.cc为例说明Probe<二>
- (四)NS3中示例:second.cc和third.cc程序的注释
- NS3
- NS3
- NS3
- NS3
- NS3
- 请问java.util.ConcurrentModificationException怎么解决啊
- c++静态库与动态库的区别
- Cocos2D-x权威指南: CCNode类方法:
- 使用httpclient无需证书调用https的示例(java调用https)
- dll 导出函数名的那些事
- NS3之first.cc注解
- Servlet 中文乱码问题及解决方案剖析
- This Android SDK requires Android Developer Toolkit version 22.6.3 or above. Current version is 22.3
- 苹果iPad Air:史诗再度上演
- 【12】设计一个不能被继承的类
- 得经常去的博客地址(持续补充)
- 简单的继承模版
- Jersey (JAX-RS) implements a Cross domain filter
- python -- 获取 bing 查询结果