ns-3脚本初识——CSMA有线网络:second脚本

本文详细介绍了使用ns-3模拟器创建CSMA有线网络的second脚本,包括网络拓扑、TCP/IP协议安装、路由设置、数据追踪等内容。通过实例展示了如何配置全局路由,使节点间能正确通信,并通过嗅探设备观察数据包在不同网络设备间的传输过程。
摘要由CSDN通过智能技术生成

ns-3脚本初识——CSMA有线网络:second脚本

ps:本文所有文件和目录的默认根目录均为ns-3.29/。

该脚本默认拓扑结构如下:

       10.1.1.0
  n0 -------------- n1   n2   n3   n4
    point-to-point   |    |    |    |
                   ===================
                       LAN 10.1.2.0

n0和n1实现点到点通信(与first.cc中相似),n1~n4是个CSMA有线局域网。网络可以实现n0经由n1,和n4进行通信。

1.代码规范
 /* -*- Mode:C++; c-file-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
 */
2.头文件
#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"
3.命名空间
using namespace ns3;
4.日志
NS_LOG_COMPONENT_DEFINE ("SecondScriptExample");
5.主函数声明
int 
main (int argc, char *argv[])
{
…
}
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值