From 2228a32b8f6bf761c0ebc6e14da8c39f18c706e6 Mon Sep 17 00:00:00 2001 From: Pavel Boyko Date: Thu, 6 Aug 2009 10:23:12 +0400 Subject: [PATCH 01/28] Route lookup removed in ARP request (see bug 606) --- src/internet-stack/arp-l3-protocol.cc | 20 +++++--------------- src/internet-stack/arp-l3-protocol.h | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/internet-stack/arp-l3-protocol.cc b/src/internet-stack/arp-l3-protocol.cc index f98f9f2ad..da46e9c3b 100644 --- a/src/internet-stack/arp-l3-protocol.cc +++ b/src/internet-stack/arp-l3-protocol.cc @@ -186,7 +186,7 @@ ArpL3Protocol::Receive(Ptr device, Ptr p, uint16_t prot found = true; NS_LOG_LOGIC ("node="<GetId () <<", got request from " << arp.GetSourceIpv4Address () << " -- send reply"); - SendArpReply (cache, arp.GetSourceIpv4Address (), + SendArpReply (cache, arp.GetDestinationIpv4Address (), arp.GetSourceIpv4Address (), arp.GetSourceHardwareAddress ()); break; } @@ -338,26 +338,16 @@ ArpL3Protocol::SendArpRequest (Ptr cache, Ipv4Address to) } void -ArpL3Protocol::SendArpReply (Ptr cache, Ipv4Address toIp, Address toMac) +ArpL3Protocol::SendArpReply (Ptr cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac) { NS_LOG_FUNCTION (this << cache << toIp << toMac); ArpHeader arp; - // need to pick a source address; use routing implementation to select - Ptr ipv4 = m_node->GetObject (); - int32_t interface = ipv4->GetInterfaceForDevice (cache->GetDevice ()); - NS_ASSERT (interface >= 0); - Ipv4Header header; - header.SetDestination (toIp); - Socket::SocketErrno errno_; - Ptr packet = Create (); - Ptr route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, interface, errno_); - NS_ASSERT (route != 0); NS_LOG_LOGIC ("ARP: sending reply from node "<GetId ()<< "|| src: " << cache->GetDevice ()->GetAddress () << - " / " << route->GetSource () << + " / " << myIp << " || dst: " << toMac << " / " << toIp); - arp.SetReply (cache->GetDevice ()->GetAddress (), - route->GetSource (), toMac, toIp); + arp.SetReply (cache->GetDevice ()->GetAddress (), myIp, toMac, toIp); + Ptr packet = Create (); packet->AddHeader (arp); cache->GetDevice ()->Send (packet, toMac, PROT_NUMBER); } diff --git a/src/internet-stack/arp-l3-protocol.h b/src/internet-stack/arp-l3-protocol.h index 7910d593a..1256e8c40 100644 --- a/src/internet-stack/arp-l3-protocol.h +++ b/src/internet-stack/arp-l3-protocol.h @@ -87,7 +87,7 @@ private: typedef std::list > CacheList; Ptr FindCache (Ptr device); void SendArpRequest (Ptrcache, Ipv4Address to); - void SendArpReply (Ptr cache, Ipv4Address toIp, Address toMac); + void SendArpReply (Ptr cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac); CacheList m_cacheList; Ptr m_node; TracedCallback > m_dropTrace; From 7d21df488f57ad2ae09e245f83c71f8b2905b970 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Wed, 5 Aug 2009 20:53:44 -0700 Subject: [PATCH 02/28] Implement UdpSocketImpl::Close () --- src/internet-stack/udp-socket-impl.cc | 9 ++++++++- src/node/socket.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/internet-stack/udp-socket-impl.cc b/src/internet-stack/udp-socket-impl.cc index 903b76bbd..c2a52df43 100644 --- a/src/internet-stack/udp-socket-impl.cc +++ b/src/internet-stack/udp-socket-impl.cc @@ -203,9 +203,16 @@ UdpSocketImpl::ShutdownRecv (void) } int -UdpSocketImpl::Close(void) +UdpSocketImpl::Close (void) { NS_LOG_FUNCTION_NOARGS (); + if (m_shutdownRecv == true && m_shutdownSend == true) + { + m_errno = Socket::ERROR_BADF; + return -1; + } + m_shutdownRecv = true; + m_shutdownSend = true; return 0; } diff --git a/src/node/socket.h b/src/node/socket.h index fbc4b723c..ef529adeb 100644 --- a/src/node/socket.h +++ b/src/node/socket.h @@ -184,6 +184,7 @@ public: /** * \brief Close a socket. + * \returns zero on success, -1 on failure. * * After the Close call, the socket is no longer valid, and cannot * safely be used for subsequent operations. From dc035d614296f3fabff647f882f1ecf24d095170 Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Thu, 6 Aug 2009 21:58:04 -0700 Subject: [PATCH 03/28] fix for bug 650 (PacketSocket Close() --- src/node/packet-socket.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node/packet-socket.cc b/src/node/packet-socket.cc index 2045a411c..07ddee6f4 100644 --- a/src/node/packet-socket.cc +++ b/src/node/packet-socket.cc @@ -172,7 +172,7 @@ PacketSocket::ShutdownRecv (void) m_errno = ERROR_BADF; return -1; } - m_shutdownRecv = false; + m_shutdownRecv = true; return 0; } @@ -186,6 +186,8 @@ PacketSocket::Close(void) return -1; } m_state = STATE_CLOSED; + m_shutdownSend = true; + m_shutdownRecv = true; return 0; } From b93690cac719e0b2143bb4698c3b0ff0a87ccebe Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Fri, 7 Aug 2009 15:34:45 -0700 Subject: [PATCH 04/28] fix manual for ConfigStore --- doc/manual/attributes.texi | 134 +++++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 59 deletions(-) diff --git a/doc/manual/attributes.texi b/doc/manual/attributes.texi index 91a7340bd..980566a41 100644 --- a/doc/manual/attributes.texi +++ b/doc/manual/attributes.texi @@ -645,11 +645,11 @@ of an instance of the new class. found in @code{src/contrib} and not in the main tree. If you like this feature and would like to provide feedback on it, please email us. -Values for ns-3 attributes can be stored in an ascii text file and +Values for ns-3 attributes can be stored in an ascii or XML text file and loaded into a future simulation. This feature is known as the ns-3 ConfigStore. The ConfigStore code is in @code{src/contrib/}. It is not yet main-tree -code, because we are seeking some user feedback. +code, because we are seeking some user feedback and experience with this. We can explore this system by using an example. Copy the @code{csma-bridge.cc} file to the scratch directory: @@ -658,8 +658,8 @@ file to the scratch directory: ./waf @end verbatim -Let's edit it to add the ConfigStore feature. First, add an include statement, -and then add these lines: +Let's edit it to add the ConfigStore feature. First, add an include statement +to include the contrib module, and then add these lines: @verbatim #include "contrib-module.h" @@ -670,20 +670,43 @@ int main (...) // Invoke just before entering Simulator::Run () ConfigStore config; - config.Configure (); + config.ConfigureDefaults (); + config.ConfigureAttributes (); Simulator::Run (); } @end verbatim -There is an attribute that governs whether the Configure() call either -stores a simulation configuration in a file and exits, or whether -it loads a simulation configuration file annd proceeds. First, -the @code{LoadFilename} attribute is checked, and if non-empty, -the program loads the configuration from the filename provided. -If LoadFilename is empty, and if the @code{StoreFilename} attribute is -populated, the configuration will be written to the output filename -specified. +There are three attributes that govern the behavior of the ConfigStore: +"Mode", "Filename", and "FileFormat". The Mode (default "None") configures +whether ns-3 should load configuration from a previously saved file +(specify "Mode=Load") or save it to a file (specify "Mode=Save"). +The Filename (default "") is where the ConfigStore should store its +output data. The FileFormat (default "RawText") governs whether +the ConfigStore format is Xml or RawText format. + +So, using the above modified program, try executing the following +waf command and +@verbatim +./waf --command-template="%s --ns3::ConfigStore::Filename=csma-bridge-config.xml --ns3::ConfigStore::Mode=Save --ns3::ConfigStore::FileFormat=Xml" --run scratch/csma-bridge +@end verbatim +After running, you can open the csma-bridge-config.xml file and it will +display the configuration that was applied to your simulation; e.g. +@verbatim + + + + + + + + + + + +... +@end verbatim +This file can be archived with your simulation script and output data. While it is possible to generate a sample config file and lightly edit it to change a couple of values, there are cases where this @@ -697,55 +720,46 @@ file only the strictly necessary elements, and move these minimal elements to a new configuration file which can then safely be edited and loaded in a subsequent simulation run. -So, let's do that as an example. We'lll run the program once -to create a configure file, and look at it. -If you are running bash shell, the below command should work (which illustrates -how to set an attribute from the command line): -@verbatim -./build/debug/scratch/csma-bridge --ns3::ConfigStore::StoreFilename=test.config -@end verbatim -or, if the above does not work (the above requires rpath support), try this: -@verbatim -./waf --command-template="%s --ns3::ConfigStore::StoreFilename=test.config" --run scratch/csma-bridge -@end verbatim +When the ConfigStore object is instantiated, its attributes Filename, +Mode, and FileFormat must be set, either via command-line or via +program statements. -Running the program should yield a "test.config" output configuration file -that looks like this: +As a more complicated example, let's assume that we want to +read in a configuration of defaults from an input file named +"input-defaults.xml", and write out the resulting attributes to a +separate file called "output-attributes.xml". (Note-- to get this +input xml file to begin with, it is sometimes helpful to run the +program to generate an output xml file first, then hand-edit that +file and re-input it for the next simulation run). @verbatim -/$ns3::NodeListPriv/NodeList/0/$ns3::Node/DeviceList/0/$ns3::CsmaNetDevice/Addre -ss 00:00:00:00:00:01 -/$ns3::NodeListPriv/NodeList/0/$ns3::Node/DeviceList/0/$ns3::CsmaNetDevice/Frame -Size 1518 -/$ns3::NodeListPriv/NodeList/0/$ns3::Node/DeviceList/0/$ns3::CsmaNetDevice/SendE -nable true -/$ns3::NodeListPriv/NodeList/0/$ns3::Node/DeviceList/0/$ns3::CsmaNetDevice/Recei -veEnable true -/$ns3::NodeListPriv/NodeList/0/$ns3::Node/DeviceList/0/$ns3::CsmaNetDevice/TxQue -ue/$ns3::DropTailQueue/MaxPackets 100 -/$ns3::NodeListPriv/NodeList/0/$ns3::Node/DeviceList/0/$ns3::CsmaNetDevice/Mtu 1 -500 +#include "contrib-module.h" ... -@end verbatim +int main (...) +{ -The above lists, for each object in the script topology, the value of each -registered attribute. The syntax of this file is that the unique name -of the attribute (in the attribute namespace) is specified on each line, -followed by a value. + Config::SetDefault ("ns3::ConfigStore::Filename", StringValue ("input-defaults.xml")); + Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Load")); + Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("Xml")); + ConfigStore inputConfig; + inputConfig.ConfigureDefaults (); + + // + // Allow the user to override any of the defaults and the above Bind() at + // run-time, via command-line arguments + // + CommandLine cmd; + cmd.Parse (argc, argv); -This file is intended to be a convenient record of the parameters that were -used in a given simulation run, and can be stored with simulation -output files. Additionally, -this file can also be used to parameterize a simulation, instead of -editing the script or passing in command line arguments. For instance, -a person wanting to run the simulation can examine and tweak the values -in a pre-existing configuration file, and pass the file to the -program. In this case, the relevant commands are: -@verbatim -./build/debug/scratch/csma-bridge --ns3::ConfigStore::LoadFilename=test.config -@end verbatim -or, if the above does not work (the above requires rpath support), try this: -@verbatim -./waf --command-template="%s --ns3::ConfigStore::LoadFilename=test.config" --run scratch/csma-bridge + // setup topology + ... + + // Invoke just before entering Simulator::Run () + Config::SetDefault ("ns3::ConfigStore::Filename", StringValue ("output-attributes.xml")); + Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save")); + ConfigStore outputConfig; + outputConfig.ConfigureAttributes (); + Simulator::Run (); +} @end verbatim @subsection GTK-based ConfigStore @@ -772,11 +786,13 @@ GtkConfigStore : not enabled (library 'gtk+-2.0 >= 2.12' not foun In the above example, it was not enabled, so it cannot be used until a suitable version is installed and ./waf configure; ./waf is rerun. -Usage is almost the same as the non-GTK-based version: +Usage is almost the same as the non-GTK-based version, but there +are no ConfigStore attributes involved: @verbatim // Invoke just before entering Simulator::Run () GtkConfigStore config; - config.Configure (); + config.ConfigureDefaults (); + config.ConfigureAttributes (); @end verbatim Now, when you run the script, a GUI should pop up, allowing you to open From 925f920b09e631ea640b1d288b2c3e03c9a62efb Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Fri, 7 Aug 2009 16:02:06 -0700 Subject: [PATCH 05/28] document how to assign attributes in constructor --- doc/manual/attributes.texi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/manual/attributes.texi b/doc/manual/attributes.texi index 980566a41..6e3cf43ad 100644 --- a/doc/manual/attributes.texi +++ b/doc/manual/attributes.texi @@ -489,6 +489,24 @@ the attribute system: @item ATTRIBUTE_HELPER_CPP @end itemize +@subsection Initialization order + +In general, the attribute code to assign values to the underlying +class member variables is executed after an object is constructed. +But what if you need the values assigned before the constructor +body executes, because you need them in the logic of the constructor? +There is a way to do this, used for example in the class +@code{ns3::ConfigStore}: call @code{ObjectBase::ConstructSelf()} +as follows: + +@verbatim +ConfigStore::ConfigStore () +{ + ObjectBase::ConstructSelf (AttributeList ()); + // continue on with constructor. +} +@end verbatim + @node Extending attributes @section Extending attributes From 3ae5224641e25b7a4ed5449103abeb6f00d74401 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Tue, 11 Aug 2009 21:29:18 -0700 Subject: [PATCH 06/28] fix Ipv4 doxygen error --- src/node/ipv4.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node/ipv4.h b/src/node/ipv4.h index 301b87769..833fa7281 100644 --- a/src/node/ipv4.h +++ b/src/node/ipv4.h @@ -37,7 +37,9 @@ class Ipv4RoutingProtocol; /** * \ingroup node * \defgroup ipv4 Ipv4 - * + */ +/** + * \ingroup ipv4 * \brief Access to the Ipv4 forwarding table, interfaces, and configuration * * This class defines the API to manipulate the following aspects of From 0ceaecc18ff38ddae920f0b48f3af4194f580168 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Wed, 12 Aug 2009 12:07:25 +0100 Subject: [PATCH 07/28] Reorder the #includes in ns3module_helpers.cc to solve Fedora 11 compilation error --- bindings/python/ns3module_helpers.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/ns3module_helpers.cc b/bindings/python/ns3module_helpers.cc index 85d0884c9..c7692a0bb 100644 --- a/bindings/python/ns3module_helpers.cc +++ b/bindings/python/ns3module_helpers.cc @@ -1,5 +1,5 @@ -#include "ns3/ref-count-base.h" #include "ns3module.h" +#include "ns3/ref-count-base.h" namespace ns3{ From 63802def2019d95920b4990b32788ccce449bd99 Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Thu, 13 Aug 2009 08:45:47 +0200 Subject: [PATCH 08/28] add an implementation of the minstrel rate control algorithm --- src/devices/wifi/minstrel-wifi-manager.cc | 720 ++++++++++++++++++++++ src/devices/wifi/minstrel-wifi-manager.h | 255 ++++++++ src/devices/wifi/wscript | 2 + 3 files changed, 977 insertions(+) create mode 100644 src/devices/wifi/minstrel-wifi-manager.cc create mode 100644 src/devices/wifi/minstrel-wifi-manager.h diff --git a/src/devices/wifi/minstrel-wifi-manager.cc b/src/devices/wifi/minstrel-wifi-manager.cc new file mode 100644 index 000000000..5dd91ef69 --- /dev/null +++ b/src/devices/wifi/minstrel-wifi-manager.cc @@ -0,0 +1,720 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2009 Duy Nguyen + * + * 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Duy Nguyen + * + * Some Comments: + * + * 1) Segment Size is declared for completeness but not used because it has + * to do more with the requirement of the specific hardware. + * + * 2) By default, Minstrel applies the multi-rate retry(the core of Minstrel + * algorithm). Otherwise, please use ConstantRateWifiManager instead. + * + * http://linuxwireless.org/en/developers/Documentation/mac80211/RateControl/minstrel + */ + + + +#include "minstrel-wifi-manager.h" +#include "wifi-phy.h" +#include "ns3/random-variable.h" +#include "ns3/simulator.h" +#include "ns3/log.h" +#include "ns3/uinteger.h" +#include "ns3/double.h" +#include "ns3/wifi-mac.h" +#include "ns3/assert.h" +#include + +NS_LOG_COMPONENT_DEFINE ("MinstrelWifiManager"); + + +namespace ns3 { + +NS_OBJECT_ENSURE_REGISTERED (MinstrelWifiManager); + +TypeId +MinstrelWifiManager::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::MinstrelWifiManager") + .SetParent () + .AddConstructor () + .AddAttribute ("UpdateStatistics", + "The interval between updating statistics table ", + TimeValue (Seconds (0.1)), + MakeTimeAccessor (&MinstrelWifiManager::m_updateStats), + MakeTimeChecker ()) + .AddAttribute ("LookAroundRate", + "the percentage to try other rates", + DoubleValue (10), + MakeDoubleAccessor (&MinstrelWifiManager::m_lookAroundRate), + MakeDoubleChecker ()) + .AddAttribute ("EWMA", + "EWMA level", + DoubleValue (75), + MakeDoubleAccessor (&MinstrelWifiManager::m_ewmaLevel), + MakeDoubleChecker ()) + .AddAttribute ("SegmentSize", + "The largest allowable segment size packet", + DoubleValue (6000), + MakeDoubleAccessor (&MinstrelWifiManager::m_segmentSize), + MakeDoubleChecker ()) + .AddAttribute ("SampleColumn", + "The number of columns used for sampling", + DoubleValue (10), + MakeDoubleAccessor (&MinstrelWifiManager::m_sampleCol), + MakeDoubleChecker ()) + .AddAttribute ("PacketLength", + "The packet length used for calculating mode TxTime", + DoubleValue (1200), + MakeDoubleAccessor (&MinstrelWifiManager::m_pktLen), + MakeDoubleChecker ()) + ; + return tid; +} + +MinstrelWifiManager::MinstrelWifiManager () +{} + +MinstrelWifiManager::~MinstrelWifiManager () +{} + +void +MinstrelWifiManager::SetupPhy (Ptr phy) +{ + uint32_t nModes = phy->GetNModes (); + for (uint32_t i = 0; i < nModes; i++) + { + WifiMode mode = phy->GetMode (i); + AddCalcTxTime (mode, phy->CalculateTxDuration (m_pktLen, mode, WIFI_PREAMBLE_LONG)); + } + WifiRemoteStationManager::SetupPhy (phy); +} + +WifiRemoteStation * +MinstrelWifiManager::CreateStation (void) +{ + return new MinstrelWifiRemoteStation (this); +} + +Time +MinstrelWifiManager::GetCalcTxTime (WifiMode mode) const +{ + + for (TxTime::const_iterator i = m_calcTxTime.begin (); i != m_calcTxTime.end (); i++) + { + if (mode == i->second) + { + return i->first; + } + } + NS_ASSERT (false); + return Seconds (0); +} + +void +MinstrelWifiManager::AddCalcTxTime (WifiMode mode, Time t) +{ + m_calcTxTime.push_back (std::make_pair (t, mode)); +} + +MinstrelWifiRemoteStation::MinstrelWifiRemoteStation (Ptr stations) + :m_stations (stations), + m_nextStatsUpdate (Simulator::Now () + stations->m_updateStats), + m_col (0), + m_index (0), + m_maxTpRate (0), + m_maxTpRate2 (0), + m_maxProbRate (0), + m_packetCount (0), + m_sampleCount (0), + m_isSampling (false), + m_sampleRate (0), + m_sampleRateSlower (false), + m_currentRate (0), + m_shortRetry (0), + m_longRetry (0), + m_retry (0), + m_err (0), + m_txrate (0), + m_initialized (false) +{} + +MinstrelWifiRemoteStation::~MinstrelWifiRemoteStation () +{} + +void +MinstrelWifiRemoteStation::CheckInit(void) +{ + if (!m_initialized) + { + m_minstrelTable = MinstrelRate(GetNSupportedModes ()); + m_sampleTable = SampleRate(GetNSupportedModes (), std::vector (m_stations->m_sampleCol)); + InitSampleTable (); + RateInit (); + m_initialized = true; + } +} + +void +MinstrelWifiRemoteStation::DoReportRxOk (double rxSnr, WifiMode txMode) +{ + NS_LOG_DEBUG("DoReportRxOk m_txrate=" << m_txrate); +} + +void +MinstrelWifiRemoteStation::DoReportRtsFailed (void) +{ + NS_LOG_DEBUG("DoReportRtsFailed m_txrate=" << m_txrate); + + m_shortRetry++; +} + +void +MinstrelWifiRemoteStation::DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr) +{ + NS_LOG_DEBUG ("self="< (m_minstrelTable[m_txrate].adjustedRetryCount + + m_minstrelTable[m_maxTpRate2].adjustedRetryCount + + m_minstrelTable[m_maxTpRate].adjustedRetryCount)) + { + m_txrate = 0; + } + } + + /// for look-around rate, we're currently sampling random rates + else + { + /// current sampling rate is slower than the current best rate + if (m_sampleRateSlower) + { + /// use best throughput rate + if (m_longRetry < m_minstrelTable[m_txrate].adjustedRetryCount) + { + ; ///< there are a few retries left + } + + /// use random rate + else if (m_longRetry <= (m_minstrelTable[m_txrate].adjustedRetryCount + + m_minstrelTable[m_maxTpRate].adjustedRetryCount)) + { + m_txrate = m_sampleRate; + } + + /// use max probability rate + else if (m_longRetry <= (m_minstrelTable[m_txrate].adjustedRetryCount + + m_minstrelTable[m_sampleRate].adjustedRetryCount + + m_minstrelTable[m_maxTpRate].adjustedRetryCount )) + { + m_txrate = m_maxProbRate; + } + + /// use lowest base rate + else if (m_longRetry > (m_minstrelTable[m_txrate].adjustedRetryCount + + m_minstrelTable[m_sampleRate].adjustedRetryCount + + m_minstrelTable[m_maxTpRate].adjustedRetryCount)) + { + m_txrate = 0; + } + } + + /// current sampling rate is better than current best rate + else + { + /// use random rate + if (m_longRetry < m_minstrelTable[m_txrate].adjustedRetryCount) + { + ; ///< keep using it + } + + /// use the best rate + else if (m_longRetry <= m_minstrelTable[m_txrate].adjustedRetryCount + + m_minstrelTable[m_sampleRate].adjustedRetryCount) + { + m_txrate = m_maxTpRate; + } + + /// use the best probability rate + else if (m_longRetry <= m_minstrelTable[m_txrate].adjustedRetryCount + + m_minstrelTable[m_maxTpRate].adjustedRetryCount + + m_minstrelTable[m_sampleRate].adjustedRetryCount) + { + m_txrate = m_maxProbRate; + } + + /// use the lowest base rate + else if (m_longRetry > m_minstrelTable[m_txrate].adjustedRetryCount + + m_minstrelTable[m_maxTpRate].adjustedRetryCount + + m_minstrelTable[m_sampleRate].adjustedRetryCount) + { + m_txrate = 0; + } + } + } +} + +void +MinstrelWifiRemoteStation::DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr) +{ + m_isSampling = false; + m_sampleRateSlower=false; + + CheckInit (); + + m_minstrelTable[m_txrate].numRateSuccess++; + m_minstrelTable[m_txrate].numRateAttempt++; + + UpdateRetry (); + + m_minstrelTable[m_txrate].numRateAttempt += m_retry; + m_packetCount++; + + if (GetNSupportedModes () >= 1) + { + m_txrate = FindRate (); + } +} + +void +MinstrelWifiRemoteStation::DoReportFinalDataFailed (void) +{ + NS_LOG_DEBUG ("DoReportFinalDataFailed m_txrate=" << m_txrate); + + m_isSampling = false; + m_sampleRateSlower=false; + + UpdateRetry (); + + m_minstrelTable[m_txrate].numRateAttempt += m_retry; + m_err++; + + if (GetNSupportedModes () >= 1) + { + m_txrate = FindRate (); + } +} + +void +MinstrelWifiRemoteStation::UpdateRetry (void) +{ + m_retry = m_shortRetry + m_longRetry; + m_shortRetry = 0; + m_longRetry = 0; +} + +Ptr +MinstrelWifiRemoteStation::GetManager (void) const +{ + return m_stations; +} + +WifiMode +MinstrelWifiRemoteStation::DoGetDataMode (uint32_t size) +{ + UpdateStats (); + if (!m_initialized) + { + CheckInit (); + + /// start the rate at half way + m_txrate = GetNSupportedModes () / 2; + } + return GetSupportedMode (m_txrate); +} + +WifiMode +MinstrelWifiRemoteStation::DoGetRtsMode (void) +{ + NS_LOG_DEBUG ("DoGetRtsMode m_txrate=" << m_txrate); + + UpdateStats (); + return GetSupportedMode (0); +} + +uint32_t +MinstrelWifiRemoteStation::GetNextSample () +{ + uint32_t bitrate; + bitrate = m_sampleTable[m_index][m_col]; + m_index++; + + /// bookeeping for m_index and m_col variables + if (m_index > (GetNSupportedModes () -2)) + { + m_index =0; + m_col++; + if (m_col >= m_stations->m_sampleCol) + { + m_col = 0; + } + } + return bitrate; +} + +uint32_t +MinstrelWifiRemoteStation::FindRate () +{ + NS_LOG_DEBUG ("FindRate " << "packet=" << m_packetCount ); + + if ((m_sampleCount + m_packetCount) == 0) + { + return 0; + } + + + uint32_t idx; + + /// for determining when to try a sample rate + UniformVariable coinFlip (0, 100); + + /** + * if we are below the target of look around rate percentage, look around + * note: do it randomly by flipping a coin instead sampling + * all at once until it reaches the look around rate + */ + if ( (((100* m_sampleCount) / (m_sampleCount + m_packetCount )) < m_stations->m_lookAroundRate) && + ((int)coinFlip.GetValue ()) % 2 == 1 ) + { + + /// now go through the table and find an index rate + idx = GetNextSample (); + + + /** + * This if condition is used to make sure that we don't need to use + * the sample rate it is the same as our current rate + */ + if (idx != m_maxTpRate && idx != m_txrate) + { + + /// start sample count + m_sampleCount++; + + /// set flag that we are currently sampling + m_isSampling = true; + + /// bookeeping for resetting stuff + if (m_packetCount >= 10000) + { + m_sampleCount = 0; + m_packetCount = 0; + } + + /// error check + if (idx >= GetNSupportedModes () || idx < 0 ) + { + NS_LOG_DEBUG ("ALERT!!! ERROR"); + } + + /// set the rate that we're currently sampling + m_sampleRate = idx; + + if (m_sampleRate == m_maxTpRate) + { + m_sampleRate = m_maxTpRate2; + } + + /// is this rate slower than the current best rate + m_sampleRateSlower = (m_minstrelTable[idx].perfectTxTime > m_minstrelTable[m_maxTpRate].perfectTxTime); + + /// using the best rate instead + if (m_sampleRateSlower) + { + idx = m_maxTpRate; + } + } + + } + + /// continue using the best rate + else + { + idx = m_maxTpRate; + } + + + NS_LOG_DEBUG ("FindRate " << "sample rate=" << idx); + + return idx; +} + +void +MinstrelWifiRemoteStation::UpdateStats () +{ + if (Simulator::Now () < m_nextStatsUpdate) + { + return; + } + + NS_LOG_DEBUG ("Updating stats="<m_updateStats; + + Time txTime; + uint32_t tempProb; + + for (uint32_t i =0; i < GetNSupportedModes (); i++) + { + + /// calculate the perfect tx time for this rate + txTime = m_minstrelTable[i].perfectTxTime; + + /// just for initialization + if (txTime.GetMicroSeconds () == 0) + { + txTime = Seconds (1); + } + + NS_LOG_DEBUG ("m_txrate=" << m_txrate << "\t attempt=" << m_minstrelTable[i].numRateAttempt << "\t success=" << m_minstrelTable[i].numRateSuccess); + + /// if we've attempted something + if (m_minstrelTable[i].numRateAttempt) + { + /** + * calculate the probability of success + * assume probability scales from 0 to 18000 + */ + tempProb = (m_minstrelTable[i].numRateSuccess * 18000) / m_minstrelTable[i].numRateAttempt; + + /// bookeeping + m_minstrelTable[i].successHist += m_minstrelTable[i].numRateSuccess; + m_minstrelTable[i].attemptHist += m_minstrelTable[i].numRateAttempt; + m_minstrelTable[i].prob = tempProb; + + /// ewma probability + tempProb = ((tempProb * (100 - m_stations->m_ewmaLevel)) + (m_minstrelTable[i].ewmaProb * m_stations->m_ewmaLevel) )/100; + + m_minstrelTable[i].ewmaProb = tempProb; + + /// calculating throughput + m_minstrelTable[i].throughput = tempProb * (1000000 / txTime.GetMicroSeconds()); + + } + + /// bookeeping + m_minstrelTable[i].prevNumRateAttempt= m_minstrelTable[i].numRateAttempt; + m_minstrelTable[i].prevNumRateSuccess = m_minstrelTable[i].numRateSuccess; + m_minstrelTable[i].numRateSuccess = 0; + m_minstrelTable[i].numRateAttempt = 0; + + /// Sample less often below 10% and above 95% of success + if ((m_minstrelTable[i].ewmaProb > 17100) || (m_minstrelTable[i].ewmaProb < 1800)) + { + /** + * retry count denotes the number of retries permitted for each rate + * # retry_count/2 + */ + m_minstrelTable[i].adjustedRetryCount = m_minstrelTable[i].retryCount >> 1; + if (m_minstrelTable[i].adjustedRetryCount > 2) + { + m_minstrelTable[i].adjustedRetryCount = 2 ; + } + } + else + { + m_minstrelTable[i].adjustedRetryCount = m_minstrelTable[i].retryCount; + } + + /// if it's 0 allow one retry limit + if (m_minstrelTable[i].adjustedRetryCount == 0) + { + m_minstrelTable[i].adjustedRetryCount = 1; + } + } + + + uint32_t max_prob = 0, index_max_prob =0, max_tp =0, index_max_tp=0, index_max_tp2=0; + + /// go find max throughput, second maximum throughput, high probability succ + for (uint32_t i =0; i < GetNSupportedModes (); i++) + { + NS_LOG_DEBUG ("throughput" << m_minstrelTable[i].throughput << "\n ewma" << m_minstrelTable[i].ewmaProb); + + if (max_tp < m_minstrelTable[i].throughput) + { + index_max_tp = i; + max_tp = m_minstrelTable[i].throughput; + } + + if (max_prob < m_minstrelTable[i].ewmaProb) + { + index_max_prob = i; + max_prob = m_minstrelTable[i].ewmaProb; + } + } + + + max_tp = 0; + /// find the second highest max + for (uint32_t i =0; i < GetNSupportedModes (); i++) + { + if ((i != index_max_tp) && (max_tp < m_minstrelTable[i].throughput)) + { + index_max_tp2 = i; + max_tp = m_minstrelTable[i].throughput; + } + } + + m_maxTpRate = index_max_tp; + m_maxTpRate2 = index_max_tp2; + m_maxProbRate = index_max_prob; + m_currentRate = index_max_tp; + + if (index_max_tp > m_txrate) + { + m_txrate= index_max_tp; + } + + NS_LOG_DEBUG ("max tp="<< index_max_tp << "\nmax tp2="<< index_max_tp2<< "\nmax prob="<< index_max_prob); + + /// reset it + RateInit (); +} + +void +MinstrelWifiRemoteStation::RateInit () +{ + NS_LOG_DEBUG ("RateInit="<GetCalcTxTime (GetSupportedMode (i)); + m_minstrelTable[i].retryCount =1; + m_minstrelTable[i].adjustedRetryCount =1; + } +} + +void +MinstrelWifiRemoteStation::InitSampleTable () +{ + NS_LOG_DEBUG ("InitSampleTable="<m_sampleCol; col++) + { + for (uint32_t i = 0; i < numSampleRates; i++ ) + { + + /** + * The next two lines basically tries to generate a random number + * between 0 and the number of available rates + */ + UniformVariable uv (0, numSampleRates); + newIndex = (i + (uint32_t)uv.GetValue ()) % numSampleRates; + + /// this loop is used for filling in other uninitilized places + while (m_sampleTable[newIndex][col] != 0) + { + newIndex = (newIndex + 1)%GetNSupportedModes (); + } + m_sampleTable[newIndex][col] = i+1; + + } + } +} + +void +MinstrelWifiRemoteStation::PrintSampleTable () +{ + NS_LOG_DEBUG ("PrintSampleTable="<m_sampleCol; j++) + { + std::cout << m_sampleTable[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +void +MinstrelWifiRemoteStation::PrintTable () +{ + NS_LOG_DEBUG ("PrintTable="< + */ + + + +#ifndef MINSTREL_WIFI_MANAGER_H +#define MINSTREL_WIFI_MANAGER_H + +#include "wifi-remote-station-manager.h" +#include "wifi-mode.h" +#include "ns3/nstime.h" +#include + + + +/** + * \author Duy Nguyen + * \brief Implementation of Minstrel Rate Control Algorithm + * + * Porting Minstrel from Madwifi and Linux Kernel + * http://linuxwireless.org/en/developers/Documentation/mac80211/RateControl/minstrel + */ + + +namespace ns3 { + + +/** + * A struct to contain all information related to a data rate + */ +struct RateInfo{ + + /** + * Perfect transmission time calculation, or frame calculation + * Given a bit rate and a packet length n bytes + */ + Time perfectTxTime; + + + uint32_t retryCount; ///< retry limit + uint32_t adjustedRetryCount; ///< adjust the retry limit for this rate + uint32_t numRateAttempt; ///< how many number of attempts so far + uint32_t numRateSuccess; ///< number of successful pkts + uint32_t prob; ///< (# pkts success )/(# total pkts) + + /** + * EWMA calculation + * ewma_prob =[prob *(100 - ewma_level) + (ewma_prob_old * ewma_level)]/100 + */ + uint32_t ewmaProb; + + uint32_t prevNumRateAttempt; ///< from last rate + uint32_t prevNumRateSuccess; ///< from last rate + uint64_t successHist; ///< aggregate of all successes + uint64_t attemptHist; ///< aggregate of all attempts + uint32_t throughput; ///< throughput of a rate +}; + +/** + * Data structure for a Minstrel Rate table + * A vector of a struct RateInfo + */ +typedef std::vector MinstrelRate; + +/** + * Data structure for a Sample Rate table + * A vector of a vector uint32_t + */ +typedef std::vector > SampleRate; + + +class MinstrelWifiManager : public WifiRemoteStationManager +{ + +public: + static TypeId GetTypeId (void); + MinstrelWifiManager (); + virtual ~MinstrelWifiManager(); + + virtual void SetupPhy (Ptr phy); + + /// for estimating the TxTime of a packet with a given mode + Time GetCalcTxTime (WifiMode mode) const; + void AddCalcTxTime (WifiMode mode, Time t); + +private: + friend class MinstrelWifiRemoteStation; + virtual class WifiRemoteStation *CreateStation (void); + + typedef std::vector > TxTime; + + TxTime m_calcTxTime; ///< to hold all the calculated TxTime for all modes + Time m_updateStats; ///< how frequent do we calculate the stats(1/10 seconds) + double m_lookAroundRate; ///< the % to try other rates than our current rate + double m_ewmaLevel; ///< exponential weighted moving average + uint32_t m_segmentSize; ///< largest allowable segment size + uint32_t m_sampleCol; ///< number of sample columns + uint32_t m_pktLen; ///< packet length used for calculate mode TxTime + +}; + +class MinstrelWifiRemoteStation : public WifiRemoteStation +{ +public: + MinstrelWifiRemoteStation (Ptr stations); + + virtual ~MinstrelWifiRemoteStation (); + +protected: + + /** + * when packet is successfully received + * see wifi-remote-station-manager.h for more documentation + */ + virtual void DoReportRxOk (double rxSnr, WifiMode txMode); + + /// when RTS timeout expires + virtual void DoReportRtsFailed (void); + + + /** + * + * Retry Chain table is implemented here + * + * Try | LOOKAROUND RATE | NORMAL RATE + * | random < best | random > best | + * -------------------------------------------------------------- + * 1 | Best throughput | Random rate | Best throughput + * 2 | Random rate | Best throughput | Next best throughput + * 3 | Best probability | Best probability | Best probability + * 4 | Lowest Baserate | Lowest baserate | Lowest baserate + * + * Note: For clarity, multiple blocks of if's and else's are used + * After a failing 7 times, DoReportFinalDataFailed will be called + */ + virtual void DoReportDataFailed (void); + + /// when receive a CTS, associated with an RTS + virtual void DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr); + + /// when an ACK, associated with a data pkt, is received + virtual void DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr); + + /// after calling ReportRtsFailed if NeedRtsRetransmission returns false + virtual void DoReportFinalRtsFailed (void); + + /// after calling ReportDataFailed if NeedDataRetransmission returns false + virtual void DoReportFinalDataFailed (void); + + +private: + virtual Ptr GetManager (void) const; + + /** + * returns the transmission mode for sending this packet + * this function gets called when node is getting ready to send DATA + * see wifi-remote-station-manager.h for more documentation + */ + virtual WifiMode DoGetDataMode (uint32_t size); + + /// returns the transmission mode for sending RTS packet + virtual WifiMode DoGetRtsMode (void); + + /// update the number of retries and reset accordingly + void UpdateRetry (void); + + /// getting the next sample from Sample Table + uint32_t GetNextSample (void); + + /// find a rate to use from Minstrel Table + uint32_t FindRate (void); + + /// updating the Minstrel Table every 1/10 seconds + void UpdateStats (void); + + /// initialize Minstrel Table + void RateInit (void); + + /// initialize Sample Table + void InitSampleTable (void); + + /// printing Sample Table + void PrintSampleTable (void); + + /// printing Minstrel Table + void PrintTable (void); + + /** + * \param packet lenghth + * \param current WifiMode + * \returns calcuated transmit duration + */ + Time CalcRatePacket (uint32_t, WifiMode); + + void CheckInit(void); ///< check for initializations + + Ptr m_stations; + + Time m_nextStatsUpdate; ///< 10 times every second + + MinstrelRate m_minstrelTable; ///< minstrel table + + SampleRate m_sampleTable; ///< sample table + + /** + * To keep track of the current position in the our random sample table + * going row by row from 1st column until the 10th column(Minstrel defines 10) + * then we wrap back to the row 1 col 1. + * note: there are many other ways to do this. + */ + uint32_t m_col, m_index; + + uint32_t m_maxTpRate; ///< the current throughput rate + uint32_t m_maxTpRate2; ///< second highest throughput rate + uint32_t m_maxProbRate; ///< rate with highest prob of success + + int m_packetCount; ///< total number of packets as of now + int m_sampleCount; ///< how many packets we have sample so far + + bool m_isSampling; ///< a flag to indicate we are currently sampling + uint32_t m_sampleRate; ///< current sample rate + bool m_sampleRateSlower; ///< a flag to indicate sample rate is slower + uint32_t m_currentRate; ///< current rate we are using + + uint32_t m_shortRetry; ///< short retries such as control packts + uint32_t m_longRetry; ///< long retries such as data packets + uint32_t m_retry; ///< total retries short + long + uint32_t m_err; ///< retry errors + uint32_t m_txrate; ///< current transmit rate + + bool m_initialized; ///< for initializing tables + + +}; + +}// namespace ns3 + +#endif /* MINSTREL_WIFI_MANAGER_H */ diff --git a/src/devices/wifi/wscript b/src/devices/wifi/wscript index 82e0195d4..e265afaf6 100644 --- a/src/devices/wifi/wscript +++ b/src/devices/wifi/wscript @@ -63,6 +63,7 @@ def build(bld): 'msdu-aggregator.cc', 'amsdu-subframe-header.cc', 'msdu-standard-aggregator.cc', + 'minstrel-wifi-manager.cc', ] headers = bld.new_task_gen('ns3header') headers.module = 'wifi' @@ -113,6 +114,7 @@ def build(bld): 'dcf-manager.h', 'mac-rx-middle.h', 'mac-low.h', + 'minstrel-wifi-manager.h' ] if bld.env['ENABLE_GSL']: From 11679dc9c571ec3cf363ccbda40be98f238fc2ea Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Thu, 13 Aug 2009 08:47:59 +0200 Subject: [PATCH 09/28] stub release notes for 3.6 --- RELEASE_NOTES | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 79f4dbce8..651628914 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -6,6 +6,50 @@ This file contains ns-3 release notes (most recent releases first). All of the ns-3 documentation is accessible from the ns-3 website: http://www.nsnam.org including tutorials: http://www.nsnam.org/tutorials.html +Release 3.6 +=========== + +Availability +------------ +This release is immediately available from: +http://www.nsnam.org/releases/ns-allinone-3.6.tar.bz2 + +Supported platforms +------------------- +ns-3.6 has been tested on the following platforms: + - linux x86 gcc 4.2, 4.1, and, 3.4.6. + - linux x86_64 gcc 4.4.0, 4.3.2, 4.2.3, 4.2.1, 4.1.3, 3.4.6 + - MacOS X ppc and x86 (gcc 4.0.x and 4.2.x) + - cygwin gcc 3.4.4 (debug only), gcc 4.3.2 (debug and optimized) + - mingw gcc 3.4.5 (debug only) + +Not all ns-3 options are available on all platforms; consult the +wiki for more information: +http://www.nsnam.org/wiki/index.php/Installation + +New user-visible features +------------------------- + + - Add an implementation of the minstrel rate control algorithm + (Duy Nguyen for gsoc) + + +API changes from ns-3.5 +----------------------- +API changes for this release are documented in the file CHANGES.html. +XXX + +Known issues +------------ +ns-3 build is known to fail on the following platforms: + - gcc 3.3 and earlier + - optimized builds on gcc 3.4.4 and 3.4.5 + - optimized builds on linux x86 gcc 4.0.x + +Future releases +--------------- +XXX + Release 3.5 =========== From b632c051c7845c3ccb6912bf68098fba29d903fe Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Thu, 13 Aug 2009 09:06:01 +0200 Subject: [PATCH 10/28] rescan python --- bindings/python/callbacks_list.py | 1 + bindings/python/ns3_module_wifi.py | 990 ++++++++++++++++++++++++++++- 2 files changed, 990 insertions(+), 1 deletion(-) diff --git a/bindings/python/callbacks_list.py b/bindings/python/callbacks_list.py index 0058d7106..3e1a882b1 100644 --- a/bindings/python/callbacks_list.py +++ b/bindings/python/callbacks_list.py @@ -2,6 +2,7 @@ callback_classes = [ ['void', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['bool', 'ns3::Ptr', 'ns3::Address const&', 'ns3::Address const&', 'unsigned short', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Ptr', 'ns3::Mac48Address', 'ns3::Mac48Address', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], + ['void', 'ns3::Ptr', 'ns3::WifiMacHeader const*', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Ptr', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Ptr', 'unsigned int', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Ptr', 'ns3::Address const&', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], diff --git a/bindings/python/ns3_module_wifi.py b/bindings/python/ns3_module_wifi.py index 06db78743..bb258387b 100644 --- a/bindings/python/ns3_module_wifi.py +++ b/bindings/python/ns3_module_wifi.py @@ -4,7 +4,7 @@ def register_types(module): root_module = module.get_root() ## wifi-mac-header.h: ns3::WifiMacType [enumeration] - module.add_enum('WifiMacType', ['WIFI_MAC_CTL_RTS', 'WIFI_MAC_CTL_CTS', 'WIFI_MAC_CTL_ACK', 'WIFI_MAC_CTL_BACKREQ', 'WIFI_MAC_CTL_BACKRESP', 'WIFI_MAC_MGT_BEACON', 'WIFI_MAC_MGT_ASSOCIATION_REQUEST', 'WIFI_MAC_MGT_ASSOCIATION_RESPONSE', 'WIFI_MAC_MGT_DISASSOCIATION', 'WIFI_MAC_MGT_REASSOCIATION_REQUEST', 'WIFI_MAC_MGT_REASSOCIATION_RESPONSE', 'WIFI_MAC_MGT_PROBE_REQUEST', 'WIFI_MAC_MGT_PROBE_RESPONSE', 'WIFI_MAC_MGT_AUTHENTICATION', 'WIFI_MAC_MGT_DEAUTHENTICATION', 'WIFI_MAC_DATA', 'WIFI_MAC_DATA_CFACK', 'WIFI_MAC_DATA_CFPOLL', 'WIFI_MAC_DATA_CFACK_CFPOLL', 'WIFI_MAC_DATA_NULL', 'WIFI_MAC_DATA_NULL_CFACK', 'WIFI_MAC_DATA_NULL_CFPOLL', 'WIFI_MAC_DATA_NULL_CFACK_CFPOLL', 'WIFI_MAC_QOSDATA', 'WIFI_MAC_QOSDATA_CFACK', 'WIFI_MAC_QOSDATA_CFPOLL', 'WIFI_MAC_QOSDATA_CFACK_CFPOLL', 'WIFI_MAC_QOSDATA_NULL', 'WIFI_MAC_QOSDATA_NULL_CFPOLL', 'WIFI_MAC_QOSDATA_NULL_CFACK_CFPOLL']) + module.add_enum('WifiMacType', ['WIFI_MAC_CTL_RTS', 'WIFI_MAC_CTL_CTS', 'WIFI_MAC_CTL_ACK', 'WIFI_MAC_CTL_BACKREQ', 'WIFI_MAC_CTL_BACKRESP', 'WIFI_MAC_MGT_BEACON', 'WIFI_MAC_MGT_ASSOCIATION_REQUEST', 'WIFI_MAC_MGT_ASSOCIATION_RESPONSE', 'WIFI_MAC_MGT_DISASSOCIATION', 'WIFI_MAC_MGT_REASSOCIATION_REQUEST', 'WIFI_MAC_MGT_REASSOCIATION_RESPONSE', 'WIFI_MAC_MGT_PROBE_REQUEST', 'WIFI_MAC_MGT_PROBE_RESPONSE', 'WIFI_MAC_MGT_AUTHENTICATION', 'WIFI_MAC_MGT_DEAUTHENTICATION', 'WIFI_MAC_MGT_ACTION', 'WIFI_MAC_MGT_ACTION_NO_ACK', 'WIFI_MAC_MGT_MULTIHOP_ACTION', 'WIFI_MAC_DATA', 'WIFI_MAC_DATA_CFACK', 'WIFI_MAC_DATA_CFPOLL', 'WIFI_MAC_DATA_CFACK_CFPOLL', 'WIFI_MAC_DATA_NULL', 'WIFI_MAC_DATA_NULL_CFACK', 'WIFI_MAC_DATA_NULL_CFPOLL', 'WIFI_MAC_DATA_NULL_CFACK_CFPOLL', 'WIFI_MAC_QOSDATA', 'WIFI_MAC_QOSDATA_CFACK', 'WIFI_MAC_QOSDATA_CFPOLL', 'WIFI_MAC_QOSDATA_CFACK_CFPOLL', 'WIFI_MAC_QOSDATA_NULL', 'WIFI_MAC_QOSDATA_NULL_CFPOLL', 'WIFI_MAC_QOSDATA_NULL_CFACK_CFPOLL']) ## wifi-preamble.h: ns3::WifiPreamble [enumeration] module.add_enum('WifiPreamble', ['WIFI_PREAMBLE_LONG', 'WIFI_PREAMBLE_SHORT']) ## wifi-phy-standard.h: ns3::WifiPhyStandard [enumeration] @@ -13,12 +13,30 @@ def register_types(module): module.add_enum('AccessClass', ['AC_VO', 'AC_VI', 'AC_BE', 'AC_BK', 'AC_UNDEF']) ## edca-txop-n.h: ns3::TypeOfStation [enumeration] module.add_enum('TypeOfStation', ['STA', 'AP', 'ADHOC_STA']) + ## capability-information.h: ns3::CapabilityInformation [class] + module.add_class('CapabilityInformation') + ## dcf-manager.h: ns3::DcfManager [class] + module.add_class('DcfManager') + ## dcf-manager.h: ns3::DcfState [class] + module.add_class('DcfState', allow_subclassing=True) ## interference-helper.h: ns3::InterferenceHelper [class] module.add_class('InterferenceHelper', allow_subclassing=False) ## interference-helper.h: ns3::InterferenceHelper::SnrPer [struct] module.add_class('SnrPer', outer_class=root_module['ns3::InterferenceHelper']) + ## mac-low.h: ns3::MacLowDcfListener [class] + module.add_class('MacLowDcfListener', allow_subclassing=True) + ## mac-low.h: ns3::MacLowTransmissionListener [class] + module.add_class('MacLowTransmissionListener', allow_subclassing=True) + ## mac-low.h: ns3::MacLowTransmissionParameters [class] + module.add_class('MacLowTransmissionParameters') + ## mac-rx-middle.h: ns3::MacRxMiddle [class] + module.add_class('MacRxMiddle') + ## minstrel-wifi-manager.h: ns3::RateInfo [struct] + module.add_class('RateInfo') ## ssid.h: ns3::Ssid [class] module.add_class('Ssid') + ## status-code.h: ns3::StatusCode [class] + module.add_class('StatusCode') ## supported-rates.h: ns3::SupportedRates [class] module.add_class('SupportedRates') ## rraa-wifi-manager.h: ns3::ThresholdsItem [struct] @@ -41,6 +59,16 @@ def register_types(module): module.add_class('ConstantRateWifiRemoteStation', parent=root_module['ns3::WifiRemoteStation']) ## ideal-wifi-manager.h: ns3::IdealWifiRemoteStation [class] module.add_class('IdealWifiRemoteStation', parent=root_module['ns3::WifiRemoteStation']) + ## mgt-headers.h: ns3::MgtAssocRequestHeader [class] + module.add_class('MgtAssocRequestHeader', parent=root_module['ns3::Header']) + ## mgt-headers.h: ns3::MgtAssocResponseHeader [class] + module.add_class('MgtAssocResponseHeader', parent=root_module['ns3::Header']) + ## mgt-headers.h: ns3::MgtProbeRequestHeader [class] + module.add_class('MgtProbeRequestHeader', parent=root_module['ns3::Header']) + ## mgt-headers.h: ns3::MgtProbeResponseHeader [class] + module.add_class('MgtProbeResponseHeader', parent=root_module['ns3::Header']) + ## minstrel-wifi-manager.h: ns3::MinstrelWifiRemoteStation [class] + module.add_class('MinstrelWifiRemoteStation', parent=root_module['ns3::WifiRemoteStation']) ## onoe-wifi-manager.h: ns3::OnoeWifiRemoteStation [class] module.add_class('OnoeWifiRemoteStation', parent=root_module['ns3::WifiRemoteStation']) ## propagation-delay-model.h: ns3::PropagationDelayModel [class] @@ -111,6 +139,12 @@ def register_types(module): module.add_class('JakesPropagationLossModel', parent=root_module['ns3::PropagationLossModel']) ## propagation-loss-model.h: ns3::LogDistancePropagationLossModel [class] module.add_class('LogDistancePropagationLossModel', parent=root_module['ns3::PropagationLossModel']) + ## mac-low.h: ns3::MacLow [class] + module.add_class('MacLow', parent=root_module['ns3::Object']) + ## mgt-headers.h: ns3::MgtBeaconHeader [class] + module.add_class('MgtBeaconHeader', parent=root_module['ns3::MgtProbeResponseHeader']) + ## minstrel-wifi-manager.h: ns3::MinstrelWifiManager [class] + module.add_class('MinstrelWifiManager', parent=root_module['ns3::WifiRemoteStationManager']) ## msdu-aggregator.h: ns3::MsduAggregator [class] module.add_class('MsduAggregator', parent=root_module['ns3::Object']) ## propagation-loss-model.h: ns3::NakagamiPropagationLossModel [class] @@ -139,6 +173,8 @@ def register_types(module): module.add_class('YansWifiChannel', parent=root_module['ns3::WifiChannel']) ## aarf-wifi-manager.h: ns3::AarfWifiManager [class] module.add_class('AarfWifiManager', parent=root_module['ns3::ArfWifiManager']) + typehandlers.add_type_alias('std::vector< ns3::RateInfo, std::allocator< ns3::RateInfo > >', 'ns3::MinstrelRate') + typehandlers.add_type_alias('std::vector< std::vector< unsigned int, std::allocator< unsigned int > >, std::allocator< std::vector< unsigned int, std::allocator< unsigned int > > > >', 'ns3::SampleRate') typehandlers.add_type_alias('std::vector< ns3::ThresholdsItem, std::allocator< ns3::ThresholdsItem > >', 'ns3::Thresholds') ## Register a nested module for the namespace Config @@ -192,9 +228,18 @@ def register_types_ns3_olsr(module): def register_methods(root_module): + register_Ns3CapabilityInformation_methods(root_module, root_module['ns3::CapabilityInformation']) + register_Ns3DcfManager_methods(root_module, root_module['ns3::DcfManager']) + register_Ns3DcfState_methods(root_module, root_module['ns3::DcfState']) register_Ns3InterferenceHelper_methods(root_module, root_module['ns3::InterferenceHelper']) register_Ns3InterferenceHelperSnrPer_methods(root_module, root_module['ns3::InterferenceHelper::SnrPer']) + register_Ns3MacLowDcfListener_methods(root_module, root_module['ns3::MacLowDcfListener']) + register_Ns3MacLowTransmissionListener_methods(root_module, root_module['ns3::MacLowTransmissionListener']) + register_Ns3MacLowTransmissionParameters_methods(root_module, root_module['ns3::MacLowTransmissionParameters']) + register_Ns3MacRxMiddle_methods(root_module, root_module['ns3::MacRxMiddle']) + register_Ns3RateInfo_methods(root_module, root_module['ns3::RateInfo']) register_Ns3Ssid_methods(root_module, root_module['ns3::Ssid']) + register_Ns3StatusCode_methods(root_module, root_module['ns3::StatusCode']) register_Ns3SupportedRates_methods(root_module, root_module['ns3::SupportedRates']) register_Ns3ThresholdsItem_methods(root_module, root_module['ns3::ThresholdsItem']) register_Ns3WifiMode_methods(root_module, root_module['ns3::WifiMode']) @@ -205,6 +250,11 @@ def register_methods(root_module): register_Ns3ArfWifiRemoteStation_methods(root_module, root_module['ns3::ArfWifiRemoteStation']) register_Ns3ConstantRateWifiRemoteStation_methods(root_module, root_module['ns3::ConstantRateWifiRemoteStation']) register_Ns3IdealWifiRemoteStation_methods(root_module, root_module['ns3::IdealWifiRemoteStation']) + register_Ns3MgtAssocRequestHeader_methods(root_module, root_module['ns3::MgtAssocRequestHeader']) + register_Ns3MgtAssocResponseHeader_methods(root_module, root_module['ns3::MgtAssocResponseHeader']) + register_Ns3MgtProbeRequestHeader_methods(root_module, root_module['ns3::MgtProbeRequestHeader']) + register_Ns3MgtProbeResponseHeader_methods(root_module, root_module['ns3::MgtProbeResponseHeader']) + register_Ns3MinstrelWifiRemoteStation_methods(root_module, root_module['ns3::MinstrelWifiRemoteStation']) register_Ns3OnoeWifiRemoteStation_methods(root_module, root_module['ns3::OnoeWifiRemoteStation']) register_Ns3PropagationDelayModel_methods(root_module, root_module['ns3::PropagationDelayModel']) register_Ns3PropagationLossModel_methods(root_module, root_module['ns3::PropagationLossModel']) @@ -237,6 +287,9 @@ def register_methods(root_module): register_Ns3IdealWifiManager_methods(root_module, root_module['ns3::IdealWifiManager']) register_Ns3JakesPropagationLossModel_methods(root_module, root_module['ns3::JakesPropagationLossModel']) register_Ns3LogDistancePropagationLossModel_methods(root_module, root_module['ns3::LogDistancePropagationLossModel']) + register_Ns3MacLow_methods(root_module, root_module['ns3::MacLow']) + register_Ns3MgtBeaconHeader_methods(root_module, root_module['ns3::MgtBeaconHeader']) + register_Ns3MinstrelWifiManager_methods(root_module, root_module['ns3::MinstrelWifiManager']) register_Ns3MsduAggregator_methods(root_module, root_module['ns3::MsduAggregator']) register_Ns3NakagamiPropagationLossModel_methods(root_module, root_module['ns3::NakagamiPropagationLossModel']) register_Ns3NqapWifiMac_methods(root_module, root_module['ns3::NqapWifiMac']) @@ -253,6 +306,200 @@ def register_methods(root_module): register_Ns3AarfWifiManager_methods(root_module, root_module['ns3::AarfWifiManager']) return +def register_Ns3CapabilityInformation_methods(root_module, cls): + ## capability-information.h: ns3::CapabilityInformation::CapabilityInformation(ns3::CapabilityInformation const & arg0) [copy constructor] + cls.add_constructor([param('ns3::CapabilityInformation const &', 'arg0')]) + ## capability-information.h: ns3::CapabilityInformation::CapabilityInformation() [constructor] + cls.add_constructor([]) + ## capability-information.h: void ns3::CapabilityInformation::SetEss() [member function] + cls.add_method('SetEss', + 'void', + []) + ## capability-information.h: void ns3::CapabilityInformation::SetIbss() [member function] + cls.add_method('SetIbss', + 'void', + []) + ## capability-information.h: bool ns3::CapabilityInformation::IsEss() const [member function] + cls.add_method('IsEss', + 'bool', + [], + is_const=True) + ## capability-information.h: bool ns3::CapabilityInformation::IsIbss() const [member function] + cls.add_method('IsIbss', + 'bool', + [], + is_const=True) + ## capability-information.h: uint32_t ns3::CapabilityInformation::GetSerializedSize() const [member function] + cls.add_method('GetSerializedSize', + 'uint32_t', + [], + is_const=True) + ## capability-information.h: ns3::Buffer::Iterator ns3::CapabilityInformation::Serialize(ns3::Buffer::Iterator start) const [member function] + cls.add_method('Serialize', + 'ns3::Buffer::Iterator', + [param('ns3::Buffer::Iterator', 'start')], + is_const=True) + ## capability-information.h: ns3::Buffer::Iterator ns3::CapabilityInformation::Deserialize(ns3::Buffer::Iterator start) [member function] + cls.add_method('Deserialize', + 'ns3::Buffer::Iterator', + [param('ns3::Buffer::Iterator', 'start')]) + return + +def register_Ns3DcfManager_methods(root_module, cls): + ## dcf-manager.h: ns3::DcfManager::DcfManager(ns3::DcfManager const & arg0) [copy constructor] + cls.add_constructor([param('ns3::DcfManager const &', 'arg0')]) + ## dcf-manager.h: ns3::DcfManager::DcfManager() [constructor] + cls.add_constructor([]) + ## dcf-manager.h: void ns3::DcfManager::SetupPhyListener(ns3::Ptr phy) [member function] + cls.add_method('SetupPhyListener', + 'void', + [param('ns3::Ptr< ns3::WifiPhy >', 'phy')]) + ## dcf-manager.h: void ns3::DcfManager::SetupLowListener(ns3::Ptr low) [member function] + cls.add_method('SetupLowListener', + 'void', + [param('ns3::Ptr< ns3::MacLow >', 'low')]) + ## dcf-manager.h: void ns3::DcfManager::SetSlot(ns3::Time slotTime) [member function] + cls.add_method('SetSlot', + 'void', + [param('ns3::Time', 'slotTime')]) + ## dcf-manager.h: void ns3::DcfManager::SetSifs(ns3::Time sifs) [member function] + cls.add_method('SetSifs', + 'void', + [param('ns3::Time', 'sifs')]) + ## dcf-manager.h: void ns3::DcfManager::SetEifsNoDifs(ns3::Time eifsNoDifs) [member function] + cls.add_method('SetEifsNoDifs', + 'void', + [param('ns3::Time', 'eifsNoDifs')]) + ## dcf-manager.h: ns3::Time ns3::DcfManager::GetEifsNoDifs() const [member function] + cls.add_method('GetEifsNoDifs', + 'ns3::Time', + [], + is_const=True) + ## dcf-manager.h: void ns3::DcfManager::Add(ns3::DcfState * dcf) [member function] + cls.add_method('Add', + 'void', + [param('ns3::DcfState *', 'dcf')]) + ## dcf-manager.h: void ns3::DcfManager::RequestAccess(ns3::DcfState * state) [member function] + cls.add_method('RequestAccess', + 'void', + [param('ns3::DcfState *', 'state')]) + ## dcf-manager.h: void ns3::DcfManager::NotifyRxStartNow(ns3::Time duration) [member function] + cls.add_method('NotifyRxStartNow', + 'void', + [param('ns3::Time', 'duration')]) + ## dcf-manager.h: void ns3::DcfManager::NotifyRxEndOkNow() [member function] + cls.add_method('NotifyRxEndOkNow', + 'void', + []) + ## dcf-manager.h: void ns3::DcfManager::NotifyRxEndErrorNow() [member function] + cls.add_method('NotifyRxEndErrorNow', + 'void', + []) + ## dcf-manager.h: void ns3::DcfManager::NotifyTxStartNow(ns3::Time duration) [member function] + cls.add_method('NotifyTxStartNow', + 'void', + [param('ns3::Time', 'duration')]) + ## dcf-manager.h: void ns3::DcfManager::NotifyMaybeCcaBusyStartNow(ns3::Time duration) [member function] + cls.add_method('NotifyMaybeCcaBusyStartNow', + 'void', + [param('ns3::Time', 'duration')]) + ## dcf-manager.h: void ns3::DcfManager::NotifyNavResetNow(ns3::Time duration) [member function] + cls.add_method('NotifyNavResetNow', + 'void', + [param('ns3::Time', 'duration')]) + ## dcf-manager.h: void ns3::DcfManager::NotifyNavStartNow(ns3::Time duration) [member function] + cls.add_method('NotifyNavStartNow', + 'void', + [param('ns3::Time', 'duration')]) + ## dcf-manager.h: void ns3::DcfManager::NotifyAckTimeoutStartNow(ns3::Time duration) [member function] + cls.add_method('NotifyAckTimeoutStartNow', + 'void', + [param('ns3::Time', 'duration')]) + ## dcf-manager.h: void ns3::DcfManager::NotifyAckTimeoutResetNow() [member function] + cls.add_method('NotifyAckTimeoutResetNow', + 'void', + []) + ## dcf-manager.h: void ns3::DcfManager::NotifyCtsTimeoutStartNow(ns3::Time duration) [member function] + cls.add_method('NotifyCtsTimeoutStartNow', + 'void', + [param('ns3::Time', 'duration')]) + ## dcf-manager.h: void ns3::DcfManager::NotifyCtsTimeoutResetNow() [member function] + cls.add_method('NotifyCtsTimeoutResetNow', + 'void', + []) + return + +def register_Ns3DcfState_methods(root_module, cls): + ## dcf-manager.h: ns3::DcfState::DcfState(ns3::DcfState const & arg0) [copy constructor] + cls.add_constructor([param('ns3::DcfState const &', 'arg0')]) + ## dcf-manager.h: ns3::DcfState::DcfState() [constructor] + cls.add_constructor([]) + ## dcf-manager.h: void ns3::DcfState::SetAifsn(uint32_t aifsn) [member function] + cls.add_method('SetAifsn', + 'void', + [param('uint32_t', 'aifsn')]) + ## dcf-manager.h: void ns3::DcfState::SetCwMin(uint32_t minCw) [member function] + cls.add_method('SetCwMin', + 'void', + [param('uint32_t', 'minCw')]) + ## dcf-manager.h: void ns3::DcfState::SetCwMax(uint32_t maxCw) [member function] + cls.add_method('SetCwMax', + 'void', + [param('uint32_t', 'maxCw')]) + ## dcf-manager.h: uint32_t ns3::DcfState::GetAifsn() const [member function] + cls.add_method('GetAifsn', + 'uint32_t', + [], + is_const=True) + ## dcf-manager.h: uint32_t ns3::DcfState::GetCwMin() const [member function] + cls.add_method('GetCwMin', + 'uint32_t', + [], + is_const=True) + ## dcf-manager.h: uint32_t ns3::DcfState::GetCwMax() const [member function] + cls.add_method('GetCwMax', + 'uint32_t', + [], + is_const=True) + ## dcf-manager.h: void ns3::DcfState::ResetCw() [member function] + cls.add_method('ResetCw', + 'void', + []) + ## dcf-manager.h: void ns3::DcfState::UpdateFailedCw() [member function] + cls.add_method('UpdateFailedCw', + 'void', + []) + ## dcf-manager.h: void ns3::DcfState::StartBackoffNow(uint32_t nSlots) [member function] + cls.add_method('StartBackoffNow', + 'void', + [param('uint32_t', 'nSlots')]) + ## dcf-manager.h: uint32_t ns3::DcfState::GetCw() const [member function] + cls.add_method('GetCw', + 'uint32_t', + [], + is_const=True) + ## dcf-manager.h: bool ns3::DcfState::IsAccessRequested() const [member function] + cls.add_method('IsAccessRequested', + 'bool', + [], + is_const=True) + ## dcf-manager.h: void ns3::DcfState::DoNotifyAccessGranted() [member function] + cls.add_method('DoNotifyAccessGranted', + 'void', + [], + is_pure_virtual=True, visibility='private', is_virtual=True) + ## dcf-manager.h: void ns3::DcfState::DoNotifyInternalCollision() [member function] + cls.add_method('DoNotifyInternalCollision', + 'void', + [], + is_pure_virtual=True, visibility='private', is_virtual=True) + ## dcf-manager.h: void ns3::DcfState::DoNotifyCollision() [member function] + cls.add_method('DoNotifyCollision', + 'void', + [], + is_pure_virtual=True, visibility='private', is_virtual=True) + return + def register_Ns3InterferenceHelper_methods(root_module, cls): ## interference-helper.h: ns3::InterferenceHelper::InterferenceHelper() [constructor] cls.add_constructor([]) @@ -324,6 +571,219 @@ def register_Ns3InterferenceHelperSnrPer_methods(root_module, cls): cls.add_instance_attribute('snr', 'double', is_const=False) return +def register_Ns3MacLowDcfListener_methods(root_module, cls): + ## mac-low.h: ns3::MacLowDcfListener::MacLowDcfListener(ns3::MacLowDcfListener const & arg0) [copy constructor] + cls.add_constructor([param('ns3::MacLowDcfListener const &', 'arg0')]) + ## mac-low.h: ns3::MacLowDcfListener::MacLowDcfListener() [constructor] + cls.add_constructor([]) + ## mac-low.h: void ns3::MacLowDcfListener::NavStart(ns3::Time duration) [member function] + cls.add_method('NavStart', + 'void', + [param('ns3::Time', 'duration')], + is_pure_virtual=True, is_virtual=True) + ## mac-low.h: void ns3::MacLowDcfListener::NavReset(ns3::Time duration) [member function] + cls.add_method('NavReset', + 'void', + [param('ns3::Time', 'duration')], + is_pure_virtual=True, is_virtual=True) + ## mac-low.h: void ns3::MacLowDcfListener::AckTimeoutStart(ns3::Time duration) [member function] + cls.add_method('AckTimeoutStart', + 'void', + [param('ns3::Time', 'duration')], + is_pure_virtual=True, is_virtual=True) + ## mac-low.h: void ns3::MacLowDcfListener::AckTimeoutReset() [member function] + cls.add_method('AckTimeoutReset', + 'void', + [], + is_pure_virtual=True, is_virtual=True) + ## mac-low.h: void ns3::MacLowDcfListener::CtsTimeoutStart(ns3::Time duration) [member function] + cls.add_method('CtsTimeoutStart', + 'void', + [param('ns3::Time', 'duration')], + is_pure_virtual=True, is_virtual=True) + ## mac-low.h: void ns3::MacLowDcfListener::CtsTimeoutReset() [member function] + cls.add_method('CtsTimeoutReset', + 'void', + [], + is_pure_virtual=True, is_virtual=True) + return + +def register_Ns3MacLowTransmissionListener_methods(root_module, cls): + ## mac-low.h: ns3::MacLowTransmissionListener::MacLowTransmissionListener(ns3::MacLowTransmissionListener const & arg0) [copy constructor] + cls.add_constructor([param('ns3::MacLowTransmissionListener const &', 'arg0')]) + ## mac-low.h: ns3::MacLowTransmissionListener::MacLowTransmissionListener() [constructor] + cls.add_constructor([]) + ## mac-low.h: void ns3::MacLowTransmissionListener::GotCts(double snr, ns3::WifiMode txMode) [member function] + cls.add_method('GotCts', + 'void', + [param('double', 'snr'), param('ns3::WifiMode', 'txMode')], + is_pure_virtual=True, is_virtual=True) + ## mac-low.h: void ns3::MacLowTransmissionListener::MissedCts() [member function] + cls.add_method('MissedCts', + 'void', + [], + is_pure_virtual=True, is_virtual=True) + ## mac-low.h: void ns3::MacLowTransmissionListener::GotAck(double snr, ns3::WifiMode txMode) [member function] + cls.add_method('GotAck', + 'void', + [param('double', 'snr'), param('ns3::WifiMode', 'txMode')], + is_pure_virtual=True, is_virtual=True) + ## mac-low.h: void ns3::MacLowTransmissionListener::MissedAck() [member function] + cls.add_method('MissedAck', + 'void', + [], + is_pure_virtual=True, is_virtual=True) + ## mac-low.h: void ns3::MacLowTransmissionListener::StartNext() [member function] + cls.add_method('StartNext', + 'void', + [], + is_pure_virtual=True, is_virtual=True) + ## mac-low.h: void ns3::MacLowTransmissionListener::Cancel() [member function] + cls.add_method('Cancel', + 'void', + [], + is_pure_virtual=True, is_virtual=True) + return + +def register_Ns3MacLowTransmissionParameters_methods(root_module, cls): + cls.add_output_stream_operator() + ## mac-low.h: ns3::MacLowTransmissionParameters::MacLowTransmissionParameters(ns3::MacLowTransmissionParameters const & arg0) [copy constructor] + cls.add_constructor([param('ns3::MacLowTransmissionParameters const &', 'arg0')]) + ## mac-low.h: ns3::MacLowTransmissionParameters::MacLowTransmissionParameters() [constructor] + cls.add_constructor([]) + ## mac-low.h: void ns3::MacLowTransmissionParameters::DisableAck() [member function] + cls.add_method('DisableAck', + 'void', + []) + ## mac-low.h: void ns3::MacLowTransmissionParameters::DisableNextData() [member function] + cls.add_method('DisableNextData', + 'void', + []) + ## mac-low.h: void ns3::MacLowTransmissionParameters::DisableOverrideDurationId() [member function] + cls.add_method('DisableOverrideDurationId', + 'void', + []) + ## mac-low.h: void ns3::MacLowTransmissionParameters::DisableRts() [member function] + cls.add_method('DisableRts', + 'void', + []) + ## mac-low.h: void ns3::MacLowTransmissionParameters::EnableAck() [member function] + cls.add_method('EnableAck', + 'void', + []) + ## mac-low.h: void ns3::MacLowTransmissionParameters::EnableFastAck() [member function] + cls.add_method('EnableFastAck', + 'void', + []) + ## mac-low.h: void ns3::MacLowTransmissionParameters::EnableNextData(uint32_t size) [member function] + cls.add_method('EnableNextData', + 'void', + [param('uint32_t', 'size')]) + ## mac-low.h: void ns3::MacLowTransmissionParameters::EnableOverrideDurationId(ns3::Time durationId) [member function] + cls.add_method('EnableOverrideDurationId', + 'void', + [param('ns3::Time', 'durationId')]) + ## mac-low.h: void ns3::MacLowTransmissionParameters::EnableRts() [member function] + cls.add_method('EnableRts', + 'void', + []) + ## mac-low.h: void ns3::MacLowTransmissionParameters::EnableSuperFastAck() [member function] + cls.add_method('EnableSuperFastAck', + 'void', + []) + ## mac-low.h: ns3::Time ns3::MacLowTransmissionParameters::GetDurationId() const [member function] + cls.add_method('GetDurationId', + 'ns3::Time', + [], + is_const=True) + ## mac-low.h: uint32_t ns3::MacLowTransmissionParameters::GetNextPacketSize() const [member function] + cls.add_method('GetNextPacketSize', + 'uint32_t', + [], + is_const=True) + ## mac-low.h: bool ns3::MacLowTransmissionParameters::HasDurationId() const [member function] + cls.add_method('HasDurationId', + 'bool', + [], + is_const=True) + ## mac-low.h: bool ns3::MacLowTransmissionParameters::HasNextPacket() const [member function] + cls.add_method('HasNextPacket', + 'bool', + [], + is_const=True) + ## mac-low.h: bool ns3::MacLowTransmissionParameters::MustSendRts() const [member function] + cls.add_method('MustSendRts', + 'bool', + [], + is_const=True) + ## mac-low.h: bool ns3::MacLowTransmissionParameters::MustWaitAck() const [member function] + cls.add_method('MustWaitAck', + 'bool', + [], + is_const=True) + ## mac-low.h: bool ns3::MacLowTransmissionParameters::MustWaitFastAck() const [member function] + cls.add_method('MustWaitFastAck', + 'bool', + [], + is_const=True) + ## mac-low.h: bool ns3::MacLowTransmissionParameters::MustWaitNormalAck() const [member function] + cls.add_method('MustWaitNormalAck', + 'bool', + [], + is_const=True) + ## mac-low.h: bool ns3::MacLowTransmissionParameters::MustWaitSuperFastAck() const [member function] + cls.add_method('MustWaitSuperFastAck', + 'bool', + [], + is_const=True) + return + +def register_Ns3MacRxMiddle_methods(root_module, cls): + ## mac-rx-middle.h: ns3::MacRxMiddle::MacRxMiddle(ns3::MacRxMiddle const & arg0) [copy constructor] + cls.add_constructor([param('ns3::MacRxMiddle const &', 'arg0')]) + ## mac-rx-middle.h: ns3::MacRxMiddle::MacRxMiddle() [constructor] + cls.add_constructor([]) + ## mac-rx-middle.h: void ns3::MacRxMiddle::SetForwardCallback(ns3::Callback, ns3::WifiMacHeader const*, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> callback) [member function] + cls.add_method('SetForwardCallback', + 'void', + [param('ns3::Callback< void, ns3::Ptr< ns3::Packet >, ns3::WifiMacHeader const *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'callback')]) + ## mac-rx-middle.h: void ns3::MacRxMiddle::Receive(ns3::Ptr packet, ns3::WifiMacHeader const * hdr) [member function] + cls.add_method('Receive', + 'void', + [param('ns3::Ptr< ns3::Packet >', 'packet'), param('ns3::WifiMacHeader const *', 'hdr')]) + return + +def register_Ns3RateInfo_methods(root_module, cls): + ## minstrel-wifi-manager.h: ns3::RateInfo::perfectTxTime [variable] + cls.add_instance_attribute('perfectTxTime', 'ns3::Time', is_const=False) + ## minstrel-wifi-manager.h: ns3::RateInfo::retryCount [variable] + cls.add_instance_attribute('retryCount', 'uint32_t', is_const=False) + ## minstrel-wifi-manager.h: ns3::RateInfo::adjustedRetryCount [variable] + cls.add_instance_attribute('adjustedRetryCount', 'uint32_t', is_const=False) + ## minstrel-wifi-manager.h: ns3::RateInfo::numRateAttempt [variable] + cls.add_instance_attribute('numRateAttempt', 'uint32_t', is_const=False) + ## minstrel-wifi-manager.h: ns3::RateInfo::numRateSuccess [variable] + cls.add_instance_attribute('numRateSuccess', 'uint32_t', is_const=False) + ## minstrel-wifi-manager.h: ns3::RateInfo::prob [variable] + cls.add_instance_attribute('prob', 'uint32_t', is_const=False) + ## minstrel-wifi-manager.h: ns3::RateInfo::ewmaProb [variable] + cls.add_instance_attribute('ewmaProb', 'uint32_t', is_const=False) + ## minstrel-wifi-manager.h: ns3::RateInfo::prevNumRateAttempt [variable] + cls.add_instance_attribute('prevNumRateAttempt', 'uint32_t', is_const=False) + ## minstrel-wifi-manager.h: ns3::RateInfo::prevNumRateSuccess [variable] + cls.add_instance_attribute('prevNumRateSuccess', 'uint32_t', is_const=False) + ## minstrel-wifi-manager.h: ns3::RateInfo::successHist [variable] + cls.add_instance_attribute('successHist', 'uint64_t', is_const=False) + ## minstrel-wifi-manager.h: ns3::RateInfo::attemptHist [variable] + cls.add_instance_attribute('attemptHist', 'uint64_t', is_const=False) + ## minstrel-wifi-manager.h: ns3::RateInfo::throughput [variable] + cls.add_instance_attribute('throughput', 'uint32_t', is_const=False) + ## minstrel-wifi-manager.h: ns3::RateInfo::RateInfo(ns3::RateInfo const & arg0) [copy constructor] + cls.add_constructor([param('ns3::RateInfo const &', 'arg0')]) + ## minstrel-wifi-manager.h: ns3::RateInfo::RateInfo() [constructor] + cls.add_constructor([]) + return + def register_Ns3Ssid_methods(root_module, cls): cls.add_output_stream_operator() ## ssid.h: ns3::Ssid::Ssid(ns3::Ssid const & arg0) [copy constructor] @@ -370,6 +830,41 @@ def register_Ns3Ssid_methods(root_module, cls): is_const=True) return +def register_Ns3StatusCode_methods(root_module, cls): + cls.add_output_stream_operator() + ## status-code.h: ns3::StatusCode::StatusCode(ns3::StatusCode const & arg0) [copy constructor] + cls.add_constructor([param('ns3::StatusCode const &', 'arg0')]) + ## status-code.h: ns3::StatusCode::StatusCode() [constructor] + cls.add_constructor([]) + ## status-code.h: ns3::Buffer::Iterator ns3::StatusCode::Deserialize(ns3::Buffer::Iterator start) [member function] + cls.add_method('Deserialize', + 'ns3::Buffer::Iterator', + [param('ns3::Buffer::Iterator', 'start')]) + ## status-code.h: uint32_t ns3::StatusCode::GetSerializedSize() const [member function] + cls.add_method('GetSerializedSize', + 'uint32_t', + [], + is_const=True) + ## status-code.h: bool ns3::StatusCode::IsSuccess() const [member function] + cls.add_method('IsSuccess', + 'bool', + [], + is_const=True) + ## status-code.h: ns3::Buffer::Iterator ns3::StatusCode::Serialize(ns3::Buffer::Iterator start) const [member function] + cls.add_method('Serialize', + 'ns3::Buffer::Iterator', + [param('ns3::Buffer::Iterator', 'start')], + is_const=True) + ## status-code.h: void ns3::StatusCode::SetFailure() [member function] + cls.add_method('SetFailure', + 'void', + []) + ## status-code.h: void ns3::StatusCode::SetSuccess() [member function] + cls.add_method('SetSuccess', + 'void', + []) + return + def register_Ns3SupportedRates_methods(root_module, cls): cls.add_output_stream_operator() ## supported-rates.h: ns3::SupportedRates::SupportedRates(ns3::SupportedRates const & arg0) [copy constructor] @@ -690,6 +1185,11 @@ def register_Ns3WifiRemoteStation_methods(root_module, cls): cls.add_method('GetAckMode', 'ns3::WifiMode', [param('ns3::WifiMode', 'dataMode')]) + ## wifi-remote-station-manager.h: double ns3::WifiRemoteStation::GetAvgSlrc() const [member function] + cls.add_method('GetAvgSlrc', + 'double', + [], + is_const=True) ## wifi-remote-station-manager.h: uint32_t ns3::WifiRemoteStation::GetNSupportedModes() const [member function] cls.add_method('GetNSupportedModes', 'uint32_t', @@ -1020,6 +1520,303 @@ def register_Ns3IdealWifiRemoteStation_methods(root_module, cls): visibility='private', is_virtual=True) return +def register_Ns3MgtAssocRequestHeader_methods(root_module, cls): + ## mgt-headers.h: ns3::MgtAssocRequestHeader::MgtAssocRequestHeader(ns3::MgtAssocRequestHeader const & arg0) [copy constructor] + cls.add_constructor([param('ns3::MgtAssocRequestHeader const &', 'arg0')]) + ## mgt-headers.h: ns3::MgtAssocRequestHeader::MgtAssocRequestHeader() [constructor] + cls.add_constructor([]) + ## mgt-headers.h: void ns3::MgtAssocRequestHeader::SetSsid(ns3::Ssid ssid) [member function] + cls.add_method('SetSsid', + 'void', + [param('ns3::Ssid', 'ssid')]) + ## mgt-headers.h: void ns3::MgtAssocRequestHeader::SetSupportedRates(ns3::SupportedRates rates) [member function] + cls.add_method('SetSupportedRates', + 'void', + [param('ns3::SupportedRates', 'rates')]) + ## mgt-headers.h: void ns3::MgtAssocRequestHeader::SetListenInterval(uint16_t interval) [member function] + cls.add_method('SetListenInterval', + 'void', + [param('uint16_t', 'interval')]) + ## mgt-headers.h: ns3::Ssid ns3::MgtAssocRequestHeader::GetSsid() const [member function] + cls.add_method('GetSsid', + 'ns3::Ssid', + [], + is_const=True) + ## mgt-headers.h: ns3::SupportedRates ns3::MgtAssocRequestHeader::GetSupportedRates() const [member function] + cls.add_method('GetSupportedRates', + 'ns3::SupportedRates', + [], + is_const=True) + ## mgt-headers.h: uint16_t ns3::MgtAssocRequestHeader::GetListenInterval() const [member function] + cls.add_method('GetListenInterval', + 'uint16_t', + [], + is_const=True) + ## mgt-headers.h: static ns3::TypeId ns3::MgtAssocRequestHeader::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## mgt-headers.h: ns3::TypeId ns3::MgtAssocRequestHeader::GetInstanceTypeId() const [member function] + cls.add_method('GetInstanceTypeId', + 'ns3::TypeId', + [], + is_const=True, is_virtual=True) + ## mgt-headers.h: void ns3::MgtAssocRequestHeader::Print(std::ostream & os) const [member function] + cls.add_method('Print', + 'void', + [param('std::ostream &', 'os')], + is_const=True, is_virtual=True) + ## mgt-headers.h: uint32_t ns3::MgtAssocRequestHeader::GetSerializedSize() const [member function] + cls.add_method('GetSerializedSize', + 'uint32_t', + [], + is_const=True, is_virtual=True) + ## mgt-headers.h: void ns3::MgtAssocRequestHeader::Serialize(ns3::Buffer::Iterator start) const [member function] + cls.add_method('Serialize', + 'void', + [param('ns3::Buffer::Iterator', 'start')], + is_const=True, is_virtual=True) + ## mgt-headers.h: uint32_t ns3::MgtAssocRequestHeader::Deserialize(ns3::Buffer::Iterator start) [member function] + cls.add_method('Deserialize', + 'uint32_t', + [param('ns3::Buffer::Iterator', 'start')], + is_virtual=True) + return + +def register_Ns3MgtAssocResponseHeader_methods(root_module, cls): + ## mgt-headers.h: ns3::MgtAssocResponseHeader::MgtAssocResponseHeader(ns3::MgtAssocResponseHeader const & arg0) [copy constructor] + cls.add_constructor([param('ns3::MgtAssocResponseHeader const &', 'arg0')]) + ## mgt-headers.h: ns3::MgtAssocResponseHeader::MgtAssocResponseHeader() [constructor] + cls.add_constructor([]) + ## mgt-headers.h: ns3::StatusCode ns3::MgtAssocResponseHeader::GetStatusCode() [member function] + cls.add_method('GetStatusCode', + 'ns3::StatusCode', + []) + ## mgt-headers.h: ns3::SupportedRates ns3::MgtAssocResponseHeader::GetSupportedRates() [member function] + cls.add_method('GetSupportedRates', + 'ns3::SupportedRates', + []) + ## mgt-headers.h: void ns3::MgtAssocResponseHeader::SetSupportedRates(ns3::SupportedRates rates) [member function] + cls.add_method('SetSupportedRates', + 'void', + [param('ns3::SupportedRates', 'rates')]) + ## mgt-headers.h: void ns3::MgtAssocResponseHeader::SetStatusCode(ns3::StatusCode code) [member function] + cls.add_method('SetStatusCode', + 'void', + [param('ns3::StatusCode', 'code')]) + ## mgt-headers.h: static ns3::TypeId ns3::MgtAssocResponseHeader::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## mgt-headers.h: ns3::TypeId ns3::MgtAssocResponseHeader::GetInstanceTypeId() const [member function] + cls.add_method('GetInstanceTypeId', + 'ns3::TypeId', + [], + is_const=True, is_virtual=True) + ## mgt-headers.h: void ns3::MgtAssocResponseHeader::Print(std::ostream & os) const [member function] + cls.add_method('Print', + 'void', + [param('std::ostream &', 'os')], + is_const=True, is_virtual=True) + ## mgt-headers.h: uint32_t ns3::MgtAssocResponseHeader::GetSerializedSize() const [member function] + cls.add_method('GetSerializedSize', + 'uint32_t', + [], + is_const=True, is_virtual=True) + ## mgt-headers.h: void ns3::MgtAssocResponseHeader::Serialize(ns3::Buffer::Iterator start) const [member function] + cls.add_method('Serialize', + 'void', + [param('ns3::Buffer::Iterator', 'start')], + is_const=True, is_virtual=True) + ## mgt-headers.h: uint32_t ns3::MgtAssocResponseHeader::Deserialize(ns3::Buffer::Iterator start) [member function] + cls.add_method('Deserialize', + 'uint32_t', + [param('ns3::Buffer::Iterator', 'start')], + is_virtual=True) + return + +def register_Ns3MgtProbeRequestHeader_methods(root_module, cls): + ## mgt-headers.h: ns3::MgtProbeRequestHeader::MgtProbeRequestHeader(ns3::MgtProbeRequestHeader const & arg0) [copy constructor] + cls.add_constructor([param('ns3::MgtProbeRequestHeader const &', 'arg0')]) + ## mgt-headers.h: ns3::MgtProbeRequestHeader::MgtProbeRequestHeader() [constructor] + cls.add_constructor([]) + ## mgt-headers.h: void ns3::MgtProbeRequestHeader::SetSsid(ns3::Ssid ssid) [member function] + cls.add_method('SetSsid', + 'void', + [param('ns3::Ssid', 'ssid')]) + ## mgt-headers.h: void ns3::MgtProbeRequestHeader::SetSupportedRates(ns3::SupportedRates rates) [member function] + cls.add_method('SetSupportedRates', + 'void', + [param('ns3::SupportedRates', 'rates')]) + ## mgt-headers.h: ns3::Ssid ns3::MgtProbeRequestHeader::GetSsid() const [member function] + cls.add_method('GetSsid', + 'ns3::Ssid', + [], + is_const=True) + ## mgt-headers.h: ns3::SupportedRates ns3::MgtProbeRequestHeader::GetSupportedRates() const [member function] + cls.add_method('GetSupportedRates', + 'ns3::SupportedRates', + [], + is_const=True) + ## mgt-headers.h: static ns3::TypeId ns3::MgtProbeRequestHeader::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## mgt-headers.h: ns3::TypeId ns3::MgtProbeRequestHeader::GetInstanceTypeId() const [member function] + cls.add_method('GetInstanceTypeId', + 'ns3::TypeId', + [], + is_const=True, is_virtual=True) + ## mgt-headers.h: void ns3::MgtProbeRequestHeader::Print(std::ostream & os) const [member function] + cls.add_method('Print', + 'void', + [param('std::ostream &', 'os')], + is_const=True, is_virtual=True) + ## mgt-headers.h: uint32_t ns3::MgtProbeRequestHeader::GetSerializedSize() const [member function] + cls.add_method('GetSerializedSize', + 'uint32_t', + [], + is_const=True, is_virtual=True) + ## mgt-headers.h: void ns3::MgtProbeRequestHeader::Serialize(ns3::Buffer::Iterator start) const [member function] + cls.add_method('Serialize', + 'void', + [param('ns3::Buffer::Iterator', 'start')], + is_const=True, is_virtual=True) + ## mgt-headers.h: uint32_t ns3::MgtProbeRequestHeader::Deserialize(ns3::Buffer::Iterator start) [member function] + cls.add_method('Deserialize', + 'uint32_t', + [param('ns3::Buffer::Iterator', 'start')], + is_virtual=True) + return + +def register_Ns3MgtProbeResponseHeader_methods(root_module, cls): + ## mgt-headers.h: ns3::MgtProbeResponseHeader::MgtProbeResponseHeader(ns3::MgtProbeResponseHeader const & arg0) [copy constructor] + cls.add_constructor([param('ns3::MgtProbeResponseHeader const &', 'arg0')]) + ## mgt-headers.h: ns3::MgtProbeResponseHeader::MgtProbeResponseHeader() [constructor] + cls.add_constructor([]) + ## mgt-headers.h: ns3::Ssid ns3::MgtProbeResponseHeader::GetSsid() const [member function] + cls.add_method('GetSsid', + 'ns3::Ssid', + [], + is_const=True) + ## mgt-headers.h: uint64_t ns3::MgtProbeResponseHeader::GetBeaconIntervalUs() const [member function] + cls.add_method('GetBeaconIntervalUs', + 'uint64_t', + [], + is_const=True) + ## mgt-headers.h: ns3::SupportedRates ns3::MgtProbeResponseHeader::GetSupportedRates() const [member function] + cls.add_method('GetSupportedRates', + 'ns3::SupportedRates', + [], + is_const=True) + ## mgt-headers.h: void ns3::MgtProbeResponseHeader::SetSsid(ns3::Ssid ssid) [member function] + cls.add_method('SetSsid', + 'void', + [param('ns3::Ssid', 'ssid')]) + ## mgt-headers.h: void ns3::MgtProbeResponseHeader::SetBeaconIntervalUs(uint64_t us) [member function] + cls.add_method('SetBeaconIntervalUs', + 'void', + [param('uint64_t', 'us')]) + ## mgt-headers.h: void ns3::MgtProbeResponseHeader::SetSupportedRates(ns3::SupportedRates rates) [member function] + cls.add_method('SetSupportedRates', + 'void', + [param('ns3::SupportedRates', 'rates')]) + ## mgt-headers.h: uint64_t ns3::MgtProbeResponseHeader::GetTimestamp() [member function] + cls.add_method('GetTimestamp', + 'uint64_t', + []) + ## mgt-headers.h: static ns3::TypeId ns3::MgtProbeResponseHeader::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## mgt-headers.h: ns3::TypeId ns3::MgtProbeResponseHeader::GetInstanceTypeId() const [member function] + cls.add_method('GetInstanceTypeId', + 'ns3::TypeId', + [], + is_const=True, is_virtual=True) + ## mgt-headers.h: void ns3::MgtProbeResponseHeader::Print(std::ostream & os) const [member function] + cls.add_method('Print', + 'void', + [param('std::ostream &', 'os')], + is_const=True, is_virtual=True) + ## mgt-headers.h: uint32_t ns3::MgtProbeResponseHeader::GetSerializedSize() const [member function] + cls.add_method('GetSerializedSize', + 'uint32_t', + [], + is_const=True, is_virtual=True) + ## mgt-headers.h: void ns3::MgtProbeResponseHeader::Serialize(ns3::Buffer::Iterator start) const [member function] + cls.add_method('Serialize', + 'void', + [param('ns3::Buffer::Iterator', 'start')], + is_const=True, is_virtual=True) + ## mgt-headers.h: uint32_t ns3::MgtProbeResponseHeader::Deserialize(ns3::Buffer::Iterator start) [member function] + cls.add_method('Deserialize', + 'uint32_t', + [param('ns3::Buffer::Iterator', 'start')], + is_virtual=True) + return + +def register_Ns3MinstrelWifiRemoteStation_methods(root_module, cls): + ## minstrel-wifi-manager.h: ns3::MinstrelWifiRemoteStation::MinstrelWifiRemoteStation(ns3::MinstrelWifiRemoteStation const & arg0) [copy constructor] + cls.add_constructor([param('ns3::MinstrelWifiRemoteStation const &', 'arg0')]) + ## minstrel-wifi-manager.h: ns3::MinstrelWifiRemoteStation::MinstrelWifiRemoteStation(ns3::Ptr stations) [constructor] + cls.add_constructor([param('ns3::Ptr< ns3::MinstrelWifiManager >', 'stations')]) + ## minstrel-wifi-manager.h: void ns3::MinstrelWifiRemoteStation::DoReportRxOk(double rxSnr, ns3::WifiMode txMode) [member function] + cls.add_method('DoReportRxOk', + 'void', + [param('double', 'rxSnr'), param('ns3::WifiMode', 'txMode')], + visibility='protected', is_virtual=True) + ## minstrel-wifi-manager.h: void ns3::MinstrelWifiRemoteStation::DoReportRtsFailed() [member function] + cls.add_method('DoReportRtsFailed', + 'void', + [], + visibility='protected', is_virtual=True) + ## minstrel-wifi-manager.h: void ns3::MinstrelWifiRemoteStation::DoReportDataFailed() [member function] + cls.add_method('DoReportDataFailed', + 'void', + [], + visibility='protected', is_virtual=True) + ## minstrel-wifi-manager.h: void ns3::MinstrelWifiRemoteStation::DoReportRtsOk(double ctsSnr, ns3::WifiMode ctsMode, double rtsSnr) [member function] + cls.add_method('DoReportRtsOk', + 'void', + [param('double', 'ctsSnr'), param('ns3::WifiMode', 'ctsMode'), param('double', 'rtsSnr')], + visibility='protected', is_virtual=True) + ## minstrel-wifi-manager.h: void ns3::MinstrelWifiRemoteStation::DoReportDataOk(double ackSnr, ns3::WifiMode ackMode, double dataSnr) [member function] + cls.add_method('DoReportDataOk', + 'void', + [param('double', 'ackSnr'), param('ns3::WifiMode', 'ackMode'), param('double', 'dataSnr')], + visibility='protected', is_virtual=True) + ## minstrel-wifi-manager.h: void ns3::MinstrelWifiRemoteStation::DoReportFinalRtsFailed() [member function] + cls.add_method('DoReportFinalRtsFailed', + 'void', + [], + visibility='protected', is_virtual=True) + ## minstrel-wifi-manager.h: void ns3::MinstrelWifiRemoteStation::DoReportFinalDataFailed() [member function] + cls.add_method('DoReportFinalDataFailed', + 'void', + [], + visibility='protected', is_virtual=True) + ## minstrel-wifi-manager.h: ns3::Ptr ns3::MinstrelWifiRemoteStation::GetManager() const [member function] + cls.add_method('GetManager', + 'ns3::Ptr< ns3::WifiRemoteStationManager >', + [], + is_const=True, visibility='private', is_virtual=True) + ## minstrel-wifi-manager.h: ns3::WifiMode ns3::MinstrelWifiRemoteStation::DoGetDataMode(uint32_t size) [member function] + cls.add_method('DoGetDataMode', + 'ns3::WifiMode', + [param('uint32_t', 'size')], + visibility='private', is_virtual=True) + ## minstrel-wifi-manager.h: ns3::WifiMode ns3::MinstrelWifiRemoteStation::DoGetRtsMode() [member function] + cls.add_method('DoGetRtsMode', + 'ns3::WifiMode', + [], + visibility='private', is_virtual=True) + return + def register_Ns3OnoeWifiRemoteStation_methods(root_module, cls): ## onoe-wifi-manager.h: ns3::OnoeWifiRemoteStation::OnoeWifiRemoteStation(ns3::OnoeWifiRemoteStation const & arg0) [copy constructor] cls.add_constructor([param('ns3::OnoeWifiRemoteStation const &', 'arg0')]) @@ -1133,6 +1930,8 @@ def register_Ns3QosTag_methods(root_module, cls): is_const=True, is_virtual=True) ## qos-tag.h: ns3::QosTag::QosTag() [constructor] cls.add_constructor([]) + ## qos-tag.h: ns3::QosTag::QosTag(uint8_t tid) [constructor] + cls.add_constructor([param('uint8_t', 'tid')]) ## qos-tag.h: void ns3::QosTag::Serialize(ns3::TagBuffer i) const [member function] cls.add_method('Serialize', 'void', @@ -1552,6 +2351,14 @@ def register_Ns3WifiMacHeader_methods(root_module, cls): cls.add_method('SetTypeData', 'void', []) + ## wifi-mac-header.h: void ns3::WifiMacHeader::SetAction() [member function] + cls.add_method('SetAction', + 'void', + []) + ## wifi-mac-header.h: void ns3::WifiMacHeader::SetMultihopAction() [member function] + cls.add_method('SetMultihopAction', + 'void', + []) ## wifi-mac-header.h: void ns3::WifiMacHeader::SetDsFrom() [member function] cls.add_method('SetDsFrom', 'void', @@ -1777,6 +2584,16 @@ def register_Ns3WifiMacHeader_methods(root_module, cls): 'bool', [], is_const=True) + ## wifi-mac-header.h: bool ns3::WifiMacHeader::IsAction() const [member function] + cls.add_method('IsAction', + 'bool', + [], + is_const=True) + ## wifi-mac-header.h: bool ns3::WifiMacHeader::IsMultihopAction() const [member function] + cls.add_method('IsMultihopAction', + 'bool', + [], + is_const=True) ## wifi-mac-header.h: uint16_t ns3::WifiMacHeader::GetRawDuration() const [member function] cls.add_method('GetRawDuration', 'uint16_t', @@ -2009,6 +2826,16 @@ def register_Ns3WifiPhy_methods(root_module, cls): 'double', [param('ns3::WifiMode', 'txMode'), param('double', 'ber')], is_pure_virtual=True, is_const=True, is_virtual=True) + ## wifi-phy.h: void ns3::WifiPhy::SetChannelNumber(uint16_t id) [member function] + cls.add_method('SetChannelNumber', + 'void', + [param('uint16_t', 'id')], + is_pure_virtual=True, is_virtual=True) + ## wifi-phy.h: uint16_t ns3::WifiPhy::GetChannelNumber() const [member function] + cls.add_method('GetChannelNumber', + 'uint16_t', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) ## wifi-phy.h: ns3::Ptr ns3::WifiPhy::GetChannel() const [member function] cls.add_method('GetChannel', 'ns3::Ptr< ns3::WifiChannel >', @@ -2314,6 +3141,21 @@ def register_Ns3YansWifiPhy_methods(root_module, cls): cls.add_method('SetChannel', 'void', [param('ns3::Ptr< ns3::YansWifiChannel >', 'channel')]) + ## yans-wifi-phy.h: void ns3::YansWifiPhy::SetChannelNumber(uint16_t id) [member function] + cls.add_method('SetChannelNumber', + 'void', + [param('uint16_t', 'id')], + is_virtual=True) + ## yans-wifi-phy.h: uint16_t ns3::YansWifiPhy::GetChannelNumber() const [member function] + cls.add_method('GetChannelNumber', + 'uint16_t', + [], + is_const=True, is_virtual=True) + ## yans-wifi-phy.h: double ns3::YansWifiPhy::GetChannelFrequencyMhz() const [member function] + cls.add_method('GetChannelFrequencyMhz', + 'double', + [], + is_const=True) ## yans-wifi-phy.h: void ns3::YansWifiPhy::StartReceivePacket(ns3::Ptr packet, double rxPowerDbm, ns3::WifiMode mode, ns3::WifiPreamble preamble) [member function] cls.add_method('StartReceivePacket', 'void', @@ -3274,6 +4116,152 @@ def register_Ns3LogDistancePropagationLossModel_methods(root_module, cls): is_const=True, visibility='private', is_virtual=True) return +def register_Ns3MacLow_methods(root_module, cls): + ## mac-low.h: ns3::MacLow::MacLow(ns3::MacLow const & arg0) [copy constructor] + cls.add_constructor([param('ns3::MacLow const &', 'arg0')]) + ## mac-low.h: ns3::MacLow::MacLow() [constructor] + cls.add_constructor([]) + ## mac-low.h: void ns3::MacLow::SetPhy(ns3::Ptr phy) [member function] + cls.add_method('SetPhy', + 'void', + [param('ns3::Ptr< ns3::WifiPhy >', 'phy')]) + ## mac-low.h: void ns3::MacLow::SetWifiRemoteStationManager(ns3::Ptr manager) [member function] + cls.add_method('SetWifiRemoteStationManager', + 'void', + [param('ns3::Ptr< ns3::WifiRemoteStationManager >', 'manager')]) + ## mac-low.h: void ns3::MacLow::SetAddress(ns3::Mac48Address ad) [member function] + cls.add_method('SetAddress', + 'void', + [param('ns3::Mac48Address', 'ad')]) + ## mac-low.h: void ns3::MacLow::SetAckTimeout(ns3::Time ackTimeout) [member function] + cls.add_method('SetAckTimeout', + 'void', + [param('ns3::Time', 'ackTimeout')]) + ## mac-low.h: void ns3::MacLow::SetCtsTimeout(ns3::Time ctsTimeout) [member function] + cls.add_method('SetCtsTimeout', + 'void', + [param('ns3::Time', 'ctsTimeout')]) + ## mac-low.h: void ns3::MacLow::SetSifs(ns3::Time sifs) [member function] + cls.add_method('SetSifs', + 'void', + [param('ns3::Time', 'sifs')]) + ## mac-low.h: void ns3::MacLow::SetSlotTime(ns3::Time slotTime) [member function] + cls.add_method('SetSlotTime', + 'void', + [param('ns3::Time', 'slotTime')]) + ## mac-low.h: void ns3::MacLow::SetPifs(ns3::Time pifs) [member function] + cls.add_method('SetPifs', + 'void', + [param('ns3::Time', 'pifs')]) + ## mac-low.h: void ns3::MacLow::SetBssid(ns3::Mac48Address ad) [member function] + cls.add_method('SetBssid', + 'void', + [param('ns3::Mac48Address', 'ad')]) + ## mac-low.h: ns3::Mac48Address ns3::MacLow::GetAddress() const [member function] + cls.add_method('GetAddress', + 'ns3::Mac48Address', + [], + is_const=True) + ## mac-low.h: ns3::Time ns3::MacLow::GetAckTimeout() const [member function] + cls.add_method('GetAckTimeout', + 'ns3::Time', + [], + is_const=True) + ## mac-low.h: ns3::Time ns3::MacLow::GetCtsTimeout() const [member function] + cls.add_method('GetCtsTimeout', + 'ns3::Time', + [], + is_const=True) + ## mac-low.h: ns3::Time ns3::MacLow::GetSifs() const [member function] + cls.add_method('GetSifs', + 'ns3::Time', + [], + is_const=True) + ## mac-low.h: ns3::Time ns3::MacLow::GetSlotTime() const [member function] + cls.add_method('GetSlotTime', + 'ns3::Time', + [], + is_const=True) + ## mac-low.h: ns3::Time ns3::MacLow::GetPifs() const [member function] + cls.add_method('GetPifs', + 'ns3::Time', + [], + is_const=True) + ## mac-low.h: ns3::Mac48Address ns3::MacLow::GetBssid() const [member function] + cls.add_method('GetBssid', + 'ns3::Mac48Address', + [], + is_const=True) + ## mac-low.h: void ns3::MacLow::SetRxCallback(ns3::Callback, ns3::WifiMacHeader const*, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> callback) [member function] + cls.add_method('SetRxCallback', + 'void', + [param('ns3::Callback< void, ns3::Ptr< ns3::Packet >, ns3::WifiMacHeader const *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'callback')]) + ## mac-low.h: void ns3::MacLow::RegisterDcfListener(ns3::MacLowDcfListener * listener) [member function] + cls.add_method('RegisterDcfListener', + 'void', + [param('ns3::MacLowDcfListener *', 'listener')]) + ## mac-low.h: ns3::Time ns3::MacLow::CalculateTransmissionTime(ns3::Ptr packet, ns3::WifiMacHeader const * hdr, ns3::MacLowTransmissionParameters const & parameters) const [member function] + cls.add_method('CalculateTransmissionTime', + 'ns3::Time', + [param('ns3::Ptr< ns3::Packet const >', 'packet'), param('ns3::WifiMacHeader const *', 'hdr'), param('ns3::MacLowTransmissionParameters const &', 'parameters')], + is_const=True) + ## mac-low.h: void ns3::MacLow::StartTransmission(ns3::Ptr packet, ns3::WifiMacHeader const * hdr, ns3::MacLowTransmissionParameters parameters, ns3::MacLowTransmissionListener * listener) [member function] + cls.add_method('StartTransmission', + 'void', + [param('ns3::Ptr< ns3::Packet const >', 'packet'), param('ns3::WifiMacHeader const *', 'hdr'), param('ns3::MacLowTransmissionParameters', 'parameters'), param('ns3::MacLowTransmissionListener *', 'listener')]) + ## mac-low.h: void ns3::MacLow::ReceiveOk(ns3::Ptr packet, double rxSnr, ns3::WifiMode txMode, ns3::WifiPreamble preamble) [member function] + cls.add_method('ReceiveOk', + 'void', + [param('ns3::Ptr< ns3::Packet >', 'packet'), param('double', 'rxSnr'), param('ns3::WifiMode', 'txMode'), param('ns3::WifiPreamble', 'preamble')]) + ## mac-low.h: void ns3::MacLow::ReceiveError(ns3::Ptr packet, double rxSnr) [member function] + cls.add_method('ReceiveError', + 'void', + [param('ns3::Ptr< ns3::Packet const >', 'packet'), param('double', 'rxSnr')]) + ## mac-low.h: void ns3::MacLow::DoDispose() [member function] + cls.add_method('DoDispose', + 'void', + [], + visibility='private', is_virtual=True) + return + +def register_Ns3MgtBeaconHeader_methods(root_module, cls): + ## mgt-headers.h: ns3::MgtBeaconHeader::MgtBeaconHeader(ns3::MgtBeaconHeader const & arg0) [copy constructor] + cls.add_constructor([param('ns3::MgtBeaconHeader const &', 'arg0')]) + ## mgt-headers.h: ns3::MgtBeaconHeader::MgtBeaconHeader() [constructor] + cls.add_constructor([]) + return + +def register_Ns3MinstrelWifiManager_methods(root_module, cls): + ## minstrel-wifi-manager.h: ns3::MinstrelWifiManager::MinstrelWifiManager(ns3::MinstrelWifiManager const & arg0) [copy constructor] + cls.add_constructor([param('ns3::MinstrelWifiManager const &', 'arg0')]) + ## minstrel-wifi-manager.h: static ns3::TypeId ns3::MinstrelWifiManager::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## minstrel-wifi-manager.h: ns3::MinstrelWifiManager::MinstrelWifiManager() [constructor] + cls.add_constructor([]) + ## minstrel-wifi-manager.h: void ns3::MinstrelWifiManager::SetupPhy(ns3::Ptr phy) [member function] + cls.add_method('SetupPhy', + 'void', + [param('ns3::Ptr< ns3::WifiPhy >', 'phy')], + is_virtual=True) + ## minstrel-wifi-manager.h: ns3::Time ns3::MinstrelWifiManager::GetCalcTxTime(ns3::WifiMode mode) const [member function] + cls.add_method('GetCalcTxTime', + 'ns3::Time', + [param('ns3::WifiMode', 'mode')], + is_const=True) + ## minstrel-wifi-manager.h: void ns3::MinstrelWifiManager::AddCalcTxTime(ns3::WifiMode mode, ns3::Time t) [member function] + cls.add_method('AddCalcTxTime', + 'void', + [param('ns3::WifiMode', 'mode'), param('ns3::Time', 't')]) + ## minstrel-wifi-manager.h: ns3::WifiRemoteStation * ns3::MinstrelWifiManager::CreateStation() [member function] + cls.add_method('CreateStation', + 'ns3::WifiRemoteStation *', + [], + visibility='private', is_virtual=True) + return + def register_Ns3MsduAggregator_methods(root_module, cls): ## msdu-aggregator.h: ns3::MsduAggregator::MsduAggregator(ns3::MsduAggregator const & arg0) [copy constructor] cls.add_constructor([param('ns3::MsduAggregator const &', 'arg0')]) From 5ed18f1374583ac824d4c378a8c8086feefe901d Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Thu, 13 Aug 2009 09:06:17 +0200 Subject: [PATCH 11/28] add minstrel examples --- examples/multi-rate-first.cc | 317 ++++++++++++++++++++++++++++++++++ examples/multi-rate-second.cc | 256 +++++++++++++++++++++++++++ examples/wscript | 8 + 3 files changed, 581 insertions(+) create mode 100644 examples/multi-rate-first.cc create mode 100644 examples/multi-rate-second.cc diff --git a/examples/multi-rate-first.cc b/examples/multi-rate-first.cc new file mode 100644 index 000000000..336e9d985 --- /dev/null +++ b/examples/multi-rate-first.cc @@ -0,0 +1,317 @@ +/** + * + * Instructions: + * ./waf --run multi-rate-first > m.data + * gnuplot m.data + * eog *.png + * + */ + +#include "ns3/core-module.h" +#include "ns3/common-module.h" +#include "ns3/node-module.h" +#include "ns3/helper-module.h" +#include "ns3/mobility-module.h" +#include "ns3/contrib-module.h" + +#include + +NS_LOG_COMPONENT_DEFINE ("Main"); + +using namespace ns3; + +class Experiment +{ +public: + Experiment (); + Experiment (std::string name); + Gnuplot2dDataset Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, + const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility, int positionStep); +private: + void ReceivePacket (Ptr socket); + void SetPosition (Ptr node, Vector position); + Vector GetPosition (Ptr node); + void AdvancePosition (Ptr node); + void BackTrackPosition (Ptr node); + void StationaryPosition (Ptr node); + Ptr SetupPacketReceive (Ptr node); + + uint32_t m_bytesTotal; + Gnuplot2dDataset m_output; +}; + +Experiment::Experiment () +{} + +Experiment::Experiment (std::string name) + : m_output (name) +{ + m_output.SetStyle (Gnuplot2dDataset::LINES); +} + +void +Experiment::SetPosition (Ptr node, Vector position) +{ + Ptr mobility = node->GetObject (); + mobility->SetPosition (position); +} + +Vector +Experiment::GetPosition (Ptr node) +{ + Ptr mobility = node->GetObject (); + return mobility->GetPosition (); +} + +void +Experiment::AdvancePosition (Ptr node) +{ + Vector pos = GetPosition (node); + double mbs = ((m_bytesTotal * 8.0) / 1000000); + m_bytesTotal = 0; + m_output.Add ((Simulator::Now()).GetSeconds(), mbs); + pos.x += 1.0; + + if (pos.x >= 210.0) + { + return; + } + SetPosition (node, pos); + + //std::cout << "x="< node) +{ + Vector pos = GetPosition (node); + double mbs = ((m_bytesTotal * 8.0) / 1000000); + m_bytesTotal = 0; + m_output.Add ((Simulator::Now()).GetSeconds(), mbs); + pos.x -= 1.0; + + if (pos.x < 0) + { + return; + } + SetPosition (node, pos); + + //std::cout << "x="< node) +{ + double mbs = ((m_bytesTotal * 8.0) / 1000000); + m_bytesTotal = 0; + m_output.Add ((Simulator::Now()).GetSeconds(), mbs); + +} + +void +Experiment::ReceivePacket (Ptr socket) +{ + Ptr packet; + while (packet = socket->Recv ()) + { + m_bytesTotal += packet->GetSize (); + } +} + +Ptr +Experiment::SetupPacketReceive (Ptr node) +{ + TypeId tid = TypeId::LookupByName ("ns3::PacketSocketFactory"); + Ptr sink = Socket::CreateSocket (node, tid); + sink->Bind (); + sink->SetRecvCallback (MakeCallback (&Experiment::ReceivePacket, this)); + + return sink; + +} + +Gnuplot2dDataset +Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, + const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility, int positionStep) +{ + m_bytesTotal = 0; + + NodeContainer c; + c.Create (2); + + PacketSocketHelper packetSocket; + packetSocket.Install (c); + + YansWifiPhyHelper phy = wifiPhy; + phy.SetChannel (wifiChannel.Create ()); + + NqosWifiMacHelper mac = wifiMac; + NetDeviceContainer devices = wifi.Install (phy, mac, c); + + mobility.Install (c); + + PacketSocketAddress socket; + socket.SetSingleDevice(devices.Get (0)->GetIfIndex ()); + socket.SetPhysicalAddress (devices.Get (1)->GetAddress ()); + socket.SetProtocol (1); + + OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket)); + onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (250))); + onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); + onoff.SetAttribute ("DataRate", DataRateValue (DataRate (60000000))); + onoff.SetAttribute ("PacketSize", UintegerValue (2000)); + + ApplicationContainer apps = onoff.Install (c.Get (0)); + apps.Start (Seconds (0.5)); + apps.Stop (Seconds (250.0)); + + + Ptr recvSink = SetupPacketReceive (c.Get (1)); + + if(positionStep == 1) + { + Simulator::Schedule (Seconds (1.5), &Experiment::AdvancePosition, this, c.Get (1)); + } + else if(positionStep == -1) + { + Simulator::Schedule (Seconds (1.5), &Experiment::BackTrackPosition, this, c.Get (1)); + } + else if(positionStep == 0) + { + for(int i = 1; i <= 210; i++) + { + Simulator::Schedule (Seconds (i), &Experiment::StationaryPosition, this, c.Get (1)); + } + } + Simulator::Run (); + Simulator::Destroy (); + + return m_output; +} + +int main (int argc, char *argv[]) +{ + // disable fragmentation + Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200")); + Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200")); + + CommandLine cmd; + cmd.Parse (argc, argv); + + Gnuplot gnuplot = Gnuplot ("multi-rate-first.png"); + Experiment experiment; + WifiHelper wifi = WifiHelper::Default (); + NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); + YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); + Gnuplot2dDataset dataset; + int myPositionStep = 0; + +/* + + // Scenario 1: moving away from one another + // Initially set them 5 meters apart + // Set positionStep parameter of Experiment::Run to 1 + // Set RateErrorModel of Experiment::Run to 0 + myPositionStep = 1; + + MobilityHelper mobility; + Ptr positionAlloc = CreateObject (); + positionAlloc->Add (Vector (0.0, 0.0, 0.0)); + positionAlloc->Add (Vector (5.0, 0.0, 0.0)); + mobility.SetPositionAllocator (positionAlloc); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + + wifiMac.SetType ("ns3::AdhocWifiMac"); + + gnuplot = Gnuplot ("multi-rate-first.png"); + Config::SetDefault ("ns3::YansWifiPhy::Standard", StringValue ("holland")); + + NS_LOG_DEBUG ("minstrel"); + experiment = Experiment ("minstrel"); + wifi.SetRemoteStationManager ("ns3::MinstrelWifiManager"); + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility, myPositionStep); + gnuplot.AddDataset (dataset); + + NS_LOG_DEBUG ("ideal"); + experiment = Experiment ("ideal"); + wifi.SetRemoteStationManager ("ns3::IdealWifiManager"); + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility, myPositionStep); + gnuplot.AddDataset (dataset); + + gnuplot.GenerateOutput (std::cout); + */ + + + // Scenario 2: two nodes out of range, moving into transmission range range + // Initially set them 230 meters apart + // Set positionStep parameter of Experiment::Rung to -1 + // set RateErrorModel of Experiment::Run to 0 + + myPositionStep = -1; + + MobilityHelper mobility; + Ptr positionAlloc = CreateObject (); + positionAlloc->Add (Vector (0.0, 0.0, 0.0)); + positionAlloc->Add (Vector (230.0, 0.0, 0.0)); + mobility.SetPositionAllocator (positionAlloc); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + + wifiMac.SetType ("ns3::AdhocWifiMac"); + + gnuplot = Gnuplot ("multi-rate-first.png"); + Config::SetDefault ("ns3::YansWifiPhy::Standard", StringValue ("holland")); + + NS_LOG_DEBUG ("minstrel"); + experiment = Experiment ("minstrel"); + wifi.SetRemoteStationManager ("ns3::MinstrelWifiManager"); + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility, myPositionStep); + gnuplot.AddDataset (dataset); + + NS_LOG_DEBUG ("ideal"); + experiment = Experiment ("ideal"); + wifi.SetRemoteStationManager ("ns3::IdealWifiManager"); + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility, myPositionStep); + gnuplot.AddDataset (dataset); + + gnuplot.GenerateOutput (std::cout); + + + +/* + // Scenario 3: + // Initially set them 25 meters apart, stationary + // Set positionStep parameter of Experiment::Rung to 0 + // This is a sanity check + + myPositionStep = 0; + MobilityHelper mobility; + Ptr positionAlloc = CreateObject (); + positionAlloc->Add (Vector (0.0, 0.0, 0.0)); + positionAlloc->Add (Vector (25.0, 0.0, 0.0)); + mobility.SetPositionAllocator (positionAlloc); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + + wifiMac.SetType ("ns3::AdhocWifiMac"); + + gnuplot = Gnuplot ("multi-rate-first.png"); + Config::SetDefault ("ns3::YansWifiPhy::Standard", StringValue ("holland")); + + NS_LOG_DEBUG ("minstrel"); + experiment = Experiment ("minstrel"); + wifi.SetRemoteStationManager ("ns3::MinstrelWifiManager"); + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility, myPositionStep); + gnuplot.AddDataset (dataset); + + NS_LOG_DEBUG ("ideal"); + experiment = Experiment ("ideal"); + wifi.SetRemoteStationManager ("ns3::IdealWifiManager"); + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility, myPositionStep); + gnuplot.AddDataset (dataset); + + gnuplot.GenerateOutput (std::cout); + */ + + return 0; +} diff --git a/examples/multi-rate-second.cc b/examples/multi-rate-second.cc new file mode 100644 index 000000000..9fb14f8f4 --- /dev/null +++ b/examples/multi-rate-second.cc @@ -0,0 +1,256 @@ +/* + * Instructions: + * ./waf --run multi-rate-second + * gnuplot multi-rate-second.plt + * + * Output: multi-rate-second.eps + * + */ + +#include "ns3/core-module.h" +#include "ns3/common-module.h" +#include "ns3/node-module.h" +#include "ns3/helper-module.h" +#include "ns3/mobility-module.h" +#include "ns3/contrib-module.h" + +#include +#include +#include +#include + +NS_LOG_COMPONENT_DEFINE ("Main"); + +using namespace ns3; + +class Experiment +{ +public: + Experiment (); + Experiment (std::string name); + Gnuplot2dDataset Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, + const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel); +private: + void ReceivePacket (Ptr socket); + void SetPosition (Ptr node, Vector position); + Vector GetPosition (Ptr node); + Ptr SetupPacketReceive (Ptr node); + void GenerateTraffic (Ptr socket, uint32_t pktSize, + uint32_t pktCount, Time pktInterval , Ptr node); + + uint32_t m_pktsTotal; + Gnuplot2dDataset m_output; + bool advanceStep; +}; + +Experiment::Experiment () +{ + advanceStep= true; +} + +Experiment::Experiment (std::string name) + : m_output (name) +{ + m_output.SetStyle (Gnuplot2dDataset::LINES); +} + +void +Experiment::SetPosition (Ptr node, Vector position) +{ + Ptr mobility = node->GetObject (); + mobility->SetPosition (position); +} + +Vector +Experiment::GetPosition (Ptr node) +{ + Ptr mobility = node->GetObject (); + return mobility->GetPosition (); +} + +void +Experiment::ReceivePacket (Ptr socket) +{ + Ptr packet; + while (packet = socket->Recv ()) + { + m_pktsTotal ++; + } +} + +Ptr +Experiment::SetupPacketReceive (Ptr node) +{ + TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); + Ptr sink = Socket::CreateSocket (node, tid); + InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80); + sink->Bind (local); + sink->SetRecvCallback (MakeCallback (&Experiment::ReceivePacket, this)); + return sink; +} + +void +Experiment::GenerateTraffic (Ptr socket, uint32_t pktSize, + uint32_t pktCount, Time pktInterval, Ptr node ) +{ + Vector pos = GetPosition(node); + + ///to offset the start time + double offSetTime = 100; + + if (pktCount > 0) + { + ///To simulate nodes moving in and out of transmission constantly + if(pos.x <= 305 && advanceStep) + { + ///keep moving away + pos.x += .1; + SetPosition(node, pos); + } + else + { + if(pos.x < 150) + { + advanceStep=true; + } + else + { + advanceStep = false; + } + + ///moving back in + pos.x -= .1; + SetPosition(node, pos); + } + socket->Send (Create (pktSize)); + Simulator::Schedule (pktInterval, &Experiment::GenerateTraffic, this, + socket, pktSize,pktCount-1, pktInterval, node); + } + else + { + m_output.Add((Simulator::Now()).GetSeconds() - offSetTime , m_pktsTotal); + } +} + +Gnuplot2dDataset +Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, + const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel) +{ + m_pktsTotal = 0; + + NodeContainer c; + c.Create (2); + + YansWifiPhyHelper phy = wifiPhy; + phy.SetChannel (wifiChannel.Create ()); + + NqosWifiMacHelper mac = wifiMac; + NetDeviceContainer devices = wifi.Install (phy, mac, c); + + MobilityHelper mobility; + Ptr positionAlloc = CreateObject (); + positionAlloc->Add (Vector (0.0, 0.0, 0.0)); + positionAlloc->Add (Vector (5.0, 0.0, 0.0)); + mobility.SetPositionAllocator (positionAlloc); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (c); + + InternetStackHelper internet; + internet.Install (c); + + Ipv4AddressHelper ipv4; + NS_LOG_INFO ("Assign IP Addresses."); + ipv4.SetBase ("10.1.1.0", "255.255.255.0"); + Ipv4InterfaceContainer wifiNodesInterface = ipv4.Assign (devices); + + + Ptr recvSink = SetupPacketReceive (c.Get (0)); + + TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); + Ptr source = Socket::CreateSocket (c.Get (1), tid); + InetSocketAddress remote = InetSocketAddress (Ipv4Address ("255.255.255.255"), 80); + source->Connect (remote); + uint32_t packetSize = 1014; + uint32_t maxPacketCount = 1000; + Time interPacketInterval = Seconds (.1); + + Ptr n1 = c.Get(0); + Ptr ipv41 = n1->GetObject (); + + + + for (int i= 1; i <= 100; i++) + { + + Simulator::Schedule (Seconds (i), &Experiment::GenerateTraffic, + this, source, packetSize, maxPacketCount,interPacketInterval, c.Get(1)); + + if( i % 5 == 0 ) + { + ///bring a network interface down + Simulator::Schedule (Seconds (i+.5), &Ipv4::SetDown, ipv41, 1); + i++; + Simulator::Schedule (Seconds (i), &Experiment::GenerateTraffic, + this, source, packetSize, maxPacketCount,interPacketInterval, c.Get(1)); + + ///bring a network interface up + Simulator::Schedule (Seconds (i+.2), &Ipv4::SetUp, ipv41, 1); + i++; + Simulator::Schedule (Seconds (i), &Experiment::GenerateTraffic, + this, source, packetSize, maxPacketCount,interPacketInterval, c.Get(1)); + } + } + + Simulator::Run (); + Simulator::Destroy (); + + return m_output; +} + +int main (int argc, char *argv[]) +{ + std::vector ratesControl; + ratesControl.push_back ("Ideal"); + ratesControl.push_back ("Minstrel"); + + std::vector wifiManager; + wifiManager.push_back("ns3::IdealWifiManager"); + wifiManager.push_back("ns3::MinstrelWifiManager"); + + // disable fragmentation + Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200")); + Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200")); + + CommandLine cmd; + cmd.Parse (argc, argv); + + Gnuplot gnuplot = Gnuplot ("multi-rate-second.eps"); + + for (uint32_t i = 0; i < ratesControl.size(); i++) + { + Gnuplot2dDataset dataset (ratesControl[i]); + dataset.SetStyle (Gnuplot2dDataset::LINES); + Experiment experiment; + + + WifiHelper wifi = WifiHelper::Default (); + NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); + YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); + + wifiMac.SetType ("ns3::AdhocWifiMac"); + + NS_LOG_DEBUG (ratesControl[i]); + + experiment = Experiment (ratesControl[i]); + dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel); + gnuplot.AddDataset (dataset); + + } + gnuplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\""); + gnuplot.SetLegend ("Time (Seconds)", "Number of packets received"); + gnuplot.SetExtra ("set xrange [0:100]"); + gnuplot.GenerateOutput (std::cout); + + return 0; +} diff --git a/examples/wscript b/examples/wscript index 906355a4f..ca0e171c4 100644 --- a/examples/wscript +++ b/examples/wscript @@ -163,3 +163,11 @@ def build(bld): obj = bld.create_ns3_program('simple-wifi-frame-aggregation', ['core', 'simulator', 'mobility', 'wifi']) obj.source = 'simple-wifi-frame-aggregation.cc' + + obj = bld.create_ns3_program('multi-rate-first', + ['core', 'simulator', 'mobility', 'wifi']) + obj.source = 'multi-rate-first.cc' + + obj = bld.create_ns3_program('multi-rate-second', + ['core', 'simulator', 'mobility', 'wifi']) + obj.source = 'multi-rate-second.cc' From ba865deb53e6ca93748180d39a0e790135cb465b Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Thu, 13 Aug 2009 09:09:53 +0200 Subject: [PATCH 12/28] add duy nguyen, sort list alphabetically --- AUTHORS | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/AUTHORS b/AUTHORS index 311dc742e..5b22c6f68 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,30 +1,31 @@ +Kirill V. Andreev (kirillano@yandex.ru) Nicola Baldo (nbaldo@cttc.es) Mirko Banchi (mk.banchi@gmail.com) +Mehdi Benamor (mehdi.benamor@telecom-bretagne.eu) Raj Bhattacharjea (raj.b@gatech.edu) +Timo Bingmann (timo.bingmann@student.kit.edu) Gustavo Carneiro (gjc@inescporto.pt, gjcarneiro@gmail.com) +Angelos Chatzipapas (chatzipa@ceid.upatras.gr) +Luis Cortes (cortes@gatech.edu) Craig Dowell (craigdo@ee.washington.edu) +David Gross (gdavid.devel@gmail.com) Tom Henderson (tomhend@u.washington.edu) +Andrey Hippo (ahippo@yandex.ru) +Sam Jansen (sam.jansen@gmail.com) +Liu Jian (liujatp@gmail.com) Joe Kopena (tjkopena@cs.drexel.edu) +Aleksey Kovalenko (kovalenko@iitp.ru) Mathieu Lacage (mathieu.lacage@sophia.inria.fr) Emmanuelle Laprise (emmmanuelle.laprise@bluekazoo.ca) Federico Maguolo (maguolof@dei.unipd.it) -George F. Riley (riley@ece.gatech.edu) -Guillaume Vu-Brugier (gvubrugier@gmail.com) -Florian Westphal (fw@strlen.de) -Sebastien Vincent (vincent@lsiit.u-strasbg.fr) -David Gross (gdavid.devel@gmail.com) -Mehdi Benamor (mehdi.benamor@telecom-bretagne.eu) -Angelos Chatzipapas (chatzipa@ceid.upatras.gr) -Luis Cortes (cortes@gatech.edu) -Kulin Shah (m.kulin@gmail.com) -Sam Jansen (sam.jansen@gmail.com) -Timo Bingmann (timo.bingmann@student.kit.edu) -Kirill V. Andreev (kirillano@yandex.ru) -Providence Salumu Munga (Providence.Salumu@gmail.com, Providence.Salumu_Munga@it-sudparis.eu) -Mauro Tortonesi (mauro.tortonesi@unife.it) -Aleksey Kovalenko (kovalenko@iitp.ru) -Liu Jian (liujatp@gmail.com) -Andrey Hippo (ahippo@yandex.ru) Francesco Malandrino (francesco.malandrino@gmail.com) Faker Moatamri (faker.moatamri@sophia.inria.fr) +Duy Nguyen (duy@soe.ucsc.edu) Guangyu Pei (guangyu.pei@boeing.com) +George F. Riley (riley@ece.gatech.edu) +Providence Salumu Munga (Providence.Salumu@gmail.com, Providence.Salumu_Munga@it-sudparis.eu) +Kulin Shah (m.kulin@gmail.com) +Mauro Tortonesi (mauro.tortonesi@unife.it) +Sebastien Vincent (vincent@lsiit.u-strasbg.fr) +Guillaume Vu-Brugier (gvubrugier@gmail.com) +Florian Westphal (fw@strlen.de) From 0372fed519ff6a3a9af2f99efb309d14bed41c9a Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Thu, 13 Aug 2009 09:36:16 +0200 Subject: [PATCH 13/28] bug 639: Buffer::CopyData is buggy. --- src/common/buffer.cc | 37 +++++++++++++++++++------------------ src/common/buffer.h | 6 ++++++ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/common/buffer.cc b/src/common/buffer.cc index ddbf8f800..2f1e61838 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -20,6 +20,7 @@ #include "buffer.h" #include "ns3/assert.h" #include "ns3/log.h" +#include "ns3/fatal-error.h" #include NS_LOG_COMPONENT_DEFINE ("Buffer"); @@ -646,25 +647,25 @@ Buffer::PeekData (void) const void Buffer::CopyData(std::ostream *os, uint32_t size) const { - if (size == GetSize ()) + if (size > 0) { - // fast path - os->write((const char*)(m_data->m_data + m_start), m_zeroAreaStart-m_start); - char zero = 0; - for (uint32_t i = 0; i < m_zeroAreaEnd - m_zeroAreaStart; ++i) - { - os->write (&zero, 1); - } - os->write ((const char*)(m_data->m_data + m_zeroAreaStart), m_end - m_zeroAreaEnd); - } - else - { - // slow path - Buffer::Iterator i = Begin (); - while (!i.IsEnd () && size > 0) - { - char byte = i.ReadU8 (); - os->write (&byte, 1); + uint32_t tmpsize = std::min (m_zeroAreaStart-m_start, size); + os->write((const char*)(m_data->m_data + m_start), tmpsize); + if (size > tmpsize) + { + size -= m_zeroAreaStart-m_start; + tmpsize = std::min (m_zeroAreaEnd - m_zeroAreaStart, size); + char zero = 0; + for (uint32_t i = 0; i < tmpsize; ++i) + { + os->write (&zero, 1); + } + if (size > tmpsize) + { + size -= tmpsize; + tmpsize = std::min (m_end - m_zeroAreaEnd, size); + os->write ((const char*)(m_data->m_data + m_zeroAreaStart), tmpsize); + } } } } diff --git a/src/common/buffer.h b/src/common/buffer.h index 3124b8d11..b22ef909d 100644 --- a/src/common/buffer.h +++ b/src/common/buffer.h @@ -487,6 +487,12 @@ public: int32_t GetCurrentStartOffset (void) const; int32_t GetCurrentEndOffset (void) const; + /** + * Copy the specified amount of data from the buffer to the given output stream. + * + * @param os the output stream + * @param size the maximum amount of bytes to copy. If zero, nothing is copied. + */ void CopyData (std::ostream *os, uint32_t size) const; Buffer (Buffer const &o); From 605ca58e9b5f79b4f83f89503693a822dd23825d Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Thu, 13 Aug 2009 09:36:53 +0200 Subject: [PATCH 14/28] bug 639: add configurable capture size to pcap --- src/common/pcap-writer.cc | 89 +++++++++++++++++++++++------ src/common/pcap-writer.h | 15 ++++- src/helper/csma-helper.cc | 2 +- src/helper/emu-helper.cc | 2 +- src/helper/internet-stack-helper.cc | 2 +- src/helper/point-to-point-helper.cc | 2 +- src/helper/yans-wifi-helper.cc | 4 +- 7 files changed, 90 insertions(+), 26 deletions(-) diff --git a/src/common/pcap-writer.cc b/src/common/pcap-writer.cc index 3fbc9bd5d..273f1407f 100644 --- a/src/common/pcap-writer.cc +++ b/src/common/pcap-writer.cc @@ -29,6 +29,7 @@ #include "ns3/assert.h" #include "ns3/abort.h" #include "ns3/simulator.h" +#include "ns3/uinteger.h" #include "pcap-writer.h" #include "packet.h" @@ -36,6 +37,8 @@ NS_LOG_COMPONENT_DEFINE ("PcapWriter"); namespace ns3 { +NS_OBJECT_ENSURE_REGISTERED (PcapWriter); + enum { PCAP_ETHERNET = 1, PCAP_PPP = 9, @@ -45,6 +48,21 @@ enum { PCAP_80211_RADIOTAP = 127, }; +TypeId +PcapWriter::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::PcapWriter") + .SetParent () + .AddConstructor () + .AddAttribute ("CaptureSize", + "Number of bytes to capture at the start of each packet written in the pcap file. Zero means capture all bytes.", + UintegerValue (0), + MakeUintegerAccessor (&PcapWriter::m_captureSize), + MakeUintegerChecker ()) + ; + return tid; +} + PcapWriter::PcapWriter () { NS_LOG_FUNCTION (this); @@ -162,9 +180,18 @@ PcapWriter::WritePacket (Ptr packet) uint64_t us = current % 1000000; Write32 (s & 0xffffffff); Write32 (us & 0xffffffff); - Write32 (packet->GetSize ()); - Write32 (packet->GetSize ()); - packet->CopyData (m_writer, packet->GetSize ()); + uint32_t thisCaptureSize; + if (m_captureSize == 0) + { + thisCaptureSize = packet->GetSize (); + } + else + { + thisCaptureSize = std::min (m_captureSize, packet->GetSize ()); + } + Write32 (thisCaptureSize); + Write32 (packet->GetSize ()); // actual packet size + packet->CopyData (m_writer, thisCaptureSize); } } @@ -203,7 +230,10 @@ void PcapWriter::WriteWifiMonitorPacket(Ptr packet, uint16_t chann // real devices (e.g. madwifi) handle this case, especially for TX // packets (radiotap specs says TSFT is not used for TX packets, // but madwifi actually uses it). - uint64_t tsft = current; + uint64_t tsft = current; + + + uint32_t wifiMonitorHeaderSize; if (m_pcapMode == PCAP_80211_PRISM) { @@ -226,10 +256,17 @@ void PcapWriter::WriteWifiMonitorPacket(Ptr packet, uint16_t chann #define PRISM_ITEM_LENGTH 4 - - uint32_t size = packet->GetSize () + PRISM_MSG_LENGTH; - Write32 (size); // total packet size - Write32 (size); // captured size + wifiMonitorHeaderSize = PRISM_MSG_LENGTH; + if (m_captureSize == 0) + { + Write32 (packet->GetSize () + wifiMonitorHeaderSize); // captured size == actual packet size + } + else + { + uint32_t thisCaptureSize = std::min (m_captureSize, packet->GetSize () + wifiMonitorHeaderSize); + Write32 (thisCaptureSize); + } + Write32 (packet->GetSize () + wifiMonitorHeaderSize); // actual packet size Write32(PRISM_MSG_CODE); Write32(PRISM_MSG_LENGTH); @@ -349,18 +386,26 @@ void PcapWriter::WriteWifiMonitorPacket(Ptr packet, uint16_t chann #define RADIOTAP_TX_PRESENT (RADIOTAP_TSFT | RADIOTAP_FLAGS | RADIOTAP_RATE | RADIOTAP_CHANNEL) #define RADIOTAP_TX_LENGTH (8+8+1+1+2+2) - - uint32_t size; + if (isTx) { - size = packet->GetSize () + RADIOTAP_TX_LENGTH; + wifiMonitorHeaderSize = RADIOTAP_TX_LENGTH; } else { - size = packet->GetSize () + RADIOTAP_RX_LENGTH; + wifiMonitorHeaderSize = RADIOTAP_RX_LENGTH; + } + + if (m_captureSize == 0) + { + Write32 (packet->GetSize () + wifiMonitorHeaderSize); // captured size == actual packet size } - Write32 (size); // total packet size - Write32 (size); // captured size + else + { + uint32_t thisCaptureSize = std::min (m_captureSize, packet->GetSize () + wifiMonitorHeaderSize); + Write32 (thisCaptureSize); + } + Write32 (packet->GetSize () + wifiMonitorHeaderSize); // actual packet size Write8(0); // radiotap version Write8(0); // padding @@ -412,11 +457,23 @@ void PcapWriter::WriteWifiMonitorPacket(Ptr packet, uint16_t chann } // finally, write rest of packet - packet->CopyData (m_writer, packet->GetSize ()); + if (m_captureSize == 0) + { + packet->CopyData (m_writer, packet->GetSize ()); + } + else + { + packet->CopyData (m_writer, m_captureSize - wifiMonitorHeaderSize); + } + } - +void +PcapWriter::SetCaptureSize (uint32_t size) +{ + m_captureSize = size; +} int8_t PcapWriter::RoundToInt8 (double value) diff --git a/src/common/pcap-writer.h b/src/common/pcap-writer.h index d99754915..b688e6001 100644 --- a/src/common/pcap-writer.h +++ b/src/common/pcap-writer.h @@ -22,7 +22,7 @@ #define PCAP_WRITER_H #include -#include "ns3/ref-count-base.h" +#include "ns3/object.h" namespace ns3 { @@ -36,9 +36,10 @@ class Packet; * Log Packets to a file in pcap format which can be * read by pcap readers. */ -class PcapWriter : public RefCountBase +class PcapWriter : public Object { public: + static TypeId GetTypeId (void); PcapWriter (); ~PcapWriter (); @@ -128,7 +129,13 @@ public: uint32_t rate, bool isShortPreamble, bool isTx, double signalDbm, double noiseDbm); - + /** + * Set the maximum number of bytes to be captured for each packet. + * + * @param size the maximum number of bytes to be captured. If zero + * (default), the whole packet will be captured. + */ + void SetCaptureSize (uint32_t size); private: @@ -141,6 +148,8 @@ private: int8_t RoundToInt8 (double value); std::ofstream *m_writer; uint32_t m_pcapMode; + uint32_t m_captureSize; + }; } // namespace ns3 diff --git a/src/helper/csma-helper.cc b/src/helper/csma-helper.cc index be3337d8f..34c55f143 100644 --- a/src/helper/csma-helper.cc +++ b/src/helper/csma-helper.cc @@ -76,7 +76,7 @@ CsmaHelper::EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid } oss.str (""); oss << filename << "-" << nodeid << "-" << deviceid << ".pcap"; - Ptr pcap = Create (); + Ptr pcap = CreateObject (); pcap->Open (oss.str ()); pcap->WriteEthernetHeader (); oss.str (""); diff --git a/src/helper/emu-helper.cc b/src/helper/emu-helper.cc index de11a1117..a5298834f 100644 --- a/src/helper/emu-helper.cc +++ b/src/helper/emu-helper.cc @@ -70,7 +70,7 @@ EmuHelper::EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid, NS_LOG_FUNCTION (filename << nodeid << deviceid << promiscuous); std::ostringstream oss; oss << filename << "-" << nodeid << "-" << deviceid << ".pcap"; - Ptr pcap = Create (); + Ptr pcap = CreateObject (); pcap->Open (oss.str ()); pcap->WriteEthernetHeader (); diff --git a/src/helper/internet-stack-helper.cc b/src/helper/internet-stack-helper.cc index ad65850e4..03fc978ed 100644 --- a/src/helper/internet-stack-helper.cc +++ b/src/helper/internet-stack-helper.cc @@ -356,7 +356,7 @@ InternetStackHelper::GetStream (uint32_t nodeId, uint32_t interfaceId) InternetStackHelper::Trace trace; trace.nodeId = nodeId; trace.interfaceId = interfaceId; - trace.writer = Create (); + trace.writer = CreateObject (); std::ostringstream oss; oss << m_pcapBaseFilename << "-" << nodeId << "-" << interfaceId << ".pcap"; trace.writer->Open (oss.str ()); diff --git a/src/helper/point-to-point-helper.cc b/src/helper/point-to-point-helper.cc index e53bd6ed8..e6f04b76f 100644 --- a/src/helper/point-to-point-helper.cc +++ b/src/helper/point-to-point-helper.cc @@ -75,7 +75,7 @@ PointToPointHelper::EnablePcap (std::string filename, uint32_t nodeid, uint32_t } oss.str (""); oss << filename << "-" << nodeid << "-" << deviceid << ".pcap"; - Ptr pcap = Create (); + Ptr pcap = CreateObject (); pcap->Open (oss.str ()); pcap->WritePppHeader (); oss.str (""); diff --git a/src/helper/yans-wifi-helper.cc b/src/helper/yans-wifi-helper.cc index 626f9d24a..4848cb268 100644 --- a/src/helper/yans-wifi-helper.cc +++ b/src/helper/yans-wifi-helper.cc @@ -234,9 +234,7 @@ YansWifiPhyHelper::EnablePcap (std::string filename, uint32_t nodeid, uint32_t d } oss.str (""); oss << filename << "-" << nodeid << "-" << deviceid << ".pcap"; - // we must fully-qualify the call to Create below because it conflicts - // with the locally-defined WifiPhyHelper::Create method. - Ptr pcap = ::ns3::Create (); + Ptr pcap = CreateObject (); pcap->Open (oss.str ()); switch (m_pcapFormat) { From e0160608a793608b26f6d29ff671b88bec223795 Mon Sep 17 00:00:00 2001 From: Wilson Thong Date: Thu, 13 Aug 2009 09:47:53 +0200 Subject: [PATCH 15/28] bug 638: add missing tx trace source --- src/applications/udp-echo/udp-echo-client.cc | 14 ++++++++++---- src/applications/udp-echo/udp-echo-client.h | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/applications/udp-echo/udp-echo-client.cc b/src/applications/udp-echo/udp-echo-client.cc index 7553f0306..363e74c3f 100644 --- a/src/applications/udp-echo/udp-echo-client.cc +++ b/src/applications/udp-echo/udp-echo-client.cc @@ -24,6 +24,7 @@ #include "ns3/socket-factory.h" #include "ns3/packet.h" #include "ns3/uinteger.h" +#include "ns3/trace-source-accessor.h" #include "udp-echo-client.h" namespace ns3 { @@ -62,6 +63,8 @@ UdpEchoClient::GetTypeId (void) MakeUintegerAccessor (&UdpEchoClient::SetDataSize, &UdpEchoClient::GetDataSize), MakeUintegerChecker ()) + .AddTraceSource ("Tx", "A new packet is created and is sent", + MakeTraceSourceAccessor (&UdpEchoClient::m_txTrace)) ; return tid; } @@ -246,6 +249,7 @@ UdpEchoClient::Send (void) NS_ASSERT (m_sendEvent.IsExpired ()); + Ptr p; if (m_dataSize) { // @@ -256,8 +260,7 @@ UdpEchoClient::Send (void) // NS_ASSERT_MSG (m_dataSize == m_size, "UdpEchoClient::Send(): m_size and m_dataSize inconsistent"); NS_ASSERT_MSG (m_data, "UdpEchoClient::Send(): m_dataSize but no m_data"); - Ptr p = Create (m_data, m_dataSize); - m_socket->Send (p); + p = Create (m_data, m_dataSize); } else { @@ -268,9 +271,12 @@ UdpEchoClient::Send (void) // this case, we don't worry about it either. But we do allow m_size // to have a value different from the (zero) m_dataSize. // - Ptr p = Create (m_size); - m_socket->Send (p); + p = Create (m_size); } + // call to the trace sinks before the packet is actually sent, + // so that tags added to the packet can be sent as well + m_txTrace (p); + m_socket->Send (p); ++m_sent; diff --git a/src/applications/udp-echo/udp-echo-client.h b/src/applications/udp-echo/udp-echo-client.h index c8514640b..faabcd781 100644 --- a/src/applications/udp-echo/udp-echo-client.h +++ b/src/applications/udp-echo/udp-echo-client.h @@ -23,6 +23,7 @@ #include "ns3/event-id.h" #include "ns3/ptr.h" #include "ns3/ipv4-address.h" +#include "ns3/traced-callback.h" namespace ns3 { @@ -140,7 +141,8 @@ private: Ipv4Address m_peerAddress; uint16_t m_peerPort; EventId m_sendEvent; - + /// Callbacks for tracing the packet Tx events + TracedCallback > m_txTrace; }; } // namespace ns3 From c11373476eb59e83ca962fba02c5c873b7b2f637 Mon Sep 17 00:00:00 2001 From: Guillaume Seguin Date: Thu, 13 Aug 2009 12:54:21 +0200 Subject: [PATCH 16/28] add an ascii writer class --- src/common/ascii-writer.cc | 89 ++++++++++++++++++++++++++++++++++++++ src/common/ascii-writer.h | 67 ++++++++++++++++++++++++++++ src/common/wscript | 2 + 3 files changed, 158 insertions(+) create mode 100644 src/common/ascii-writer.cc create mode 100644 src/common/ascii-writer.h diff --git a/src/common/ascii-writer.cc b/src/common/ascii-writer.cc new file mode 100644 index 000000000..e00b6f485 --- /dev/null +++ b/src/common/ascii-writer.cc @@ -0,0 +1,89 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2009 INRIA + * + * 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Guillaume Seguin + */ +#include "ascii-writer.h" + +#include "ns3/log.h" +#include "ns3/simulator.h" +#include "ns3/simulation-singleton.h" +#include "ns3/packet.h" + +#include +#include + + +NS_LOG_COMPONENT_DEFINE ("AsciiWriter"); + +namespace ns3 { + +typedef std::map > AsciiWritersMap; + +Ptr +AsciiWriter::Get (std::ostream &os) +{ + AsciiWritersMap *map = SimulationSingleton::Get (); + Ptr writer = (*map)[&os]; + if (writer == 0) + { + // don't call Create<> because constructor is private + writer = Ptr (new AsciiWriter (&os), false); + (*map)[&os] = writer; + } + return writer; +} + +AsciiWriter::AsciiWriter (std::ostream *os) + : m_writer (os) +{ + NS_LOG_FUNCTION (this); +} + +AsciiWriter::~AsciiWriter (void) +{ + NS_LOG_FUNCTION (this); +} + +void +AsciiWriter::WritePacket (enum Type type, std::string message, Ptr packet) +{ + std::string typeString; + switch (type) + { + case ENQUEUE: + typeString = "+"; + break; + case DEQUEUE: + typeString = "-"; + break; + case RX: + typeString = "r"; + break; + case TX: + typeString = "t"; + break; + case DROP: + typeString = "d"; + break; + } + NS_LOG_FUNCTION (this << typeString << message); + *m_writer << typeString << " " << Simulator::Now ().GetSeconds () << " " + << message << " " << *packet << std::endl; +} + +} // namespace ns3 diff --git a/src/common/ascii-writer.h b/src/common/ascii-writer.h new file mode 100644 index 000000000..03cdc7cf4 --- /dev/null +++ b/src/common/ascii-writer.h @@ -0,0 +1,67 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2009 INRIA + * + * 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Guillaume Seguin + */ + +#ifndef ASCII_WRITER_H +#define ASCII_WRITER_H + +#include +#include +#include "ns3/ref-count-base.h" +#include "ns3/ptr.h" + +namespace ns3 { + +class Packet; + +/** + * \ingroup common + * + * \brief Ascii output + */ +class AsciiWriter : public RefCountBase +{ +public: + static Ptr Get (std::ostream &os); + + enum Type { + ENQUEUE, + DEQUEUE, + DROP, + TX, + RX + }; + + ~AsciiWriter (void); + + /** + * Writes a message in the output file, checking if the files will + * need to be reordered. + */ + void WritePacket (enum Type type, std::string message, Ptr p); + +private: + AsciiWriter (std::ostream *os); + + std::ostream *m_writer; +}; + +} // namespace ns3 + +#endif /* ASCII_WRITER_H */ diff --git a/src/common/wscript b/src/common/wscript index e8e028511..d6f0d8d09 100644 --- a/src/common/wscript +++ b/src/common/wscript @@ -17,6 +17,7 @@ def build(bld): 'byte-tag-list.cc', 'tag-buffer.cc', 'packet-tag-list.cc', + 'ascii-writer.cc', ] headers = bld.new_task_gen('ns3header') @@ -35,4 +36,5 @@ def build(bld): 'byte-tag-list.h', 'tag-buffer.h', 'packet-tag-list.h', + 'ascii-writer.h', ] From 0ff784c41f56457416842e27fb264f3eaffdbeab Mon Sep 17 00:00:00 2001 From: Guillaume Seguin Date: Thu, 13 Aug 2009 12:54:22 +0200 Subject: [PATCH 17/28] use ascii writer --- src/helper/csma-helper.cc | 32 +++++++------- src/helper/csma-helper.h | 10 ++--- src/helper/emu-helper.cc | 66 +++++++++++++---------------- src/helper/emu-helper.h | 9 ++-- src/helper/internet-stack-helper.cc | 12 +++--- src/helper/internet-stack-helper.h | 3 +- src/helper/point-to-point-helper.cc | 41 +++++++++--------- src/helper/point-to-point-helper.h | 9 ++-- src/helper/yans-wifi-helper.cc | 18 ++++---- 9 files changed, 98 insertions(+), 102 deletions(-) diff --git a/src/helper/csma-helper.cc b/src/helper/csma-helper.cc index 34c55f143..234a75c2f 100644 --- a/src/helper/csma-helper.cc +++ b/src/helper/csma-helper.cc @@ -23,10 +23,11 @@ #include "ns3/queue.h" #include "ns3/csma-net-device.h" #include "ns3/csma-channel.h" -#include "ns3/pcap-writer.h" #include "ns3/config.h" #include "ns3/packet.h" #include "ns3/names.h" +#include "ns3/pcap-writer.h" +#include "ns3/ascii-writer.h" #include namespace ns3 { @@ -139,19 +140,20 @@ CsmaHelper::EnablePcapAll (std::string filename, bool promiscuous) void CsmaHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid) { + Ptr writer = AsciiWriter::Get (os); Packet::EnablePrinting (); std::ostringstream oss; oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/MacRx"; - Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiRxEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiRxEvent, writer)); oss.str (""); oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/TxQueue/Enqueue"; - Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiEnqueueEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiEnqueueEvent, writer)); oss.str (""); oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/TxQueue/Dequeue"; - Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiDequeueEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiDequeueEvent, writer)); oss.str (""); oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/TxQueue/Drop"; - Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiDropEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiDropEvent, writer)); } void CsmaHelper::EnableAscii (std::ostream &os, NetDeviceContainer d) @@ -294,31 +296,27 @@ CsmaHelper::SniffEvent (Ptr writer, Ptr packet) } void -CsmaHelper::AsciiEnqueueEvent (std::ostream *os, std::string path, Ptr packet) +CsmaHelper::AsciiEnqueueEvent (Ptr writer, std::string path, Ptr packet) { - *os << "+ " << Simulator::Now ().GetSeconds () << " "; - *os << path << " " << *packet << std::endl; + writer->WritePacket (AsciiWriter::ENQUEUE, path, packet); } void -CsmaHelper::AsciiDequeueEvent (std::ostream *os, std::string path, Ptr packet) +CsmaHelper::AsciiDequeueEvent (Ptr writer, std::string path, Ptr packet) { - *os << "- " << Simulator::Now ().GetSeconds () << " "; - *os << path << " " << *packet << std::endl; + writer->WritePacket (AsciiWriter::DEQUEUE, path, packet); } void -CsmaHelper::AsciiDropEvent (std::ostream *os, std::string path, Ptr packet) +CsmaHelper::AsciiDropEvent (Ptr writer, std::string path, Ptr packet) { - *os << "d " << Simulator::Now ().GetSeconds () << " "; - *os << path << " " << *packet << std::endl; + writer->WritePacket (AsciiWriter::DROP, path, packet); } void -CsmaHelper::AsciiRxEvent (std::ostream *os, std::string path, Ptr packet) +CsmaHelper::AsciiRxEvent (Ptr writer, std::string path, Ptr packet) { - *os << "r " << Simulator::Now ().GetSeconds () << " "; - *os << path << " " << *packet << std::endl; + writer->WritePacket (AsciiWriter::RX, path, packet); } } // namespace ns3 diff --git a/src/helper/csma-helper.h b/src/helper/csma-helper.h index 4f6aa6025..490fb2923 100644 --- a/src/helper/csma-helper.h +++ b/src/helper/csma-helper.h @@ -21,7 +21,6 @@ #define CSMA_HELPER_H #include -#include #include "ns3/attribute.h" #include "ns3/object-factory.h" #include "ns3/net-device-container.h" @@ -33,6 +32,7 @@ namespace ns3 { class Packet; class PcapWriter; +class AsciiWriter; /** * \brief build a set of CsmaNetDevice objects @@ -353,10 +353,10 @@ private: static void SniffEvent (Ptr writer, Ptr packet); - static void AsciiRxEvent (std::ostream *os, std::string path, Ptr packet); - static void AsciiEnqueueEvent (std::ostream *os, std::string path, Ptr packet); - static void AsciiDequeueEvent (std::ostream *os, std::string path, Ptr packet); - static void AsciiDropEvent (std::ostream *os, std::string path, Ptr packet); + static void AsciiRxEvent (Ptr writer, std::string path, Ptr packet); + static void AsciiEnqueueEvent (Ptr writer, std::string path, Ptr packet); + static void AsciiDequeueEvent (Ptr writer, std::string path, Ptr packet); + static void AsciiDropEvent (Ptr writer, std::string path, Ptr packet); ObjectFactory m_queueFactory; ObjectFactory m_deviceFactory; diff --git a/src/helper/emu-helper.cc b/src/helper/emu-helper.cc index a5298834f..758a259f1 100644 --- a/src/helper/emu-helper.cc +++ b/src/helper/emu-helper.cc @@ -25,6 +25,7 @@ #include "ns3/queue.h" #include "ns3/emu-net-device.h" #include "ns3/pcap-writer.h" +#include "ns3/ascii-writer.h" #include "ns3/config.h" #include "ns3/packet.h" @@ -140,23 +141,24 @@ void EmuHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid) { NS_LOG_FUNCTION (&os << nodeid << deviceid); + Ptr writer = AsciiWriter::Get (os); Packet::EnablePrinting (); std::ostringstream oss; oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::EmuNetDevice/MacRx"; - Config::Connect (oss.str (), MakeBoundCallback (&EmuHelper::AsciiRxEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&EmuHelper::AsciiRxEvent, writer)); oss.str (""); oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::EmuNetDevice/TxQueue/Enqueue"; - Config::Connect (oss.str (), MakeBoundCallback (&EmuHelper::AsciiEnqueueEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&EmuHelper::AsciiEnqueueEvent, writer)); oss.str (""); oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::EmuNetDevice/TxQueue/Dequeue"; - Config::Connect (oss.str (), MakeBoundCallback (&EmuHelper::AsciiDequeueEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&EmuHelper::AsciiDequeueEvent, writer)); oss.str (""); oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::EmuNetDevice/TxQueue/Drop"; - Config::Connect (oss.str (), MakeBoundCallback (&EmuHelper::AsciiDropEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&EmuHelper::AsciiDropEvent, writer)); } void @@ -238,48 +240,40 @@ EmuHelper::SniffEvent (Ptr writer, Ptr packet) writer->WritePacket (packet); } -void -EmuHelper::AsciiEnqueueEvent ( - std::ostream *os, - std::string path, - Ptr packet) +void +EmuHelper::AsciiEnqueueEvent (Ptr writer, + std::string path, + Ptr packet) { - NS_LOG_FUNCTION (&os << path << packet); - *os << "+ " << Simulator::Now ().GetSeconds () << " "; - *os << path << " " << *packet << std::endl; + NS_LOG_FUNCTION (writer << path << packet); + writer->WritePacket (AsciiWriter::ENQUEUE, path, packet); } -void -EmuHelper::AsciiDequeueEvent ( - std::ostream *os, - std::string path, - Ptr packet) +void +EmuHelper::AsciiDequeueEvent (Ptr writer, + std::string path, + Ptr packet) { - NS_LOG_FUNCTION (&os << path << packet); - *os << "- " << Simulator::Now ().GetSeconds () << " "; - *os << path << " " << *packet << std::endl; + NS_LOG_FUNCTION (writer << path << packet); + writer->WritePacket (AsciiWriter::DEQUEUE, path, packet); } -void -EmuHelper::AsciiDropEvent ( - std::ostream *os, - std::string path, - Ptr packet) +void +EmuHelper::AsciiDropEvent (Ptr writer, + std::string path, + Ptr packet) { - NS_LOG_FUNCTION (&os << path << packet); - *os << "d " << Simulator::Now ().GetSeconds () << " "; - *os << path << " " << *packet << std::endl; + NS_LOG_FUNCTION (writer << path << packet); + writer->WritePacket (AsciiWriter::DROP, path, packet); } -void -EmuHelper::AsciiRxEvent ( - std::ostream *os, - std::string path, - Ptr packet) +void +EmuHelper::AsciiRxEvent (Ptr writer, + std::string path, + Ptr packet) { - NS_LOG_FUNCTION (&os << path << packet); - *os << "r " << Simulator::Now ().GetSeconds () << " "; - *os << path << " " << *packet << std::endl; + NS_LOG_FUNCTION (writer << path << packet); + writer->WritePacket (AsciiWriter::RX, path, packet); } } // namespace ns3 diff --git a/src/helper/emu-helper.h b/src/helper/emu-helper.h index 2aeb297ec..8ea9a018e 100644 --- a/src/helper/emu-helper.h +++ b/src/helper/emu-helper.h @@ -31,6 +31,7 @@ namespace ns3 { class Packet; class PcapWriter; +class AsciiWriter; /** * \brief build a set of EmuNetDevice objects @@ -208,10 +209,10 @@ private: Ptr InstallPriv (Ptr node) const; static void SniffEvent (Ptr writer, Ptr packet); - static void AsciiRxEvent (std::ostream *os, std::string path, Ptr packet); - static void AsciiEnqueueEvent (std::ostream *os, std::string path, Ptr packet); - static void AsciiDequeueEvent (std::ostream *os, std::string path, Ptr packet); - static void AsciiDropEvent (std::ostream *os, std::string path, Ptr packet); + static void AsciiRxEvent (Ptr writer, std::string path, Ptr packet); + static void AsciiEnqueueEvent (Ptr writer, std::string path, Ptr packet); + static void AsciiDequeueEvent (Ptr writer, std::string path, Ptr packet); + static void AsciiDropEvent (Ptr writer, std::string path, Ptr packet); ObjectFactory m_queueFactory; ObjectFactory m_deviceFactory; diff --git a/src/helper/internet-stack-helper.cc b/src/helper/internet-stack-helper.cc index 03fc978ed..87dc99f44 100644 --- a/src/helper/internet-stack-helper.cc +++ b/src/helper/internet-stack-helper.cc @@ -161,6 +161,8 @@ #include "ns3/callback.h" #include "ns3/node.h" #include "ns3/core-config.h" +#include "ns3/pcap-writer.h" +#include "ns3/ascii-writer.h" #include "internet-stack-helper.h" #include "ipv4-list-routing-helper.h" #include "ipv4-static-routing-helper.h" @@ -279,16 +281,17 @@ InternetStackHelper::Install (std::string nodeName) const void InternetStackHelper::EnableAscii (std::ostream &os, NodeContainer n) { + Ptr writer = AsciiWriter::Get (os); Packet::EnablePrinting (); std::ostringstream oss; for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i) { Ptr node = *i; oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Drop"; - Config::Connect (oss.str (), MakeBoundCallback (&InternetStackHelper::AsciiDropEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&InternetStackHelper::AsciiDropEvent, writer)); oss.str (""); oss << "/NodeList/" << node->GetId () << "/$ns3::ArpL3Protocol/Drop"; - Config::Connect (oss.str (), MakeBoundCallback (&InternetStackHelper::AsciiDropEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&InternetStackHelper::AsciiDropEvent, writer)); oss.str (""); } } @@ -366,10 +369,9 @@ InternetStackHelper::GetStream (uint32_t nodeId, uint32_t interfaceId) } void -InternetStackHelper::AsciiDropEvent (std::ostream *os, std::string path, Ptr packet) +InternetStackHelper::AsciiDropEvent (Ptr writer, std::string path, Ptr packet) { - *os << "d " << Simulator::Now ().GetSeconds () << " "; - *os << path << " " << *packet << std::endl; + writer->WritePacket (AsciiWriter::DROP, path, packet); } } // namespace ns3 diff --git a/src/helper/internet-stack-helper.h b/src/helper/internet-stack-helper.h index 396b564d4..734096e43 100644 --- a/src/helper/internet-stack-helper.h +++ b/src/helper/internet-stack-helper.h @@ -23,7 +23,6 @@ #include "node-container.h" #include "net-device-container.h" -#include "ns3/pcap-writer.h" #include "ns3/packet.h" #include "ns3/ptr.h" #include "ns3/object-factory.h" @@ -169,7 +168,7 @@ private: uint32_t interfaceId; Ptr writer; }; - static void AsciiDropEvent (std::ostream *os, std::string path, Ptr packet); + static void AsciiDropEvent (Ptr writer, std::string path, Ptr packet); static std::string m_pcapBaseFilename; static uint32_t GetNodeIndex (std::string context); static std::vector m_traces; diff --git a/src/helper/point-to-point-helper.cc b/src/helper/point-to-point-helper.cc index e6f04b76f..d3d182e6d 100644 --- a/src/helper/point-to-point-helper.cc +++ b/src/helper/point-to-point-helper.cc @@ -22,10 +22,11 @@ #include "ns3/point-to-point-net-device.h" #include "ns3/point-to-point-channel.h" #include "ns3/queue.h" -#include "ns3/pcap-writer.h" #include "ns3/config.h" #include "ns3/packet.h" #include "ns3/names.h" +#include "ns3/pcap-writer.h" +#include "ns3/ascii-writer.h" namespace ns3 { @@ -131,19 +132,20 @@ PointToPointHelper::EnablePcapAll (std::string filename) void PointToPointHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid) { + Ptr writer = AsciiWriter::Get (os); Packet::EnablePrinting (); std::ostringstream oss; oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/MacRx"; - Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiRxEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiRxEvent, writer)); oss.str (""); oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Enqueue"; - Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiEnqueueEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiEnqueueEvent, writer)); oss.str (""); oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Dequeue"; - Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiDequeueEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiDequeueEvent, writer)); oss.str (""); oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Drop"; - Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiDropEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiDropEvent, writer)); } void @@ -256,32 +258,29 @@ PointToPointHelper::SniffEvent (Ptr writer, Ptr packet writer->WritePacket (packet); } -void -PointToPointHelper::AsciiEnqueueEvent (std::ostream *os, std::string path, Ptr packet) +void +PointToPointHelper::AsciiEnqueueEvent (Ptr writer, std::string path, + Ptr packet) { - *os << "+ " << Simulator::Now ().GetSeconds () << " "; - *os << path << " " << *packet << std::endl; + writer->WritePacket (AsciiWriter::ENQUEUE, path, packet); } -void -PointToPointHelper::AsciiDequeueEvent (std::ostream *os, std::string path, Ptr packet) +void +PointToPointHelper::AsciiDequeueEvent (Ptr writer, std::string path, Ptr packet) { - *os << "- " << Simulator::Now ().GetSeconds () << " "; - *os << path << " " << *packet << std::endl; + writer->WritePacket (AsciiWriter::DEQUEUE, path, packet); } -void -PointToPointHelper::AsciiDropEvent (std::ostream *os, std::string path, Ptr packet) +void +PointToPointHelper::AsciiDropEvent (Ptr writer, std::string path, Ptr packet) { - *os << "d " << Simulator::Now ().GetSeconds () << " "; - *os << path << " " << *packet << std::endl; + writer->WritePacket (AsciiWriter::DROP, path, packet); } -void -PointToPointHelper::AsciiRxEvent (std::ostream *os, std::string path, Ptr packet) +void +PointToPointHelper::AsciiRxEvent (Ptr writer, std::string path, Ptr packet) { - *os << "r " << Simulator::Now ().GetSeconds () << " "; - *os << path << " " << *packet << std::endl; + writer->WritePacket (AsciiWriter::RX, path, packet); } } // namespace ns3 diff --git a/src/helper/point-to-point-helper.h b/src/helper/point-to-point-helper.h index b55734e10..4edfa5499 100644 --- a/src/helper/point-to-point-helper.h +++ b/src/helper/point-to-point-helper.h @@ -32,6 +32,7 @@ class Queue; class NetDevice; class Node; class PcapWriter; +class AsciiWriter; /** * \brief build a set of PointToPointNetDevice objects @@ -286,10 +287,10 @@ private: static void SniffEvent (Ptr writer, Ptr packet); void EnableAscii (Ptr node, Ptr device); - static void AsciiRxEvent (std::ostream *os, std::string path, Ptr packet); - static void AsciiEnqueueEvent (std::ostream *os, std::string path, Ptr packet); - static void AsciiDequeueEvent (std::ostream *os, std::string path, Ptr packet); - static void AsciiDropEvent (std::ostream *os, std::string path, Ptr packet); + static void AsciiRxEvent (Ptr writer, std::string path, Ptr packet); + static void AsciiEnqueueEvent (Ptr writer, std::string path, Ptr packet); + static void AsciiDequeueEvent (Ptr writer, std::string path, Ptr packet); + static void AsciiDropEvent (Ptr writer, std::string path, Ptr packet); ObjectFactory m_queueFactory; ObjectFactory m_channelFactory; diff --git a/src/helper/yans-wifi-helper.cc b/src/helper/yans-wifi-helper.cc index 4848cb268..9af1ed6b2 100644 --- a/src/helper/yans-wifi-helper.cc +++ b/src/helper/yans-wifi-helper.cc @@ -25,6 +25,7 @@ #include "ns3/yans-wifi-phy.h" #include "ns3/wifi-net-device.h" #include "ns3/pcap-writer.h" +#include "ns3/ascii-writer.h" #include "ns3/simulator.h" #include "ns3/config.h" #include "ns3/names.h" @@ -46,19 +47,19 @@ static void PcapSniffRxEvent (Ptr writer, Ptr packet, } -static void AsciiPhyTxEvent (std::ostream *os, std::string context, +static void AsciiPhyTxEvent (Ptr writer, std::string path, Ptr packet, - WifiMode mode, WifiPreamble preamble, + WifiMode mode, WifiPreamble preamble, uint8_t txLevel) { - *os << "+ " << Simulator::Now () << " " << context << " " << *packet << std::endl; + writer->WritePacket (AsciiWriter::TX, path, packet); } -static void AsciiPhyRxOkEvent (std::ostream *os, std::string context, - Ptr packet, double snr, WifiMode mode, +static void AsciiPhyRxOkEvent (Ptr writer, std::string path, + Ptr packet, double snr, WifiMode mode, enum WifiPreamble preamble) { - *os << "r " << Simulator::Now () << " " << context << " " << *packet << std::endl; + writer->WritePacket (AsciiWriter::RX, path, packet); } @@ -307,13 +308,14 @@ YansWifiPhyHelper::EnablePcapAll (std::string filename) void YansWifiPhyHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid) { + Ptr writer = AsciiWriter::Get (os); Packet::EnablePrinting (); std::ostringstream oss; oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/RxOk"; - Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyRxOkEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyRxOkEvent, writer)); oss.str (""); oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/Tx"; - Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyTxEvent, &os)); + Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyTxEvent, writer)); } void YansWifiPhyHelper::EnableAscii (std::ostream &os, NetDeviceContainer d) From 990b54684c9864c2e0c431e77b2bdec312915426 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Thu, 13 Aug 2009 13:12:16 +0200 Subject: [PATCH 18/28] bug 654: avoid segfault with ConfigStore loading --- src/devices/wifi/wifi-mode.cc | 26 +++++++++++++++----------- src/devices/wifi/wifi-mode.h | 3 ++- src/devices/wifi/wifi-phy-standard.h | 3 ++- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/devices/wifi/wifi-mode.cc b/src/devices/wifi/wifi-mode.cc index 485551d10..60b0814df 100644 --- a/src/devices/wifi/wifi-mode.cc +++ b/src/devices/wifi/wifi-mode.cc @@ -88,11 +88,6 @@ std::string WifiMode::GetUniqueName (void) const { // needed for ostream printing of the invalid mode - if (m_uid == 0) - { - return "Invalid-WifiMode"; - } - struct WifiModeFactory::WifiModeItem *item = WifiModeFactory::GetFactory ()->Get (m_uid); return item->uniqueUid; } @@ -220,7 +215,7 @@ WifiModeFactory::CreateDqpsk (std::string uniqueName, bool WifiModeFactory::Search (std::string name, WifiMode *mode) { - uint32_t j = 1; + uint32_t j = 0; for (WifiModeItemList::const_iterator i = m_itemList.begin (); i != m_itemList.end (); i++) { @@ -238,7 +233,7 @@ WifiModeFactory::Search (std::string name, WifiMode *mode) uint32_t WifiModeFactory::AllocateUid (std::string uniqueUid) { - uint32_t j = 1; + uint32_t j = 0; for (WifiModeItemList::const_iterator i = m_itemList.begin (); i != m_itemList.end (); i++) { @@ -248,16 +243,16 @@ WifiModeFactory::AllocateUid (std::string uniqueUid) } j++; } - m_itemList.push_back (WifiModeItem ()); uint32_t uid = m_itemList.size (); + m_itemList.push_back (WifiModeItem ()); return uid; } struct WifiModeFactory::WifiModeItem * WifiModeFactory::Get (uint32_t uid) { - NS_ASSERT (uid > 0 && uid <= m_itemList.size ()); - return &m_itemList[uid - 1]; + NS_ASSERT (uid < m_itemList.size ()); + return &m_itemList[uid]; } WifiModeFactory * @@ -267,7 +262,16 @@ WifiModeFactory::GetFactory (void) static WifiModeFactory factory; if (isFirstTime) { - factory.AllocateUid ("Invalid-WifiMode"); + uint32_t uid = factory.AllocateUid ("Invalid-WifiMode"); + WifiModeItem *item = factory.Get (uid); + item->uniqueUid = "Invalid-WifiMode"; + item->bandwidth = 0; + item->dataRate = 0; + item->phyRate = 0; + item->modulation = WifiMode::UNKNOWN; + item->constellationSize = 0; + item->isMandatory = false; + item->standard = WIFI_PHY_UNKNOWN; isFirstTime = false; } return &factory; diff --git a/src/devices/wifi/wifi-mode.h b/src/devices/wifi/wifi-mode.h index a2247c540..15b73f611 100644 --- a/src/devices/wifi/wifi-mode.h +++ b/src/devices/wifi/wifi-mode.h @@ -44,7 +44,8 @@ class WifiMode BPSK, DBPSK, DQPSK, - QAM + QAM, + UNKNOWN }; /** diff --git a/src/devices/wifi/wifi-phy-standard.h b/src/devices/wifi/wifi-phy-standard.h index 7f6c84bfb..8a3a7b757 100644 --- a/src/devices/wifi/wifi-phy-standard.h +++ b/src/devices/wifi/wifi-phy-standard.h @@ -27,7 +27,8 @@ enum WifiPhyStandard { WIFI_PHY_STANDARD_80211b, WIFI_PHY_STANDARD_80211_10Mhz, WIFI_PHY_STANDARD_80211_5Mhz, - WIFI_PHY_STANDARD_holland + WIFI_PHY_STANDARD_holland, + WIFI_PHY_UNKNOWN }; } // namespace ns3 From e8fa8c79ab8ae7791c2bc42a4404d70c54e1f534 Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Thu, 13 Aug 2009 13:39:14 +0200 Subject: [PATCH 19/28] bug 644: make sure we set standard and frequency correctly in radiotap output --- src/common/pcap-writer.cc | 52 ++++++++++++++++++++----------- src/common/pcap-writer.h | 4 ++- src/devices/wifi/wifi-phy.cc | 8 ++--- src/devices/wifi/wifi-phy.h | 8 ++--- src/devices/wifi/yans-wifi-phy.cc | 4 +-- src/helper/yans-wifi-helper.cc | 8 ++--- 6 files changed, 50 insertions(+), 34 deletions(-) diff --git a/src/common/pcap-writer.cc b/src/common/pcap-writer.cc index 273f1407f..c69cb223e 100644 --- a/src/common/pcap-writer.cc +++ b/src/common/pcap-writer.cc @@ -196,7 +196,7 @@ PcapWriter::WritePacket (Ptr packet) } -void PcapWriter::WriteWifiMonitorPacket(Ptr packet, uint16_t channelFreqMhz, +void PcapWriter::WriteWifiMonitorPacket(Ptr packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, bool isTx, double signalDbm, double noiseDbm) { @@ -288,10 +288,8 @@ void PcapWriter::WriteWifiMonitorPacket(Ptr packet, uint16_t chann Write32(PRISM_DID_CHANNEL); Write16(PRISM_STATUS_PRESENT); - Write16(PRISM_ITEM_LENGTH); - // convert from frequency to channel number. This conversion is - // correct only for IEEE 802.11b/g channels 1-13. - Write32((2437 - 2407) / 5); + Write16(PRISM_ITEM_LENGTH); + Write32((uint32_t) channelNumber); Write32(PRISM_DID_RSSI); Write16(PRISM_STATUS_PRESENT); @@ -372,14 +370,18 @@ void PcapWriter::WriteWifiMonitorPacket(Ptr packet, uint16_t chann #define RADIOTAP_FLAG_DATAPAD 0x20 #define RADIOTAP_FLAG_BADFCS 0x40 -#define RADIOTAP_CHANNEL_TURBO 0x0010 -#define RADIOTAP_CHANNEL_CCK 0x0020 -#define RADIOTAP_CHANNEL_OFDM 0x0040 -#define RADIOTAP_CHANNEL_2GHZ 0x0080 -#define RADIOTAP_CHANNEL_5GHZ 0x0100 -#define RADIOTAP_CHANNEL_PASSIVE 0x0200 -#define RADIOTAP_CHANNEL_DYN 0x0400 -#define RADIOTAP_CHANNEL_GFSK 0x0800 +#define RADIOTAP_CHANNEL_TURBO 0x0010 +#define RADIOTAP_CHANNEL_CCK 0x0020 +#define RADIOTAP_CHANNEL_OFDM 0x0040 +#define RADIOTAP_CHANNEL_2GHZ 0x0080 +#define RADIOTAP_CHANNEL_5GHZ 0x0100 +#define RADIOTAP_CHANNEL_PASSIVE 0x0200 +#define RADIOTAP_CHANNEL_DYN_CCK_OFDM 0x0400 +#define RADIOTAP_CHANNEL_GFSK 0x0800 +#define RADIOTAP_CHANNEL_GSM 0x1000 +#define RADIOTAP_CHANNEL_STATIC_TURBO 0x2000 +#define RADIOTAP_CHANNEL_HALF_RATE 0x4000 +#define RADIOTAP_CHANNEL_QUARTER_RATE 0x8000 #define RADIOTAP_RX_PRESENT (RADIOTAP_TSFT | RADIOTAP_FLAGS | RADIOTAP_RATE | RADIOTAP_CHANNEL | RADIOTAP_DBM_ANTSIGNAL | RADIOTAP_DBM_ANTNOISE) #define RADIOTAP_RX_LENGTH (8+8+1+1+2+2+1+1) @@ -433,12 +435,24 @@ void PcapWriter::WriteWifiMonitorPacket(Ptr packet, uint16_t chann Write8(rate); - Write16((uint16_t) 2437); - - // we might want to make this setting depend on the WifiMode and - // on the ChannelFrequency at some time in the future. But for now - // I think a fixed setting is more than enough for most purposes. - Write16(RADIOTAP_CHANNEL_OFDM | RADIOTAP_CHANNEL_2GHZ); + Write16(channelFreqMhz); + + uint16_t channelFlags; + if (channelFreqMhz < 2500) + { + // TODO: when 802.11g WifiModes will be implemented + // we will need to check dinamically whether channelFlags + // needs to be set to RADIOTAP_CHANNEL_CCK, + // RADIOTAP_CHANNEL_DYN or RADIOTAP_CHANNEL_OFDM. + channelFlags = RADIOTAP_CHANNEL_2GHZ | RADIOTAP_CHANNEL_CCK; + } + else + { + // TODO: we should handle correctly the case of half rate + // (10 MHz channel) and quarter rate (5 Mhz channel). + channelFlags = RADIOTAP_CHANNEL_5GHZ | RADIOTAP_CHANNEL_OFDM; + } + Write16(channelFlags); if (!isTx) { diff --git a/src/common/pcap-writer.h b/src/common/pcap-writer.h index b688e6001..91a878cdc 100644 --- a/src/common/pcap-writer.h +++ b/src/common/pcap-writer.h @@ -117,6 +117,8 @@ public: * transmitted. This is because it is possible to have the receiver * tuned on a given channel and still to be able to receive packets * on a nearby channel. + * @param channelNumber the channel number, as defined by the + * IEEE 802.11 standard. * @param rate the PHY data rate in units of 500kbps (i.e., the same * units used both for the radiotap and for the prism header) * @param isShortPreamble true if short preamble is used, false otherwise @@ -125,7 +127,7 @@ public: * @param signalDbm signal power in dBm * @param noiseDbm noise power in dBm */ - void WriteWifiMonitorPacket(Ptr packet, uint16_t channelFreqMhz, + void WriteWifiMonitorPacket(Ptr packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, bool isTx, double signalDbm, double noiseDbm); diff --git a/src/devices/wifi/wifi-phy.cc b/src/devices/wifi/wifi-phy.cc index 949708f8a..9de83f3c6 100644 --- a/src/devices/wifi/wifi-phy.cc +++ b/src/devices/wifi/wifi-phy.cc @@ -205,15 +205,15 @@ WifiPhy::NotifyRxDrop (Ptr packet) } void -WifiPhy::NotifyPromiscSniffRx (Ptr packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm) +WifiPhy::NotifyPromiscSniffRx (Ptr packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm) { - m_phyPromiscSniffRxTrace (packet, channelFreqMhz, rate, isShortPreamble, signalDbm, noiseDbm); + m_phyPromiscSniffRxTrace (packet, channelFreqMhz, channelNumber, rate, isShortPreamble, signalDbm, noiseDbm); } void -WifiPhy::NotifyPromiscSniffTx (Ptr packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble) +WifiPhy::NotifyPromiscSniffTx (Ptr packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble) { - m_phyPromiscSniffTxTrace (packet, channelFreqMhz, rate, isShortPreamble); + m_phyPromiscSniffTxTrace (packet, channelFreqMhz, channelNumber, rate, isShortPreamble); } WifiMode diff --git a/src/devices/wifi/wifi-phy.h b/src/devices/wifi/wifi-phy.h index f17adac2c..b9519a812 100644 --- a/src/devices/wifi/wifi-phy.h +++ b/src/devices/wifi/wifi-phy.h @@ -341,7 +341,7 @@ public: * @param signalDbm signal power in dBm * @param noiseDbm noise power in dBm */ - void NotifyPromiscSniffRx (Ptr packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble, + void NotifyPromiscSniffRx (Ptr packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm); /** @@ -361,7 +361,7 @@ public: * units used both for the radiotap and for the prism header) * @param isShortPreamble true if short preamble is used, false otherwise */ - void NotifyPromiscSniffTx (Ptr packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble); + void NotifyPromiscSniffTx (Ptr packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble); private: @@ -422,7 +422,7 @@ private: * * \see class CallBackTraceSource */ - TracedCallback, uint16_t, uint32_t, bool, double, double> m_phyPromiscSniffRxTrace; + TracedCallback, uint16_t, uint16_t, uint32_t, bool, double, double> m_phyPromiscSniffRxTrace; /** * A trace source that emulates a wifi device in monitor mode @@ -434,7 +434,7 @@ private: * * \see class CallBackTraceSource */ - TracedCallback, uint16_t, uint32_t, bool> m_phyPromiscSniffTxTrace; + TracedCallback, uint16_t, uint16_t, uint32_t, bool> m_phyPromiscSniffTxTrace; }; diff --git a/src/devices/wifi/yans-wifi-phy.cc b/src/devices/wifi/yans-wifi-phy.cc index 75024b1c2..6d2a36867 100644 --- a/src/devices/wifi/yans-wifi-phy.cc +++ b/src/devices/wifi/yans-wifi-phy.cc @@ -451,7 +451,7 @@ YansWifiPhy::SendPacket (Ptr packet, WifiMode txMode, WifiPreamble NotifyTxBegin (packet); uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000; bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble); - NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate500KbpsUnits, isShortPreamble); + NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble); m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower); m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble); } @@ -657,7 +657,7 @@ YansWifiPhy::EndSync (Ptr packet, Ptr event) bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ()); double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30; double noiseDbm = RatioToDb(event->GetRxPowerW() / snrPer.snr) - GetRxNoiseFigure() + 30 ; - NotifyPromiscSniffRx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm); + NotifyPromiscSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm); m_state->SwitchFromSyncEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ()); } else diff --git a/src/helper/yans-wifi-helper.cc b/src/helper/yans-wifi-helper.cc index 9af1ed6b2..5b5980986 100644 --- a/src/helper/yans-wifi-helper.cc +++ b/src/helper/yans-wifi-helper.cc @@ -32,18 +32,18 @@ namespace ns3 { -static void PcapSniffTxEvent (Ptr writer, Ptr packet, uint16_t channelFreqMhz, +static void PcapSniffTxEvent (Ptr writer, Ptr packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble) { const double unusedValue = 0; - writer->WriteWifiMonitorPacket(packet, channelFreqMhz, rate, isShortPreamble, true, unusedValue, unusedValue); + writer->WriteWifiMonitorPacket(packet, channelFreqMhz, channelNumber, rate, isShortPreamble, true, unusedValue, unusedValue); } -static void PcapSniffRxEvent (Ptr writer, Ptr packet, uint16_t channelFreqMhz, +static void PcapSniffRxEvent (Ptr writer, Ptr packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm) { - writer->WriteWifiMonitorPacket(packet, channelFreqMhz, rate, isShortPreamble, false, signalDbm, noiseDbm); + writer->WriteWifiMonitorPacket(packet, channelFreqMhz, channelNumber, rate, isShortPreamble, false, signalDbm, noiseDbm); } From fe570568ec892cd78bada7e99d0eb1c1534f19e4 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Thu, 13 Aug 2009 13:39:23 +0200 Subject: [PATCH 20/28] rescan python --- bindings/python/ns3_module_common.py | 34 +++++++++++++++++++++++++--- bindings/python/ns3_module_wifi.py | 12 +++++----- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/bindings/python/ns3_module_common.py b/bindings/python/ns3_module_common.py index 08e0b76c8..87debb26c 100644 --- a/bindings/python/ns3_module_common.py +++ b/bindings/python/ns3_module_common.py @@ -43,6 +43,10 @@ def register_types(module): module.add_class('Tag', parent=root_module['ns3::ObjectBase']) ## tag-buffer.h: ns3::TagBuffer [class] module.add_class('TagBuffer') + ## ascii-writer.h: ns3::AsciiWriter [class] + module.add_class('AsciiWriter', parent=root_module['ns3::RefCountBase']) + ## ascii-writer.h: ns3::AsciiWriter::Type [enumeration] + module.add_enum('Type', ['ENQUEUE', 'DEQUEUE', 'DROP', 'TX', 'RX'], outer_class=root_module['ns3::AsciiWriter']) ## chunk.h: ns3::Chunk [class] module.add_class('Chunk', parent=root_module['ns3::ObjectBase']) ## data-rate.h: ns3::DataRateChecker [class] @@ -52,7 +56,7 @@ def register_types(module): ## header.h: ns3::Header [class] module.add_class('Header', parent=root_module['ns3::Chunk']) ## pcap-writer.h: ns3::PcapWriter [class] - module.add_class('PcapWriter', parent=root_module['ns3::RefCountBase']) + module.add_class('PcapWriter', parent=root_module['ns3::Object']) ## trailer.h: ns3::Trailer [class] module.add_class('Trailer', parent=root_module['ns3::Chunk']) ## error-model.h: ns3::ErrorModel [class] @@ -131,6 +135,7 @@ def register_methods(root_module): register_Ns3PacketTagListTagData_methods(root_module, root_module['ns3::PacketTagList::TagData']) register_Ns3Tag_methods(root_module, root_module['ns3::Tag']) register_Ns3TagBuffer_methods(root_module, root_module['ns3::TagBuffer']) + register_Ns3AsciiWriter_methods(root_module, root_module['ns3::AsciiWriter']) register_Ns3Chunk_methods(root_module, root_module['ns3::Chunk']) register_Ns3DataRateChecker_methods(root_module, root_module['ns3::DataRateChecker']) register_Ns3DataRateValue_methods(root_module, root_module['ns3::DataRateValue']) @@ -949,6 +954,20 @@ def register_Ns3TagBuffer_methods(root_module, cls): [param('uint8_t *', 'buffer'), param('uint32_t', 'size')]) return +def register_Ns3AsciiWriter_methods(root_module, cls): + ## ascii-writer.h: ns3::AsciiWriter::AsciiWriter(ns3::AsciiWriter const & arg0) [copy constructor] + cls.add_constructor([param('ns3::AsciiWriter const &', 'arg0')]) + ## ascii-writer.h: static ns3::Ptr ns3::AsciiWriter::Get(std::ostream & os) [member function] + cls.add_method('Get', + 'ns3::Ptr< ns3::AsciiWriter >', + [param('std::ostream &', 'os')], + is_static=True) + ## ascii-writer.h: void ns3::AsciiWriter::WritePacket(ns3::AsciiWriter::Type type, std::string message, ns3::Ptr p) [member function] + cls.add_method('WritePacket', + 'void', + [param('ns3::AsciiWriter::Type', 'type'), param('std::string', 'message'), param('ns3::Ptr< ns3::Packet const >', 'p')]) + return + def register_Ns3Chunk_methods(root_module, cls): ## chunk.h: ns3::Chunk::Chunk(ns3::Chunk const & arg0) [copy constructor] cls.add_constructor([param('ns3::Chunk const &', 'arg0')]) @@ -1047,6 +1066,11 @@ def register_Ns3Header_methods(root_module, cls): def register_Ns3PcapWriter_methods(root_module, cls): ## pcap-writer.h: ns3::PcapWriter::PcapWriter(ns3::PcapWriter const & arg0) [copy constructor] cls.add_constructor([param('ns3::PcapWriter const &', 'arg0')]) + ## pcap-writer.h: static ns3::TypeId ns3::PcapWriter::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) ## pcap-writer.h: ns3::PcapWriter::PcapWriter() [constructor] cls.add_constructor([]) ## pcap-writer.h: void ns3::PcapWriter::Open(std::string const & name) [member function] @@ -1081,10 +1105,14 @@ def register_Ns3PcapWriter_methods(root_module, cls): cls.add_method('WritePacket', 'void', [param('ns3::Ptr< ns3::Packet const >', 'packet')]) - ## pcap-writer.h: void ns3::PcapWriter::WriteWifiMonitorPacket(ns3::Ptr packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble, bool isTx, double signalDbm, double noiseDbm) [member function] + ## pcap-writer.h: void ns3::PcapWriter::WriteWifiMonitorPacket(ns3::Ptr packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, bool isTx, double signalDbm, double noiseDbm) [member function] cls.add_method('WriteWifiMonitorPacket', 'void', - [param('ns3::Ptr< ns3::Packet const >', 'packet'), param('uint16_t', 'channelFreqMhz'), param('uint32_t', 'rate'), param('bool', 'isShortPreamble'), param('bool', 'isTx'), param('double', 'signalDbm'), param('double', 'noiseDbm')]) + [param('ns3::Ptr< ns3::Packet const >', 'packet'), param('uint16_t', 'channelFreqMhz'), param('uint16_t', 'channelNumber'), param('uint32_t', 'rate'), param('bool', 'isShortPreamble'), param('bool', 'isTx'), param('double', 'signalDbm'), param('double', 'noiseDbm')]) + ## pcap-writer.h: void ns3::PcapWriter::SetCaptureSize(uint32_t size) [member function] + cls.add_method('SetCaptureSize', + 'void', + [param('uint32_t', 'size')]) return def register_Ns3Trailer_methods(root_module, cls): diff --git a/bindings/python/ns3_module_wifi.py b/bindings/python/ns3_module_wifi.py index bb258387b..dc44fbdc1 100644 --- a/bindings/python/ns3_module_wifi.py +++ b/bindings/python/ns3_module_wifi.py @@ -8,7 +8,7 @@ def register_types(module): ## wifi-preamble.h: ns3::WifiPreamble [enumeration] module.add_enum('WifiPreamble', ['WIFI_PREAMBLE_LONG', 'WIFI_PREAMBLE_SHORT']) ## wifi-phy-standard.h: ns3::WifiPhyStandard [enumeration] - module.add_enum('WifiPhyStandard', ['WIFI_PHY_STANDARD_80211a', 'WIFI_PHY_STANDARD_80211b', 'WIFI_PHY_STANDARD_80211_10Mhz', 'WIFI_PHY_STANDARD_80211_5Mhz', 'WIFI_PHY_STANDARD_holland']) + module.add_enum('WifiPhyStandard', ['WIFI_PHY_STANDARD_80211a', 'WIFI_PHY_STANDARD_80211b', 'WIFI_PHY_STANDARD_80211_10Mhz', 'WIFI_PHY_STANDARD_80211_5Mhz', 'WIFI_PHY_STANDARD_holland', 'WIFI_PHY_UNKNOWN']) ## qos-utils.h: ns3::AccessClass [enumeration] module.add_enum('AccessClass', ['AC_VO', 'AC_VI', 'AC_BE', 'AC_BK', 'AC_UNDEF']) ## edca-txop-n.h: ns3::TypeOfStation [enumeration] @@ -44,7 +44,7 @@ def register_types(module): ## wifi-mode.h: ns3::WifiMode [class] module.add_class('WifiMode') ## wifi-mode.h: ns3::WifiMode::ModulationType [enumeration] - module.add_enum('ModulationType', ['BPSK', 'DBPSK', 'DQPSK', 'QAM'], outer_class=root_module['ns3::WifiMode']) + module.add_enum('ModulationType', ['BPSK', 'DBPSK', 'DQPSK', 'QAM', 'UNKNOWN'], outer_class=root_module['ns3::WifiMode']) ## wifi-mode.h: ns3::WifiModeFactory [class] module.add_class('WifiModeFactory') ## wifi-phy.h: ns3::WifiPhyListener [class] @@ -3005,14 +3005,14 @@ def register_Ns3WifiPhy_methods(root_module, cls): cls.add_method('NotifyRxDrop', 'void', [param('ns3::Ptr< ns3::Packet const >', 'packet')]) - ## wifi-phy.h: void ns3::WifiPhy::NotifyPromiscSniffRx(ns3::Ptr packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm) [member function] + ## wifi-phy.h: void ns3::WifiPhy::NotifyPromiscSniffRx(ns3::Ptr packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm) [member function] cls.add_method('NotifyPromiscSniffRx', 'void', - [param('ns3::Ptr< ns3::Packet const >', 'packet'), param('uint16_t', 'channelFreqMhz'), param('uint32_t', 'rate'), param('bool', 'isShortPreamble'), param('double', 'signalDbm'), param('double', 'noiseDbm')]) - ## wifi-phy.h: void ns3::WifiPhy::NotifyPromiscSniffTx(ns3::Ptr packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble) [member function] + [param('ns3::Ptr< ns3::Packet const >', 'packet'), param('uint16_t', 'channelFreqMhz'), param('uint16_t', 'channelNumber'), param('uint32_t', 'rate'), param('bool', 'isShortPreamble'), param('double', 'signalDbm'), param('double', 'noiseDbm')]) + ## wifi-phy.h: void ns3::WifiPhy::NotifyPromiscSniffTx(ns3::Ptr packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble) [member function] cls.add_method('NotifyPromiscSniffTx', 'void', - [param('ns3::Ptr< ns3::Packet const >', 'packet'), param('uint16_t', 'channelFreqMhz'), param('uint32_t', 'rate'), param('bool', 'isShortPreamble')]) + [param('ns3::Ptr< ns3::Packet const >', 'packet'), param('uint16_t', 'channelFreqMhz'), param('uint16_t', 'channelNumber'), param('uint32_t', 'rate'), param('bool', 'isShortPreamble')]) return def register_Ns3WifiRemoteStationManager_methods(root_module, cls): From 9bfce1c7b29579806395881ba21d110ccfe494cd Mon Sep 17 00:00:00 2001 From: Gary Pei Date: Thu, 13 Aug 2009 23:03:13 -0700 Subject: [PATCH 21/28] add Standard attribute to wifi-clear-channel-cmu, for clarity --- examples/wifi-clear-channel-cmu.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/wifi-clear-channel-cmu.cc b/examples/wifi-clear-channel-cmu.cc index 4028d6789..219f90b20 100644 --- a/examples/wifi-clear-channel-cmu.cc +++ b/examples/wifi-clear-channel-cmu.cc @@ -197,7 +197,8 @@ int main (int argc, char *argv[]) wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode",StringValue(modes[i]), "ControlMode",StringValue(modes[i])); - wifiMac.SetType ("ns3::AdhocWifiMac"); + wifiMac.SetType ("ns3::AdhocWifiMac", + "Standard",StringValue ("802.11b")); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel ; From 7e5b776cda941826dc5d894442e8f4ad8b228f0b Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 14 Aug 2009 11:53:23 +0200 Subject: [PATCH 22/28] introduce Vector2D and Vector3D --- src/{mobility => core}/vector.cc | 51 ++++++- src/core/vector.h | 126 ++++++++++++++++++ src/core/wscript | 2 + .../constant-position-mobility-model.h | 1 - src/mobility/constant-velocity-helper.h | 2 +- .../constant-velocity-mobility-model.h | 2 +- src/mobility/mobility-model.h | 3 +- src/mobility/position-allocator.h | 2 +- src/mobility/rectangle.cc | 2 +- src/mobility/rectangle.h | 3 +- src/mobility/vector.h | 81 ----------- src/mobility/wscript | 2 - 12 files changed, 179 insertions(+), 98 deletions(-) rename src/{mobility => core}/vector.cc (56%) create mode 100644 src/core/vector.h delete mode 100644 src/mobility/vector.h diff --git a/src/mobility/vector.cc b/src/core/vector.cc similarity index 56% rename from src/mobility/vector.cc rename to src/core/vector.cc index 32da74326..03e96ce42 100644 --- a/src/mobility/vector.cc +++ b/src/core/vector.cc @@ -24,23 +24,39 @@ namespace ns3 { -ATTRIBUTE_HELPER_CPP (Vector); +ATTRIBUTE_HELPER_CPP (Vector3D); +ATTRIBUTE_HELPER_CPP (Vector2D); + // compatibility for mobility code +Ptr MakeVectorChecker (void) +{ + return MakeVector3DChecker (); +} -Vector::Vector (double _x, double _y, double _z) +Vector3D::Vector3D (double _x, double _y, double _z) : x (_x), y (_y), z (_z) {} -Vector::Vector () +Vector3D::Vector3D () : x (0.0), y (0.0), z (0.0) {} +Vector2D::Vector2D (double _x, double _y) + : x (_x), + y (_y) +{} + +Vector2D::Vector2D () + : x (0.0), + y (0.0) +{} + double -CalculateDistance (const Vector &a, const Vector &b) +CalculateDistance (const Vector3D &a, const Vector3D &b) { double dx = b.x - a.x; double dy = b.y - a.y; @@ -48,13 +64,21 @@ CalculateDistance (const Vector &a, const Vector &b) double distance = std::sqrt (dx * dx + dy * dy + dz * dz); return distance; } +double +CalculateDistance (const Vector2D &a, const Vector2D &b) +{ + double dx = b.x - a.x; + double dy = b.y - a.y; + double distance = std::sqrt (dx * dx + dy * dy); + return distance; +} -std::ostream &operator << (std::ostream &os, const Vector &vector) +std::ostream &operator << (std::ostream &os, const Vector3D &vector) { os << vector.x << ":" << vector.y << ":" << vector.z; return os; } -std::istream &operator >> (std::istream &is, Vector &vector) +std::istream &operator >> (std::istream &is, Vector3D &vector) { char c1, c2; is >> vector.x >> c1 >> vector.y >> c2 >> vector.z; @@ -65,5 +89,20 @@ std::istream &operator >> (std::istream &is, Vector &vector) } return is; } +std::ostream &operator << (std::ostream &os, const Vector2D &vector) +{ + os << vector.x << ":" << vector.y; + return os; +} +std::istream &operator >> (std::istream &is, Vector2D &vector) +{ + char c1; + is >> vector.x >> c1 >> vector.y; + if (c1 != ':') + { + is.setstate (std::ios_base::failbit); + } + return is; +} } // namespace ns3 diff --git a/src/core/vector.h b/src/core/vector.h new file mode 100644 index 000000000..434765e9e --- /dev/null +++ b/src/core/vector.h @@ -0,0 +1,126 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2007 INRIA + * + * 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + */ +#ifndef NS3_VECTOR_H +#define NS3_VECTOR_H + +#include "ns3/attribute.h" +#include "ns3/attribute-helper.h" + +namespace ns3 { + +/** + * \brief a 3d vector + */ +class Vector3D +{ +public: + /** + * \param _x x coordinate of vector + * \param _y y coordinate of vector + * \param _z z coordinate of vector + * + * Create vector (_x, _y, _z) + */ + Vector3D (double _x, double _y, double _z); + /** + * Create vector (0.0, 0.0, 0.0) + */ + Vector3D (); + /** + * x coordinate of vector + */ + double x; + /** + * y coordinate of vector + */ + double y; + /** + * z coordinate of vector + */ + double z; +}; + +/** + * \brief a 3d vector + */ +class Vector2D +{ +public: + /** + * \param _x x coordinate of vector + * \param _y y coordinate of vector + * + * Create vector (_x, _y) + */ + Vector2D (double _x, double _y); + /** + * Create vector vector (0.0, 0.0) + */ + Vector2D (); + /** + * x coordinate of vector + */ + double x; + /** + * y coordinate of vector + */ + double y; +}; + +/** + * \param a one point + * \param b another point + * \returns the cartesian distance between a and b. + */ +double CalculateDistance (const Vector3D &a, const Vector3D &b); + +/** + * \param a one point + * \param b another point + * \returns the cartesian distance between a and b. + */ +double CalculateDistance (const Vector2D &a, const Vector2D &b); + +/** + * \class ns3::Vector3DValue + * \brief hold objects of type ns3::Vector3D + */ +/** + * \class ns3::Vector2DValue + * \brief hold objects of type ns3::Vector2D + */ +ATTRIBUTE_HELPER_HEADER (Vector3D); +ATTRIBUTE_HELPER_HEADER (Vector2D); + +std::ostream &operator << (std::ostream &os, const Vector3D &vector); +std::istream &operator >> (std::istream &is, Vector3D &vector); +std::ostream &operator << (std::ostream &os, const Vector2D &vector); +std::istream &operator >> (std::istream &is, Vector2D &vector); + +// for compatibility with mobility models +typedef Vector3D Vector; +typedef Vector3DValue VectorValue; +typedef Vector3DChecker VectorChecker; +ATTRIBUTE_ACCESSOR_DEFINE(Vector); +Ptr MakeVectorChecker (void); + +} // namespace ns3 + +#endif /* NS3_VECTOR_H */ diff --git a/src/core/wscript b/src/core/wscript index 1c8a5de37..b75c99e8b 100644 --- a/src/core/wscript +++ b/src/core/wscript @@ -78,6 +78,7 @@ def build(bld): 'config.cc', 'callback.cc', 'names.cc', + 'vector.cc', ] headers = bld.new_task_gen('ns3header') @@ -123,6 +124,7 @@ def build(bld): 'deprecated.h', 'abort.h', 'names.h', + 'vector.h', ] if sys.platform == 'win32': diff --git a/src/mobility/constant-position-mobility-model.h b/src/mobility/constant-position-mobility-model.h index 31aa2e978..ee9c894c7 100644 --- a/src/mobility/constant-position-mobility-model.h +++ b/src/mobility/constant-position-mobility-model.h @@ -21,7 +21,6 @@ #define CONSTANT_POSITION_MOBILITY_MODEL_H #include "mobility-model.h" -#include "vector.h" namespace ns3 { diff --git a/src/mobility/constant-velocity-helper.h b/src/mobility/constant-velocity-helper.h index 3430381e6..95346d4a1 100644 --- a/src/mobility/constant-velocity-helper.h +++ b/src/mobility/constant-velocity-helper.h @@ -21,7 +21,7 @@ #define CONSTANT_VELOCITY_HELPER_H #include "ns3/nstime.h" -#include "vector.h" +#include "ns3/vector.h" namespace ns3 { diff --git a/src/mobility/constant-velocity-mobility-model.h b/src/mobility/constant-velocity-mobility-model.h index 6db3312ec..8936c3ad0 100644 --- a/src/mobility/constant-velocity-mobility-model.h +++ b/src/mobility/constant-velocity-mobility-model.h @@ -21,8 +21,8 @@ #define CONSTANT_VELOCITY_MOBILITY_MODEL_H #include -#include "mobility-model.h" #include "ns3/nstime.h" +#include "mobility-model.h" #include "constant-velocity-helper.h" namespace ns3 { diff --git a/src/mobility/mobility-model.h b/src/mobility/mobility-model.h index 1d58baf9e..6fd268c37 100644 --- a/src/mobility/mobility-model.h +++ b/src/mobility/mobility-model.h @@ -20,8 +20,7 @@ #ifndef MOBILITY_MODEL_H #define MOBILITY_MODEL_H -#include "vector.h" - +#include "ns3/vector.h" #include "ns3/object.h" #include "ns3/traced-callback.h" diff --git a/src/mobility/position-allocator.h b/src/mobility/position-allocator.h index e9756896c..da6f49f0b 100644 --- a/src/mobility/position-allocator.h +++ b/src/mobility/position-allocator.h @@ -22,7 +22,7 @@ #include "ns3/object.h" #include "ns3/random-variable.h" -#include "vector.h" +#include "ns3/vector.h" namespace ns3 { diff --git a/src/mobility/rectangle.cc b/src/mobility/rectangle.cc index 6a0c5e221..ee5e29f0f 100644 --- a/src/mobility/rectangle.cc +++ b/src/mobility/rectangle.cc @@ -18,7 +18,7 @@ * Author: Mathieu Lacage */ #include "rectangle.h" -#include "vector.h" +#include "ns3/vector.h" #include "ns3/assert.h" #include "ns3/fatal-error.h" #include diff --git a/src/mobility/rectangle.h b/src/mobility/rectangle.h index fcc8fc1cb..90d147736 100644 --- a/src/mobility/rectangle.h +++ b/src/mobility/rectangle.h @@ -22,11 +22,10 @@ #include "ns3/attribute.h" #include "ns3/attribute-helper.h" +#include "ns3/vector.h" namespace ns3 { -class Vector; - /** * \brief a 2d rectangle */ diff --git a/src/mobility/vector.h b/src/mobility/vector.h deleted file mode 100644 index e3e3191aa..000000000 --- a/src/mobility/vector.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007 INRIA - * - * 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#ifndef VECTOR_H -#define VECTOR_H - -#include "ns3/attribute.h" -#include "ns3/attribute-helper.h" - -namespace ns3 { - -/** - * \brief a 3d cartesian position vector - * - * Unit is meters. - */ -class Vector -{ -public: - /** - * \param _x x coordinate of vector vector - * \param _y y coordinate of vector vector - * \param _z z coordinate of vector vector - * - * Create vector vector (_x, _y, _z) - */ - Vector (double _x, double _y, double _z); - /** - * Create vector vector (0.0, 0.0, 0.0) - */ - Vector (); - /** - * x coordinate of vector vector - */ - double x; - /** - * y coordinate of vector vector - */ - double y; - /** - * z coordinate of vector vector - */ - double z; -}; - -/** - * \param a one point - * \param b another point - * \returns the cartesian distance between a and b. - */ -double CalculateDistance (const Vector &a, const Vector &b); - -/** - * \class ns3::VectorValue - * \brief hold objects of type ns3::Vector - */ - -ATTRIBUTE_HELPER_HEADER (Vector); - -std::ostream &operator << (std::ostream &os, const Vector &vector); -std::istream &operator >> (std::istream &is, Vector &vector); - -} // namespace ns3 - -#endif /* VECTOR_H */ diff --git a/src/mobility/wscript b/src/mobility/wscript index ad368ebbf..6bcfd2e5c 100644 --- a/src/mobility/wscript +++ b/src/mobility/wscript @@ -3,7 +3,6 @@ def build(bld): mobility = bld.create_ns3_module('mobility', ['core', 'simulator']) mobility.source = [ - 'vector.cc', 'hierarchical-mobility-model.cc', 'mobility-model.cc', 'position-allocator.cc', @@ -20,7 +19,6 @@ def build(bld): headers = bld.new_task_gen('ns3header') headers.module = 'mobility' headers.source = [ - 'vector.h', 'hierarchical-mobility-model.h', 'mobility-model.h', 'position-allocator.h', From 893360bfe5de4a20d1f7925c732d6ad3f6de5563 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 14 Aug 2009 11:53:27 +0200 Subject: [PATCH 23/28] rescan python --- bindings/python/ns3_module_core.py | 154 +++++++++++++++++++++++++ bindings/python/ns3_module_mobility.py | 73 ------------ 2 files changed, 154 insertions(+), 73 deletions(-) diff --git a/bindings/python/ns3_module_core.py b/bindings/python/ns3_module_core.py index 1d5cd0e9a..9b0535a14 100644 --- a/bindings/python/ns3_module_core.py +++ b/bindings/python/ns3_module_core.py @@ -83,6 +83,10 @@ def register_types(module): module.add_class('UniformVariable', parent=root_module['ns3::RandomVariable']) ## attribute-list.h: ns3::UnsafeAttributeList [class] module.add_class('UnsafeAttributeList') + ## vector.h: ns3::Vector2D [class] + module.add_class('Vector2D') + ## vector.h: ns3::Vector3D [class] + module.add_class('Vector3D') ## random-variable.h: ns3::WeibullVariable [class] module.add_class('WeibullVariable', parent=root_module['ns3::RandomVariable']) ## random-variable.h: ns3::ZipfVariable [class] @@ -165,6 +169,14 @@ def register_types(module): module.add_class('TypeIdValue', parent=root_module['ns3::AttributeValue']) ## uinteger.h: ns3::UintegerValue [class] module.add_class('UintegerValue', parent=root_module['ns3::AttributeValue']) + ## vector.h: ns3::Vector2DChecker [class] + module.add_class('Vector2DChecker', parent=root_module['ns3::AttributeChecker']) + ## vector.h: ns3::Vector2DValue [class] + module.add_class('Vector2DValue', parent=root_module['ns3::AttributeValue']) + ## vector.h: ns3::Vector3DChecker [class] + module.add_class('Vector3DChecker', parent=root_module['ns3::AttributeChecker']) + ## vector.h: ns3::Vector3DValue [class] + module.add_class('Vector3DValue', parent=root_module['ns3::AttributeValue']) ## traced-value.h: ns3::TracedValue [class] module.add_class('TracedValue', template_parameters=['unsigned int']) ## traced-value.h: ns3::TracedValue [class] @@ -175,6 +187,12 @@ def register_types(module): root_module['ns3::TracedValue< unsigned int >'].implicitly_converts_to(root_module['ns3::BooleanValue']) ## traced-value.h: ns3::TracedValue [class] root_module['ns3::TracedValue< unsigned int >'].implicitly_converts_to(root_module['ns3::EnumValue']) + typehandlers.add_type_alias('ns3::Vector3D', 'ns3::Vector') + module.add_typedef(root_module['ns3::Vector3D'], 'Vector') + typehandlers.add_type_alias('ns3::Vector3DValue', 'ns3::VectorValue') + module.add_typedef(root_module['ns3::Vector3DValue'], 'VectorValue') + typehandlers.add_type_alias('ns3::Vector3DChecker', 'ns3::VectorChecker') + module.add_typedef(root_module['ns3::Vector3DChecker'], 'VectorChecker') ## Register a nested module for the namespace Config @@ -261,6 +279,8 @@ def register_methods(root_module): register_Ns3TypeIdAttributeInfo_methods(root_module, root_module['ns3::TypeId::AttributeInfo']) register_Ns3UniformVariable_methods(root_module, root_module['ns3::UniformVariable']) register_Ns3UnsafeAttributeList_methods(root_module, root_module['ns3::UnsafeAttributeList']) + register_Ns3Vector2D_methods(root_module, root_module['ns3::Vector2D']) + register_Ns3Vector3D_methods(root_module, root_module['ns3::Vector3D']) register_Ns3WeibullVariable_methods(root_module, root_module['ns3::WeibullVariable']) register_Ns3ZipfVariable_methods(root_module, root_module['ns3::ZipfVariable']) register_Ns3Empty_methods(root_module, root_module['ns3::empty']) @@ -302,6 +322,10 @@ def register_methods(root_module): register_Ns3TypeIdChecker_methods(root_module, root_module['ns3::TypeIdChecker']) register_Ns3TypeIdValue_methods(root_module, root_module['ns3::TypeIdValue']) register_Ns3UintegerValue_methods(root_module, root_module['ns3::UintegerValue']) + register_Ns3Vector2DChecker_methods(root_module, root_module['ns3::Vector2DChecker']) + register_Ns3Vector2DValue_methods(root_module, root_module['ns3::Vector2DValue']) + register_Ns3Vector3DChecker_methods(root_module, root_module['ns3::Vector3DChecker']) + register_Ns3Vector3DValue_methods(root_module, root_module['ns3::Vector3DValue']) register_Ns3TracedValue__Unsigned_int_methods(root_module, root_module['ns3::TracedValue< unsigned int >']) register_Ns3ConfigMatchContainer_methods(root_module, root_module['ns3::Config::MatchContainer']) return @@ -1180,6 +1204,36 @@ def register_Ns3UnsafeAttributeList_methods(root_module, cls): is_const=True) return +def register_Ns3Vector2D_methods(root_module, cls): + cls.add_output_stream_operator() + ## vector.h: ns3::Vector2D::Vector2D(ns3::Vector2D const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Vector2D const &', 'arg0')]) + ## vector.h: ns3::Vector2D::Vector2D(double _x, double _y) [constructor] + cls.add_constructor([param('double', '_x'), param('double', '_y')]) + ## vector.h: ns3::Vector2D::Vector2D() [constructor] + cls.add_constructor([]) + ## vector.h: ns3::Vector2D::x [variable] + cls.add_instance_attribute('x', 'double', is_const=False) + ## vector.h: ns3::Vector2D::y [variable] + cls.add_instance_attribute('y', 'double', is_const=False) + return + +def register_Ns3Vector3D_methods(root_module, cls): + cls.add_output_stream_operator() + ## vector.h: ns3::Vector3D::Vector3D(ns3::Vector3D const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Vector3D const &', 'arg0')]) + ## vector.h: ns3::Vector3D::Vector3D(double _x, double _y, double _z) [constructor] + cls.add_constructor([param('double', '_x'), param('double', '_y'), param('double', '_z')]) + ## vector.h: ns3::Vector3D::Vector3D() [constructor] + cls.add_constructor([]) + ## vector.h: ns3::Vector3D::x [variable] + cls.add_instance_attribute('x', 'double', is_const=False) + ## vector.h: ns3::Vector3D::y [variable] + cls.add_instance_attribute('y', 'double', is_const=False) + ## vector.h: ns3::Vector3D::z [variable] + cls.add_instance_attribute('z', 'double', is_const=False) + return + def register_Ns3WeibullVariable_methods(root_module, cls): ## random-variable.h: ns3::WeibullVariable::WeibullVariable(ns3::WeibullVariable const & arg0) [copy constructor] cls.add_constructor([param('ns3::WeibullVariable const &', 'arg0')]) @@ -2046,6 +2100,86 @@ def register_Ns3UintegerValue_methods(root_module, cls): is_virtual=True) return +def register_Ns3Vector2DChecker_methods(root_module, cls): + ## vector.h: ns3::Vector2DChecker::Vector2DChecker(ns3::Vector2DChecker const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Vector2DChecker const &', 'arg0')]) + ## vector.h: ns3::Vector2DChecker::Vector2DChecker() [constructor] + cls.add_constructor([]) + return + +def register_Ns3Vector2DValue_methods(root_module, cls): + ## vector.h: ns3::Vector2DValue::Vector2DValue(ns3::Vector2DValue const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Vector2DValue const &', 'arg0')]) + ## vector.h: ns3::Vector2DValue::Vector2DValue() [constructor] + cls.add_constructor([]) + ## vector.h: ns3::Vector2DValue::Vector2DValue(ns3::Vector2D const & value) [constructor] + cls.add_constructor([param('ns3::Vector2D const &', 'value')]) + ## vector.h: void ns3::Vector2DValue::Set(ns3::Vector2D const & value) [member function] + cls.add_method('Set', + 'void', + [param('ns3::Vector2D const &', 'value')]) + ## vector.h: ns3::Vector2D ns3::Vector2DValue::Get() const [member function] + cls.add_method('Get', + 'ns3::Vector2D', + [], + is_const=True) + ## vector.h: ns3::Ptr ns3::Vector2DValue::Copy() const [member function] + cls.add_method('Copy', + 'ns3::Ptr< ns3::AttributeValue >', + [], + is_const=True, is_virtual=True) + ## vector.h: std::string ns3::Vector2DValue::SerializeToString(ns3::Ptr checker) const [member function] + cls.add_method('SerializeToString', + 'std::string', + [param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], + is_const=True, is_virtual=True) + ## vector.h: bool ns3::Vector2DValue::DeserializeFromString(std::string value, ns3::Ptr checker) [member function] + cls.add_method('DeserializeFromString', + 'bool', + [param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], + is_virtual=True) + return + +def register_Ns3Vector3DChecker_methods(root_module, cls): + ## vector.h: ns3::Vector3DChecker::Vector3DChecker(ns3::Vector3DChecker const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Vector3DChecker const &', 'arg0')]) + ## vector.h: ns3::Vector3DChecker::Vector3DChecker() [constructor] + cls.add_constructor([]) + return + +def register_Ns3Vector3DValue_methods(root_module, cls): + ## vector.h: ns3::Vector3DValue::Vector3DValue(ns3::Vector3DValue const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Vector3DValue const &', 'arg0')]) + ## vector.h: ns3::Vector3DValue::Vector3DValue() [constructor] + cls.add_constructor([]) + ## vector.h: ns3::Vector3DValue::Vector3DValue(ns3::Vector3D const & value) [constructor] + cls.add_constructor([param('ns3::Vector3D const &', 'value')]) + ## vector.h: void ns3::Vector3DValue::Set(ns3::Vector3D const & value) [member function] + cls.add_method('Set', + 'void', + [param('ns3::Vector3D const &', 'value')]) + ## vector.h: ns3::Vector3D ns3::Vector3DValue::Get() const [member function] + cls.add_method('Get', + 'ns3::Vector3D', + [], + is_const=True) + ## vector.h: ns3::Ptr ns3::Vector3DValue::Copy() const [member function] + cls.add_method('Copy', + 'ns3::Ptr< ns3::AttributeValue >', + [], + is_const=True, is_virtual=True) + ## vector.h: std::string ns3::Vector3DValue::SerializeToString(ns3::Ptr checker) const [member function] + cls.add_method('SerializeToString', + 'std::string', + [param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], + is_const=True, is_virtual=True) + ## vector.h: bool ns3::Vector3DValue::DeserializeFromString(std::string value, ns3::Ptr checker) [member function] + cls.add_method('DeserializeFromString', + 'bool', + [param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], + is_virtual=True) + return + def register_Ns3TracedValue__Unsigned_int_methods(root_module, cls): ## traced-value.h: ns3::TracedValue::TracedValue() [constructor] cls.add_constructor([]) @@ -2153,6 +2287,14 @@ def register_functions(root_module): module.add_function('BreakpointFallback', 'void', []) + ## vector.h: extern double ns3::CalculateDistance(ns3::Vector2D const & a, ns3::Vector2D const & b) [free function] + module.add_function('CalculateDistance', + 'double', + [param('ns3::Vector2D const &', 'a'), param('ns3::Vector2D const &', 'b')]) + ## vector.h: extern double ns3::CalculateDistance(ns3::Vector3D const & a, ns3::Vector3D const & b) [free function] + module.add_function('CalculateDistance', + 'double', + [param('ns3::Vector3D const &', 'a'), param('ns3::Vector3D const &', 'b')]) ## ptr.h: extern ns3::Ptr ns3::Create() [free function] module.add_function('Create', 'ns3::Ptr< ns3::ObjectVectorValue >', @@ -2207,6 +2349,18 @@ def register_functions(root_module): module.add_function('MakeTypeIdChecker', 'ns3::Ptr< ns3::AttributeChecker const >', []) + ## vector.h: extern ns3::Ptr ns3::MakeVector2DChecker() [free function] + module.add_function('MakeVector2DChecker', + 'ns3::Ptr< ns3::AttributeChecker const >', + []) + ## vector.h: extern ns3::Ptr ns3::MakeVector3DChecker() [free function] + module.add_function('MakeVector3DChecker', + 'ns3::Ptr< ns3::AttributeChecker const >', + []) + ## vector.h: extern ns3::Ptr ns3::MakeVectorChecker() [free function] + module.add_function('MakeVectorChecker', + 'ns3::Ptr< ns3::AttributeChecker const >', + []) ## type-name.h: extern std::string ns3::TypeNameGet() [free function] module.add_function('TypeNameGet', 'std::string', diff --git a/bindings/python/ns3_module_mobility.py b/bindings/python/ns3_module_mobility.py index fdf2f0bdd..4b89e1731 100644 --- a/bindings/python/ns3_module_mobility.py +++ b/bindings/python/ns3_module_mobility.py @@ -9,8 +9,6 @@ def register_types(module): module.add_class('Rectangle') ## rectangle.h: ns3::Rectangle::Side [enumeration] module.add_enum('Side', ['RIGHT', 'LEFT', 'TOP', 'BOTTOM'], outer_class=root_module['ns3::Rectangle']) - ## vector.h: ns3::Vector [class] - module.add_class('Vector') ## position-allocator.h: ns3::PositionAllocator [class] module.add_class('PositionAllocator', parent=root_module['ns3::Object']) ## position-allocator.h: ns3::RandomDiscPositionAllocator [class] @@ -21,10 +19,6 @@ def register_types(module): module.add_class('RectangleChecker', parent=root_module['ns3::AttributeChecker']) ## rectangle.h: ns3::RectangleValue [class] module.add_class('RectangleValue', parent=root_module['ns3::AttributeValue']) - ## vector.h: ns3::VectorChecker [class] - module.add_class('VectorChecker', parent=root_module['ns3::AttributeChecker']) - ## vector.h: ns3::VectorValue [class] - module.add_class('VectorValue', parent=root_module['ns3::AttributeValue']) ## position-allocator.h: ns3::GridPositionAllocator [class] module.add_class('GridPositionAllocator', parent=root_module['ns3::PositionAllocator']) ## position-allocator.h: ns3::GridPositionAllocator::LayoutType [enumeration] @@ -103,14 +97,11 @@ def register_types_ns3_olsr(module): def register_methods(root_module): register_Ns3ConstantVelocityHelper_methods(root_module, root_module['ns3::ConstantVelocityHelper']) register_Ns3Rectangle_methods(root_module, root_module['ns3::Rectangle']) - register_Ns3Vector_methods(root_module, root_module['ns3::Vector']) register_Ns3PositionAllocator_methods(root_module, root_module['ns3::PositionAllocator']) register_Ns3RandomDiscPositionAllocator_methods(root_module, root_module['ns3::RandomDiscPositionAllocator']) register_Ns3RandomRectanglePositionAllocator_methods(root_module, root_module['ns3::RandomRectanglePositionAllocator']) register_Ns3RectangleChecker_methods(root_module, root_module['ns3::RectangleChecker']) register_Ns3RectangleValue_methods(root_module, root_module['ns3::RectangleValue']) - register_Ns3VectorChecker_methods(root_module, root_module['ns3::VectorChecker']) - register_Ns3VectorValue_methods(root_module, root_module['ns3::VectorValue']) register_Ns3GridPositionAllocator_methods(root_module, root_module['ns3::GridPositionAllocator']) register_Ns3ListPositionAllocator_methods(root_module, root_module['ns3::ListPositionAllocator']) register_Ns3MobilityModel_methods(root_module, root_module['ns3::MobilityModel']) @@ -203,22 +194,6 @@ def register_Ns3Rectangle_methods(root_module, cls): cls.add_instance_attribute('yMin', 'double', is_const=False) return -def register_Ns3Vector_methods(root_module, cls): - cls.add_output_stream_operator() - ## vector.h: ns3::Vector::Vector(ns3::Vector const & arg0) [copy constructor] - cls.add_constructor([param('ns3::Vector const &', 'arg0')]) - ## vector.h: ns3::Vector::Vector(double _x, double _y, double _z) [constructor] - cls.add_constructor([param('double', '_x'), param('double', '_y'), param('double', '_z')]) - ## vector.h: ns3::Vector::Vector() [constructor] - cls.add_constructor([]) - ## vector.h: ns3::Vector::x [variable] - cls.add_instance_attribute('x', 'double', is_const=False) - ## vector.h: ns3::Vector::y [variable] - cls.add_instance_attribute('y', 'double', is_const=False) - ## vector.h: ns3::Vector::z [variable] - cls.add_instance_attribute('z', 'double', is_const=False) - return - def register_Ns3PositionAllocator_methods(root_module, cls): ## position-allocator.h: ns3::PositionAllocator::PositionAllocator(ns3::PositionAllocator const & arg0) [copy constructor] cls.add_constructor([param('ns3::PositionAllocator const &', 'arg0')]) @@ -334,46 +309,6 @@ def register_Ns3RectangleValue_methods(root_module, cls): is_virtual=True) return -def register_Ns3VectorChecker_methods(root_module, cls): - ## vector.h: ns3::VectorChecker::VectorChecker(ns3::VectorChecker const & arg0) [copy constructor] - cls.add_constructor([param('ns3::VectorChecker const &', 'arg0')]) - ## vector.h: ns3::VectorChecker::VectorChecker() [constructor] - cls.add_constructor([]) - return - -def register_Ns3VectorValue_methods(root_module, cls): - ## vector.h: ns3::VectorValue::VectorValue(ns3::VectorValue const & arg0) [copy constructor] - cls.add_constructor([param('ns3::VectorValue const &', 'arg0')]) - ## vector.h: ns3::VectorValue::VectorValue() [constructor] - cls.add_constructor([]) - ## vector.h: ns3::VectorValue::VectorValue(ns3::Vector const & value) [constructor] - cls.add_constructor([param('ns3::Vector const &', 'value')]) - ## vector.h: void ns3::VectorValue::Set(ns3::Vector const & value) [member function] - cls.add_method('Set', - 'void', - [param('ns3::Vector const &', 'value')]) - ## vector.h: ns3::Vector ns3::VectorValue::Get() const [member function] - cls.add_method('Get', - 'ns3::Vector', - [], - is_const=True) - ## vector.h: ns3::Ptr ns3::VectorValue::Copy() const [member function] - cls.add_method('Copy', - 'ns3::Ptr< ns3::AttributeValue >', - [], - is_const=True, is_virtual=True) - ## vector.h: std::string ns3::VectorValue::SerializeToString(ns3::Ptr checker) const [member function] - cls.add_method('SerializeToString', - 'std::string', - [param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], - is_const=True, is_virtual=True) - ## vector.h: bool ns3::VectorValue::DeserializeFromString(std::string value, ns3::Ptr checker) [member function] - cls.add_method('DeserializeFromString', - 'bool', - [param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], - is_virtual=True) - return - def register_Ns3GridPositionAllocator_methods(root_module, cls): ## position-allocator.h: ns3::GridPositionAllocator::GridPositionAllocator(ns3::GridPositionAllocator const & arg0) [copy constructor] cls.add_constructor([param('ns3::GridPositionAllocator const &', 'arg0')]) @@ -744,18 +679,10 @@ def register_Ns3HierarchicalMobilityModel_methods(root_module, cls): def register_functions(root_module): module = root_module - ## vector.h: extern double ns3::CalculateDistance(ns3::Vector const & a, ns3::Vector const & b) [free function] - module.add_function('CalculateDistance', - 'double', - [param('ns3::Vector const &', 'a'), param('ns3::Vector const &', 'b')]) ## rectangle.h: extern ns3::Ptr ns3::MakeRectangleChecker() [free function] module.add_function('MakeRectangleChecker', 'ns3::Ptr< ns3::AttributeChecker const >', []) - ## vector.h: extern ns3::Ptr ns3::MakeVectorChecker() [free function] - module.add_function('MakeVectorChecker', - 'ns3::Ptr< ns3::AttributeChecker const >', - []) register_functions_ns3_Config(module.get_submodule('Config'), root_module) register_functions_ns3_TimeStepPrecision(module.get_submodule('TimeStepPrecision'), root_module) register_functions_ns3_addressUtils(module.get_submodule('addressUtils'), root_module) From d365379e455f3f7e4b0b6a62cc8aefde0eb399a8 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 14 Aug 2009 12:21:39 +0200 Subject: [PATCH 24/28] bug 641: CwMin setting for 802.11b --- bindings/python/ns3_module_helper.py | 12 +-- bindings/python/ns3_module_wifi.py | 53 ++++++++++-- src/devices/wifi/adhoc-wifi-mac.cc | 32 +++++-- src/devices/wifi/adhoc-wifi-mac.h | 2 +- src/devices/wifi/dca-txop.cc | 15 ---- src/devices/wifi/dca-txop.h | 15 ++-- src/devices/wifi/edca-txop-n.cc | 15 ---- src/devices/wifi/edca-txop-n.h | 15 ++-- src/devices/wifi/nqap-wifi-mac.cc | 37 ++++++-- src/devices/wifi/nqap-wifi-mac.h | 2 +- src/devices/wifi/nqsta-wifi-mac.cc | 37 ++++++-- src/devices/wifi/nqsta-wifi-mac.h | 2 +- src/devices/wifi/qadhoc-wifi-mac.cc | 108 ++++++++++++------------ src/devices/wifi/qadhoc-wifi-mac.h | 8 +- src/devices/wifi/qap-wifi-mac.cc | 122 ++++++++++++--------------- src/devices/wifi/qap-wifi-mac.h | 22 ++--- src/devices/wifi/qos-utils.h | 1 + src/devices/wifi/qsta-wifi-mac.cc | 103 +++++++++++----------- src/devices/wifi/qsta-wifi-mac.h | 18 +--- src/devices/wifi/wifi-mac.cc | 50 ++++++++--- src/devices/wifi/wifi-mac.h | 17 +++- src/devices/wifi/wifi-phy.h | 2 + src/devices/wifi/wifi-test.cc | 4 +- src/devices/wifi/wscript | 5 +- src/devices/wifi/yans-wifi-phy.cc | 12 +-- src/devices/wifi/yans-wifi-phy.h | 3 +- src/helper/nqos-wifi-mac-helper.cc | 18 +--- src/helper/nqos-wifi-mac-helper.h | 15 ---- src/helper/qos-wifi-mac-helper.cc | 112 +++++------------------- src/helper/qos-wifi-mac-helper.h | 20 +---- src/helper/wifi-helper.cc | 9 ++ src/helper/wifi-helper.h | 4 + 32 files changed, 419 insertions(+), 471 deletions(-) diff --git a/bindings/python/ns3_module_helper.py b/bindings/python/ns3_module_helper.py index 7da39dd99..eed28c7a9 100644 --- a/bindings/python/ns3_module_helper.py +++ b/bindings/python/ns3_module_helper.py @@ -1121,6 +1121,10 @@ def register_Ns3WifiHelper_methods(root_module, cls): 'ns3::NetDeviceContainer', [param('ns3::WifiPhyHelper const &', 'phy'), param('ns3::WifiMacHelper const &', 'mac'), param('std::string', 'nodeName')], is_const=True) + ## wifi-helper.h: void ns3::WifiHelper::SetStandard(ns3::WifiPhyStandard standard) [member function] + cls.add_method('SetStandard', + 'void', + [param('ns3::WifiPhyStandard', 'standard')]) ## wifi-helper.h: static void ns3::WifiHelper::EnableLogComponents() [member function] cls.add_method('EnableLogComponents', 'void', @@ -1310,10 +1314,6 @@ def register_Ns3NqosWifiMacHelper_methods(root_module, cls): cls.add_method('SetType', 'void', [param('std::string', 'type'), param('std::string', 'n0', default_value='""'), param('ns3::AttributeValue const &', 'v0', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n1', default_value='""'), param('ns3::AttributeValue const &', 'v1', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n2', default_value='""'), param('ns3::AttributeValue const &', 'v2', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n3', default_value='""'), param('ns3::AttributeValue const &', 'v3', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n4', default_value='""'), param('ns3::AttributeValue const &', 'v4', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n5', default_value='""'), param('ns3::AttributeValue const &', 'v5', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n6', default_value='""'), param('ns3::AttributeValue const &', 'v6', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n7', default_value='""'), param('ns3::AttributeValue const &', 'v7', default_value='ns3::EmptyAttributeValue()')]) - ## nqos-wifi-mac-helper.h: void ns3::NqosWifiMacHelper::SetDcaParameters(std::string n0="", ns3::AttributeValue const & v0=ns3::EmptyAttributeValue(), std::string n1="", ns3::AttributeValue const & v1=ns3::EmptyAttributeValue(), std::string n2="", ns3::AttributeValue const & v2=ns3::EmptyAttributeValue(), std::string n3="", ns3::AttributeValue const & v3=ns3::EmptyAttributeValue()) [member function] - cls.add_method('SetDcaParameters', - 'void', - [param('std::string', 'n0', default_value='""'), param('ns3::AttributeValue const &', 'v0', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n1', default_value='""'), param('ns3::AttributeValue const &', 'v1', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n2', default_value='""'), param('ns3::AttributeValue const &', 'v2', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n3', default_value='""'), param('ns3::AttributeValue const &', 'v3', default_value='ns3::EmptyAttributeValue()')]) ## nqos-wifi-mac-helper.h: ns3::Ptr ns3::NqosWifiMacHelper::Create() const [member function] cls.add_method('Create', 'ns3::Ptr< ns3::WifiMac >', @@ -1339,10 +1339,6 @@ def register_Ns3QosWifiMacHelper_methods(root_module, cls): cls.add_method('SetMsduAggregatorForAc', 'void', [param('ns3::AccessClass', 'accessClass'), param('std::string', 'type'), param('std::string', 'n0', default_value='""'), param('ns3::AttributeValue const &', 'v0', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n1', default_value='""'), param('ns3::AttributeValue const &', 'v1', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n2', default_value='""'), param('ns3::AttributeValue const &', 'v2', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n3', default_value='""'), param('ns3::AttributeValue const &', 'v3', default_value='ns3::EmptyAttributeValue()')]) - ## qos-wifi-mac-helper.h: void ns3::QosWifiMacHelper::SetEdcaParametersForAc(ns3::AccessClass accessClass, std::string n0="", ns3::AttributeValue const & v0=ns3::EmptyAttributeValue(), std::string n1="", ns3::AttributeValue const & v1=ns3::EmptyAttributeValue(), std::string n2="", ns3::AttributeValue const & v2=ns3::EmptyAttributeValue(), std::string n3="", ns3::AttributeValue const & v3=ns3::EmptyAttributeValue()) [member function] - cls.add_method('SetEdcaParametersForAc', - 'void', - [param('ns3::AccessClass', 'accessClass'), param('std::string', 'n0', default_value='""'), param('ns3::AttributeValue const &', 'v0', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n1', default_value='""'), param('ns3::AttributeValue const &', 'v1', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n2', default_value='""'), param('ns3::AttributeValue const &', 'v2', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n3', default_value='""'), param('ns3::AttributeValue const &', 'v3', default_value='ns3::EmptyAttributeValue()')]) ## qos-wifi-mac-helper.h: ns3::Ptr ns3::QosWifiMacHelper::Create() const [member function] cls.add_method('Create', 'ns3::Ptr< ns3::WifiMac >', diff --git a/bindings/python/ns3_module_wifi.py b/bindings/python/ns3_module_wifi.py index dc44fbdc1..06aa9f6e5 100644 --- a/bindings/python/ns3_module_wifi.py +++ b/bindings/python/ns3_module_wifi.py @@ -2286,10 +2286,15 @@ def register_Ns3WifiMac_methods(root_module, cls): cls.add_method('NotifyRxDrop', 'void', [param('ns3::Ptr< ns3::Packet const >', 'packet')]) - ## wifi-mac.h: void ns3::WifiMac::SetStandard(ns3::WifiPhyStandard standard) [member function] - cls.add_method('SetStandard', + ## wifi-mac.h: void ns3::WifiMac::ConfigureStandard(ns3::WifiPhyStandard standard) [member function] + cls.add_method('ConfigureStandard', 'void', [param('ns3::WifiPhyStandard', 'standard')]) + ## wifi-mac.h: void ns3::WifiMac::FinishConfigureStandard(ns3::WifiPhyStandard standard) [member function] + cls.add_method('FinishConfigureStandard', + 'void', + [param('ns3::WifiPhyStandard', 'standard')], + is_pure_virtual=True, visibility='private', is_virtual=True) return def register_Ns3WifiMacHeader_methods(root_module, cls): @@ -2836,6 +2841,11 @@ def register_Ns3WifiPhy_methods(root_module, cls): 'uint16_t', [], is_pure_virtual=True, is_const=True, is_virtual=True) + ## wifi-phy.h: void ns3::WifiPhy::ConfigureStandard(ns3::WifiPhyStandard standard) [member function] + cls.add_method('ConfigureStandard', + 'void', + [param('ns3::WifiPhyStandard', 'standard')], + is_pure_virtual=True, is_virtual=True) ## wifi-phy.h: ns3::Ptr ns3::WifiPhy::GetChannel() const [member function] cls.add_method('GetChannel', 'ns3::Ptr< ns3::WifiChannel >', @@ -3160,10 +3170,6 @@ def register_Ns3YansWifiPhy_methods(root_module, cls): cls.add_method('StartReceivePacket', 'void', [param('ns3::Ptr< ns3::Packet >', 'packet'), param('double', 'rxPowerDbm'), param('ns3::WifiMode', 'mode'), param('ns3::WifiPreamble', 'preamble')]) - ## yans-wifi-phy.h: void ns3::YansWifiPhy::SetStandard(ns3::WifiPhyStandard standard) [member function] - cls.add_method('SetStandard', - 'void', - [param('ns3::WifiPhyStandard', 'standard')]) ## yans-wifi-phy.h: void ns3::YansWifiPhy::SetRxNoiseFigure(double noiseFigureDb) [member function] cls.add_method('SetRxNoiseFigure', 'void', @@ -3347,6 +3353,11 @@ def register_Ns3YansWifiPhy_methods(root_module, cls): 'ns3::Ptr< ns3::WifiChannel >', [], is_const=True, is_virtual=True) + ## yans-wifi-phy.h: void ns3::YansWifiPhy::ConfigureStandard(ns3::WifiPhyStandard standard) [member function] + cls.add_method('ConfigureStandard', + 'void', + [param('ns3::WifiPhyStandard', 'standard')], + is_virtual=True) ## yans-wifi-phy.h: void ns3::YansWifiPhy::DoDispose() [member function] cls.add_method('DoDispose', 'void', @@ -3514,6 +3525,11 @@ def register_Ns3AdhocWifiMac_methods(root_module, cls): 'void', [], visibility='private', is_virtual=True) + ## adhoc-wifi-mac.h: void ns3::AdhocWifiMac::FinishConfigureStandard(ns3::WifiPhyStandard standard) [member function] + cls.add_method('FinishConfigureStandard', + 'void', + [param('ns3::WifiPhyStandard', 'standard')], + visibility='private', is_virtual=True) return def register_Ns3AmrrWifiManager_methods(root_module, cls): @@ -4450,6 +4466,11 @@ def register_Ns3NqapWifiMac_methods(root_module, cls): 'void', [], visibility='private', is_virtual=True) + ## nqap-wifi-mac.h: void ns3::NqapWifiMac::FinishConfigureStandard(ns3::WifiPhyStandard standard) [member function] + cls.add_method('FinishConfigureStandard', + 'void', + [param('ns3::WifiPhyStandard', 'standard')], + visibility='private', is_virtual=True) return def register_Ns3NqstaWifiMac_methods(root_module, cls): @@ -4606,6 +4627,11 @@ def register_Ns3NqstaWifiMac_methods(root_module, cls): 'void', [], visibility='private', is_virtual=True) + ## nqsta-wifi-mac.h: void ns3::NqstaWifiMac::FinishConfigureStandard(ns3::WifiPhyStandard standard) [member function] + cls.add_method('FinishConfigureStandard', + 'void', + [param('ns3::WifiPhyStandard', 'standard')], + visibility='private', is_virtual=True) return def register_Ns3OnoeWifiManager_methods(root_module, cls): @@ -4763,6 +4789,11 @@ def register_Ns3QadhocWifiMac_methods(root_module, cls): 'void', [], visibility='private', is_virtual=True) + ## qadhoc-wifi-mac.h: void ns3::QadhocWifiMac::FinishConfigureStandard(ns3::WifiPhyStandard standard) [member function] + cls.add_method('FinishConfigureStandard', + 'void', + [param('ns3::WifiPhyStandard', 'standard')], + visibility='private', is_virtual=True) return def register_Ns3QapWifiMac_methods(root_module, cls): @@ -4916,6 +4947,11 @@ def register_Ns3QapWifiMac_methods(root_module, cls): 'void', [], visibility='private', is_virtual=True) + ## qap-wifi-mac.h: void ns3::QapWifiMac::FinishConfigureStandard(ns3::WifiPhyStandard standard) [member function] + cls.add_method('FinishConfigureStandard', + 'void', + [param('ns3::WifiPhyStandard', 'standard')], + visibility='private', is_virtual=True) return def register_Ns3QstaWifiMac_methods(root_module, cls): @@ -5072,6 +5108,11 @@ def register_Ns3QstaWifiMac_methods(root_module, cls): 'void', [], visibility='private', is_virtual=True) + ## qsta-wifi-mac.h: void ns3::QstaWifiMac::FinishConfigureStandard(ns3::WifiPhyStandard standard) [member function] + cls.add_method('FinishConfigureStandard', + 'void', + [param('ns3::WifiPhyStandard', 'standard')], + visibility='private', is_virtual=True) return def register_Ns3RraaWifiManager_methods(root_module, cls): diff --git a/src/devices/wifi/adhoc-wifi-mac.cc b/src/devices/wifi/adhoc-wifi-mac.cc index 2baceceff..3c11aa718 100644 --- a/src/devices/wifi/adhoc-wifi-mac.cc +++ b/src/devices/wifi/adhoc-wifi-mac.cc @@ -46,8 +46,7 @@ AdhocWifiMac::GetTypeId (void) .AddConstructor () .AddAttribute ("DcaTxop", "The DcaTxop object", PointerValue (), - MakePointerAccessor (&AdhocWifiMac::GetDcaTxop, - &AdhocWifiMac::SetDcaTxop), + MakePointerAccessor (&AdhocWifiMac::GetDcaTxop), MakePointerChecker ()) ; return tid; @@ -64,6 +63,10 @@ AdhocWifiMac::AdhocWifiMac () m_dcfManager = new DcfManager (); m_dcfManager->SetupLowListener (m_low); + + m_dca = CreateObject (); + m_dca->SetLow (m_low); + m_dca->SetManager (m_dcfManager); } AdhocWifiMac::~AdhocWifiMac () {} @@ -251,12 +254,27 @@ AdhocWifiMac::GetDcaTxop(void) const return m_dca; } -void -AdhocWifiMac::SetDcaTxop (Ptr dcaTxop) +void +AdhocWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) { - m_dca = dcaTxop; - m_dca->SetLow (m_low); - m_dca->SetManager (m_dcfManager); + switch (standard) + { + case WIFI_PHY_STANDARD_holland: + // fall through + case WIFI_PHY_STANDARD_80211_10Mhz: + // fall through + case WIFI_PHY_STANDARD_80211_5Mhz: + // fall through + case WIFI_PHY_STANDARD_80211a: + ConfigureDcf (m_dca, 15, 1023, AC_BE_NQOS); + break; + case WIFI_PHY_STANDARD_80211b: + ConfigureDcf (m_dca, 31, 1023, AC_BE_NQOS); + break; + default: + NS_ASSERT (false); + break; + } } diff --git a/src/devices/wifi/adhoc-wifi-mac.h b/src/devices/wifi/adhoc-wifi-mac.h index 3c56182c1..21bd2d8f2 100644 --- a/src/devices/wifi/adhoc-wifi-mac.h +++ b/src/devices/wifi/adhoc-wifi-mac.h @@ -87,7 +87,7 @@ private: AdhocWifiMac (const AdhocWifiMac & ctor_arg); AdhocWifiMac &operator = (const AdhocWifiMac &o); Ptr GetDcaTxop(void) const; - void SetDcaTxop (Ptr dcaTxop); + virtual void FinishConfigureStandard (enum WifiPhyStandard standard); Ptr m_dca; Callback, Mac48Address, Mac48Address> m_upCallback; diff --git a/src/devices/wifi/dca-txop.cc b/src/devices/wifi/dca-txop.cc index 0aff87242..6b4a64f43 100644 --- a/src/devices/wifi/dca-txop.cc +++ b/src/devices/wifi/dca-txop.cc @@ -101,21 +101,6 @@ DcaTxop::GetTypeId (void) static TypeId tid = TypeId ("ns3::DcaTxop") .SetParent () .AddConstructor () - .AddAttribute ("MinCw", "The minimum value of the contention window.", - UintegerValue (15), - MakeUintegerAccessor (&DcaTxop::SetMinCw, - &DcaTxop::GetMinCw), - MakeUintegerChecker ()) - .AddAttribute ("MaxCw", "The maximum value of the contention window.", - UintegerValue (1023), - MakeUintegerAccessor (&DcaTxop::SetMaxCw, - &DcaTxop::GetMaxCw), - MakeUintegerChecker ()) - .AddAttribute ("Aifsn", "The AIFSN: the default value conforms to simple DCA.", - UintegerValue (2), - MakeUintegerAccessor (&DcaTxop::SetAifsn, - &DcaTxop::GetAifsn), - MakeUintegerChecker ()) ; return tid; } diff --git a/src/devices/wifi/dca-txop.h b/src/devices/wifi/dca-txop.h index 7c4e2bb91..4fd697230 100644 --- a/src/devices/wifi/dca-txop.h +++ b/src/devices/wifi/dca-txop.h @@ -29,6 +29,7 @@ #include "wifi-mac-header.h" #include "wifi-mode.h" #include "wifi-remote-station-manager.h" +#include "dcf.h" namespace ns3 { @@ -62,7 +63,7 @@ class MacStations; * The rts/cts policy is similar to the fragmentation policy: when * a packet is bigger than a threshold, the rts/cts protocol is used. */ -class DcaTxop : public Object +class DcaTxop : public Dcf { public: static TypeId GetTypeId (void); @@ -90,12 +91,12 @@ public: void SetMaxQueueSize (uint32_t size); void SetMaxQueueDelay (Time delay); - void SetMinCw (uint32_t minCw); - void SetMaxCw (uint32_t maxCw); - void SetAifsn (uint32_t aifsn); - uint32_t GetMinCw (void) const; - uint32_t GetMaxCw (void) const; - uint32_t GetAifsn (void) const; + virtual void SetMinCw (uint32_t minCw); + virtual void SetMaxCw (uint32_t maxCw); + virtual void SetAifsn (uint32_t aifsn); + virtual uint32_t GetMinCw (void) const; + virtual uint32_t GetMaxCw (void) const; + virtual uint32_t GetAifsn (void) const; /** * \param packet packet to send diff --git a/src/devices/wifi/edca-txop-n.cc b/src/devices/wifi/edca-txop-n.cc index 5c751ecef..2fb1ada8b 100644 --- a/src/devices/wifi/edca-txop-n.cc +++ b/src/devices/wifi/edca-txop-n.cc @@ -98,21 +98,6 @@ EdcaTxopN::GetTypeId (void) static TypeId tid = TypeId ("ns3::EdcaTxopN") .SetParent () .AddConstructor () - .AddAttribute ("MinCw", "The minimun value of the contention window.", - UintegerValue (31), - MakeUintegerAccessor (&EdcaTxopN::SetMinCw, - &EdcaTxopN::GetMinCw), - MakeUintegerChecker ()) - .AddAttribute ("MaxCw", "The maximum value of the contention window.", - UintegerValue (1023), - MakeUintegerAccessor (&EdcaTxopN::SetMaxCw, - &EdcaTxopN::GetMaxCw), - MakeUintegerChecker ()) - .AddAttribute ("Aifsn", "The AIFSN: the default value conforms to simple DCA.", - UintegerValue (3), - MakeUintegerAccessor (&EdcaTxopN::SetAifsn, - &EdcaTxopN::GetAifsn), - MakeUintegerChecker ()) ; return tid; } diff --git a/src/devices/wifi/edca-txop-n.h b/src/devices/wifi/edca-txop-n.h index a89b5292d..216c77bb1 100644 --- a/src/devices/wifi/edca-txop-n.h +++ b/src/devices/wifi/edca-txop-n.h @@ -30,6 +30,7 @@ #include "wifi-mac.h" #include "wifi-mac-header.h" #include "qos-utils.h" +#include "dcf.h" #include #include @@ -62,7 +63,7 @@ enum TypeOfStation ADHOC_STA }; -class EdcaTxopN : public Object +class EdcaTxopN : public Dcf { public: @@ -85,12 +86,12 @@ public: void SetMaxQueueSize (uint32_t size); void SetMaxQueueDelay (Time delay); - void SetMinCw (uint32_t minCw); - void SetMaxCw (uint32_t maxCw); - void SetAifsn (uint32_t aifsn); - uint32_t GetMinCw (void) const; - uint32_t GetMaxCw (void) const; - uint32_t GetAifsn (void) const; + virtual void SetMinCw (uint32_t minCw); + virtual void SetMaxCw (uint32_t maxCw); + virtual void SetAifsn (uint32_t aifsn); + virtual uint32_t GetMinCw (void) const; + virtual uint32_t GetMaxCw (void) const; + virtual uint32_t GetAifsn (void) const; Ptr Low (void); Ptr GetMsduAggregator (void) const; diff --git a/src/devices/wifi/nqap-wifi-mac.cc b/src/devices/wifi/nqap-wifi-mac.cc index 4b9c8ce0b..07e5ec7b1 100644 --- a/src/devices/wifi/nqap-wifi-mac.cc +++ b/src/devices/wifi/nqap-wifi-mac.cc @@ -60,8 +60,7 @@ NqapWifiMac::GetTypeId (void) MakeBooleanChecker ()) .AddAttribute ("DcaTxop", "The DcaTxop object", PointerValue (), - MakePointerAccessor (&NqapWifiMac::GetDcaTxop, - &NqapWifiMac::SetDcaTxop), + MakePointerAccessor (&NqapWifiMac::GetDcaTxop), MakePointerChecker ()) ; return tid; @@ -85,6 +84,12 @@ NqapWifiMac::NqapWifiMac () m_beaconDca->SetMaxCw(0); m_beaconDca->SetLow (m_low); m_beaconDca->SetManager (m_dcfManager); + + m_dca = CreateObject (); + m_dca->SetLow (m_low); + m_dca->SetManager (m_dcfManager); + m_dca->SetTxOkCallback (MakeCallback (&NqapWifiMac::TxOk, this)); + m_dca->SetTxFailedCallback (MakeCallback (&NqapWifiMac::TxFailed, this)); } NqapWifiMac::~NqapWifiMac () { @@ -565,14 +570,28 @@ NqapWifiMac::GetDcaTxop(void) const return m_dca; } -void -NqapWifiMac::SetDcaTxop (Ptr dcaTxop) +void +NqapWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) { - m_dca = dcaTxop; - m_dca->SetLow (m_low); - m_dca->SetManager (m_dcfManager); - m_dca->SetTxOkCallback (MakeCallback (&NqapWifiMac::TxOk, this)); - m_dca->SetTxFailedCallback (MakeCallback (&NqapWifiMac::TxFailed, this)); + switch (standard) + { + case WIFI_PHY_STANDARD_holland: + // fall through + case WIFI_PHY_STANDARD_80211_10Mhz: + // fall through + case WIFI_PHY_STANDARD_80211_5Mhz: + // fall through + case WIFI_PHY_STANDARD_80211a: + ConfigureDcf (m_dca, 15, 1023, AC_BE_NQOS); + break; + case WIFI_PHY_STANDARD_80211b: + ConfigureDcf (m_dca, 31, 1023, AC_BE_NQOS); + break; + default: + NS_ASSERT (false); + break; + } } + } // namespace ns3 diff --git a/src/devices/wifi/nqap-wifi-mac.h b/src/devices/wifi/nqap-wifi-mac.h index 998bc0d61..414248571 100644 --- a/src/devices/wifi/nqap-wifi-mac.h +++ b/src/devices/wifi/nqap-wifi-mac.h @@ -115,7 +115,7 @@ private: NqapWifiMac (const NqapWifiMac & ctor_arg); NqapWifiMac &operator = (const NqapWifiMac &o); Ptr GetDcaTxop (void) const; - void SetDcaTxop (Ptr dcaTxop); + virtual void FinishConfigureStandard (enum WifiPhyStandard standard); Ptr m_dca; Ptr m_beaconDca; diff --git a/src/devices/wifi/nqsta-wifi-mac.cc b/src/devices/wifi/nqsta-wifi-mac.cc index e7bceba8f..26ade167a 100644 --- a/src/devices/wifi/nqsta-wifi-mac.cc +++ b/src/devices/wifi/nqsta-wifi-mac.cc @@ -89,8 +89,7 @@ NqstaWifiMac::GetTypeId (void) MakeBooleanChecker ()) .AddAttribute ("DcaTxop", "The DcaTxop object", PointerValue (), - MakePointerAccessor (&NqstaWifiMac::GetDcaTxop, - &NqstaWifiMac::SetDcaTxop), + MakePointerAccessor (&NqstaWifiMac::GetDcaTxop), MakePointerChecker ()) .AddTraceSource ("Assoc", "Associated with an access point.", MakeTraceSourceAccessor (&NqstaWifiMac::m_assocLogger)) @@ -115,6 +114,10 @@ NqstaWifiMac::NqstaWifiMac () m_dcfManager = new DcfManager (); m_dcfManager->SetupLowListener (m_low); + + m_dca = CreateObject (); + m_dca->SetLow (m_low); + m_dca->SetManager (m_dcfManager); } NqstaWifiMac::~NqstaWifiMac () @@ -208,13 +211,6 @@ NqstaWifiMac::GetDcaTxop(void) const { return m_dca; } -void -NqstaWifiMac::SetDcaTxop (Ptr dcaTxop) -{ - m_dca = dcaTxop; - m_dca->SetLow (m_low); - m_dca->SetManager (m_dcfManager); -} void NqstaWifiMac::SetWifiPhy (Ptr phy) { @@ -668,4 +664,27 @@ NqstaWifiMac::SetState (MacState value) m_state = value; } +void +NqstaWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) +{ + switch (standard) + { + case WIFI_PHY_STANDARD_holland: + // fall through + case WIFI_PHY_STANDARD_80211_10Mhz: + // fall through + case WIFI_PHY_STANDARD_80211_5Mhz: + // fall through + case WIFI_PHY_STANDARD_80211a: + ConfigureDcf (m_dca, 15, 1023, AC_BE_NQOS); + break; + case WIFI_PHY_STANDARD_80211b: + ConfigureDcf (m_dca, 31, 1023, AC_BE_NQOS); + break; + default: + NS_ASSERT (false); + break; + } +} + } // namespace ns3 diff --git a/src/devices/wifi/nqsta-wifi-mac.h b/src/devices/wifi/nqsta-wifi-mac.h index def5fc23d..88c10e463 100644 --- a/src/devices/wifi/nqsta-wifi-mac.h +++ b/src/devices/wifi/nqsta-wifi-mac.h @@ -139,8 +139,8 @@ private: NqstaWifiMac (const NqstaWifiMac & ctor_arg); NqstaWifiMac &operator = (const NqstaWifiMac & ctor_arg); Ptr GetDcaTxop(void) const; - void SetDcaTxop (Ptr dcaTxop); void SetState (enum MacState value); + virtual void FinishConfigureStandard (enum WifiPhyStandard standard); enum MacState m_state; Time m_probeRequestTimeout; diff --git a/src/devices/wifi/qadhoc-wifi-mac.cc b/src/devices/wifi/qadhoc-wifi-mac.cc index 66793e4fa..d795d2263 100644 --- a/src/devices/wifi/qadhoc-wifi-mac.cc +++ b/src/devices/wifi/qadhoc-wifi-mac.cc @@ -50,26 +50,22 @@ QadhocWifiMac::GetTypeId (void) .AddAttribute ("VO_EdcaTxopN", "Queue that manages packets belonging to AC_VO access class", PointerValue (), - MakePointerAccessor(&QadhocWifiMac::GetVOQueue, - &QadhocWifiMac::SetVOQueue), + MakePointerAccessor(&QadhocWifiMac::GetVOQueue), MakePointerChecker ()) .AddAttribute ("VI_EdcaTxopN", "Queue that manages packets belonging to AC_VI access class", PointerValue (), - MakePointerAccessor(&QadhocWifiMac::GetVIQueue, - &QadhocWifiMac::SetVIQueue), + MakePointerAccessor(&QadhocWifiMac::GetVIQueue), MakePointerChecker ()) .AddAttribute ("BE_EdcaTxopN", "Queue that manages packets belonging to AC_BE access class", PointerValue (), - MakePointerAccessor(&QadhocWifiMac::GetBEQueue, - &QadhocWifiMac::SetBEQueue), + MakePointerAccessor(&QadhocWifiMac::GetBEQueue), MakePointerChecker ()) .AddAttribute ("BK_EdcaTxopN", "Queue that manages packets belonging to AC_BK access class", PointerValue (), - MakePointerAccessor(&QadhocWifiMac::GetBKQueue, - &QadhocWifiMac::SetBKQueue), + MakePointerAccessor(&QadhocWifiMac::GetBKQueue), MakePointerChecker ()) ; return tid; @@ -88,6 +84,11 @@ QadhocWifiMac::QadhocWifiMac () m_dcfManager = new DcfManager (); m_dcfManager->SetupLowListener (m_low); + + SetQueue (AC_VO); + SetQueue (AC_VI); + SetQueue (AC_BE); + SetQueue (AC_BK); } QadhocWifiMac::~QadhocWifiMac () @@ -112,10 +113,9 @@ QadhocWifiMac::DoDispose (void) m_beEdca = 0; m_bkEdca = 0; m_stationManager = 0; - std::map >::iterator it = m_queues.begin (); - for (;it != m_queues.end (); it++) + for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i) { - it->second = 0; + (*i).second = 0; } WifiMac::DoDispose (); } @@ -208,10 +208,10 @@ QadhocWifiMac::SetWifiRemoteStationManager (Ptr statio { NS_LOG_FUNCTION (this << stationManager); m_stationManager = stationManager; - m_voEdca->SetWifiRemoteStationManager (stationManager); - m_viEdca->SetWifiRemoteStationManager (stationManager); - m_beEdca->SetWifiRemoteStationManager (stationManager); - m_bkEdca->SetWifiRemoteStationManager (stationManager); + for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i) + { + (*i).second->SetWifiRemoteStationManager (stationManager); + } m_low->SetWifiRemoteStationManager (stationManager); } @@ -373,69 +373,65 @@ QadhocWifiMac::DeaggregateAmsduAndForward (Ptr aggregatedPacket, Ptr QadhocWifiMac::GetVOQueue (void) const { - return m_voEdca; + return m_queues.find (AC_VO)->second; } Ptr QadhocWifiMac::GetVIQueue (void) const { - return m_viEdca; + return m_queues.find (AC_VI)->second; } Ptr QadhocWifiMac::GetBEQueue (void) const { - return m_beEdca; + return m_queues.find (AC_BE)->second; } Ptr QadhocWifiMac::GetBKQueue (void) const { - return m_bkEdca; + return m_queues.find (AC_BK)->second; } void -QadhocWifiMac::SetVOQueue (Ptr voQueue) +QadhocWifiMac::SetQueue (enum AccessClass ac) { - m_voEdca = voQueue; - m_queues.insert (std::make_pair(AC_VO, m_voEdca)); - m_queues[AC_VO]->SetLow (m_low); - m_queues[AC_VO]->SetManager (m_dcfManager); - m_queues[AC_VO]->SetTypeOfStation (ADHOC_STA); - m_queues[AC_VO]->SetTxMiddle (m_txMiddle); + Ptr edca = CreateObject (); + edca->SetLow (m_low); + edca->SetManager (m_dcfManager); + edca->SetTypeOfStation (ADHOC_STA); + edca->SetTxMiddle (m_txMiddle); + m_queues.insert (std::make_pair(ac, edca)); } -void -QadhocWifiMac::SetVIQueue (Ptr viQueue) +void +QadhocWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) { - m_viEdca = viQueue; - m_queues.insert (std::make_pair(AC_VI, m_viEdca)); - m_queues[AC_VI]->SetLow (m_low); - m_queues[AC_VI]->SetManager (m_dcfManager); - m_queues[AC_VI]->SetTypeOfStation (ADHOC_STA); - m_queues[AC_VI]->SetTxMiddle (m_txMiddle); -} - -void -QadhocWifiMac::SetBEQueue (Ptr beQueue) -{ - m_beEdca = beQueue; - m_queues.insert (std::make_pair(AC_BE, m_beEdca)); - m_queues[AC_BE]->SetLow (m_low); - m_queues[AC_BE]->SetManager (m_dcfManager); - m_queues[AC_BE]->SetTypeOfStation (ADHOC_STA); - m_queues[AC_BE]->SetTxMiddle (m_txMiddle); -} - -void -QadhocWifiMac::SetBKQueue (Ptr bkQueue) -{ - m_bkEdca = bkQueue; - m_queues.insert (std::make_pair(AC_BK, m_bkEdca)); - m_queues[AC_BK]->SetLow (m_low); - m_queues[AC_BK]->SetManager (m_dcfManager); - m_queues[AC_BK]->SetTypeOfStation (ADHOC_STA); - m_queues[AC_BK]->SetTxMiddle (m_txMiddle); + switch (standard) + { + case WIFI_PHY_STANDARD_holland: + // fall through + case WIFI_PHY_STANDARD_80211a: + // fall through + case WIFI_PHY_STANDARD_80211_10Mhz: + // fall through + case WIFI_PHY_STANDARD_80211_5Mhz: + ConfigureDcf (m_queues[AC_BK], 15, 1023, AC_BK); + ConfigureDcf (m_queues[AC_BE], 15, 1023, AC_BE); + ConfigureDcf (m_queues[AC_VI], 15, 1023, AC_VI); + ConfigureDcf (m_queues[AC_VO], 15, 1023, AC_VO); + break; + case WIFI_PHY_STANDARD_80211b: + ConfigureDcf (m_queues[AC_BK], 31, 1023, AC_BK); + ConfigureDcf (m_queues[AC_BE], 31, 1023, AC_BE); + ConfigureDcf (m_queues[AC_VI], 31, 1023, AC_VI); + ConfigureDcf (m_queues[AC_VO], 31, 1023, AC_VO); + break; + default: + NS_ASSERT (false); + break; + } } } //namespace ns3 diff --git a/src/devices/wifi/qadhoc-wifi-mac.h b/src/devices/wifi/qadhoc-wifi-mac.h index a5b16a3f1..9e3e28eec 100644 --- a/src/devices/wifi/qadhoc-wifi-mac.h +++ b/src/devices/wifi/qadhoc-wifi-mac.h @@ -74,6 +74,7 @@ public: virtual void SetSsid (Ssid ssid); virtual Mac48Address GetBssid (void) const; + private: Callback, Mac48Address, Mac48Address> m_forwardUp; virtual void DoDispose (void); @@ -92,16 +93,13 @@ private: typedef std::list, AmsduSubframeHeader> > DeaggregatedMsdus; typedef std::list, AmsduSubframeHeader> >::const_iterator DeaggregatedMsdusCI; + virtual void FinishConfigureStandard (enum WifiPhyStandard standard); + void SetQueue (enum AccessClass ac); Ptr GetVOQueue (void) const; Ptr GetVIQueue (void) const; Ptr GetBEQueue (void) const; Ptr GetBKQueue (void) const; - void SetVOQueue (Ptr voQueue); - void SetVIQueue (Ptr viQueue); - void SetBEQueue (Ptr beQueue); - void SetBKQueue (Ptr bkQueue); - Queues m_queues; Ptr m_voEdca; Ptr m_viEdca; diff --git a/src/devices/wifi/qap-wifi-mac.cc b/src/devices/wifi/qap-wifi-mac.cc index af9bb6938..7c5e51c29 100644 --- a/src/devices/wifi/qap-wifi-mac.cc +++ b/src/devices/wifi/qap-wifi-mac.cc @@ -63,26 +63,22 @@ QapWifiMac::GetTypeId (void) .AddAttribute ("VO_EdcaTxopN", "Queue that manages packets belonging to AC_VO access class", PointerValue (), - MakePointerAccessor(&QapWifiMac::GetVOQueue, - &QapWifiMac::SetVOQueue), + MakePointerAccessor(&QapWifiMac::GetVOQueue), MakePointerChecker ()) .AddAttribute ("VI_EdcaTxopN", "Queue that manages packets belonging to AC_VI access class", PointerValue (), - MakePointerAccessor(&QapWifiMac::GetVIQueue, - &QapWifiMac::SetVIQueue), + MakePointerAccessor(&QapWifiMac::GetVIQueue), MakePointerChecker ()) .AddAttribute ("BE_EdcaTxopN", "Queue that manages packets belonging to AC_BE access class", PointerValue (), - MakePointerAccessor(&QapWifiMac::GetBEQueue, - &QapWifiMac::SetBEQueue), + MakePointerAccessor(&QapWifiMac::GetBEQueue), MakePointerChecker ()) .AddAttribute ("BK_EdcaTxopN", "Queue that manages packets belonging to AC_BK access class", PointerValue (), - MakePointerAccessor(&QapWifiMac::GetBKQueue, - &QapWifiMac::SetBKQueue), + MakePointerAccessor(&QapWifiMac::GetBKQueue), MakePointerChecker ()) ; return tid; @@ -108,6 +104,11 @@ QapWifiMac::QapWifiMac () m_beaconDca->SetMaxCw(0); m_beaconDca->SetLow (m_low); m_beaconDca->SetManager (m_dcfManager); + + SetQueue (AC_VO); + SetQueue (AC_VI); + SetQueue (AC_BE); + SetQueue (AC_BK); } QapWifiMac::~QapWifiMac () @@ -129,15 +130,10 @@ QapWifiMac::DoDispose () m_phy = 0; m_beaconDca = 0; m_beaconEvent.Cancel (); - m_voEdca = 0; - m_viEdca = 0; - m_beEdca = 0; - m_bkEdca = 0; m_stationManager = 0; - std::map >::iterator it = m_queues.begin (); - for (;it != m_queues.end (); it++) + for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i) { - it->second = 0; + (*i).second = 0; } WifiMac::DoDispose (); } @@ -259,10 +255,10 @@ QapWifiMac::SetWifiRemoteStationManager (Ptr stationMa { NS_LOG_FUNCTION (this << stationManager); m_stationManager = stationManager; - m_voEdca->SetWifiRemoteStationManager (stationManager); - m_viEdca->SetWifiRemoteStationManager (stationManager); - m_beEdca->SetWifiRemoteStationManager (stationManager); - m_bkEdca->SetWifiRemoteStationManager (stationManager); + for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i) + { + (*i).second->SetWifiRemoteStationManager (stationManager); + } m_beaconDca->SetWifiRemoteStationManager (stationManager); m_low->SetWifiRemoteStationManager (stationManager); } @@ -713,77 +709,67 @@ QapWifiMac::DeaggregateAmsduAndForward (Ptr aggregatedPacket, WifiMacHea Ptr QapWifiMac::GetVOQueue (void) const { - return m_voEdca; + return m_queues.find (AC_VO)->second; } Ptr QapWifiMac::GetVIQueue (void) const { - return m_viEdca; + return m_queues.find (AC_VI)->second; } Ptr QapWifiMac::GetBEQueue (void) const { - return m_beEdca; + return m_queues.find (AC_BE)->second; } Ptr QapWifiMac::GetBKQueue (void) const { - return m_bkEdca; + return m_queues.find (AC_BK)->second; } void -QapWifiMac::SetVOQueue (Ptr voQueue) +QapWifiMac::SetQueue (enum AccessClass ac) { - m_voEdca = voQueue; - m_queues.insert (std::make_pair(AC_VO, m_voEdca)); - m_queues[AC_VO]->SetLow (m_low); - m_queues[AC_VO]->SetManager (m_dcfManager); - m_queues[AC_VO]->SetTypeOfStation (AP); - m_queues[AC_VO]->SetTxMiddle (m_txMiddle); - m_queues[AC_VO]->SetTxOkCallback (MakeCallback (&QapWifiMac::TxOk, this)); - m_queues[AC_VO]->SetTxFailedCallback (MakeCallback (&QapWifiMac::TxFailed, this)); + Ptr edca = CreateObject (); + edca->SetLow (m_low); + edca->SetManager (m_dcfManager); + edca->SetTypeOfStation (AP); + edca->SetTxMiddle (m_txMiddle); + edca->SetTxOkCallback (MakeCallback (&QapWifiMac::TxOk, this)); + edca->SetTxFailedCallback (MakeCallback (&QapWifiMac::TxFailed, this)); + m_queues.insert (std::make_pair(ac, edca)); } -void -QapWifiMac::SetVIQueue (Ptr viQueue) +void +QapWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) { - m_viEdca = viQueue; - m_queues.insert (std::make_pair(AC_VI, m_viEdca)); - m_queues[AC_VI]->SetLow (m_low); - m_queues[AC_VI]->SetManager (m_dcfManager); - m_queues[AC_VI]->SetTypeOfStation (AP); - m_queues[AC_VI]->SetTxMiddle (m_txMiddle); - m_queues[AC_VI]->SetTxOkCallback (MakeCallback (&QapWifiMac::TxOk, this)); - m_queues[AC_VI]->SetTxFailedCallback (MakeCallback (&QapWifiMac::TxFailed, this)); -} - -void -QapWifiMac::SetBEQueue (Ptr beQueue) -{ - m_beEdca = beQueue; - m_queues.insert (std::make_pair(AC_BE, m_beEdca)); - m_queues[AC_BE]->SetLow (m_low); - m_queues[AC_BE]->SetManager (m_dcfManager); - m_queues[AC_BE]->SetTypeOfStation (AP); - m_queues[AC_BE]->SetTxMiddle (m_txMiddle); - m_queues[AC_BE]->SetTxOkCallback (MakeCallback (&QapWifiMac::TxOk, this)); - m_queues[AC_BE]->SetTxFailedCallback (MakeCallback (&QapWifiMac::TxFailed, this)); -} - -void -QapWifiMac::SetBKQueue (Ptr bkQueue) -{ - m_bkEdca = bkQueue; - m_queues.insert (std::make_pair(AC_BK, m_bkEdca)); - m_queues[AC_BK]->SetLow (m_low); - m_queues[AC_BK]->SetManager (m_dcfManager); - m_queues[AC_BK]->SetTypeOfStation (AP); - m_queues[AC_BK]->SetTxMiddle (m_txMiddle); - m_queues[AC_BK]->SetTxOkCallback (MakeCallback (&QapWifiMac::TxOk, this)); - m_queues[AC_BK]->SetTxFailedCallback (MakeCallback (&QapWifiMac::TxFailed, this)); + switch (standard) + { + case WIFI_PHY_STANDARD_holland: + // fall through + case WIFI_PHY_STANDARD_80211a: + // fall through + case WIFI_PHY_STANDARD_80211_10Mhz: + // fall through + case WIFI_PHY_STANDARD_80211_5Mhz: + ConfigureDcf (m_queues[AC_BK], 15, 1023, AC_BK); + ConfigureDcf (m_queues[AC_BE], 15, 1023, AC_BE); + ConfigureDcf (m_queues[AC_VI], 15, 1023, AC_VI); + ConfigureDcf (m_queues[AC_VO], 15, 1023, AC_VO); + break; + case WIFI_PHY_STANDARD_80211b: + ConfigureDcf (m_queues[AC_BK], 31, 1023, AC_BK); + ConfigureDcf (m_queues[AC_BE], 31, 1023, AC_BE); + ConfigureDcf (m_queues[AC_VI], 31, 1023, AC_VI); + ConfigureDcf (m_queues[AC_VO], 31, 1023, AC_VO); + break; + default: + NS_ASSERT (false); + break; + } } } //namespace ns3 diff --git a/src/devices/wifi/qap-wifi-mac.h b/src/devices/wifi/qap-wifi-mac.h index c906a14a5..1c789e96f 100644 --- a/src/devices/wifi/qap-wifi-mac.h +++ b/src/devices/wifi/qap-wifi-mac.h @@ -87,6 +87,10 @@ public: void StartBeaconing (void); private: + typedef std::map > Queues; + typedef std::list, AmsduSubframeHeader> > DeaggregatedMsdus; + typedef std::list, AmsduSubframeHeader> >::const_iterator DeaggregatedMsdusCI; + virtual void DoDispose (void); void Receive (Ptr packet, WifiMacHeader const*hdr); void ForwardUp (Ptr packet, Mac48Address from, Mac48Address to); @@ -107,28 +111,15 @@ private: QapWifiMac &operator = (const QapWifiMac &); QapWifiMac (const QapWifiMac &); - typedef std::map > Queues; - typedef std::list, AmsduSubframeHeader> > DeaggregatedMsdus; - typedef std::list, AmsduSubframeHeader> >::const_iterator DeaggregatedMsdusCI; - - Callback, Mac48Address, Mac48Address> m_forwardUp; - Ptr GetVOQueue (void) const; Ptr GetVIQueue (void) const; Ptr GetBEQueue (void) const; Ptr GetBKQueue (void) const; + void SetQueue (enum AccessClass ac); - void SetVOQueue (Ptr voQueue); - void SetVIQueue (Ptr viQueue); - void SetBEQueue (Ptr beQueue); - void SetBKQueue (Ptr bkQueue); + virtual void FinishConfigureStandard (enum WifiPhyStandard standard); - /*Next map is used only for an esay access to a specific queue*/ Queues m_queues; - Ptr m_voEdca; - Ptr m_viEdca; - Ptr m_beEdca; - Ptr m_bkEdca; Ptr m_beaconDca; Ptr m_low; Ptr m_phy; @@ -139,6 +130,7 @@ private: Ssid m_ssid; EventId m_beaconEvent; Time m_beaconInterval; + Callback, Mac48Address, Mac48Address> m_forwardUp; }; } //namespace ns3 diff --git a/src/devices/wifi/qos-utils.h b/src/devices/wifi/qos-utils.h index b54a60fe4..184759ed4 100644 --- a/src/devices/wifi/qos-utils.h +++ b/src/devices/wifi/qos-utils.h @@ -31,6 +31,7 @@ enum AccessClass { AC_VI = 1, AC_BE = 2, AC_BK = 3, + AC_BE_NQOS = 4, AC_UNDEF }; diff --git a/src/devices/wifi/qsta-wifi-mac.cc b/src/devices/wifi/qsta-wifi-mac.cc index e3c3fed5a..ba8f2f1f5 100644 --- a/src/devices/wifi/qsta-wifi-mac.cc +++ b/src/devices/wifi/qsta-wifi-mac.cc @@ -69,26 +69,22 @@ QstaWifiMac::GetTypeId (void) .AddAttribute ("VO_EdcaTxopN", "Queue that manages packets belonging to AC_VO access class", PointerValue (), - MakePointerAccessor(&QstaWifiMac::GetVOQueue, - &QstaWifiMac::SetVOQueue), + MakePointerAccessor(&QstaWifiMac::GetVOQueue), MakePointerChecker ()) .AddAttribute ("VI_EdcaTxopN", "Queue that manages packets belonging to AC_VI access class", PointerValue (), - MakePointerAccessor(&QstaWifiMac::GetVIQueue, - &QstaWifiMac::SetVIQueue), + MakePointerAccessor(&QstaWifiMac::GetVIQueue), MakePointerChecker ()) .AddAttribute ("BE_EdcaTxopN", "Queue that manages packets belonging to AC_BE access class", PointerValue (), - MakePointerAccessor(&QstaWifiMac::GetBEQueue, - &QstaWifiMac::SetBEQueue), + MakePointerAccessor(&QstaWifiMac::GetBEQueue), MakePointerChecker ()) .AddAttribute ("BK_EdcaTxopN", "Queue that manages packets belonging to AC_BK access class", PointerValue (), - MakePointerAccessor(&QstaWifiMac::GetBKQueue, - &QstaWifiMac::SetBKQueue), + MakePointerAccessor(&QstaWifiMac::GetBKQueue), MakePointerChecker ()) ; return tid; @@ -111,6 +107,11 @@ QstaWifiMac::QstaWifiMac () m_dcfManager = new DcfManager (); m_dcfManager->SetupLowListener (m_low); + + SetQueue (AC_VO); + SetQueue (AC_VI); + SetQueue (AC_BE); + SetQueue (AC_BK); } QstaWifiMac::~QstaWifiMac () @@ -131,15 +132,10 @@ QstaWifiMac::DoDispose () m_low = 0; m_phy = 0; m_dcfManager = 0; - m_voEdca = 0; - m_viEdca = 0; - m_beEdca = 0; - m_bkEdca = 0; m_stationManager = 0; - std::map >::iterator it = m_queues.begin (); - for (;it != m_queues.end (); it++) + for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i) { - it->second = 0; + (*i).second = 0; } WifiMac::DoDispose (); } @@ -706,69 +702,66 @@ QstaWifiMac::DeaggregateAmsduAndForward (Ptr aggregatedPacket, WifiMacHe Ptr QstaWifiMac::GetVOQueue (void) const { - return m_voEdca; + return m_queues.find (AC_VO)->second; } Ptr QstaWifiMac::GetVIQueue (void) const { - return m_viEdca; + return m_queues.find (AC_VI)->second; } Ptr QstaWifiMac::GetBEQueue (void) const { - return m_beEdca; + return m_queues.find (AC_BE)->second; } Ptr QstaWifiMac::GetBKQueue (void) const { - return m_bkEdca; + return m_queues.find (AC_BK)->second; } void -QstaWifiMac::SetVOQueue (Ptr voQueue) +QstaWifiMac::SetQueue (enum AccessClass ac) { - m_voEdca = voQueue; - m_queues.insert (std::make_pair(AC_VO, m_voEdca)); - m_queues[AC_VO]->SetLow (m_low); - m_queues[AC_VO]->SetManager (m_dcfManager); - m_queues[AC_VO]->SetTypeOfStation (STA); - m_queues[AC_VO]->SetTxMiddle (m_txMiddle); + Ptr edca = CreateObject (); + edca->SetLow (m_low); + edca->SetManager (m_dcfManager); + edca->SetTypeOfStation (STA); + edca->SetTxMiddle (m_txMiddle); + m_queues.insert (std::make_pair(ac, edca)); } -void -QstaWifiMac::SetVIQueue (Ptr viQueue) +void +QstaWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) { - m_viEdca = viQueue; - m_queues.insert (std::make_pair(AC_VI, m_viEdca)); - m_queues[AC_VI]->SetLow (m_low); - m_queues[AC_VI]->SetManager (m_dcfManager); - m_queues[AC_VI]->SetTypeOfStation (STA); - m_queues[AC_VI]->SetTxMiddle (m_txMiddle); + switch (standard) + { + case WIFI_PHY_STANDARD_holland: + // fall through + case WIFI_PHY_STANDARD_80211a: + // fall through + case WIFI_PHY_STANDARD_80211_10Mhz: + // fall through + case WIFI_PHY_STANDARD_80211_5Mhz: + ConfigureDcf (m_queues[AC_BK], 15, 1023, AC_BK); + ConfigureDcf (m_queues[AC_BE], 15, 1023, AC_BE); + ConfigureDcf (m_queues[AC_VI], 15, 1023, AC_VI); + ConfigureDcf (m_queues[AC_VO], 15, 1023, AC_VO); + break; + case WIFI_PHY_STANDARD_80211b: + ConfigureDcf (m_queues[AC_BK], 31, 1023, AC_BK); + ConfigureDcf (m_queues[AC_BE], 31, 1023, AC_BE); + ConfigureDcf (m_queues[AC_VI], 31, 1023, AC_VI); + ConfigureDcf (m_queues[AC_VO], 31, 1023, AC_VO); + break; + default: + NS_ASSERT (false); + break; + } } -void -QstaWifiMac::SetBEQueue (Ptr beQueue) -{ - m_beEdca = beQueue; - m_queues.insert (std::make_pair(AC_BE, m_beEdca)); - m_queues[AC_BE]->SetLow (m_low); - m_queues[AC_BE]->SetManager (m_dcfManager); - m_queues[AC_BE]->SetTypeOfStation (STA); - m_queues[AC_BE]->SetTxMiddle (m_txMiddle); -} - -void -QstaWifiMac::SetBKQueue (Ptr bkQueue) -{ - m_bkEdca = bkQueue; - m_queues.insert (std::make_pair(AC_BK, m_bkEdca)); - m_queues[AC_BK]->SetLow (m_low); - m_queues[AC_BK]->SetManager (m_dcfManager); - m_queues[AC_BK]->SetTypeOfStation (STA); - m_queues[AC_BK]->SetTxMiddle (m_txMiddle); -} } //namespace ns3 diff --git a/src/devices/wifi/qsta-wifi-mac.h b/src/devices/wifi/qsta-wifi-mac.h index 1d80e1383..ea87db875 100644 --- a/src/devices/wifi/qsta-wifi-mac.h +++ b/src/devices/wifi/qsta-wifi-mac.h @@ -111,19 +111,15 @@ private: */ void DeaggregateAmsduAndForward (Ptr aggregatedPacket, WifiMacHeader const *hdr); + QstaWifiMac &operator = (const QstaWifiMac &); + QstaWifiMac (const QstaWifiMac &); + virtual void FinishConfigureStandard (enum WifiPhyStandard standard); + void SetQueue (enum AccessClass ac); Ptr GetVOQueue (void) const; Ptr GetVIQueue (void) const; Ptr GetBEQueue (void) const; Ptr GetBKQueue (void) const; - void SetVOQueue (Ptr voQueue); - void SetVIQueue (Ptr viQueue); - void SetBEQueue (Ptr beQueue); - void SetBKQueue (Ptr bkQueue); - - QstaWifiMac &operator = (const QstaWifiMac &); - QstaWifiMac (const QstaWifiMac &); - typedef std::map > Queues; typedef std::list, AmsduSubframeHeader> > DeaggregatedMsdus; typedef std::list, AmsduSubframeHeader> >::const_iterator DeaggregatedMsdusCI; @@ -136,13 +132,7 @@ private: REFUSED } m_state; - /*Next map is used only for an esay access to a specific queue*/ Queues m_queues; - Ptr m_voEdca; - Ptr m_viEdca; - Ptr m_beEdca; - Ptr m_bkEdca; - Ptr m_low; Ptr m_phy; Ptr m_stationManager; diff --git a/src/devices/wifi/wifi-mac.cc b/src/devices/wifi/wifi-mac.cc index 8f9bca897..8448e5e9d 100644 --- a/src/devices/wifi/wifi-mac.cc +++ b/src/devices/wifi/wifi-mac.cc @@ -18,6 +18,7 @@ * Author: Mathieu Lacage */ #include "wifi-mac.h" +#include "dcf.h" #include "ns3/uinteger.h" #include "ns3/trace-source-accessor.h" @@ -117,14 +118,6 @@ WifiMac::GetTypeId (void) MakeSsidAccessor (&WifiMac::GetSsid, &WifiMac::SetSsid), MakeSsidChecker ()) - .AddAttribute ("Standard", "The standard chosen configures some MAC-specific constants", - EnumValue (WIFI_PHY_STANDARD_80211a), - MakeEnumAccessor (&WifiMac::SetStandard), - MakeEnumChecker (WIFI_PHY_STANDARD_80211a, "802.11a", - WIFI_PHY_STANDARD_80211b, "802.11b", - WIFI_PHY_STANDARD_80211_10Mhz,"802.11_10Mhz", - WIFI_PHY_STANDARD_80211_5Mhz,"802-11_5Mhz", - WIFI_PHY_STANDARD_holland, "holland")) .AddTraceSource ("MacTx", "A packet has been received from higher layers and is being processed in preparation for " "queueing for transmission.", @@ -209,9 +202,8 @@ WifiMac::NotifyRxDrop (Ptr packet) } void -WifiMac::SetStandard (enum WifiPhyStandard standard) +WifiMac::ConfigureStandard (enum WifiPhyStandard standard) { - m_standard = standard; switch (standard) { case WIFI_PHY_STANDARD_80211a: Configure80211a (); @@ -232,6 +224,7 @@ WifiMac::SetStandard (enum WifiPhyStandard standard) NS_ASSERT (false); break; } + FinishConfigureStandard (standard); } void @@ -278,4 +271,41 @@ WifiMac::Configure80211_5Mhz (void) SetAckTimeout(MicroSeconds(64+176+21+GetDefaultMaxPropagationDelay().GetMicroSeconds ()*2)); } +void +WifiMac::ConfigureDcf (Ptr dcf, uint32_t cwmin, uint32_t cwmax, enum AccessClass ac) +{ + /* see IEE802.11 section 7.3.2.29 */ + switch (ac) { + case AC_VO: + dcf->SetMinCw ((cwmin+1)/4-1); + dcf->SetMaxCw ((cwmin+1)/2-1); + dcf->SetAifsn (2); + break; + case AC_VI: + dcf->SetMinCw ((cwmin+1)/2-1); + dcf->SetMaxCw (cwmin); + dcf->SetAifsn (2); + break; + case AC_BE: + dcf->SetMinCw (cwmin); + dcf->SetMaxCw (cwmax); + dcf->SetAifsn (3); + break; + case AC_BK: + dcf->SetMinCw (cwmin); + dcf->SetMaxCw (cwmax); + dcf->SetAifsn (7); + break; + case AC_BE_NQOS: + dcf->SetMinCw (cwmin); + dcf->SetMaxCw (cwmax); + dcf->SetAifsn (2); + break; + case AC_UNDEF: + NS_FATAL_ERROR ("I don't know what to do with this"); + break; + } +} + + } // namespace ns3 diff --git a/src/devices/wifi/wifi-mac.h b/src/devices/wifi/wifi-mac.h index 5a3d3d97a..0a59acd59 100644 --- a/src/devices/wifi/wifi-mac.h +++ b/src/devices/wifi/wifi-mac.h @@ -26,9 +26,12 @@ #include "wifi-phy.h" #include "wifi-remote-station-manager.h" #include "ssid.h" +#include "qos-utils.h" namespace ns3 { +class Dcf; + /** * \brief base class for all MAC-level wifi objects. * @@ -209,8 +212,10 @@ public: /** * \param standard the wifi standard to be configured */ - void SetStandard (enum WifiPhyStandard standard); + void ConfigureStandard (enum WifiPhyStandard standard); +protected: + void ConfigureDcf (Ptr dcf, uint32_t cwmin, uint32_t cwmax, enum AccessClass ac); private: static Time GetDefaultMaxPropagationDelay (void); static Time GetDefaultSlot (void); @@ -218,10 +223,18 @@ private: static Time GetDefaultEifsNoDifs (void); static Time GetDefaultCtsAckDelay (void); static Time GetDefaultCtsAckTimeout (void); + /** + * \param standard the phy standard to be used + * + * This method is called by ns3::WifiMac::ConfigureStandard to complete + * the configuration process for a requested phy standard. Subclasses should + * implement this method to configure their dcf queues according to the + * requested standard. + */ + virtual void FinishConfigureStandard (enum WifiPhyStandard standard) = 0; Time m_maxPropagationDelay; uint32_t m_maxMsduSize; - WifiPhyStandard m_standard; void Configure80211a (void); void Configure80211b (void); diff --git a/src/devices/wifi/wifi-phy.h b/src/devices/wifi/wifi-phy.h index b9519a812..222ff8ccf 100644 --- a/src/devices/wifi/wifi-phy.h +++ b/src/devices/wifi/wifi-phy.h @@ -253,6 +253,8 @@ public: virtual void SetChannelNumber (uint16_t id) = 0; /// Return current channel number, see SetChannelNumber() virtual uint16_t GetChannelNumber () const = 0; + + virtual void ConfigureStandard (enum WifiPhyStandard standard) = 0; virtual Ptr GetChannel (void) const = 0; diff --git a/src/devices/wifi/wifi-test.cc b/src/devices/wifi/wifi-test.cc index c2a9ba532..1e2d8893b 100644 --- a/src/devices/wifi/wifi-test.cc +++ b/src/devices/wifi/wifi-test.cc @@ -71,9 +71,8 @@ WifiTest::CreateOne (Vector pos, Ptr channel) Ptr node = CreateObject (); Ptr dev = CreateObject (); - Ptr queue = CreateObject (); Ptr mac = m_mac.Create (); - mac->SetAttribute("DcaTxop", PointerValue (queue)); + mac->ConfigureStandard (WIFI_PHY_STANDARD_80211a); Ptr mobility = CreateObject (); Ptr phy = CreateObject (); Ptr error = CreateObject (); @@ -81,6 +80,7 @@ WifiTest::CreateOne (Vector pos, Ptr channel) phy->SetChannel (channel); phy->SetDevice (dev); phy->SetMobility (node); + phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a); Ptr manager = m_manager.Create (); mobility->SetPosition (pos); diff --git a/src/devices/wifi/wscript b/src/devices/wifi/wscript index e265afaf6..7df865e15 100644 --- a/src/devices/wifi/wscript +++ b/src/devices/wifi/wscript @@ -64,6 +64,7 @@ def build(bld): 'amsdu-subframe-header.cc', 'msdu-standard-aggregator.cc', 'minstrel-wifi-manager.cc', + 'dcf.cc', ] headers = bld.new_task_gen('ns3header') headers.module = 'wifi' @@ -107,14 +108,14 @@ def build(bld): 'msdu-aggregator.h', 'amsdu-subframe-header.h', 'qos-tag.h', -# Need this for module devices/mesh 'mgt-headers.h', 'status-code.h', 'capability-information.h', 'dcf-manager.h', 'mac-rx-middle.h', 'mac-low.h', - 'minstrel-wifi-manager.h' + 'minstrel-wifi-manager.h', + 'dcf.h', ] if bld.env['ENABLE_GSL']: diff --git a/src/devices/wifi/yans-wifi-phy.cc b/src/devices/wifi/yans-wifi-phy.cc index 6d2a36867..eead8afae 100644 --- a/src/devices/wifi/yans-wifi-phy.cc +++ b/src/devices/wifi/yans-wifi-phy.cc @@ -105,15 +105,6 @@ YansWifiPhy::GetTypeId (void) MakeDoubleAccessor (&YansWifiPhy::SetRxNoiseFigure, &YansWifiPhy::GetRxNoiseFigure), MakeDoubleChecker ()) - .AddAttribute ("Standard", "The standard chosen configures a set of transmission modes" - " and some PHY-specific constants.", - EnumValue (WIFI_PHY_STANDARD_80211a), - MakeEnumAccessor (&YansWifiPhy::SetStandard), - MakeEnumChecker (WIFI_PHY_STANDARD_80211a, "802.11a", - WIFI_PHY_STANDARD_80211b, "802.11b", - WIFI_PHY_STANDARD_80211_10Mhz,"802.11_10Mhz", - WIFI_PHY_STANDARD_80211_5Mhz,"802.11_5Mhz", - WIFI_PHY_STANDARD_holland, "holland")) .AddAttribute ("State", "The state of the PHY layer", PointerValue (), MakePointerAccessor (&YansWifiPhy::m_state), @@ -151,10 +142,9 @@ YansWifiPhy::DoDispose (void) } void -YansWifiPhy::SetStandard (enum WifiPhyStandard standard) +YansWifiPhy::ConfigureStandard (enum WifiPhyStandard standard) { NS_LOG_FUNCTION (this << standard); - m_standard = standard; switch (standard) { case WIFI_PHY_STANDARD_80211a: Configure80211a (); diff --git a/src/devices/wifi/yans-wifi-phy.h b/src/devices/wifi/yans-wifi-phy.h index a2efeba4e..34c3313e7 100644 --- a/src/devices/wifi/yans-wifi-phy.h +++ b/src/devices/wifi/yans-wifi-phy.h @@ -89,7 +89,6 @@ public: WifiMode mode, WifiPreamble preamble); - void SetStandard (enum WifiPhyStandard standard); void SetRxNoiseFigure (double noiseFigureDb); void SetTxPowerStart (double start); void SetTxPowerEnd (double end); @@ -133,6 +132,7 @@ public: virtual WifiMode GetMode (uint32_t mode) const; virtual double CalculateSnr (WifiMode txMode, double ber) const; virtual Ptr GetChannel (void) const; + virtual void ConfigureStandard (enum WifiPhyStandard standard); private: typedef std::vector Modes; @@ -170,7 +170,6 @@ private: Modes m_modes; EventId m_endSyncEvent; UniformVariable m_random; - WifiPhyStandard m_standard; /// Standard-dependent center frequency of 0-th channel, MHz double m_channelStartingFrequency; Ptr m_state; diff --git a/src/helper/nqos-wifi-mac-helper.cc b/src/helper/nqos-wifi-mac-helper.cc index fbe904ab9..ccc4c2f3a 100644 --- a/src/helper/nqos-wifi-mac-helper.cc +++ b/src/helper/nqos-wifi-mac-helper.cc @@ -25,9 +25,7 @@ namespace ns3 { NqosWifiMacHelper::NqosWifiMacHelper () -{ - m_queue.SetTypeId ("ns3::DcaTxop"); -} +{} NqosWifiMacHelper::~NqosWifiMacHelper () {} @@ -62,24 +60,10 @@ NqosWifiMacHelper::SetType (std::string type, m_mac.Set (n7, v7); } -void -NqosWifiMacHelper::SetDcaParameters (std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3) -{ - m_queue.Set (n0, v0); - m_queue.Set (n1, v1); - m_queue.Set (n2, v2); - m_queue.Set (n3, v3); -} - Ptr NqosWifiMacHelper::Create (void) const { Ptr mac = m_mac.Create (); - Ptr queue = m_queue.Create (); - mac->SetAttribute ("DcaTxop", PointerValue (queue)); return mac; } diff --git a/src/helper/nqos-wifi-mac-helper.h b/src/helper/nqos-wifi-mac-helper.h index 032d783ba..14446e647 100644 --- a/src/helper/nqos-wifi-mac-helper.h +++ b/src/helper/nqos-wifi-mac-helper.h @@ -69,20 +69,6 @@ public: std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); - /** - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - */ - void SetDcaParameters (std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue ()); private: /** * \returns a newly-created MAC object. @@ -92,7 +78,6 @@ private: virtual Ptr Create (void) const; ObjectFactory m_mac; - ObjectFactory m_queue; }; } //namespace ns3 diff --git a/src/helper/qos-wifi-mac-helper.cc b/src/helper/qos-wifi-mac-helper.cc index 634c80cd0..4f1a08444 100644 --- a/src/helper/qos-wifi-mac-helper.cc +++ b/src/helper/qos-wifi-mac-helper.cc @@ -28,20 +28,12 @@ namespace ns3 { QosWifiMacHelper::QosWifiMacHelper () { - m_aggregators.insert (std::make_pair (AC_VO, ObjectFactory ())); - m_aggregators.insert (std::make_pair (AC_VI, ObjectFactory ())); - m_aggregators.insert (std::make_pair (AC_BE, ObjectFactory ())); - m_aggregators.insert (std::make_pair (AC_BK, ObjectFactory ())); - - m_queues.insert (std::make_pair (AC_VO, ObjectFactory ())); - m_queues.insert (std::make_pair (AC_VI, ObjectFactory ())); - m_queues.insert (std::make_pair (AC_BE, ObjectFactory ())); - m_queues.insert (std::make_pair (AC_BK, ObjectFactory ())); - - m_queues[AC_VO].SetTypeId ("ns3::EdcaTxopN"); - m_queues[AC_VI].SetTypeId ("ns3::EdcaTxopN"); - m_queues[AC_BE].SetTypeId ("ns3::EdcaTxopN"); - m_queues[AC_BK].SetTypeId ("ns3::EdcaTxopN"); + ObjectFactory defaultAggregator; + defaultAggregator.SetTypeId ("ns3::MsduStandardAggregator"); + m_aggregators.insert (std::make_pair (AC_VO, defaultAggregator)); + m_aggregators.insert (std::make_pair (AC_VI, defaultAggregator)); + m_aggregators.insert (std::make_pair (AC_BE, defaultAggregator)); + m_aggregators.insert (std::make_pair (AC_BK, defaultAggregator)); } QosWifiMacHelper::~QosWifiMacHelper () @@ -52,19 +44,7 @@ QosWifiMacHelper::Default (void) { QosWifiMacHelper helper; helper.SetType ("ns3::QstaWifiMac"); - /* For more details about this default parameters see IEE802.11 section 7.3.2.29 */ - helper.SetEdcaParametersForAc (AC_VO,"MinCw", UintegerValue (3), - "MaxCw", UintegerValue (7), - "Aifsn", UintegerValue (2)); - helper.SetEdcaParametersForAc (AC_VI,"MinCw", UintegerValue (7), - "MaxCw", UintegerValue (15), - "Aifsn", UintegerValue (2)); - helper.SetEdcaParametersForAc (AC_BE,"MinCw", UintegerValue (15), - "MaxCw", UintegerValue (1023), - "Aifsn", UintegerValue (3)); - helper.SetEdcaParametersForAc (AC_BK,"MinCw", UintegerValue (15), - "MaxCw", UintegerValue (1023), - "Aifsn", UintegerValue (7)); + return helper; } @@ -110,80 +90,26 @@ QosWifiMacHelper::SetMsduAggregatorForAc (AccessClass accessClass, std::string t } void -QosWifiMacHelper::SetEdcaParametersForAc (AccessClass accessClass, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3) +QosWifiMacHelper::Setup (Ptr mac, enum AccessClass ac, std::string dcaAttrName) const { - std::map::iterator it; - it = m_queues.find (accessClass); - if (it != m_queues.end ()) - { - it->second.Set (n0, v0); - it->second.Set (n1, v1); - it->second.Set (n2, v2); - it->second.Set (n3, v3); - } + ObjectFactory factory = m_aggregators.find (ac)->second; + PointerValue ptr; + mac->GetAttribute (dcaAttrName, ptr); + Ptr edca = ptr.Get (); + Ptr aggregator = factory.Create (); + edca->SetMsduAggregator (aggregator); } + Ptr QosWifiMacHelper::Create (void) const { Ptr mac = m_mac.Create (); - Ptr edcaQueue; - Ptr aggregator; - std::map::const_iterator itQueue; - std::map::const_iterator itAggr; - - /* Setting for VO queue */ - itQueue = m_queues.find (AC_VO); - itAggr = m_aggregators.find (AC_VO); - - edcaQueue = itQueue->second.Create (); - if (itAggr->second.GetTypeId ().GetUid () != 0) - { - aggregator = itAggr->second.Create (); - edcaQueue->SetMsduAggregator (aggregator); - } - mac->SetAttribute ("VO_EdcaTxopN", PointerValue (edcaQueue)); - - /* Setting for VI queue */ - itQueue = m_queues.find (AC_VI); - itAggr = m_aggregators.find (AC_VI); - - edcaQueue = itQueue->second.Create (); - if (itAggr->second.GetTypeId ().GetUid () != 0) - { - aggregator = itAggr->second.Create (); - edcaQueue->SetMsduAggregator (aggregator); - } - mac->SetAttribute ("VI_EdcaTxopN", PointerValue (edcaQueue)); - - /* Setting for BE queue */ - itQueue = m_queues.find (AC_BE); - itAggr = m_aggregators.find (AC_BE); - - edcaQueue = itQueue->second.Create (); - if (itAggr->second.GetTypeId ().GetUid () != 0) - { - aggregator = itAggr->second.Create (); - edcaQueue->SetMsduAggregator (aggregator); - } - mac->SetAttribute ("BE_EdcaTxopN", PointerValue (edcaQueue)); - - /* Setting for BK queue */ - itQueue = m_queues.find (AC_BK); - itAggr = m_aggregators.find (AC_BK); - - edcaQueue = itQueue->second.Create (); - if (itAggr->second.GetTypeId ().GetUid () != 0) - { - aggregator = itAggr->second.Create (); - edcaQueue->SetMsduAggregator (aggregator); - } - mac->SetAttribute ("BK_EdcaTxopN", PointerValue (edcaQueue)); + Setup (mac, AC_VO, "VO_EdcaTxopN"); + Setup (mac, AC_VI, "VI_EdcaTxopN"); + Setup (mac, AC_BE, "BE_EdcaTxopN"); + Setup (mac, AC_BK, "BK_EdcaTxopN"); return mac; } diff --git a/src/helper/qos-wifi-mac-helper.h b/src/helper/qos-wifi-mac-helper.h index cfe1cb84f..f0bb26e30 100644 --- a/src/helper/qos-wifi-mac-helper.h +++ b/src/helper/qos-wifi-mac-helper.h @@ -92,23 +92,6 @@ public: std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue ()); - /** - * \param accessClass access class for which we are setting edca params. Possibilities - * are: AC_BK, AC_BE, AC_VI, AC_VO. - * \param n0 the name of the attribute to set - * \param v0 the value of the attribute to set - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set - * \param n2 the name of the attribute to set - * \param v2 the value of the attribute to set - * \param n3 the name of the attribute to set - * \param v3 the value of the attribute to set - */ - void SetEdcaParametersForAc (AccessClass accessClass, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue ()); private: /** * \returns a newly-created MAC object. @@ -116,9 +99,10 @@ private: * This method implements the pure virtual method defined in \ref ns3::WifiMacHelper. */ virtual Ptr Create (void) const; + void Setup (Ptr mac, enum AccessClass ac, std::string dcaAttrName) const; + ObjectFactory m_mac; - std::map m_queues; std::map m_aggregators; }; diff --git a/src/helper/wifi-helper.cc b/src/helper/wifi-helper.cc index 0b0ebe959..8254f497b 100644 --- a/src/helper/wifi-helper.cc +++ b/src/helper/wifi-helper.cc @@ -46,6 +46,7 @@ WifiMacHelper::~WifiMacHelper () {} WifiHelper::WifiHelper () + : m_standard (WIFI_PHY_STANDARD_80211a) {} WifiHelper @@ -79,6 +80,12 @@ WifiHelper::SetRemoteStationManager (std::string type, m_stationManager.Set (n7, v7); } +void +WifiHelper::SetStandard (enum WifiPhyStandard standard) +{ + m_standard = standard; +} + NetDeviceContainer WifiHelper::Install (const WifiPhyHelper &phyHelper, const WifiMacHelper &macHelper, NodeContainer c) const @@ -92,6 +99,8 @@ WifiHelper::Install (const WifiPhyHelper &phyHelper, Ptr mac = macHelper.Create (); Ptr phy = phyHelper.Create (node, device); mac->SetAddress (Mac48Address::Allocate ()); + mac->ConfigureStandard (m_standard); + phy->ConfigureStandard (m_standard); device->SetMac (mac); device->SetPhy (phy); device->SetRemoteStationManager (manager); diff --git a/src/helper/wifi-helper.h b/src/helper/wifi-helper.h index 04648dfa8..4c2ccfbb8 100644 --- a/src/helper/wifi-helper.h +++ b/src/helper/wifi-helper.h @@ -27,6 +27,7 @@ #include "ns3/object-factory.h" #include "ns3/node-container.h" #include "ns3/net-device-container.h" +#include "ns3/wifi-phy-standard.h" namespace ns3 { @@ -155,6 +156,8 @@ public: NetDeviceContainer Install (const WifiPhyHelper &phy, const WifiMacHelper &mac, std::string nodeName) const; + void SetStandard (enum WifiPhyStandard standard); + /** * Helper to enable all WifiNetDevice log components with one statement */ @@ -162,6 +165,7 @@ public: private: ObjectFactory m_stationManager; + enum WifiPhyStandard m_standard; }; } // namespace ns3 From 202ac1ff1efae8bf0499c46ec7e73271f3558db7 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 14 Aug 2009 12:25:16 +0200 Subject: [PATCH 25/28] bug 641: forgot to add files. --- src/devices/wifi/dcf.cc | 51 +++++++++++++++++++++++++++++++++++++++++ src/devices/wifi/dcf.h | 43 ++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 src/devices/wifi/dcf.cc create mode 100644 src/devices/wifi/dcf.h diff --git a/src/devices/wifi/dcf.cc b/src/devices/wifi/dcf.cc new file mode 100644 index 000000000..c49647ed7 --- /dev/null +++ b/src/devices/wifi/dcf.cc @@ -0,0 +1,51 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2005 INRIA + * + * 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + */ +#include "dcf.h" +#include "ns3/uinteger.h" + +namespace ns3 { + +NS_OBJECT_ENSURE_REGISTERED (Dcf); + +TypeId +Dcf::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::Dcf") + .SetParent () + .AddAttribute ("MinCw", "The minimum value of the contention window.", + UintegerValue (15), + MakeUintegerAccessor (&Dcf::SetMinCw, + &Dcf::GetMinCw), + MakeUintegerChecker ()) + .AddAttribute ("MaxCw", "The maximum value of the contention window.", + UintegerValue (1023), + MakeUintegerAccessor (&Dcf::SetMaxCw, + &Dcf::GetMaxCw), + MakeUintegerChecker ()) + .AddAttribute ("Aifsn", "The AIFSN: the default value conforms to simple DCA.", + UintegerValue (2), + MakeUintegerAccessor (&Dcf::SetAifsn, + &Dcf::GetAifsn), + MakeUintegerChecker ()) + ; + return tid; +} + +} // namespace ns3 diff --git a/src/devices/wifi/dcf.h b/src/devices/wifi/dcf.h new file mode 100644 index 000000000..d4fe39b36 --- /dev/null +++ b/src/devices/wifi/dcf.h @@ -0,0 +1,43 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2005 INRIA + * + * 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + */ + +#ifndef DCF_H +#define DCF_H + +#include "ns3/object.h" + +namespace ns3 { + +class Dcf : public Object +{ + public: + static TypeId GetTypeId (void); + + virtual void SetMinCw (uint32_t minCw) = 0; + virtual void SetMaxCw (uint32_t maxCw) = 0; + virtual void SetAifsn (uint32_t aifsn) = 0; + virtual uint32_t GetMinCw (void) const = 0; + virtual uint32_t GetMaxCw (void) const = 0; + virtual uint32_t GetAifsn (void) const = 0; +}; + +} // namespace ns3 + +#endif /* DCF_H */ From 2be1c55528d5f073a33676b8c727013a1803c33f Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 14 Aug 2009 12:31:08 +0200 Subject: [PATCH 26/28] update examples to new standard API --- examples/multi-rate-first.cc | 6 +++--- examples/wifi-adhoc.cc | 3 ++- examples/wifi-clear-channel-cmu.cc | 5 ++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/multi-rate-first.cc b/examples/multi-rate-first.cc index 336e9d985..70e52afe8 100644 --- a/examples/multi-rate-first.cc +++ b/examples/multi-rate-first.cc @@ -226,7 +226,7 @@ int main (int argc, char *argv[]) wifiMac.SetType ("ns3::AdhocWifiMac"); gnuplot = Gnuplot ("multi-rate-first.png"); - Config::SetDefault ("ns3::YansWifiPhy::Standard", StringValue ("holland")); + wifi.SetStandard (WIFI_PHY_STANDARD_holland); NS_LOG_DEBUG ("minstrel"); experiment = Experiment ("minstrel"); @@ -261,7 +261,7 @@ int main (int argc, char *argv[]) wifiMac.SetType ("ns3::AdhocWifiMac"); gnuplot = Gnuplot ("multi-rate-first.png"); - Config::SetDefault ("ns3::YansWifiPhy::Standard", StringValue ("holland")); + wifi.SetStandard (WIFI_PHY_STANDARD_holland); NS_LOG_DEBUG ("minstrel"); experiment = Experiment ("minstrel"); @@ -296,7 +296,7 @@ int main (int argc, char *argv[]) wifiMac.SetType ("ns3::AdhocWifiMac"); gnuplot = Gnuplot ("multi-rate-first.png"); - Config::SetDefault ("ns3::YansWifiPhy::Standard", StringValue ("holland")); + wifi.SetStandard (WIFI_PHY_STANDARD_holland); NS_LOG_DEBUG ("minstrel"); experiment = Experiment ("minstrel"); diff --git a/examples/wifi-adhoc.cc b/examples/wifi-adhoc.cc index d24ca101e..383be1499 100644 --- a/examples/wifi-adhoc.cc +++ b/examples/wifi-adhoc.cc @@ -174,6 +174,7 @@ int main (int argc, char *argv[]) Experiment experiment; WifiHelper wifi = WifiHelper::Default (); + wifi.SetStandard (WIFI_PHY_STANDARD_80211a); NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); @@ -241,7 +242,7 @@ int main (int argc, char *argv[]) gnuplot = Gnuplot ("rate-control.png"); - Config::SetDefault ("ns3::YansWifiPhy::Standard", StringValue ("holland")); + wifi.SetStandard (WIFI_PHY_STANDARD_holland); NS_LOG_DEBUG ("arf"); diff --git a/examples/wifi-clear-channel-cmu.cc b/examples/wifi-clear-channel-cmu.cc index 219f90b20..040e803ae 100644 --- a/examples/wifi-clear-channel-cmu.cc +++ b/examples/wifi-clear-channel-cmu.cc @@ -191,14 +191,14 @@ int main (int argc, char *argv[]) dataset.SetStyle (Gnuplot2dDataset::LINES); WifiHelper wifi; + wifi.SetStandard (WIFI_PHY_STANDARD_80211b); NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (modes[i])); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode",StringValue(modes[i]), "ControlMode",StringValue(modes[i])); - wifiMac.SetType ("ns3::AdhocWifiMac", - "Standard",StringValue ("802.11b")); + wifiMac.SetType ("ns3::AdhocWifiMac"); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel ; @@ -208,7 +208,6 @@ int main (int argc, char *argv[]) NS_LOG_DEBUG (modes[i]); experiment = Experiment (modes[i]); - wifiPhy.Set ("Standard", StringValue ("802.11b") ); wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (-110.0) ); wifiPhy.Set ("CcaMode1Threshold", DoubleValue (-110.0) ); wifiPhy.Set ("TxPowerStart", DoubleValue (15.0) ); From d823f1f47d088c04759542c23b2f0616972f603c Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 14 Aug 2009 12:31:13 +0200 Subject: [PATCH 27/28] add doxygen --- src/helper/wifi-helper.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/helper/wifi-helper.h b/src/helper/wifi-helper.h index 4c2ccfbb8..60ac1992c 100644 --- a/src/helper/wifi-helper.h +++ b/src/helper/wifi-helper.h @@ -96,7 +96,8 @@ public: * \returns a new WifiHelper in a default state * * The default state is defined as being an Adhoc MAC layer with an ARF rate control algorithm - * and both objects using their default attribute values. + * and both objects using their default attribute values. By default, configure MAC and PHY + * for 802.11a. */ static WifiHelper Default (void); @@ -156,6 +157,11 @@ public: NetDeviceContainer Install (const WifiPhyHelper &phy, const WifiMacHelper &mac, std::string nodeName) const; + /** + * \param standard the phy standard to configure during installation + * + * By default, all objects are configured for 802.11a + */ void SetStandard (enum WifiPhyStandard standard); /** From 6c5855961455bb20c543340356866106d6b1da1a Mon Sep 17 00:00:00 2001 From: Craig Dowell Date: Mon, 17 Aug 2009 18:58:54 -0700 Subject: [PATCH 28/28] fix build for gcc 3.4 --- src/devices/wifi/minstrel-wifi-manager.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/devices/wifi/minstrel-wifi-manager.cc b/src/devices/wifi/minstrel-wifi-manager.cc index 5dd91ef69..304a62a3a 100644 --- a/src/devices/wifi/minstrel-wifi-manager.cc +++ b/src/devices/wifi/minstrel-wifi-manager.cc @@ -539,8 +539,8 @@ MinstrelWifiRemoteStation::UpdateStats () m_minstrelTable[i].attemptHist += m_minstrelTable[i].numRateAttempt; m_minstrelTable[i].prob = tempProb; - /// ewma probability - tempProb = ((tempProb * (100 - m_stations->m_ewmaLevel)) + (m_minstrelTable[i].ewmaProb * m_stations->m_ewmaLevel) )/100; + /// ewma probability (cast for gcc 3.4 compatibility) + tempProb = static_cast(((tempProb * (100 - m_stations->m_ewmaLevel)) + (m_minstrelTable[i].ewmaProb * m_stations->m_ewmaLevel) )/100); m_minstrelTable[i].ewmaProb = tempProb;