没有合适的资源?快使用搜索试试~ 我知道了~
首页second.docx
second.docx
需积分: 50 455 浏览量
更新于2023-03-03
评论
收藏 14KB DOCX 举报
NS3中的第2个例子讲解,相比于网上其他的讲解来说,本文档对first.cc的讲解更加详细,有助于加快NS3的上手过程
资源详情
资源评论
资源推荐

/* -*- Mode:C++; c-le-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* 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
*/
/1.头文件
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/ipv4-global-routing-helper.h"
//仿真如下网络,包含两种网络:point-to-point 网络和 CSMA 网络,分别有 2 个和 4 个节点。其中
在节点 n1 上安装有两种 NetDevice。
// Default Network Topology
//
// 10.1.1.0
// n0 -------------- n1 n2 n3 n4
// point-to-point | | | |
// ================
// LAN 10.1.2.0
//2.名字空间
using namespace ns3;
//3.定义一个 LOG 模块
NS_LOG_COMPONENT_DEFINE ("SecondScriptExample");
//4.主函数
int
main (int argc, char *argv[])
{
bool verbose = true;
uint32_t nCsma = 3;
//使用命令行声明 nCsma 变量
CommandLine cmd;
cmd.AddValue ("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma);//读取命令
行参数
cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);//读取命令行产











安全验证
文档复制为VIP权益,开通VIP直接复制

评论0