NS3 MyApp Class Reference
官方文档:MyApp
可以在下面的几个例子找到:
examples/tutorial/fifth.cc
examples/tutorial/seventh.cc
examples/tutorial/sixth.cc
SetUp函数
class MyApp : public Application
{
public:
MyApp ();
virtual ~MyApp();
void Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate);
private:
virtual void StartApplication (void);
virtual void StopApplication (void);
void ScheduleTx (void);
void SendPacket (void);
Ptr<Socket> m_socket;
Address m_peer;
uint32_t m_packetSize;
uint32_t m_nPackets;
DataRate m_dataRate;
EventId m_sendEvent;
bool m_running;
uint32_t m_packetsSent;
};
MyApp::MyApp ()
: m_socket (0),
m_peer (),
m_packetSize (0),
m_nPackets (0),
m_dataRate (0),
m_sendEvent (),
m_running (false),
m_packetsSent (0)
{
}
MyApp::~MyApp()
{
m_socket = 0;
}
void
MyApp::Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate)
{
m_socket = socket;
m_peer = address;
m_packetSize = packetSize;
m_nPackets = nPackets;
m_dataRate = dataRate;
}
void
MyApp::StartApplication (void)
{
m_running = true;
m_packetsSent = 0;
m_socket->Bind ();
m_socket->Connect (m_peer);
SendPacket ();
}
void
MyApp::StopApplication (void)
{
m_running = false;
if (m_sendEvent.IsRunning ())
{
Simulator::Cancel (m_sendEvent);
}
if (m_socket)
{
m_socket->Close ();
}
}
void
MyApp::SendPacket (void)
{
Ptr<Packet> packet = Create<Packet> (m_packetSize);
m_socket->Send (packet);
if (++m_packetsSent < m_nPackets)
{
ScheduleTx ();
}
}
void
MyApp::ScheduleTx (void)
{
if (m_running)
{
Time tNext (Seconds (m_packetSize * 8 / static_cast<double> (m_dataRate.GetBitRate ())));
m_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this);
}
}
static void
CwndChange (uint32_t oldCwnd, uint32_t newCwnd)
{
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << "\t" << newCwnd);
}
static void
RxDrop (Ptr<const Packet> p)
{
NS_LOG_UNCOND ("RxDrop at " << Simulator::Now ().GetSeconds ());
}
NS3 MyApp Class Reference的更多相关文章
- WPF笔记(1.1 WPF基础)——Hello,WPF!
原文:WPF笔记(1.1 WPF基础)--Hello,WPF! Example 1-1. Minimal C# WPF application// MyApp.csusing System;using ...
- Springfox Reference Documentation
1. Introduction The Springfox suite of java libraries are all about automating the generation of mac ...
- Xcode Build Setting Reference
https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/ ...
- Configuration Reference In Vue CLI 3.0
Configuration Reference This project is sponsored by #Global CLI Config Some global configurations ...
- NS3 fifth.cc 拥塞窗口实例
fifth.cc /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * This progr ...
- NS3 Ptr<Rocket> 与 TcpRocket 的一个小问题
前因:ns3网络仿真 实验进行到很关键的一步,我尝试进行了代码的编写(还没有添加Traceback的函数),如下: #include "ns3/core-module.h" #in ...
- Spring Boot Reference Guide
Spring Boot Reference Guide Authors Phillip Webb, Dave Syer, Josh Long, Stéphane Nicoll, Rob Winch, ...
- ns3 802.11b PHY model
I use the ubuntu and do not install the chinse input. The Code: c file requires gnu gsl library, it ...
- ASP.NET Core: You must add a reference to assembly mscorlib, version=4.0.0.0
ASP.NET Core 引用外部程序包的时候,有时会出现下面的错误: The type 'Object' is defined in an assembly that is not referenc ...
随机推荐
- SQLSERVER数据导入到MYSQL
SQLSERVER数据导入到MYSQL http://hi.baidu.com/luck001221/item/cb4462299f9ea79ab73263d2?qq-pf-to=pcqq.group ...
- CMSPRESS-PHP无限级分类
原博文地址:http://blog.sina.com.cn/s/blog_75ad10100101mrv0.html 当你学习php无限极分类的时候,大家都觉得一个字“难”我也觉得很难,所以,现在都还 ...
- linux下面发布80端口的服务
1:linux下面发布端口号为80 的服务,要在root用户下面发布.否则提示权限不够 2:在普通用户下面配置的java环境,在root用户下面不可用. 解决方法:2.1 要使用source /et ...
- PHPExcel 基本用法详解
.header header("Content-Type:application/vnd.ms-excel"); header("Content-Disposition: ...
- angular $scope.$watch
在$scope内置的所有函数中,用得最多的可能就是$watch 函数了.当你的数据模型中某一部分发生变化时,$watch函数可以向你发出通知. 你可以监控单个对象的属性,也可以监控需要经过计算的结果( ...
- testng入门教程16数据驱动(把数据写在xml)
testng入门教程16数据驱动(把数据写在xml) testng入门教程16数据驱动(把数据写在xml)把数据写在xml文件里面,在xml文件右键选择runas---testng执行 下面是case ...
- iOS常用第三方类库及Xcode插件
第三方类库(github地址): 1.AFNetworking 网络数据 https://github.com/AFNetworking/AFNetworking 2.SDWebImage 图 ...
- Fortran入门:Windows平台的Fortran编译器安装和使用
因为课程需要,今年开始学习FORTRAN语言.之前学校的计算概论用的是C,后来又学了C++和Python作为面向对象的工具,数值计算方面主要通过学校的许可证用的MATLAB.因为专业侧重数值模拟和反演 ...
- zw版【转发·台湾nvp系列Delphi例程】HALCON MaxImage1
zw版[转发·台湾nvp系列Delphi例程]HALCON MaxImage1 procedure TForm1.FormShow(Sender: TObject);begin Set8087CW($ ...
- GBDT理论知识总结
一. GBDT的经典paper:<Greedy Function Approximation:A Gradient Boosting Machine> Abstract Function ...
