您的位置:首页 > 其它

欢迎使用CSDN-markdown编辑器

2017-03-01 10:31 696 查看
NS3学习

将介绍几个类的使用。

 Nodelist

 BulkSendHelper

 LteHexGridEnbTopologyHelper

 Ns2Mobilityhelper

1.Nodelist类

仿真节点的列表,每一个创建的节点都将会被自动的添加到这个列表。

介绍一个打印部分节点列表节点的程序片段:

for (Nodelist::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it)
{
Ptr<Node> node = *it;
int nDevs = node->GetNdevices();
for (int j = 0; j < nDevs; j++)
{
Ptr<LteEnbNetDevice> enbdev = node->GetDevice(j)->GetObject< LteEnbNetDevice >();
If(enbdev != 0)
{
Vector pos = node->GetObject<MobilityModel>()->GetPosition();
outfile << enbdev->GetCellId(0) << "at" << pos.x << "," << pos.y << std::endl;
}
}
}


2.BulkSendHelper

一个帮助类,用来在节点组上实例化 ns3::BulkSendApplication应用程序。

void ns3::BulkSendHelper::SetAttribute ( std::string name,

const AttributeValue & value

)

上述函数用来为ns3::BulkSendApplication应用程序设置相应的属性,设置的属性包括ns3::BulkSendApplication类中提到的一系列属性,这里将以MaxBytes 属性设置为例。

BulkSendHelper dlClientHelper(“ns3::TcpSocketFactory”, InetSocketAddress(ueIpIfaces.GetAddress(u), dlPort));

dlClientHelper.SetAttribute(“MaxBytes”, UintegerValue(0));

MaxBytes 属性介绍:要发送的字节的总共的数量。一旦所有字节被发送,将不再发送数据。值为0意味着发送的数据量没有限制。

ns3::BulkSendApplication类的简介:

发送尽可能多的流量,尝试填满带宽。该流量生成器尽可能快的发送最多MaxBytes的数据,如果MaxBytes为0时,直到应用程序停止。一旦底层的发送缓冲满,该流量生成器将等待直到有缓冲可以发送数据,基本上保持了恒定的数据流。支持TCP socket的使用,不支持UDP socket。

3.LteHexGridEnbTopologyHelper

该类对于要进行包含EPC的LTE的仿真很重要。该帮助类可以轻松的创建一个拓扑,其中enb被放在三扇区,三扇区构成了六边形网络。

该图中一个类似于风扇的图形是一个macroenb,其中包含了三个扇区,每个扇区都有一个enb。

Ptr<LteHexGridEnbTopologyHelper> lteHexGridEnbTopologyHelper = CreateObject<LteHexGridEnbTopologyHelper>();
lteHexGridEnbTopologyHelper->SetLteHelper(lteHelper);
//设置宏基站之间的距离
lteHexGridEnbTopologyHelper->SetAttribute("InterSiteDistance", DoubleValue(interSiteDistance));
//设置第一个宏基站的位置开始的X坐标
lteHexGridEnbTopologyHelper->SetAttribute("MinX", DoubleValue(interSiteDistance / 2));
//设置偶数行的宏基站的数目,从第一行开始。此外,奇数行宏基站数目额外加1.
lteHexGridEnbTopologyHelper->SetAttribute("GridWidth", UintegerValue(nMacroEnbSitesX));
Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(macroEnbTxPowerDbm));
//设置基站的天线类型,为抛物线角天线。
lteHelper->SetEnbAntennaModelType("ns3::ParabolicAntennaModel");
lteHelper->SetEnbAntennaModelAttribute("Beamwidth", DoubleValue(70));
lteHelper->SetEnbAntennaModelAttribute("MaxAttenuation", DoubleValue(20.0));
lteHelper->SetEnbDeviceAttribute("DlEarfcn", UintegerValue(macroEnbDlEarfcn));
lteHelper->SetEnbDeviceAttribute("UlEarfcn", UintegerValue(macroEnbDlEarfcn + 18000));
lteHelper->SetEnbDeviceAttribute("DlBandwidth", UintegerValue(macroEnbBandwidth));
lteHelper->SetEnbDeviceAttribute("UlBandwidth", UintegerValue(macroEnbBandwidth));
//由以上设置初始化enb的位置并安装enbnetdevice.
NetDeviceContainer macroEnbDevs=lteHexGridEnbTopologyHelper -> SetPositionAndInstallEnbDevice (macroEnbs) ;


4.Ns2Mobilityhelper

该帮助类阅读ns2移动文件并配置节点的运动。

重点介绍该函数,

template

void ns3::Ns2MobilityHelper::Install ( T begin,

T end

) const

Parameters

begin an iterator which points to the start of the input object array.

end an iterator which points to the end of the input object array.

Read the ns2 trace file and configure the movement patterns of all input objects. Each input object is identified by a unique node id which reflects the index of the object in the input array.

可以指定部分节点
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ns3