zoukankan      html  css  js  c++  java
  • ns-3 OnOffApplication

    关于ns-3 OnOffApplication的使用,主要通过以下几个语句的设置:

    //设置目的IP地址,及端口号

    OnOffHelper onoffA1 ("ns3::UdpSocketFactory",
    Address (InetSocketAddress (Ipv4Address ("10.1.1.2"), 1)));

    //设置发送速率
    onoffA1.SetConstantRate (DataRate ("1Mb/s"));

    //onOffApplication是“open”“close”的模式交替工作的,这里设置“open”的时间,和“close”的时间。

    onoffA1.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
    onoffA1.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); 

    //将此APP安装到节点上

    ApplicationContainer appA1 = onoffA1.Install (terminals.Get (2));

    //设置APP的开始时间和结束时间

    appA1.Start (Seconds (0.0));
    appA1.Stop (Seconds (2.0));

     

    这里需要注意的是:需要先设置发送速率,再设置"OnTime""OffTime"时间。原因:

    void
    OnOffHelper::SetConstantRate (DataRate dataRate, uint32_t packetSize)
    {
    m_factory.Set ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1000]"));
    m_factory.Set ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
    m_factory.Set ("DataRate", DataRateValue (dataRate));
    m_factory.Set ("PacketSize", UintegerValue (packetSize));
    }

    这是ns-3的SetConstantRate()函数的实现,如果先设置"OnTime""OffTime"时间,再设置发送速率,则在SetConstantRate()函数内部会修改之前设置的"OnTime""OffTime"时间,导致前面的设置不能生效。

  • 相关阅读:
    css3学习 之 css选择器(结构性伪类选择器)
    flash如何实现Enumeration
    带参数的正则匹配
    css学习记录(overflow:hidden)
    JavaScript的函数
    HTML5实现网站在windows8中的贴靠
    Modernizr 让网站进行优雅降级
    ASP.NET Web API教程(三) 增删改
    Compat Inspector 微软内部使用的兼容性检测工具
    Javascript 高级手势
  • 原文地址:https://www.cnblogs.com/jingjingblog/p/7293882.html
Copyright © 2011-2022 走看看