欢迎使用CSDN-markdown编辑器

1 篇文章 0 订阅

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.
可以指定部分节点

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值