ns3-freqhopp.rar

  • PUDN用户
    了解作者
  • TEXT
    开发工具
  • 2KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 3
    下载次数
  • 2015-12-23 03:38
    上传日期
this is a code of ns3 frequency hopping
ns3-freqhopp.rar
  • ns3 freqhopp.txt
    9KB
内容介绍
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 CTTC * * 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, Include., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Author: Nicola Baldo <nbaldo@cttc.es> */ #include <iomanip> #include <cmath> #include "ns3/log.h" #include "radiotap-header.h" NS_LOG_COMPONENT_DEFINE ("RadiotapHeader"); namespace ns3 { NS_OBJECT_ENSURE_REGISTERED (RadiotapHeader); RadiotapHeader::RadiotapHeader() : m_length (8), m_present (0), m_tsft (0), m_flags (FRAME_FLAG_NONE), m_rate (0), m_channelFreq (0), m_channelFlags (CHANNEL_FLAG_NONE), m_antennaSignal (0), m_antennaNoise (0) { NS_LOG_FUNCTION (this); } TypeId RadiotapHeader::GetTypeId (void) { static TypeId tid = TypeId ("ns3::RadiotapHeader") .SetParent<Header> () .AddConstructor<RadiotapHeader> () ; return tid; } TypeId RadiotapHeader::GetInstanceTypeId (void) const { return GetTypeId (); } uint32_t RadiotapHeader::GetSerializedSize (void) const { NS_LOG_FUNCTION (this); return m_length; } void RadiotapHeader::Serialize (Buffer::Iterator start) const { NS_LOG_FUNCTION (this << &start); start.WriteU8 (0); // major version of radiotap header start.WriteU8 (0); // pad field start.WriteU16 (m_length); // entire length of radiotap data + header start.WriteU32 (m_present); // bits describing which fields follow header // // Time Synchronization Function Timer (when the first bit of the MPDU // arrived at the MAC) // if (m_present & RADIOTAP_TSFT) // bit 0 { start.WriteU64 (m_tsft); } // // Properties of transmitted and received frames. // if (m_present & RADIOTAP_FLAGS) // bit 1 { start.WriteU8 (m_flags); } // // TX/RX data rate in units of 500 kbps // if (m_present & RADIOTAP_RATE) // bit 2 { start.WriteU8 (m_rate); } // // Tx/Rx frequency in MHz, followed by flags. // if (m_present & RADIOTAP_CHANNEL) // bit 3 { start.WriteU16 (m_channelFreq); start.WriteU16 (m_channelFlags); } // // RF signal power at the antenna, decibel difference from an arbitrary, fixed // reference. // if (m_present & RADIOTAP_DBM_ANTSIGNAL) // bit 5 { start.WriteU8 (m_antennaSignal); } // // RF noise power at the antenna, decibel difference from an arbitrary, fixed // reference. // if (m_present & RADIOTAP_DBM_ANTNOISE) // bit 6 { start.WriteU8 (m_antennaNoise); } } uint32_t RadiotapHeader::Deserialize (Buffer::Iterator start) { NS_LOG_FUNCTION (this << &start); uint8_t tmp = start.ReadU8 (); // major version of radiotap header NS_ASSERT_MSG (tmp == 0x00, "RadiotapHeader::Deserialize(): Unexpected major version"); start.ReadU8 (); // pad field m_length = start.ReadU16 (); // entire length of radiotap data + header m_present = start.ReadU32 (); // bits describing which fields follow header uint32_t bytesRead = 8; // // Time Synchronization Function Timer (when the first bit of the MPDU arrived at the MAC) // if (m_present & RADIOTAP_TSFT) // bit 0 { m_tsft = start.ReadU64 (); bytesRead += 8; } // // Properties of transmitted and received frames. // if (m_present & RADIOTAP_FLAGS) // bit 1 { m_flags = start.ReadU8 (); ++bytesRead; } // // TX/RX data rate in units of 500 kbps // if (m_present & RADIOTAP_RATE) // bit 2 { m_rate = start.ReadU8 (); ++bytesRead; } // // Tx/Rx frequency in MHz, followed by flags. // if (m_present & RADIOTAP_CHANNEL) // bit 3 { m_channelFreq = start.ReadU16 (); m_channelFlags = start.ReadU16 (); bytesRead += 4; } // // The hop set and pattern for frequency-hopping radios. We don't need it but // still need to account for it. // if (m_present & RADIOTAP_FHSS) // bit 4 { start.ReadU8 (); ++bytesRead; } // // RF signal power at the antenna, decibel difference from an arbitrary, fixed // reference. // if (m_present & RADIOTAP_DBM_ANTSIGNAL) // bit 5 { m_antennaSignal = start.ReadU8 (); ++bytesRead; } // // RF noise power at the antenna, decibel difference from an arbitrary, fixed // reference. // if (m_present & RADIOTAP_DBM_ANTNOISE) // bit 6 { m_antennaNoise = start.ReadU8 (); ++bytesRead; } NS_ASSERT_MSG (m_length == bytesRead, "RadiotapHeader::Deserialize(): expected and actual lengths inconsistent"); return bytesRead; } void RadiotapHeader::Print (std::ostream &os) const { NS_LOG_FUNCTION (this << &os); os << " tsft=" << m_tsft << " flags=" << std::hex << m_flags << std::dec << " rate=" << (uint16_t) m_rate << " freq=" << m_channelFreq << " chflags=" << std::hex << (uint32_t)m_channelFlags << std::dec << " signal=" << (int16_t) m_antennaSignal << " noise=" << (int16_t) m_antennaNoise; } void RadiotapHeader::SetTsft (uint64_t value) { NS_LOG_FUNCTION (this << value); m_tsft = value; if (!(m_present & RADIOTAP_TSFT)) { m_present |= RADIOTAP_TSFT; m_length += 8; } NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec); } uint64_t RadiotapHeader::GetTsft () const { NS_LOG_FUNCTION (this); return m_tsft; } void RadiotapHeader::SetFrameFlags (uint8_t flags) { NS_LOG_FUNCTION (this << static_cast<uint32_t> (flags)); m_flags = flags; if (!(m_present & RADIOTAP_FLAGS)) { m_present |= RADIOTAP_FLAGS; m_length += 1; } NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec); } uint8_t RadiotapHeader::GetFrameFlags (void) const { NS_LOG_FUNCTION (this); return m_flags; } void RadiotapHeader::SetRate (uint8_t rate) { NS_LOG_FUNCTION (this << static_cast<uint32_t> (rate)); m_rate = rate; if (!(m_present & RADIOTAP_RATE)) { m_present |= RADIOTAP_RATE; m_length += 1; } NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec); } uint8_t RadiotapHeader::GetRate (void) const { NS_LOG_FUNCTION (this); return m_rate; } void RadiotapHeader::SetChannelFrequencyAndFlags (uint16_t frequency, uint16_t flags) { NS_LOG_FUNCTION (this << frequency << flags); m_channelFreq = frequency; m_channelFlags = flags; if (!(m_present & RADIOTAP_CHANNEL)) { m_present |= RADIOTAP_CHANNEL; m_length += 4; } NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec); } uint16_t RadiotapHeader::GetChannelFrequency (void) const { NS_LOG_FUNCTION (this); return m_channelFreq; } uint16_t RadiotapHeader::GetChannelFlags (void) const { NS_LOG_FUNCTION (this); return m_channelFlags; } void RadiotapHeader::SetAntennaSignalPower (double signal) { NS_LOG_FUNCTION (this << signal); if (!(m_present & RADIOTAP_DBM_ANTSIGNAL)) { m_present |= RADIOTAP_DBM_ANTSIGNAL; m_le
评论
    相关推荐
    • NS3 Workshop.zip
      gives detailed description of ns3
    • ns3-mmwave-new-handover.zip
      This is mmvawe model for network simulator ns-3
    • NS3官方文档.rar
      NS3-3.30的官方学习文档,英文pdf,包括Tutorial、Manual、Model Library
    • kodo-ns3-examples-master.zip
      这个库演示如何使用Kodo的擦除编码库(http://steinwurf.com/kodo/)在各种NS-3的例子。Kodo是可用的下一个研究和教育友好的许可证,你可以在这里查看详情。 如果您试图配置没有有效的许可证,那么您将得到一个错误...
    • ns3 manual and tutorial.zip
      ns3 manual and tutorial
    • NS3 梁宪臣 2017210319.zip
      线性代数时间的减肥坚持坚持坚持坚持拒绝放假放假放假放假放假放假
    • ns3:ns3与python
      ns3 ns3与python 日期:2017年9月6日 设备ubuntu 16.04 按照以下说明在终端上安装 $ sudo apt-get install gcc g ++ python python-dev mercurial bzr gdb valgrind gsl-bin libgsl0-dev libgsl0ldbl flex bison ...
    • ns3-dtn-bit:这是ns3支持dtn的模块
      在此目录下下载源代码ns-allineone-3.26(或进行软链接),并确保您可以使用ns3 将./box/ns2mobilityhelper.cc复制到./ns-allineone-3.26/ns-3/src/mobility/helper,此文件已修改,将有助于我们解析3D运动 用手或....
    • ns3dvrp:ns-3 模拟器的距离矢量路由协议
      ns3dvrp ns-3 模拟器的距离矢量路由协议 (DVRP)。 ns3 的距离矢量路由协议 (DVRP) 集成 作为 IPv4 主动表驱动路由协议,DVRP 实施到 ns-3。 该路由协议为测试和试验不同网络类型提供了一个很好的平台。 DVRP是基于...
    • ns3-project.zip
      AODV routing protocol simulation in ns3