NS-3-MODEL-LIBRARY(1)
๐ธ NS-3-MODEL-LIBRARY(1) ๐ธ ns-3 project
โจ NAME โจ
okay so bestie, this is ns-3-model-library โ the ns-3 Model Library, and it's literally the main character of ns-3 docs. ๐
This is the ns-3 Model Library documentation. Primary documentation for the ns-3 project is available in five forms:
- ns-3 Doxygen: Documentation of the public APIs of the simulator
- Tutorial, Manual, and Model Library (this document) for the latest release and development tree
- ns-3 wiki
This document is written in reStructuredText for Sphinx and is maintained in the doc/models directory of ns-3โs source code. no cap.
๐ ORGANIZATION ๐
okay so this manual compiles documentation for ns-3 models and supporting software that enable users to construct network simulations. It is important to distinguish between modules and models:
- ns-3 software is organized into separate modules that are each built as a separate software library. Individual ns-3 programs can link the modules (libraries) they need to conduct their simulation.
- ns-3 models are abstract representations of real-world objects, protocols, devices, etc.
An ns-3 module may consist of more than one model (for instance, the internet module contains models for both TCP and UDP). In general, ns-3 models do not span multiple software modules, however.
This manual provides documentation about the models of ns-3. It complements two other sources of documentation concerning models:
- the model APIs are documented, from a programming perspective, using Doxygen. Doxygen for ns-3 models is available on the project web server.
- the ns-3 core is documented in the developerโs manual. ns-3 models make use of the facilities of the core, such as attributes, default values, random numbers, test frameworks, etc. Consult the main web site to find copies of the manual.
Finally, additional documentation about various aspects of ns-3 may exist on the project wiki.
A sample outline of how to write model library documentation can be found by executing the create-module.py program and looking at the template created in the file new-module/doc/new-module.rst.
$ cd src
$ ./create-module.py new-module
The remainder of this document is organized alphabetically by module name.
If you are new to ns-3, you might first want to read below about the network module, which contains some fundamental models for the simulator. The packet model, models for different address formats, and abstract base classes for objects such as nodes, net devices, channels, sockets, and applications are discussed there.
๐ฌ ANIMATION ๐ฌ
Animation is an important tool for network simulation. While ns-3 does not contain a default graphical animation tool, we currently have two ways to provide animation, namely using the PyViz method or the NetAnim method. The PyViz method is described in http://www.nsnam.org/wiki/PyViz.
We will describe the NetAnim method briefly here.
โจ NetAnim โจ
NetAnim is a standalone, Qt4-based software executable that uses a trace file generated during an ns-3 simulation to display the topology and animate the packet flow between nodes.
[image] An example of packet animation on wired-links.UNINDENT
In addition, NetAnim also provides useful features such as tables to display meta-data of packets like the image below
[image] An example of tables for packet meta-data with protocol filters.UNINDENT
A way to visualize the trajectory of a mobile node
[image] An example of the trajectory of a mobile node.UNINDENT
A way to display the routing-tables of multiple nodes at various points in time
[image]
A way to display counters associated with multiple nodes as a chart or a table
[image] [image]
A way to view the timeline of packet transmit and receive events
[image]
๐ Methodology ๐
The class ns3::AnimationInterface is responsible for the creation the trace XML file. AnimationInterface uses the tracing infrastructure to track packet flows between nodes. AnimationInterface registers itself as a trace hook for tx and rx events before the simulation begins. When a packet is scheduled for transmission or reception, the corresponding tx and rx trace hooks in AnimationInterface are called. When the rx hooks are called, AnimationInterface will be aware of the two endpoints between which a packet has flowed, and adds this information to the trace file, in XML format along with the corresponding tx and rx timestamps. The XML format will be discussed in a later section. It is important to note that AnimationInterface records a packet only if the rx trace hooks are called. Every tx event must be matched by an rx event.
๐ฅ Downloading NetAnim ๐ฅ
If NetAnim is not already available in the ns-3 package you downloaded, you can do the following:
Please ensure that you have installed mercurial. The latest version of NetAnim can be downloaded using mercurial with the following command:
$ hg clone http://code.nsnam.org/netanim
๐ ๏ธ Building NetAnim ๐ ๏ธ
Prerequisites
Qt5 (5.4 and over) is required to build NetAnim. This can be obtained using the following ways:
For Ubuntu Linux distributions:
$ apt-get install qt5-default
For Red Hat/Fedora based distribution:
$ yum install qt5
$ yum install qt5-devel
For Mac/OSX, see http://qt.nokia.com/downloads/
Build steps
To build NetAnim use the following commands:
$ cd netanim
$ make clean
$ qmake NetAnim.pro
$ make
Note: qmake could be โqmake-qt5โ in some systems
This should create an executable named โNetAnimโ in the same directory:
$ ls -l NetAnim
-rwxr-xr-x 1 john john 390395 2012-05-22 08:32 NetAnim
๐ Usage ๐
Using NetAnim is a two-step process
Step 1:Generate the animation XML trace file during simulation using โns3::AnimationInterfaceโ in the ns-3 code base.
Step 2:Load the XML trace file generated in Step 1 with the offline Qt4-based animator named NetAnim.
๐ Step 1: Generate XML animation trace file ๐
The class โAnimationInterfaceโ under โsrc/netanimโ uses underlying ns-3 trace sources to construct a timestamped ASCII file in XML format.
Examples are found under src/netanim/examples Example:
$ ./waf -d debug configure --enable-examples
$ ./waf --run "dumbbell-animation"
The above will create an XML file dumbbell-animation.xml
โ Mandatory โ
- Ensure that your programโs wscript includes the โ
netanimโ module. An example of such a wscript is atsrc/netanim/examples/wscript. - Include the header
[#include โns3/netanim-module.hโ]in your test program - Add the statement
AnimationInterface anim ("animation.xml"); // where "animation.xml" is any arbitrary filename
[for versions before ns-3.13 you also have to use the line โanim.SetXMLOutput() to set the XML mode and also use anim.StartAnimation();]
๐ Optional ๐
The following are optional but useful steps:
// Step 1
anim.SetMobilityPollInterval (Seconds (1));
AnimationInterface records the position of all nodes every 250 ms by default. The statement above sets the periodic interval at which AnimationInterface records the position of all nodes. If the nodes are expected to move very little, it is useful to set a high mobility poll interval to avoid large XML files.
// Step 2
anim.SetConstantPosition (Ptr< Node > n, double x, double y);
AnimationInterface requires that the position of all nodes be set. In ns-3 this is done by setting an associated MobilityModel. โSetConstantPositionโ is a quick way to set the x-y coordinates of a node which is stationary.
// Step 3
anim.SetStartTime (Seconds(150)); and anim.SetStopTime (Seconds(150));
AnimationInterface can generate large XML files. The above statements restricts the window between which AnimationInterface does tracing. Restricting the window serves to focus only on relevant portions of the simulation and creating manageably small XML files
// Step 4
AnimationInterface anim ("animation.xml", 50000);
Using the above constructor ensures that each animation XML trace file has only 50000 packets. For example, if AnimationInterface captures 150000 packets, using the above constructor splits the capture into 3 files
animation.xml- containing the packet range 1-50000animation.xml-1- containing the packet range 50001-100000animation.xml-2- containing the packet range 100001-150000
// Step 5
anim.EnablePacketMetadata (true);
With the above statement, AnimationInterface records the meta-data of each packet in the xml trace file. Metadata can be used by NetAnim to provide better statistics and filter, along with providing some brief information about the packet such as TCP sequence number or source & destination IP address during packet animation.
CAUTION: Enabling this feature will result in larger XML trace files. Please do NOT enable this feature when using Wimax links.
// Step 6
anim.UpdateNodeDescription (5, "Access-point");
With the above statement, AnimationInterface assigns the text โAccess-pointโ to node 5.
// Step 7
anim.UpdateNodeSize (6, 1.5, 1.5);
With the above statement, AnimationInterface sets the node size to scale by 1.5. NetAnim automatically scales the graphics view to fit the oboundaries of the topology. This means that NetAnim, can abnormally scale a nodeโs size too high or too low. Using AnimationInterface::UpdateNodeSize allows you to overwrite the default scaling in NetAnim and use your own custom scale.
// Step 8
anim.UpdateNodeCounter (89, 7, 3.4);
With the above statement, AnimationInterface sets the counter with Id == 89, associated with Node 7 with the value 3.4. The counter with Id 89 is obtained using AnimationInterface::AddNodeCounter. An example usage for this is in src/netanim/examples/resource-counters.cc.
๐ Step 2: Loading the XML in NetAnim ๐
- Assuming NetAnim was built, use the command โ
./NetAnimโ to launch NetAnim. Please review the section โBuilding NetAnimโ if NetAnim is not available. - When NetAnim is opened, click on the File open button at the top-left corner, select the XML file generated during Step 1.
- Hit the green play button to begin animation.
Here is a video illustrating this http://www.youtube.com/watch?v=tz_hUuNwFDs
๐ Wiki ๐
For detailed instructions on installing โNetAnimโ, F.A.Qs and loading the XML trace file (mentioned earlier) using NetAnim please refer: http://www.nsnam.org/wiki/NetAnim
๐ฆ ANTENNA MODULE ๐ฆ
โจ Design documentation โจ
๐ธ Overview ๐ธ
okay bestie, the Antenna module is literally serving all of this:
- a class (
Angles) plus utility functions so we can deal with angles - a base class (
AntennaModel) that gives you an interface for modeling the radiation pattern of an antenna - a whole set of classes derived from that base class, each one modeling the radiation pattern of different types of antennas
- a base class (
PhasedArrayModel) that hands you a flexible interface for modeling a number of Phase Antenna Array (PAA) models - a class (
UniformPlanarArray) derived from that base class, implementing a Uniform Planar Array (UPA) that supports both rectangular and linear lattices
๐ Angles ๐
The Angles class holds info about an angle in 3D space using spherical coordinates in radian units. Specifically, it uses the azimuth-inclination convention, where
- Inclination is the angle between the zenith direction (positive z-axis) and the desired direction. It lives in the range
[0, pi]radians. - Azimuth is the signed angle measured from the positive x-axis, where a positive direction goes towards the positive y-axis. It lives in the range
[-pi, pi)radians.
There are multiple constructors present, covering the most common ways to encode info about a direction. A static boolean variable lets you decide whether angles should be printed in radian or degree units. ๐
A bunch of angle-related utilities are offered too, like radians/degree conversions (for both scalars and vectors) and angle wrapping. slay.
๐ก AntennaModel ๐ก
The AntennaModel uses the coordinate system adopted in [Balanis] and depicted in Figure Coordinate system of the AntennaModel. This system is obtained by translating the Cartesian coordinate system used by the ns-3 MobilityModel into the new origin o, which is the location of the antenna, and then transforming the coordinates of every generic point p of the space from Cartesian coordinates (x,y,z) into spherical coordinates (r, \theta,\phi). The antenna model neglects the radial component r, and only considers the angle components (\theta, \phi). An antenna radiation pattern is then expressed as a mathematical function g(\theta, \phi) \longrightarrow \mathcal{R} that returns the gain (in dB) for each possible direction of transmission/reception. All angles are expressed in radians.
[image] Coordinate system of the AntennaModel.
๐ Single antenna models ๐
In this section we describe the antenna radiation pattern models that are included within the antenna module.
๐ IsotropicAntennaModel ๐
This antenna radiation pattern model provides a unitary gain (0 dB) for all direction. it's giving "no thoughts, head empty, same gain everywhere" ๐
๐ธ CosineAntennaModel ๐ธ
This is the cosine model described in [Chunjian]: the antenna gain is determined as:
g(\phi, \theta) = \cos^{n} \left(\frac{\phi - \phi_{0}}{2} \right)
where \phi_{0} is the azimuthal orientation of the antenna (i.e., its direction of maximum gain) and the exponential
n = -\frac{3}{20 \log_{10} \left( \cos \frac{\phi_{3dB}}{4} \right)}
determines the desired 3dB beamwidth \phi_{3dB}. Note that this radiation pattern is independent of the inclination angle \theta.
A major difference between the model of [Chunjian] and the one implemented in the class CosineAntennaModel is that only the element factor (i.e., what described by the above formulas) is considered. In fact, [Chunjian] also considered an additional antenna array factor. The reason why the latter is excluded is that we expect that the average user would desire to specify a given beamwidth exactly, without adding an array factor at a latter stage which would in practice alter the effective beamwidth of the resulting radiation pattern. periodt.
๐ฅ ParabolicAntennaModel ๐ฅ
This model is based on the parabolic approximation of the main lobe radiation pattern. It is often used in the context of cellular system to model the radiation pattern of a cell sector, see for instance [R4-092042a] and [Calcev]. The antenna gain in dB is determined as:
g_{dB}(\phi, \theta) = -\min \left( 12 \left(\frac{\phi -
\phi_{0}}{\phi_{3dB}} \right)^2, A_{max} \right)
where \phi_{0} is the azimuthal orientation of the antenna (i.e., its direction of maximum gain), \phi_{3dB} is its 3 dB beamwidth, and A_{max} is the maximum attenuation in dB of the antenna. Note that this radiation pattern is independent of the inclination angle \theta.
๐ ThreeGppAntennaModel ๐
This model implements the antenna element described in [38901]. Parameters are fixed from the technical report, thus no attributes nor setters are provided. The model is largely based on the ParabolicAntennaModel.
๐ง Phased Array Model ๐ง
The class PhasedArrayModel has been created with flexibility in mind. It abstracts the basic idea of a Phased Antenna Array (PAA) by removing any constraint on the position of each element, and instead generalizes the concept of steering and beamforming vectors, solely based on the generalized location of the antenna elements. For details on Phased Array Antennas see for instance [Mailloux].
Derived classes must implement the following functions:
GetNumberOfElements: returns the number of antenna elementsGetElementLocation: returns the location of the antenna element with the specified index, normalized with respect to the wavelengthGetElementFieldPattern: returns the horizontal and vertical components of the antenna element field pattern at the specified direction. Same polarization (configurable) for all antenna elements of the array is considered.
The class PhasedArrayModel also assumes that all antenna elements are equal, a typical key assumption which allows to model the PAA field pattern as the sum of the array factor, given by the geometry of the location of the antenna elements, and the element field pattern. Any class derived from AntennaModel is a valid antenna element for the PhasedArrayModel, allowing for a great flexibility of the framework. ๐
๐ UniformPlanarArray ๐
The class UniformPlanarArray is a generic implementation of Uniform Planar Arrays (UPAs), supporting rectangular and linear regular lattices. It loosely follows the implementation described in the 3GPP TR 38.901 [38901], considering only a single a single panel, i.e., N_{g} = M_{g} = 1.
By default, the array is orthogonal to the x-axis, pointing towards the positive direction, but the orientation can be changed through the attributes "BearingAngle", which adjusts the azimuth angle, and "DowntiltAngle", which adjusts the elevation angle. The slant angle is instead fixed and assumed to be 0.
The number of antenna elements in the vertical and horizontal directions can be configured through the attributes "NumRows" and "NumColumns", while the spacing between the horizontal and vertical elements can be configured through the attributes "AntennaHorizontalSpacing" and "AntennaVerticalSpacing".
The polarization of each antenna element in the array is determined by the polarization slant angle through the attribute "PolSlantAngle", as described in [38901] (i.e., {\zeta}).
- [Balanis] โ C.A. Balanis, "Antenna Theory - Analysis and Design", Wiley, 2nd Ed.
- [Chunjian] โ Li Chunjian, "Efficient Antenna Patterns for Three-Sector WCDMA Systems", Master of Science Thesis, Chalmers University of Technology, Gรถteborg, Sweden, 2003
- [Calcev] โ George Calcev and Matt Dillon, "Antenna Tilt Control in CDMA Networks", in Proc. of the 2nd Annual International Wireless Internet Conference (WICON), 2006
- [R4-092042a] โ 3GPP TSG RAN WG4 (Radio) Meeting #51, R4-092042, Simulation assumptions and parameters for FDD HeNB RF requirements.
- [38901] โ 3GPP. 2018. TR 38.901, Study on channel model for frequencies from 0.5 to 100 GHz, V15.0.0. (2018-06).
- [Mailloux] โ Robert J. Mailloux, "Phased Array Antenna Handbook", Artech House, 2nd Ed.
๐ User Documentation ๐
The antenna modeled can be used with all the wireless technologies and physical layer models that support it. Currently, this includes the physical layer models based on the SpectrumPhy. Please refer to the documentation of each of these models for details.
๐ Testing Documentation ๐
In this section we describe the test suites included with the antenna module that verify its correct functionality.
๐ Angles ๐
The unit test suite angles verifies that the Angles class is constructed properly by correct conversion from 3D Cartesian coordinates according to the available methods (construction from a single vector and from a pair of vectors). For each method, several test cases are provided that compare the values (\phi, \theta) determined by the constructor to known reference values. The test passes if for each case the values are equal to the reference up to a tolerance of 10^{-10} which accounts for numerical errors.
๐ DegreesToRadians ๐
The unit test suite degrees-radians verifies that the methods DegreesToRadians and RadiansToDegrees work properly by comparing with known reference values in a number of test cases. Each test case passes if the comparison is equal up to a tolerance of 10^{-10} which accounts for numerical errors.
๐ IsotropicAntennaModel ๐
The unit test suite isotropic-antenna-model checks that the IsotropicAntennaModel class works properly, i.e., returns always a 0dB gain regardless of the direction.
๐ธ CosineAntennaModel ๐ธ
The unit test suite cosine-antenna-model checks that the CosineAntennaModel class works properly. Several test cases are provided that check for the antenna gain value calculated at different directions and for different values of the orientation, the reference gain and the beamwidth. The reference gain is calculated by hand. Each test case passes if the reference gain in dB is equal to the value returned by CosineAntennaModel within a tolerance of 0.001, which accounts for the approximation done for the calculation of the reference values.
๐ฅ ParabolicAntennaModel ๐ฅ
The unit test suite parabolic-antenna-model checks that the ParabolicAntennaModel class works properly. Several test cases are provided that check for the antenna gain value calculated at different directions and for different values of the orientation, the maximum attenuation and the beamwidth. The reference gain is calculated by hand. Each test case passes if the reference gain in dB is equal to the value returned by ParabolicAntennaModel within a tolerance of 0.001, which accounts for the approximation done for the calculation of the reference values.
AD HOC ON-DEMAND DISTANCE VECTOR (AODV)
okay so bestie, this model is literally the base specification of the Ad Hoc On-Demand Distance Vector (AODV) protocol, implemented and everything ๐ and the implementation is based on RFC 3561. no cap.
the authorship lore, because we always give credit: the model was written by Elena Buchatskaia and Pavel Boyko of ITTP RAS, and it's based on the ns-2 AODV model developed by the CMU/MONARCH group, optimized and tuned by Samir Das and Mahesh Marina from the University of Cincinnati, and also on the AODV-UU implementation by Erik Nordstrรถm of Uppsala University. a whole collaborative slay ๐ซถโจ
Model Description ๐
The source code for the AODV model lives in the directory src/aodv. that's it, that's where she resides ๐
Design โจ
The class ns3::aodv::RoutingProtocol implements literally all functionality of service packet exchange, and it inherits from ns3::Ipv4RoutingProtocol. the base class defines two virtual functions for packet routing and forwarding:
ns3::aodv::RouteOutputโ for packets that are locally originated (home-grown packets, born right here ๐ฃ)ns3::aodv::RouteInputโ for forwarding and/or delivering received packets
Protocol operation depends on many adjustable parameters. Parameters for this functionality are attributes of ns3::aodv::RoutingProtocol. Parameter default values are drawn from the RFC, and they let you enable/disable protocol features โ stuff like broadcasting HELLO messages, broadcasting data packets, and so on. so many lil switches, we love a configurable queen ๐ธ
AODV discovers routes on demand. Therefore, the AODV model buffers all packets while a route request packet (RREQ) is disseminated. A packet queue is implemented in aodv-rqueue.cc. Stored in this queue: a smart pointer to the packet, ns3::Ipv4RoutingProtocol::ErrorCallback, ns3::Ipv4RoutingProtocol::UnicastForwardCallback, and the IP header. The packet queue implements garbage collection of old packets and a queue size limit. spring cleaning but make it networking ๐งน๐
The routing table implementation supports garbage collection of old entries and state machine, defined in the standard. It is implemented as a STL map container. The key is a destination IP address. ๐
Some elements of protocol operation aren't described in the RFC. These elements generally concern cooperation of different OSI model layers. The model uses the following heuristics:
- This AODV implementation can detect the presence of unidirectional links and avoid them if necessary. If the node the model receives an RREQ for is a neighbor, the cause may be a unidirectional link. This heuristic is taken from AODV-UU implementation and can be disabled.
- Protocol operation strongly depends on broken link detection mechanism. The model implements two such heuristics. First, this implementation support HELLO messages. However HELLO messages are not a good way to perform neighbor sensing in a wireless environment (at least not over 802.11). Therefore, one may experience bad performance when running over wireless. There are several reasons for this: 1) HELLO messages are broadcasted. In 802.11, broadcasting is often done at a lower bit rate than unicasting, thus HELLO messages can travel further than unicast data. 2) HELLO messages are small, thus less prone to bit errors than data transmissions, and 3) Broadcast transmissions are not guaranteed to be bidirectional, unlike unicast transmissions. Second, we use layer 2 feedback when possible. Link are considered to be broken if frame transmission results in a transmission failure for all retries. This mechanism is meant for active links and works faster than the first method.
ngl that HELLO-over-802.11 situation is giving chaotic, and not in a fun way ๐ญ
The layer 2 feedback implementation relies on the TxErrHeader trace source, currently supported in AdhocWifiMac only. iykyk ๐
Scope and Limitations ๐ง
The model is for IPv4 only. The following optional protocol optimizations are not implemented:
- Local link repair.
- RREP, RREQ and HELLO message extensions.
These techniques require direct access to IP header, which contradicts the assertion from the AODV RFC that AODV works over UDP. This model uses UDP for simplicity, hindering the ability to implement certain protocol optimizations. The model doesn't use low layer raw sockets because they are not portable.
fr fr, these are the tradeoffs and they're staying. no sneaky extras here ๐
Future Work ๐ฎ
No announced plans.
so likeโฆ nothing on the vision board yet. she's chilling ๐
โจ 3GPP HTTP APPLICATIONS โจ
๐ Model Description ๐
okay so bestie, this model is literally part of the applications library. The HTTP model is based on a commonly used 3GPP model in standardization [4]. no cap. ๐ซถ
๐ Design ๐
This traffic generator simulates web browsing traffic using the Hypertext Transfer Protocol (HTTP). It's giving one or more ThreeGppHttpClient applications connecting to a ThreeGppHttpServer application. The client models a web browser requesting web pages from the server, and the server is then responsible to serve the web pages as requested. For usage instructions, go look at ThreeGppHttpClientHelper and ThreeGppHttpServerHelper. periodt. ๐
Technically speaking (iykyk), the client transmits request objects to demand a service from the server. Depending on the type of request received, the server transmits either:
- a main object, i.e., the HTML file of the web page; or
- an embedded object, e.g., an image referenced by the HTML file.
The main and embedded object sizes are illustrated in figures 3GPP HTTP main object size histogram and 3GPP HTTP embedded object size histogram.
[image] 3GPP HTTP main object size histogram. [image] 3GPP HTTP embedded object size histogram.
A major portion of the traffic pattern is reading time, which does not generate any traffic. Because of this, one may need to simulate a good number of clients and/or sufficiently long simulation duration in order to generate any significant traffic in the system. Reading time is illustrated in 3GPP HTTP reading time histogram.
[image] 3GPP HTTP reading time histogram.
๐ฅ๏ธ 3GPP HTTP server description ๐ฅ๏ธ
3GPP HTTP server is a model application which simulates the traffic of a web server. This application works in conjunction with ThreeGppHttpClient applications.
The application works by responding to requests. Each request is a small packet of data which contains ThreeGppHttpHeader. The value of the content type field of the header determines the type of object that the client is requesting. The possible type is either a main object or an embedded object.
The application is responsible to generate the right type of object and send it back to the client. The size of each object to be sent is randomly determined (see ThreeGppHttpVariables). Each object may be sent as multiple packets due to limited socket buffer space.
To assist with the transmission, the application maintains several instances of ThreeGppHttpServerTxBuffer. Each instance keeps track of the object type to be served and the number of bytes left to be sent.
The application accepts connection request from clients. Every connection is kept open until the client disconnects.
Maximum transmission unit (MTU) size is configurable in ThreeGppHttpServer or in ThreeGppHttpVariables. By default, the low variant is 536 bytes and high variant is 1460 bytes. The default values are set with the intention of having a TCP header (size of which is 40 bytes) added in the packet in such way that lower layers can avoid splitting packets. The change of MTU sizes affects all TCP sockets after the server application has started. It is mainly visible in sizes of packets received by ThreeGppHttpClient applications. ๐ง
๐ 3GPP HTTP client description ๐
3GPP HTTP client is a model application which simulates the traffic of a web browser. This application works in conjunction with an ThreeGppHttpServer application.
In summary, the application works as follows.
- Upon start, it opens a connection to the destination web server (
ThreeGppHttpServer). - After the connection is established, the application immediately requests a main object from the server by sending a request packet.
- After receiving a main object (which can take some time if it consists of several packets), the application โparsesโ the main object. Parsing time is illustrated in figure 3GPP HTTP parsing time histogram.
- The parsing takes a short time (randomly determined) to determine the number of embedded objects (also randomly determined) in the web page. Number of embedded object is illustrated in 3GPP HTTP number of embedded objects histogram.
- If at least one embedded object is determined, the application requests the first embedded object from the server. The request for the next embedded object follows after the previous embedded object has been completely received.
- If there is no more embedded object to request, the application enters the reading time.
- Reading time is a long delay (again, randomly determined) where the application does not induce any network traffic, thus simulating the user reading the downloaded web page.
- After the reading time is finished, the process repeats to step #2.
[image] 3GPP HTTP parsing time histogram. [image] 3GPP HTTP number of embedded objects histogram.
The client models HTTP persistent connection, i.e., HTTP 1.1, where the connection to the server is maintained and used for transmitting and receiving all objects.
Each request by default has a constant size of 350 bytes. A ThreeGppHttpHeader is attached to each request packet. The header contains information such as the content type requested (either main object or embedded object) and the timestamp when the packet is transmitted (which will be used to compute the delay and RTT of the packet). ๐
๐ References ๐
Many aspects of the traffic are randomly determined by ThreeGppHttpVariables. A separate instance of this object is used by the HTTP server and client applications. These characteristics are based on a legacy 3GPP specification. The description can be found in the following references:
- [1] 3GPP TR 25.892, โFeasibility Study for Orthogonal Frequency Division Multiplexing (OFDM) for UTRAN enhancementโ
- [2] IEEE 802.16m, โEvaluation Methodology Document (EMD)โ, IEEE 802.16m-08/004r5, July 2008.
- [3] NGMN Alliance, โNGMN Radio Access Performance Evaluation Methodologyโ, v1.0, January 2008.
- [4] 3GPP2-TSGC5, โHTTP, FTP and TCP models for 1xEV-DV simulationsโ, 2001.
๐ ๏ธ Usage ๐ ๏ธ
The three-gpp-http-example can be referenced to see basic usage of the HTTP applications. In summary, using the ThreeGppHttpServerHelper and ThreeGppHttpClientHelper allow the user to easily install ThreeGppHttpServer and ThreeGppHttpClient applications to nodes. The helper objects can be used to configure attribute values for the client and server objects, but not for the ThreeGppHttpVariables object. Configuration of variables is done by modifying attributes of ThreeGppHttpVariables, which should be done prior to helpers installing applications to nodes. no cap. โจ
The client and server provide a number of ns-3 trace sources such as โTxโ, โRxโ, โRxDelayโ, and โStateTransitionโ on the server side, and a large number on the client side (โConnectionEstablishedโ, โConnectionClosedโ,โTxMainObjectRequestโ, โTxEmbeddedObjectRequestโ, โRxMainObjectPacketโ, โRxMainObjectโ, โRxEmbeddedObjectPacketโ, โRxEmbeddedObjectโ, โRxโ, โRxDelayโ, โRxRttโ, โStateTransitionโ). ๐ฅ
๐งฑ Building the 3GPP HTTP applications ๐งฑ
Building the applications does not require any special steps to be taken. It suffices to enable the applications module. that's it, bestie. ๐
๐ฌ Examples ๐ฌ
For an example demonstrating HTTP applications run:
$ ./waf --run 'three-gpp-http-example'
By default, the example will print out the web page requests of the client and responses of the server and client receiving content packets by using LOG_INFO of ThreeGppHttpServer and ThreeGppHttpClient.
๐งช Tests ๐งช
For testing HTTP applications, three-gpp-http-client-server-test is provided. Run:
$ ./test.py -s three-gpp-http-client-server-test
The test consists of simple Internet nodes having HTTP server and client applications installed. Multiple variant scenarios are tested: delay is 3ms, 30ms or 300ms, bit error rate 0 or 5.0*10^(-6), MTU size 536 or 1460 bytes and either IPV4 or IPV6 is used. A simulation with each combination of these parameters is run multiple times to verify functionality with different random variables.
Test cases themselves are rather simple: test verifies that HTTP object packet bytes sent match total bytes received by the client, and that ThreeGppHttpHeader matches the expected packet. ๐
๐ BRIDGE NETDEVICE ๐
Placeholder chapter โ yeah, it's literally a placeholder, bestie. ๐
Some examples of the use of Bridge NetDevice can be found in examples/csma/ directory.
๐ BRITE INTEGRATION ๐
okay so bestie, this model is literally the plug that connects ns-3 to BRITE โ the Boston university Representative Internet Topology gEnerator [1]. BRITE is a standard tool for generating realistic internet topologies. The ns-3 model described herein gives you a helper class so you can generate ns-3 specific topologies using BRITE configuration files. BRITE builds the original graph, and that graph is stored as nodes and edges in the ns-3 BriteTopolgyHelper class. In the ns-3 integration of BRITE, the generator generates a topology and then provides access to leaf nodes for each AS generated. ns-3 users can then attach custom topologies to these leaf nodes either by creating them manually or using topology generators provided in ns-3.
There are three major types of topologies available in BRITE: Router, AS, and Hierarchical which is a combination of AS and Router. For the purposes of ns-3 simulation, the most useful are likely to be Router and Hierarchical. Router level topologies be generated using either the Waxman model or the Barabasi-Albert model. Each model has different parameters that effect topology creation. For flat router topologies, all nodes are considered to be in the same AS.
BRITE Hierarchical topologies contain two levels. The first is the AS level. This level can be also be created by using either the Waxman model or the Barabasi-Albert model. Then for each node in the AS topology, a router level topology is constructed. These router level topologies can again either use the Waxman model or the Barbasi-Albert model. BRITE interconnects these separate router topologies as specified by the AS level topology. Once the hierarchical topology is constructed, it is flattened into a large router level topology.
Further information can be found in the BRITE user manual: http://www.cs.bu.edu/brite/publications/usermanual.pdf
๐ ๏ธ Model Description ๐ ๏ธ
The model relies on building an external BRITE library, and then building some ns-3 helpers that call out to the library. The source code for the ns-3 helpers lives in the directory src/brite/helper.
๐ง Design ๐ง
To generate the BRITE topology, ns-3 helpers call out to the external BRITE library, and using a standard BRITE configuration file, the BRITE code builds a graph with nodes and edges according to this configuration file. Please see the BRITE documentation or the example configuration files in src/brite/examples/conf_files to get a better grasp of BRITE configuration options. The graph built by BRITE is returned to ns-3, and a ns-3 implementation of the graph is built. Leaf nodes for each AS are available for the user to either attach custom topologies or install ns-3 applications directly.
๐ References ๐
[1] Alberto Medina, Anukool Lakhina, Ibrahim Matta, and John Byers. BRITE: An Approach to Universal Topology Generation. In Proceedings of the International Workshop on Modeling, Analysis and Simulation of Computer and Telecommunications Systems- MASCOTS โ01, Cincinnati, Ohio, August 2001.
๐ Usage ๐
The brite-generic-example can be referenced to see basic usage of the BRITE interface. In summary, the BriteTopologyHelper is used as the interface point by passing in a BRITE configuration file. Along with the configuration file a BRITE formatted random seed file can also be passed in. If a seed file is not passed in, the helper will create a seed file using ns-3โs UniformRandomVariable. Once the topology has been generated by BRITE, BuildBriteTopology() is called to create the ns-3 representation. Next IP Address can be assigned to the topology using either AssignIpv4Addresses() or AssignIpv6Addresses(). It should be noted that each point-to-point link in the topology will be treated as a new network therefore for IPV4 a /30 subnet should be used to avoid wasting a large amount of the available address space.
Example BRITE configuration files can be found in /src/brite/examples/conf_files/. ASBarbasi and ASWaxman are examples of AS only topologies. The RTBarabasi and RTWaxman files are examples of router only topologies. Finally the TD_ASBarabasi_RTWaxman configuration file is an example of a Hierarchical topology that uses the Barabasi-Albert model for the AS level and the Waxman model for each of the router level topologies. Information on the BRITE parameters used in these files can be found in the BRITE user manual.
๐๏ธ Building BRITE Integration ๐๏ธ
The first step is to download and build the ns-3 specific BRITE repository:
$ hg clone http://code.nsnam.org/BRITE
$ cd BRITE
$ make
This will build BRITE and create a library, libbrite.so, within the BRITE directory.
Once BRITE has been built successfully, we proceed to configure ns-3 with BRITE support. Change to your ns-3 directory:
$ ./waf configure --with-brite=/your/path/to/brite/source --enable-examples
Make sure it says โenabledโ beside โBRITE Integrationโ. If it does not, then something has gone wrong. Either you have forgotten to build BRITE first following the steps above, or ns-3 could not find your BRITE directory.
Next, build ns-3:
$ ./waf
โจ Examples โจ
For an example demonstrating BRITE integration run:
$ ./waf --run 'brite-generic-example'
By enabling the verbose parameter, the example will print out the node and edge information in a similar format to standard BRITE output. There are many other command-line parameters including confFile, tracing, and nix, described below:
confFileโ A BRITE configuration file. Many different BRITE configuration file examples exist in thesrc/brite/examples/conf_filesdirectory, for example,RTBarabasi20.confandRTWaxman.conf. Please refer to theconf_filesdirectory for more examples.tracingโ Enables ascii tracing.nixโ Enables nix-vector routing. Global routing is used by default.
The generic BRITE example also support visualization using pyviz, assuming python bindings in ns-3 are enabled:
$ ./waf --run brite-generic-example --vis
Simulations involving BRITE can also be used with MPI. The total number of MPI instances is passed to the BRITE topology helper where a modulo divide is used to assign the nodes for each AS to a MPI instance. An example can be found in src/brite/examples:
$ mpirun -np 2 ./waf --run brite-MPI-example
Please see the ns-3 MPI documentation for information on setting up MPI with ns-3.
๐ข BUILDINGS MODULE ๐ข
cd .. include:: replace.txt
๐ Design documentation ๐
๐ Overview ๐
The Buildings module provides:
- a new class (
Building) that models the presence of a building in a simulation scenario; - a new class (
MobilityBuildingInfo) that allows to specify the location, size and characteristics of buildings present in the simulated area, and allows the placement of nodes inside those buildings; - a container class with the definition of the most useful pathloss models and the correspondent variables called
BuildingsPropagationLossModel. - a new propagation model (
HybridBuildingsPropagationLossModel) working with the mobility model just introduced, that allows to model the phenomenon of indoor/outdoor propagation in the presence of buildings. - a simplified model working only with Okumura Hata (
OhBuildingsPropagationLossModel) considering the phenomenon of indoor/outdoor propagation in the presence of buildings. - a channel condition model (
BuildingsChannelConditionModel) which determined the LOS/NLOS channel condition based on the Building objects deployed in the scenario. - hybrid channel condition models (
ThreeGppV2vUrbanChannelConditionModelandThreeGppV2vHighwayChannelConditionModel) specifically designed to model vehicular environments (more information can be found in the documentation of the propagation module)
The models have been designed with LTE in mind, though their implementation is in fact independent from any LTE-specific code, and can be used with other ns-3 wireless technologies as well (e.g., wifi, wimax).
The HybridBuildingsPropagationLossModel pathloss model included is obtained through a combination of several well known pathloss models in order to mimic different environmental scenarios such as urban, suburban and open areas. Moreover, the model considers both outdoor and indoor โ indoor and outdoor communication has to be included since HeNB might be installed either within building and either outside. In case of indoor communication, the model has to consider also the type of building in outdoor <-> indoor communication according to some general criteria such as the wall penetration losses of the common materials; moreover it includes some general configuration for the internal walls in indoor communications.
The OhBuildingsPropagationLossModel pathloss model has been created for simplifying the previous one removing the thresholds for switching from one model to other. For doing this it has been used only one propagation model from the one available (i.e., the Okumura Hata). The presence of building is still considered in the model; therefore all the considerations of above regarding the building type are still valid. The same consideration can be done for what concern the environmental scenario and frequency since both of them are parameters of the model considered.
๐ The Building class ๐
The model includes a specific class called Building which contains a ns3 Box class for defining the dimension of the building. In order to implements the characteristics of the pathloss models included, the Building class supports the following attributes:
- building type:
- Residential (default value)
- Office
- Commercial
- external walls type
- Wood
- ConcreteWithWindows (default value)
- ConcreteWithoutWindows
- StoneBlocks
- number of floors (default value 1, which means only ground-floor)
- number of rooms in x-axis (default value 1)
- number of rooms in y-axis (default value 1)
The Building class is based on the following assumptions:
- a buildings is represented as a rectangular parallelepiped (i.e., a box)
- the walls are parallel to the x, y, and z axis
- a building is divided into a grid of rooms, identified by the following parameters:
- number of floors
- number of rooms along the x-axis
- number of rooms along the y-axis
- the z axis is the vertical axis, i.e., floor numbers increase for increasing z axis values
- the
xandyroom indices start from1and climb up along thexandyaxis respectively โจ - every single room in a building is the exact same size, no cap ๐
๐ The MobilityBuildingInfo class
So the MobilityBuildingInfo class? It inherits from the ns3 class Object, and honestly it's the main character whose whole job is keeping tabs on where a node sits relative to a building. Here's the tea it manages:
- whether the node is indoor or outdoor ๐
- if it's indoor:
- which building the node is in
- which room the node is positioned in (the
x,yand floor room indices)
The class MobilityBuildingInfo gets used by the BuildingsPropagationLossModel class, which inherits from the ns3 class PropagationLossModel and handles the pathloss computation of the single components plus how they compose according to where the nodes are. On top of that it also implements the shadowing โ aka the loss caused by obstacles sitting in the main path (vegetation, buildings, etc.).
Bestie, quick note: MobilityBuildingInfo can be used by any other propagation model. BUT โ based on the info at the time of this writing โ literally only the ones defined in the building module are actually designed to take the constraints that buildings introduce into account. ๐
๐ถ ItuR1238PropagationLossModel
This class implements a building-dependent indoor propagation loss model based on the ITU P.1238 model, and it bakes in the losses that come from the type of building (residential, office and commercial). The analytical expression is giving:
L_\mathrm{total} = 20\log f + N\log d + L_f(n)- 28 [dB]
where:
N = \left\{ \begin{array}{lll} 28 & residential \\ 30 & office \\ 22 & commercial\end{array} \right. : power loss coefficient [dB]
L_f = \left\{ \begin{array}{lll} 4n & residential \\ 15+4(n-1) & office \\ 6+3(n-1) & commercial\end{array} \right.
n: number of floors between base station and mobile (n\ge 1)f: frequency [MHz]d: distance (where d > 1) [m]
๐งฑ BuildingsPropagationLossModel
The BuildingsPropagationLossModel serves up an extra set of building-dependent pathloss model elements that get used to implement different pathloss logics. All of those elements are described in the subsections below, so stay with me ๐ซถ
๐ช External Wall Loss (EWL)
This component models the penetration loss through walls for indoor-to-outdoor communications and vice-versa. The values are straight from the [cost231] model:
- Wood ~ 4 dB
- Concrete with windows (not metallized) ~ 7 dB
- Concrete without windows ~ 15 dB (spans between 10 and 20 in COST231)
- Stone blocks ~ 12 dB
๐งฑ Internal Walls Loss (IWL)
This component models the penetration loss that happens in indoor-to-indoor communications within the same building. The total loss is calculated assuming that each single internal wall has a constant penetration loss L_{siw}, and by approximating the number of walls that get penetrated with the manhattan distance (in number of rooms) between the transmitter and the receiver. In detail, let x_1, y_1, x_2, y_2 denote the room number along the x and y axis respectively for user 1 and 2; the total loss L_{IWL} is calculated as
L_{IWL} = L_{siw} (|x_1 -x_2| + |y_1 - y_2|)
๐ Height Gain Model (HG)
This component models the gain you get from the transmitting device being on a floor above the ground. In the literature [turkmani] this gain has been evaluated as about 2 dB per floor. You can apply this gain to all the indoor-to-outdoor communications and vice-versa. ๐ซ
๐ซ๏ธ Shadowing Model
The shadowing is modeled according to a log-normal distribution with a variable standard deviation that depends on the relative position (indoor or outdoor) of the MobilityModel instances involved. One random value gets drawn for each pair of MobilityModels, and it stays constant for that pair for the whole simulation. So yeah โ the model is appropriate for static nodes only. ๐
The model assumes the mean of the shadowing loss in dB is always 0. For the variance, the model considers three possible values of standard deviation, in detail:
- outdoor (
m_shadowingSigmaOutdoor, default value of 7 dB) โX_\mathrm{O} \sim N(\mu_\mathrm{O}, \sigma_\mathrm{O}^2). - indoor (
m_shadowingSigmaIndoor, default value of 10 dB) โX_\mathrm{I} \sim N(\mu_\mathrm{I}, \sigma_\mathrm{I}^2). - external walls penetration (
m_shadowingSigmaExtWalls, default value 5 dB) โX_\mathrm{W} \sim N(\mu_\mathrm{W}, \sigma_\mathrm{W}^2)
The simulator generates a shadowing value per each active link according to the nodes' position the very first time that link is used for transmitting. When it comes to transmissions from outdoor nodes to indoor ones and vice-versa, the standard deviation (\sigma_\mathrm{IO}) has to be calculated as the square root of the sum of the quadratic values of the standard deviation in the case of outdoor nodes and the one for the external walls penetration. This is because the components producing the shadowing are independent of each other; therefore the variance of a distribution resulting from the sum of two independent normal ones is the sum of the variances. Math bestie moment:
X \sim N(\mu,\sigma^2) \mbox{ and } Y \sim N(\nu,\tau^2)
Z = X + Y \sim Z (\mu + \nu, \sigma^2 + \tau^2)
\Rightarrow \sigma_\mathrm{IO} = \sqrt{\sigma_\mathrm{O}^2 + \sigma_\mathrm{W}^2}
๐ฃ๏ธ Pathloss logics
Down here we're describing the different pathloss logics that get implemented by inheriting from BuildingsPropagationLossModel. Slay, let's go.
๐๏ธ HybridBuildingsPropagationLossModel
The HybridBuildingsPropagationLossModel pathloss model is obtained through a combination of several well known pathloss models, all so it can mimic different outdoor and indoor scenarios, plus indoor-to-outdoor and outdoor-to-indoor scenarios. In detail, the class HybridBuildingsPropagationLossModel integrates the following pathloss models:
OkumuraHataPropagationLossModel(OH) (at frequencies > 2.3 GHz substituted byKun2600MhzPropagationLossModel)ItuR1411LosPropagationLossModelandItuR1411NlosOverRooftopPropagationLossModel(I1411)ItuR1238PropagationLossModel(I1238)- the pathloss elements of the
BuildingsPropagationLossModel(EWL, HG, IWL)
The following pseudo-code illustrates how the different pathloss model elements described above are integrated in HybridBuildingsPropagationLossModel:
if (txNode is outdoor)
then
if (rxNode is outdoor)
then
if (distance > 1 km)
then
if (rxNode or txNode is below the rooftop)
then
L = I1411
else
L = OH
else
L = I1411
else (rxNode is indoor)
if (distance > 1 km)
then
if (rxNode or txNode is below the rooftop)
L = I1411 + EWL + HG
else
L = OH + EWL + HG
else
L = I1411 + EWL + HG
else (txNode is indoor)
if (rxNode is indoor)
then
if (same building)
then
L = I1238 + IWL
else
L = I1411 + 2*EWL
else (rxNode is outdoor)
if (distance > 1 km)
then
if (rxNode or txNode is below the rooftop)
then
L = I1411 + EWL + HG
else
L = OH + EWL + HG
else
L = I1411 + EWL
We note that, for the case of communication between two nodes below rooftop level with distance greater then 1 km, we still consider the I1411 model, since OH is specifically designed for macro cells and therefore for antennas above the roof-top level.
For the ITU-R P.1411 model we consider both the LOS and NLoS versions. In particular, we consider the LoS propagation for distances that are shorter than a tunable threshold (m_itu1411NlosThreshold). In case of NLoS propagation, the over the roof-top model is taken into consideration for modeling both macro BS and SC. In case of NLoS, several parameters that are scenario dependent have been included, such as average street width, orientation, etc. The values of such parameters have to be properly set according to the scenario implemented โ the model does not calculate natively their values. In case any value is provided, the standard ones are used, apart for the height of the mobile and BS, whose integrity is instead tested directly in the code (i.e., they have to be greater then zero). In the following we give the expressions of the components of the model.
We also note that the use of different propagation models (OH, I1411, I1238 with their variants) in HybridBuildingsPropagationLossModel can result in discontinuities of the pathloss with respect to distance. A proper tuning of the attributes (especially the distance threshold attributes) can avoid these discontinuities. However, since the behavior of each model depends on several other parameters (frequency, node height, etc), there is no default value of these thresholds that can avoid the discontinuities in all possible configurations. Hence, an appropriate tuning of these parameters is left to the user. ๐ซก
๐ข OhBuildingsPropagationLossModel
The OhBuildingsPropagationLossModel class was created as a simple means to solve the discontinuity problems of HybridBuildingsPropagationLossModel without doing scenario-specific parameter tuning. The solution is to use only one propagation loss model (i.e., Okumura Hata), while retaining the structure of the pathloss logic for the calculation of other path loss components (such as wall penetration losses). The result is a model that is free of discontinuities (except those due to walls), but that is less realistic overall for a generic scenario with buildings and outdoor/indoor users โ e.g., because Okumura Hata is not suitable neither for indoor communications nor for outdoor communications below rooftop level. ๐ฌ
In detail, the class OhBuildingsPropagationLossModel integrates the following pathloss models:
OkumuraHataPropagationLossModel(OH)- the pathloss elements of the
BuildingsPropagationLossModel(EWL, HG, IWL)
The following pseudo-code illustrates how the different pathloss model elements described above are integrated in OhBuildingsPropagationLossModel:
if (txNode is outdoor)
then
if (rxNode is outdoor)
then
L = OH
else (rxNode is indoor)
L = OH + EWL
else (txNode is indoor)
if (rxNode is indoor)
then
if (same building)
then
L = OH + IWL
else
L = OH + 2*EWL
else (rxNode is outdoor)
L = OH + EWL
okay so decode that with me real quick ๐
tx node outside + rx node outside โ L = OH. tx outside + rx inside โ L = OH + EWL. tx inside + rx inside and same building โ L = OH + IWL, but if they're in different buildings โ L = OH + 2*EWL. tx inside + rx outside โ L = OH + EWL. that's the whole vibe check, no cap.
And we gotta note that OhBuildingsPropagationLossModel is a significant simplification compared to HybridBuildingsPropagationLossModel, and the reason is literally just that OH gets used always. So yeah, it gives a less accurate model in some scenarios (especially below rooftop and indoor ๐ญ), but it effectively avoids the whole pathloss discontinuities problem that affects HybridBuildingsPropagationLossModel. trade-offs bestie, trade-offs.
๐ USER DOCUMENTATION ๐
๐๏ธ How to use buildings in a simulation
so this part is the "okay but how do I actually use this in a program" section. let's get into it ๐ซถ
๐ฅ Include the headers
slap this at the top of your simulation program, no thoughts needed:
#include <ns3/buildings-module.h>
๐ Create a building
okay so for example, let's make a lil residential 10 x 20 x 10 building:
double x_min = 0.0;
double x_max = 10.0;
double y_min = 0.0;
double y_max = 20.0;
double z_min = 0.0;
double z_max = 10.0;
Ptr<Building> b = CreateObject <Building> ();
b->SetBoundaries (Box (x_min, x_max, y_min, y_max, z_min, z_max));
b->SetBuildingType (Building::Residential);
b->SetExtWallsType (Building::ConcreteWithWindows);
b->SetNFloors (3);
b->SetNRoomsX (3);
b->SetNRoomsY (2);
that building has three floors and an internal 3 x 2 grid of rooms of equal size. slay โจ
also there's a helper class called GridBuildingAllocator for when you want a whole set of buildings with identical characteristics placed on a rectangular grid. here's how you'd use it:
Ptr<GridBuildingAllocator> gridBuildingAllocator;
gridBuildingAllocator = CreateObject<GridBuildingAllocator> ();
gridBuildingAllocator->SetAttribute ("GridWidth", UintegerValue (3));
gridBuildingAllocator->SetAttribute ("LengthX", DoubleValue (7));
gridBuildingAllocator->SetAttribute ("LengthY", DoubleValue (13));
gridBuildingAllocator->SetAttribute ("DeltaX", DoubleValue (3));
gridBuildingAllocator->SetAttribute ("DeltaY", DoubleValue (3));
gridBuildingAllocator->SetAttribute ("Height", DoubleValue (6));
gridBuildingAllocator->SetBuildingAttribute ("NRoomsX", UintegerValue (2));
gridBuildingAllocator->SetBuildingAttribute ("NRoomsY", UintegerValue (4));
gridBuildingAllocator->SetBuildingAttribute ("NFloors", UintegerValue (2));
gridBuildingAllocator->SetAttribute ("MinX", DoubleValue (0));
gridBuildingAllocator->SetAttribute ("MinY", DoubleValue (0));
gridBuildingAllocator->Create (6);
this creates a 3x2 grid of 6 buildings, each one 7 x 13 x 6 m with 2 x 4 rooms inside and 2 floors; the buildings are spaced by 3 m on both the x and the y axis. iconic honestly ๐
๐ฐ๏ธ Setup nodes and mobility models
nodes and mobility models get configured like always, BUT โ and this is the part people forget โ to use them with the buildings model you need one extra call to BuildingsHelper::Install(), so the mobility model actually carries the info about their position w.r.t. the buildings. like so:
MobilityHelper mobility;
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
ueNodes.Create (2);
mobility.Install (ueNodes);
BuildingsHelper::Install (ueNodes);
and fr, any mobility model can be used. but bestie, please make sure the behavior of the mobility model you picked is consistent with the presence of Buildings. like, a simple random mobility over the whole simulation area when buildings exist will very easily have nodes yeeting in and out of buildings, walls who? ๐
one dedicated buildings-aware mobility model is RandomWalk2dOutdoorMobilityModel. it's similar to RandomWalk2dMobilityModel but it avoids placing the trajectory on a path that would intersect a building wall. if a boundary gets encountered (either the bounding box or a building wall), the model rebounds with a random direction and speed that ensures the trajectory stays outside the buildings. ๐
there's an example program showing this off at src/buildings/examples/outdoor-random-walk-example.cc, and it has an associated shell script to plot the traces generated. another example program demonstrates how this outdoor mobility model can be used as the basis of a group mobility model โ with the outdoor buildings-aware model serving as the parent (or reference) mobility model, and with additional nodes defining a child mobility model that provides the offset from the reference mobility model. that example lives at src/buildings/example/outdoor-group-mobility-example.cc and it also has an associated shell script (outdoor-group-mobility-animate.sh) that you can use to generate an animated GIF of the group's movement. GIF era ๐
๐ Place some nodes
you can place nodes in your simulation using several methods, and we're about to go through all of them.
๐ฐ๏ธ Legacy positioning methods
any legacy ns-3 positioning method can be used to place a node in the simulation. the important additional step is to โ and yeah the sentence is a lil scrambled but you get the gist โ here's you placing nodes manually:
Ptr<ConstantPositionMobilityModel> mm0 = enbNodes.Get (0)->GetObject<ConstantPositionMobilityModel> ();
Ptr<ConstantPositionMobilityModel> mm1 = enbNodes.Get (1)->GetObject<ConstantPositionMobilityModel> ();
mm0->SetPosition (Vector (5.0, 5.0, 1.5));
mm1->SetPosition (Vector (30.0, 40.0, 1.5));
MobilityHelper mobility;
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
ueNodes.Create (2);
mobility.Install (ueNodes);
BuildingsHelper::Install (ueNodes);
mm0->SetPosition (Vector (5.0, 5.0, 1.5));
mm1->SetPosition (Vector (30.0, 40.0, 1.5));
alternatively you could use any existing PositionAllocator class. the coordinates of the node are what determine whether it's placed outdoor or indoor, and โ if indoor โ in which building and in which room it lands. ๐ฅ
๐ฏ Building-specific positioning methods
these position allocator classes are available to place nodes in special positions with respect to buildings:
RandomBuildingPositionAllocatorโ allocates each position by randomly choosing a building from the list of all buildings, and then randomly choosing a position inside the building. ๐ฒRandomRoomPositionAllocatorโ allocates each position by randomly choosing a room from the list of rooms in all buildings, and then randomly choosing a position inside the room.SameRoomPositionAllocatorโ walks a givenNodeContainersequentially, and for each node allocates a new position randomly in the same room of that node.FixedRoomPositionAllocatorโ generates a random position uniformly distributed in the volume of a chosen room inside a chosen building.
๐ง Making the Mobility Model Consistent for a node
initially, a node's mobility model gets made consistent when the node is initialized, which eventually triggers a call to the DoInitialize method of the MobilityBuildingInfo class. specifically, it calls the MakeMobilityModelConsistent method, which walks through the lists of all buildings, figures out if the node is indoor or outdoor, and if it's indoor it also figures out which building the node is in and the corresponding floor number inside that building. on top of all that, this method also caches the node's position, which is used to keep the mobility model consistent for a moving node whenever the IsInside method of the MobilityBuildingInfo class gets called. ๐
๐ถ Building-aware pathloss model
once you've placed buildings and nodes in a simulation, you can use a building-aware pathloss model exactly the same way you'd use any regular path loss model. how exactly you do it depends on the wireless module you're working with (lte, wifi, wimax, etc.), so please go read the docs for that specific model for instructions. iykyk ๐
๐ค๏ธ Building-aware channel condition models
the class BuildingsChannelConditionModel implements a channel condition model that determines the LOS/NLOS channel state based on the buildings deployed in the scenario. ๐ธ
the classes ThreeGppV2vUrbanChannelConditionModel and ThreeGppV2vHighwayChannelConditionModel implement hybrid channel condition models, specifically designed to model vehicular environments. more info lives in the documentation of the propagation module. ๐
โ๏ธ Main configurable attributes
the Building class has these configurable parameters:
- building type:
Residential,OfficeandCommercial. - external walls type:
Wood,ConcreteWithWindows,ConcreteWithoutWindowsandStoneBlocks. - building bounds: a
Boxclass with the building bounds. - number of floors.
- number of rooms in x-axis and y-axis (rooms can be placed only in a grid way).
the BuildingMobilityLossModel parameter that's configurable with the ns3 attribute system is represented by the bound (string Bounds) of the simulation area, by providing a Box class with the area bounds. and on top of that, by means of its methods these parameters can be configured:
- the number of floor the node is placed (default
0). - the position in the rooms grid.
the BuildingPropagationLossModel class has these configurable parameters, configurable with the attribute system:
Frequency: reference frequency (default2160 MHz), and note that by setting the frequency the wavelength is set accordingly automatically and viceversa.Lambda: the wavelength (0.139meters, considering the above frequency).ShadowSigmaOutdoor: the standard deviation of the shadowing for outdoor nodes (default7.0).ShadowSigmaIndoor: the standard deviation of the shadowing for indoor nodes (default8.0).ShadowSigmaExtWalls: the standard deviation of the shadowing due to external walls penetration for outdoor to indoor communications (default5.0).RooftopLevel: the level of the rooftop of the building in meters (default20meters).Los2NlosThr: the value of distance of the switching point between line-of-sigth and non-line-of-sight propagation model in meters (default200meters).ITU1411DistanceThr: the value of distance of the switching point between short range (ITU 1211) communications and long range (Okumura Hata) in meters (default200meters).MinDistanceโ the minimum distance, in meters, between two nodes before the pathloss even gets evaluated (anything under this threshold is treated as negligible) (default0.5meters). ๐ซEnvironmentโ the environment scenario, pick your vibe fromUrban,SubUrbanandOpenAreas(defaultUrban). ๐๏ธCitySizeโ how big the city is:Small,MediumorLarge(defaultLarge). ๐
So if you wanna run the hybrid mode, the class you reach for is HybridBuildingMobilityLossModel, and it lets you pick the right pathloss model based on that pathloss logic we went over in the design chapter. BUT โ and bestie I need you to hear this โ this solution has a whole problem: the switching points between pathloss models can show up with discontinuities, because the models just have different characteristics. Which means depending on your specific scenario, you have to properly tune the thresholds used for switching. ๐
The OhBuildingMobilityLossModel keeps it simple and dodges all that by using only the Okumura Hata model plus the wall penetration losses. ๐ซถ
๐งช Testing Documentation ๐งช
Overview โจ
To test and validate the ns-3 Building Pathloss module, some test suites are provided, and they're all integrated with the ns-3 test framework. To run them, you need to have configured the build of the simulator like this:
$ ./waf configure --enable-tests --enable-modules=buildings
$ ./test.py
The above runs not only the test suites that belong to the buildings module, but also all the ones belonging to every other ns-3 module the buildings module depends on. For the generic tea on the testing framework, go check the ns-3 manual. ๐
You can also get a more detailed report in HTML format like this:
$ ./test.py -w results.html
Once that command has run, you can view the detailed result for each test by opening the file results.html with a web browser. ๐
And you can run each test suite separately with this:
$ ./test.py -s test-suite-name
For more details about test.py and the ns-3 testing framework, please refer to the ns-3 manual. ๐
Description of the test suites ๐
BuildingsHelper test
The test suite buildings-helper checks that the method BuildingsHelper::MakeAllInstancesConsistent () works properly โ i.e., that the BuildingsHelper successfully figures out whether nodes are outdoor or indoor, and if indoor, that they're located in the correct building, room and floor. Several test cases are provided with different buildings (different size, position, rooms and floors) and different node positions. The test passes if each and every node is located correctly. โ
BuildingPositionAllocator test
The test suite building-position-allocator features two test cases that check that RandomRoomPositionAllocator and SameRoomPositionAllocator respectively work properly. Each test case involves a single 2x3x2 room building (12 rooms total) at known coordinates, and respectively 24 and 48 nodes. Both tests check that the number of nodes allocated in each room is the expected one and that the position of the nodes is correct too. ๐ฅ
Buildings Pathloss tests
The test suite buildings-pathloss-model provides different unit tests that compare the expected results of the buildings pathloss module in specific scenarios against pre-calculated values obtained offline with an Octave script (test/reference/buildings-pathloss.m). The tests are considered passed if the two values are equal up to a tolerance of 0.1, which is deemed appropriate for the typical usage of pathloss values (which are in dB). ๐ฏ
Below we detail the scenarios considered โ they were picked to cover the wide set of possible pathloss logic combinations. The pathloss logic results are therefore implicitly tested. ๐ง
Test #1 Okumura Hata
In this test we test the standard Okumura Hata model; therefore both eNB and UE are placed outside at a distance of 2000 m. The frequency used is the E-UTRA band #5, which corresponds to 869 MHz (see table 5.5-1 of 36.101). The test also includes validation of the areas extensions (i.e., urban, suburban and open-areas) and of the city size (small, medium and large). ๐ก
Test #2 COST231 Model
This test is aimed at validating the COST231 model. It's similar to the Okumura Hata one, except the frequency used is the EUTRA band #1 (2140 MHz) and the test can only be performed for large and small cities in urban scenarios, due to model limitations. โ ๏ธ
Test #3 2.6 GHz model
This test validates the 2.6 GHz Kun model. It's similar to the Okumura Hata one, except the frequency is the EUTRA band #7 (2620 MHz) and the test can only be performed in an urban scenario. ๐
Test #4 ITU1411 LoS model
This test is aimed at validating the ITU1411 model in the case of line of sight within street canyons transmissions. Here the UE is placed 100 meters away from the eNB, since the threshold for switching between LoS and NLoS is left to the default one (i.e., 200 m.). ๐
Test #5 ITU1411 NLoS model
This test is aimed at validating the ITU1411 model in the case of non line of sight over the rooftop transmissions. Here the UE is placed 900 meters away from the eNB, so that it's above the threshold for switching between LoS and NLoS, which is left to the default one (i.e., 200 m.). ๐
Test #6 ITUP1238 model
This test is aimed at validating the ITUP1238 model in the case of indoor transmissions. Here both the UE and the eNB are placed in a residential building with walls made of concrete with windows. The UE is placed on the second floor and is 30 meters away from the eNB, which is placed on the first floor. ๐ช
Test #7 Outdoor -> Indoor with Okumura Hata model
This test validates the outdoor to indoor transmissions for large distances. Here the UE is placed in a residential building with walls made of concrete with windows, and is 2000 meters from the outdoor eNB. ๐ช
Test #8 Outdoor -> Indoor with ITU1411 model
This test validates the outdoor to indoor transmissions for short distances. Here the UE is placed in a residential building with walls made of concrete with windows, and is 100 meters from the outdoor eNB. ๐ชโจ
Test #9 Indoor -> Outdoor with ITU1411 model
This test validates the outdoor to indoor transmissions for very short distances. Here the eNB is placed on the second floor of a residential building with walls made of concrete with windows, and is 100 meters from the outdoor UE (i.e., LoS communication). Therefore the height gain has to be included in the pathloss evaluation. ๐ถ
Test #10 Indoor -> Outdoor with ITU1411 model
This test validates the outdoor to indoor transmissions for short distances. Here the eNB is placed on the second floor of a residential building with walls made of concrete with windows, and is 500 meters from the outdoor UE (i.e., NLoS communication). Therefore the height gain has to be included in the pathloss evaluation. ๐ถ๐
Buildings Shadowing Test
The test suite buildings-shadowing-test is a unit test intended to verify the statistical distribution of the shadowing model implemented by BuildingsPathlossModel. The shadowing is modeled according to a normal distribution with mean \mu = 0 and variable standard deviation \sigma, according to models commonly used in literature. Three test cases are provided, covering the cases of indoor, outdoor and indoor-to-outdoor communications. Each test case generates 1000 different samples of shadowing for different pairs of MobilityModel instances in a given scenario. Shadowing values are obtained by subtracting from the total loss value returned by HybridBuildingsPathlossModel the path loss component, which is constant and pre-determined for each test case. The test verifies that the sample mean and sample variance of the shadowing values fall within the 99% confidence interval of the sample mean and sample variance. The test also verifies that the shadowing values returned at successive times for the same pair of MobilityModel instances is constant. ๐ฌ
Buildings Channel Condition Model Test
The BuildingsChannelConditionModelTestSuite tests the class BuildingsChannelConditionModel. It checks if the channel condition between two nodes is correctly determined when a building is deployed. ๐ข
๐ References ๐
[turkmani]โ Turkmani A.M.D., J.D. Parson and D.G. Lewis, "Radio propagation into buildings at 441, 900 and 1400 MHz", in Proc. of 4th Int. Conference on Land Mobile Radio, 1987. ๐ธ
โจ CLICK MODULAR ROUTER INTEGRATION โจ
okay so Click is a software architecture for building configurable routers ๐ like, you mix and match different combos of packet processing units called elements, and boom โ a Click router can be made to do a specific kind of functionality. And that flexibility? It's giving perfect testing platform for experimenting with different protocols ๐ง
๐ธ Model Description ๐ธ
The source code for the Click model lives in the directory src/click.
๐ Design ๐
ns-3's design is lowkey made for this โ here's why an integration with Click just works:
- Packets in ns-3 are serialised/deserialised as they move up/down the stack. This allows ns-3 packets to be passed to and from Click as they are โจ
- This also means that any kind of ns-3 traffic generator and transport should work easily on top of Click ๐ฅ
- By striving to implement click as an
Ipv4RoutingProtocolinstance, we can avoid significant changes to the LL and MAC layer of the ns-3 code ๐
The design goal was to make the ns-3-click public API simple enough such that the user needs to merely add an Ipv4ClickRouting instance to the node, and inform each Click node of the Click configuration file (.click file) that it is to use. simple. iconic. no cap. ๐ซถ
This model implements the interface to the Click Modular Router and provides the Ipv4ClickRouting class to allow a node to use Click for external routing. Unlike normal Ipv4RoutingProtocol sub types, Ipv4ClickRouting doesn't use a RouteInput() method, but instead, receives a packet on the appropriate interface and processes it accordingly. Note that you need to have a routing table type element in your Click graph to use Click for external routing โ this is needed by the RouteOutput() function inherited from Ipv4RoutingProtocol โญ Furthermore, a Click based node uses a different kind of L3 in the form of Ipv4L3ClickProtocol, which is a trimmed down version of Ipv4L3Protocol. Ipv4L3ClickProtocol passes on packets passing through the stack to Ipv4ClickRouting for processing.
๐ฆ Developing a Simulator API to allow ns-3 to interact with Click ๐ฆ
Much of the API is already well defined, which allows Click to probe for information from the simulator (like a Node's ID, an Interface ID and so forth) ๐ By retaining most of the methods, it should be possible to write new implementations specific to ns-3 for the same functionality.
Hence, for the Click integration with ns-3, a class named Ipv4ClickRouting will handle the interaction with Click. The code for the same can be found in src/click/model/ipv4-click-routing.{cc,h}.
๐ Packet hand off between ns-3 and Click ๐
There are four kinds of packet hand-offs that can occur between ns-3 and Click:
- L4 to L3
- L3 to L4
- L3 to L2
- L2 to L3
To overcome this, we implement Ipv4L3ClickProtocol, a stripped down version of Ipv4L3Protocol. Ipv4L3ClickProtocol passes packets to and from Ipv4ClickRouting appropriately to perform routing ๐ซ
๐ Scope and Limitations ๐
- In its current state, the NS-3 Click Integration is limited to use only with L3, leaving NS-3 to handle L2. We are currently working on adding Click MAC support as well. See the usage section to make sure that you design your Click graphs accordingly โ ๏ธ
- Furthermore, ns-3-click will work only with userlevel elements. The complete list of elements are available at
http://read.cs.ucla.edu/click/elements. Elements that have 'all', 'userlevel' or 'ns' mentioned beside them may be used. - As of now, the ns-3 interface to Click is Ipv4 only. We will be adding Ipv6 support in the future ๐ฑ
๐ References ๐
- Eddie Kohler, Robert Morris, Benjie Chen, John Jannotti, and M. Frans Kaashoek. The click modular router. ACM Transactions on Computer Systems 18(3), August 2000, pages 263-297.
- Lalith Suresh P., and Ruben Merz. Ns-3-click: click modular router integration for ns-3. In Proc. of 3rd International ICST Workshop on NS-3 (WNS3), Barcelona, Spain. March, 2011.
- Michael Neufeld, Ashish Jain, and Dirk Grunwald. Nsclick: bridging network simulation and deployment. MSWiM '02: Proceedings of the 5th ACM international workshop on Modeling analysis and simulation of wireless and mobile systems, 2002, Atlanta, Georgia, USA.
http://doi.acm.org/10.1145/570758.570772
๐ ๏ธ Usage ๐ ๏ธ
๐ป Building Click ๐ป
First step bestie: clone Click from the github repository and build it:
$ git clone https://github.com/kohler/click
$ cd click/
$ ./configure --disable-linuxmodule --enable-nsclick --enable-wifi
$ make
The --enable-wifi flag may be skipped if you don't intend on using Click with Wifi. * Note: You don't need to do a 'make install'. we love a low-maintenance build fr fr ๐
Once Click has been built successfully, change into the ns-3 directory and configure ns-3 with Click Integration support:
$ ./waf configure --enable-examples --enable-tests --with-nsclick=/path/to/click/source
Hint: If you have click installed one directory above ns-3 (such as in the ns-3-allinone directory), and the name of the directory is 'click' (or a symbolic link to the directory is named 'click'), then the --with-nsclick specifier is not necessary; the ns-3 build system will successfully find the directory ๐ฏ
If it says 'enabled' beside 'NS-3 Click Integration Support', then you're good to go ๐ซถ Note: If running modular ns-3, the minimum set of modules required to run all ns-3-click examples is wifi, csma and config-store.
Next, try running one of the examples:
$ ./waf --run nsclick-simple-lan
You may then view the resulting .pcap traces, which are named nsclick-simple-lan-0-0.pcap and nsclick-simple-lan-0-1.pcap ๐ธ
๐ง Click Graph Instructions ๐ง
The following should be kept in mind when making your Click graph:
- Only userlevel elements can be used.
- You will need to replace
FromDeviceandToDeviceelements withFromSimDeviceandToSimDeviceelements. - Packets to the kernel are sent up using
ToSimDevice(tap0,IP). - For any node, the device which sends/receives packets to/from the kernel, is named '
tap0'. The remaining interfaces should be namedeth0,eth1and so forth (even if you're using wifi). Please note that the device numbering should begin from 0. In future, this will be made flexible so that users can name devices in their Click file as they wish. - A routing table element is a mandatory. The OUTports of the routing table element should correspond to the interface number of the device through which the packet will ultimately be sent out. Violating this rule will lead to really weird packet traces ๐ This routing table element's name should then be passed to the
Ipv4ClickRoutingprotocol object as a simulation parameter. See the Click examples for details. - The current implementation leaves Click with mainly L3 functionality, with ns-3 handling L2. We will soon begin working to support the use of MAC protocols on Click as well. This means that as of now, Click's Wifi specific elements cannot be used with ns-3.
๐ Debugging Packet Flows from Click ๐
From any point within a Click graph, you may use the Print (http://read.cs.ucla.edu/click/elements/print) element and its variants for pretty printing of packet contents โจ Furthermore, you may generate pcap traces of packets flowing through a Click graph by using the ToDump (http://read.cs.ucla.edu/click/elements/todump) element as well. For instance:
myarpquerier
-> Print(fromarpquery,64)
-> ToDump(out_arpquery,PER_NODE 1)
-> ethout;
and โฆwill print the contents of packets that flow out of the ArpQuerier, then generate a pcap trace file which will have a suffix 'out_arpquery', for each node using the Click file, before pushing packets onto 'ethout' ๐
๐ซถ Helper ๐ซถ
To have a node run Click, the easiest way would be to use the ClickInternetStackHelper class in your simulation script. For instance:
ClickInternetStackHelper click;
click.SetClickFile (myNodeContainer, "nsclick-simple-lan.click");
click.SetRoutingTableElement (myNodeContainer, "u/rt");
click.Install (myNodeContainer);
The example scripts inside src/click/examples/ demonstrate the use of Click based nodes in different scenarios. The helper source can be found inside src/click/helper/click-internet-stack-helper.{h,cc}
โญ Examples โญ
The following examples have been written, which can be found in src/click/examples/:
nsclick-simple-lan.ccandnsclick-raw-wlan.cc: A Click based node communicating with a normal ns-3 node without Click, using Csma and Wifi respectively. It also demonstrates the use of TCP on top of Click, something which the original nsclick implementation for NS-2 couldn't achieve ๐nsclick-udp-client-server-csma.ccandnsclick-udp-client-server-wifi.cc: A 3 node LAN (Csma and Wifi respectively) wherein 2 Click based nodes run a UDP client, that sends packets to a third Click based node running a UDP server.nsclick-routing.cc: One Click based node communicates to another via a third node that acts as an IP router (using the IP router Click configuration). This demonstrates routing using Click.
Scripts are available within <click-dir>/conf/ that allow you to generate Click files for some common scenarios. The IP Router used in nsclick-routing.cc was generated from the make-ip-conf.pl file and slightly adapted to work with ns-3-click ๐
โ Validation โ
This model has been tested as follows:
- Unit tests have been written to verify the internals of
Ipv4ClickRouting. This can be found insrc/click/ipv4-click-routing-test.cc. These tests verify whether the methods insideIpv4ClickRoutingwhich deal with Device name to ID, IP Address from device name and Mac Address from device name bindings work as expected. - The examples have been used to test Click with actual simulation scenarios. These can be found in
src/click/examples/. These tests cover the following: the use of different kinds of transports on top of Click, TCP/UDP, whether Click nodes can communicate with non-Click based nodes, whether Click nodes can communicate with each other, using Click to route packets using static routing. - Click has been tested with Csma, Wifi and Point-to-Point devices. Usage instructions are available in the preceding section.
๐ CSMA NETDEVICE ๐
This is the introduction to CSMA NetDevice chapter, to complement the CSMA model doxygen ๐
๐ธ Overview of the CSMA model ๐ธ
The ns-3 CSMA device models a simple bus network in the spirit of Ethernet ๐ Although it does not model any real physical network you could ever build or buy, it does provide some very useful functionality โจ
Typically when you think "bus network," your brain autofills Ethernet or IEEE 802.3, right? Yeah. Ethernet runs on CSMA/CD โ that's Carrier Sense Multiple Access with Collision Detection, with exponentially increasing backoff to fight over the shared transmission medium. And the ns-3 CSMA device? Bestie, it models like a fraction of that whole thing. It leans on the fact that the channel is globally available, so it gets instantaneous (faster than light) carrier sense plus priority-based collision "avoidance." ๐ Collisions in the actual Ethernet sense never happen here, so the ns-3 CSMA device doesn't model collision detection at all, and nothing mid-transmission will ever get "jammed." Not a thing. ๐
๐ธ CSMA Layer Model ๐ธ
Okay so there's a whole genre of conventions floating around for describing layered comms architectures โ in the literature, in textbooks, everywhere. The most common layering model is the ISO seven layer reference model. In that view, the CsmaNetDevice and CsmaChannel pair sits in the lowest two layers โ physical (layer one) and data link (layer two). Then there's another big one: the model specified by RFC 1122, "Requirements for Internet Hosts โ Communication Layers." In that view, the CsmaNetDevice and CsmaChannel pair sits in just the lowest layer โ the link layer. And there's a seemingly endless litany of alternative descriptions in textbooks and the literature, iykyk. ๐ญ
We adopt the naming conventions from the IEEE 802 standards, which speak of LLC, MAC, MII and PHY layering. Those acronyms mean:
- LLC: Logical Link Control;
- MAC: Media Access Control;
- MII: Media Independent Interface;
- PHY: Physical Layer.
So in this case the LLC and MAC are sublayers of the OSI data link layer, and the MII and PHY are sublayers of the OSI physical layer.
The "top" of the CSMA device defines the transition from the network layer to the data link layer. Higher layers make that transition happen by calling either CsmaNetDevice::Send or CsmaNetDevice::SendFrom.
And here's where it diverges from IEEE 802.3 โ there's no precisely specified PHY in the CSMA model, like, none of the wire types, signals or pinouts stuff. The "bottom" interface of the CsmaNetDevice can be thought of as a kind of Media Independent Interface (MII), like the one in the "Fast Ethernet" (IEEE 802.3u) specifications. This MII interface fits into a corresponding media independent interface on the CsmaChannel. But bestie, you will not find the equivalent of a 10BASE-T or a 1000BASE-LX PHY here. ๐ซ
The CsmaNetDevice calls the CsmaChannel through a media independent interface. There's a method defined to tell the channel when to start "wiggling the wires" โ that's CsmaChannel::TransmitStart โ and a method to tell the channel when the transmission process is done and it should start propagating the last bit across the "wire": CsmaChannel::TransmitEnd. ๐
When the TransmitEnd method is executed, the channel models a single uniform signal propagation delay in the medium and delivers copies of the packet to each of the devices attached to the packet via the CsmaNetDevice::Receive method.
There's a "pin" in the device media independent interface corresponding to "COL" (collision). You can sense the state of the channel by calling CsmaChannel::GetState. Every device looks at this "pin" before starting a send, and it'll do the appropriate backoff operations if required.
Properly received packets get forwarded up to higher levels from the CsmaNetDevice via a callback mechanism. The callback function is initialized by the higher layer (when the net device is attached) using CsmaNetDevice::SetReceiveCallback, and it gets invoked upon "proper" reception of a packet by the net device so the packet can be forwarded up the protocol stack. โญ
๐ฆ CSMA Channel Model ๐ฆ
The class CsmaChannel models the actual transmission medium. There's no fixed limit on how many devices you can connect to the channel. The CsmaChannel models a data rate and a speed-of-light delay, which you can access via the attributes "DataRate" and "Delay" respectively. The data rate you hand to the channel is used to set the data rates used by the transmitter sections of the CSMA devices connected to the channel. And nope, there's no way to independently set data rates in the devices. Since the data rate is only used to calculate a delay time, there's no limitation (other than by the data type holding the value) on the speed at which CSMA channels and devices can operate โ and no restriction based on any kind of PHY characteristics. Slay. ๐
The CsmaChannel has three states: IDLE, TRANSMITTING and PROPAGATING. These three states are "seen" instantaneously by all devices on the channel. What that means: if one device begins or ends a simulated transmission, all devices on the channel are immediately aware of the change in state. There is no time during which one device may see an IDLE channel while another device physically further away in the collision domain may have begun transmitting with the associated signals not propagated down the channel to other devices. So there's no need for collision detection in the CsmaChannel model, and it's not implemented in any way. Periodt. โจ
We do, as the name indicates, have a Carrier Sense aspect to the model. Since the simulator is single threaded, access to the common channel gets serialized by the simulator. That gives you a deterministic mechanism for contending for the channel. The channel is allocated (transitioned from state IDLE to state TRANSMITTING) on a first-come first-served basis. And the channel always goes through a three state process:
IDLE -> TRANSMITTING -> PROPAGATING -> IDLE
The TRANSMITTING state models the time during which the source net device is actually wiggling the signals on the wire. The PROPAGATING state models the time after the last bit was sent, when the signal is propagating down the wire to the "far end."
The transition to the TRANSMITTING state is driven by a call to CsmaChannel::TransmitStart, which is called by the net device that transmits the packet. It's that device's responsibility to end the transmission with a call to CsmaChannel::TransmitEnd at the appropriate simulation time that reflects the time elapsed to put all of the packet bits on the wire. When TransmitEnd is called, the channel schedules an event corresponding to a single speed-of-light delay. This delay applies to all net devices on the channel identically. Think of a symmetrical hub โ the packet bits propagate to a central location and then back out equal length cables to the other devices on the channel. The single "speed of light" delay then corresponds to the time it takes for:
- a signal to propagate from one
CsmaNetDevicethrough its cable to the hub; plus - the time it takes for the hub to forward the packet out a port; plus
- the time it takes for the signal in question to propagate to the destination net device.
The CsmaChannel models a broadcast medium, so the packet is delivered to all of the devices on the channel (including the source) at the end of the propagation time. It's the responsibility of the sending device to determine whether or not it receives a packet broadcast over the channel. ๐
The CsmaChannel provides the following Attributes:
- DataRate: The bitrate for packet transmission on connected devices;
- Delay: The speed of light transmission delay for the channel.
๐ CSMA Net Device Model ๐
The CSMA network device looks, like, somewhat like an Ethernet device. The CsmaNetDevice provides the following Attributes:
- Address: The Mac48Address of the device;
- SendEnable: Enable packet transmission if true;
- ReceiveEnable: Enable packet reception if true;
- EncapsulationMode: Type of link layer encapsulation to use;
- RxErrorModel: The receive error model;
- TxQueue: The transmit queue used by the device;
- InterframeGap: The optional time to wait between "frames";
- Rx: A trace source for received packets;
- Drop: A trace source for dropped packets.
The CsmaNetDevice supports the assignment of a "receive error model." That's an ErrorModel object, and it's used to simulate data corruption on the link. ๐ซถ
Packets sent over the CsmaNetDevice are always routed through the transmit queue, which gives you a trace hook for packets sent out over the network. This transmit queue can be set (via attribute) to model different queuing strategies.
Also configurable by attribute: the encapsulation method the device uses. Every packet gets an EthernetHeader that includes the destination and source MAC addresses, and a length/type field. Every packet also gets an EthernetTrailer which includes the FCS. Data in the packet may be encapsulated in different ways.
By default, or by setting the "EncapsulationMode" attribute to "Dix", the encapsulation is according to the DEC, Intel, Xerox standard. Sometimes called EthernetII framing โ the familiar destination MAC, source MAC, EtherType, Data, CRC format. โจ
If the "EncapsulationMode" attribute is set to "Llc", the encapsulation is by LLC SNAP. In this case, a SNAP header is added that contains the EtherType (IP or ARP).
The other implemented encapsulation modes are:
- IP_ARP (set
"EncapsulationMode"to"IpArp") โ in which the length type of the Ethernet header receives the protocol number of the packet; or - ETHERNET_V1 (set
"EncapsulationMode"to"EthernetV1") โ in which the length type of the Ethernet header receives the length of the packet.
A "Raw" encapsulation mode is defined but not implemented โ use of the RAW mode results in an assertion. ๐
Note that all net devices on a channel must be set to the same encapsulation mode for correct results. The encapsulation mode is not sensed at the receiver.
The CsmaNetDevice implements a random exponential backoff algorithm that gets executed if the channel is determined to be busy (TRANSMITTING or PROPAGATING) when the device wants to start propagating. This results in a random delay of up to pow (2, retries) - 1 microseconds before a retry is attempted. The default maximum number of retries is 1000.
๐ Using the CsmaNetDevice ๐
The CSMA net devices and channels are typically created and configured using the associated CsmaHelper object. The various ns-3 device helpers generally work in a similar way, and you'll see their use in many of our example programs. ๐ฆ
The conceptual model of interest here is that of a bare computer "husk" into which you plug net devices. The bare computers are created using a NodeContainer helper. You just ask this helper to create as many computers (we call them Nodes) as you need on your network:
NodeContainer csmaNodes;
csmaNodes.Create (nCsmaNodes);
Okay so once you've got your nodes sorted, you gotta instantiate a CsmaHelper and set whatever attributes you're feeling ๐
:
CsmaHelper csma;
csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));
csma.SetDeviceAttribute ("EncapsulationMode", StringValue ("Dix"));
csma.SetDeviceAttribute ("FrameSize", UintegerValue (2000));
And once those attributes are locked in, the only thing left is to make the devices, install them on the nodes you need, and wire them together with a CSMA channel. When we create the net devices we drop them into a container so you can use them later. The whole thing is literally one line of code:
NetDeviceContainer csmaDevices = csma.Install (csmaNodes);
Real talk bestie: think very carefully before you start messing with these Attributes, because it can produce behaviour that surprises people. We let you do it anyway because we believe flexibility matters. Here's an example of a possibly-surprising effect of changing Attributes:
The Mtu Attribute is the Maximum Transmission Unit for the device โ the size of the biggest Protocol Data Unit (PDU) the device can send. It defaults to 1500 bytes and lines up with a number you'll find in RFC 894, โA Standard for the Transmission of IP Datagrams over Ethernet Networks.โ That number is actually derived from the maximum packet size for 10Base5 (full-spec Ethernet) networks โ 1518 bytes. Subtract the DIX encapsulation overhead for Ethernet packets (18 bytes) and you land on a max possible data size (MTU) of 1500 bytes. You can also find that the MTU for IEEE 802.3 networks is 1492 bytes, because LLC/SNAP encapsulation tacks on an extra eight bytes of overhead to the packet. In both cases the underlying network hardware is capped at 1518 bytes, but the MTU differs because the encapsulation differs. iykyk ๐ง
So if you leave the Mtu Attribute at 1500 bytes and switch the encapsulation mode Attribute to Llc, you get a network that encapsulates 1500 byte PDUs with LLC/SNAP framing, which produces packets of 1526 bytes. That would be illegal in a lot of networks, but we let you do it anyway ๐. The result is a simulation that very subtly does not reflect what you're probably expecting, since a real device would balk at sending a 1526 byte packet.
Then there's jumbo frames (1500 < MTU <= 9000 bytes) and super-jumbo (MTU > 9000 bytes) frames โ not officially sanctioned by IEEE, but available in some high-speed (Gigabit) networks and NICs. In the CSMA model you could leave the encapsulation mode set to Dix and set the Mtu to 64000 bytes โ even though an associated CsmaChannel DataRate was left at 10 megabits per second (definitely not Gigabit Ethernet, bestie ๐ญ). That would essentially model an Ethernet switch built out of vampire-tapped 1980s-style 10Base5 networks that support super-jumbo datagrams, which is absolutely not something that was ever made, nor is likely to ever be made; but it is extremely easy for you to configure.
Be careful about your assumptions re: what CSMA is actually modelling, and how configuration (Attributes) may let you swerve considerably away from reality. โจ
๐ฆ CSMA Tracing ๐ฆ
Like all ns-3 devices, the CSMA Model serves up a whole bunch of trace sources. You can hook these with your own custom trace code, or you can use our helper functions to arrange for tracing to be enabled on the devices you specify. Slay.
๐ธ Upper-Level (MAC) Hooks ๐ธ
From the net device tracing point of view, there are several interesting spots to insert trace hooks. There's a convention inherited from other simulators: packets destined for transmission onto attached networks pass through a single โtransmit queueโ in the net device. We provide trace hooks at this point in the packet flow, which corresponds (abstractly) only to a transition from the network layer to the data link layer, and we collectively call them the device MAC hooks.
When a packet is sent to the CSMA net device for transmission, it always passes through the transmit queue. The transmit queue in the CsmaNetDevice inherits from Queue, so it inherits three trace sources:
- An Enqueue operation source (see
Queue::m_traceEnqueue); - A Dequeue operation source (see
Queue::m_traceDequeue); - A Drop operation source (see
Queue::m_traceDrop).
The upper-level (MAC) trace hooks for the CsmaNetDevice are, in fact, exactly these three trace sources on the single transmit queue of the device. No cap. ๐
The m_traceEnqueue event fires when a packet is placed on the transmit queue. That happens at the moment CsmaNetDevice::Send or CsmaNetDevice::SendFrom gets called by a higher layer to queue a packet for transmission.
The m_traceDequeue event fires when a packet is removed from the transmit queue. Dequeues from the transmit queue can happen in three situations:
- If the underlying channel is idle when
CsmaNetDevice::SendorCsmaNetDevice::SendFromis called, a packet is dequeued from the transmit queue and immediately transmitted; - If the underlying channel is idle, a packet may be dequeued and immediately transmitted in an internal
TransmitCompleteEventthat functions a lot like a transmit complete interrupt service routine; or - from the random exponential backoff handler if a timeout is detected.
Case (3) implies that a packet is dequeued from the transmit queue if it's unable to be transmitted according to the backoff rules. It is important to understand that this will show up as a Dequeued packet, and it is easy to incorrectly assume the packet was transmitted since it passed through the transmit queue. In fact, a packet is actually dropped by the net device in this case. The reason for this behaviour comes down to the definition of the Queue Drop event. The m_traceDrop event is, by definition, fired when a packet cannot be enqueued on the transmit queue because it is full. This event only fires if the queue is full, and we do not overload this event to indicate that the CsmaChannel is โfull.โ ๐ค
๐ Lower-Level (PHY) Hooks ๐
Similar to the upper level trace hooks, there are trace hooks available at the lower levels of the net device. We call these the PHY hooks. These events fire from the device methods that talk directly to the CsmaChannel.
The trace source m_dropTrace is called to indicate a packet that is dropped by the device. This happens in two cases: First, if the receive side of the net device is not enabled (see CsmaNetDevice::m_receiveEnable and the associated attribute โReceiveEnableโ).
The m_dropTrace is also used to indicate that a packet was discarded as corrupt if a receive error model is used (see CsmaNetDevice::m_receiveErrorModel and the associated attribute โReceiveErrorModelโ).
The other low-level trace source fires on reception of an accepted packet (see CsmaNetDevice::m_rxTrace). A packet is accepted if it's destined for the broadcast address, a multicast address, or the MAC address assigned to the net device. ๐ฆ
๐ Summary ๐
The ns3 CSMA model is a simplistic model of an Ethernet-like network. It supports a Carrier-Sense function and allows for Multiple Access to a shared medium. It is not physical in the sense that the state of the medium is instantaneously shared among all devices. That means there is no collision detection required in this model, and none is implemented. There will never be a โjamโ of a packet already on the medium. Access to the shared channel is first-come first-served, as determined by the simulator scheduler. If the channel is determined to be busy by looking at the global state, a random exponential backoff is performed and a retry is attempted.
Ns-3 Attributes give you a mechanism for setting all kinds of parameters in the device and channel โ addresses, encapsulation modes, error model selection, the works. Trace hooks are provided in the usual manner, with a set of upper level hooks corresponding to a transmit queue and used in ASCII tracing; plus a set of lower level hooks used in pcap tracing. ๐
Although the ns-3 CsmaChannel and CsmaNetDevice does not model any kind of network you could actually build or buy, it does hand us some genuinely useful functionality. You should, however, understand that it is explicitly not Ethernet or any flavor of IEEE 802.3 โ it's an interesting subset. Periodt. ๐
๐ DSDV ROUTING ๐
okay so bestie, Destination-Sequenced Distance Vector (DSDV) routing protocol is a pro-active, table-driven routing protocol for MANETs developed by Charles E. Perkins and Pravin Bhagwat in 1994. It uses the hop count as metric in route selection. fr fr โจ
This model was developed by the ResiliNets research group at the University of Kansas. A paper on this model exists at this URL. ๐ซถ
๐ฆ DSDV Routing Overview ๐ฆ
DSDV Routing Table: Every node will maintain a table listing all the other nodes it has known either directly or through some neighbors. Every node has a single entry in the routing table. The entry will have information about the nodeโs IP address, last known sequence number and the hop count to reach that node. Along with these details the table also keeps track of the nexthop neighbor to reach the destination node, the timestamp of the last update received for that node. ๐
The DSDV update message consists of three fields, Destination Address, Sequence Number and Hop Count.
Each node uses 2 mechanisms to send out the DSDV updates. They are, no cap:
- Periodic Updates โ Periodic updates are sent out after every
m_periodicUpdateInterval(default:15s). In this update the node broadcasts out its entire routing table. ๐ - Trigger Updates โ Trigger Updates are small updates in-between the periodic updates. These updates are sent out whenever a node receives a DSDV packet that caused a change in its routing table. The original paper did not clearly mention when for what change in the table should a DSDV update be sent out. The current implementation sends out an update irrespective of the change in the routing table. ๐ญ
The updates are accepted based on the metric for a particular node. The first factor determining the acceptance of an update is the sequence number. It has to accept the update if the sequence number of the update message is higher irrespective of the metric. If the update with same sequence number is received, then the update with least metric (hopCount) is given precedence. ๐ฅ
In highly mobile scenarios, there is a high chance of route fluctuations, thus we have the concept of weighted settling time where an update with change in metric will not be advertised to neighbors. The node waits for the settling time to make sure that it did not receive the update from its old neighbor before sending out that update. ๐ง
The current implementation covers all the above features of DSDV. The current implementation also has a request queue to buffer packets that have no routes to destination. The default is set to buffer up to 5 packets per destination. periodt. ๐
๐ References ๐
Link to the Paper: http://portal.acm.org/citation.cfm?doid=190314.190336
๐ DSR ROUTING ๐
okay bestie, meet DSR โ the Dynamic Source Routing protocol, a reactive routing protocol built specifically for multi-hop wireless ad hoc networks full of mobile nodes. it's giving "we find the route when we actually need it" energy fr fr.
This model was developed by the ResiliNets research group at the University of Kansas. iconic of them honestly ๐
โจ DSR Routing Overview โจ
So this model implements the base specification of the Dynamic Source Routing (DSR) protocol. The implementation is based on RFC 4728, but with some extensions and modifications to the RFC specifications โ so like, inspired by the RFC, not a carbon copy. ๐
DSR operates on a on-demand behavior. Which means our DSR model buffers all packets while a route request packet (RREQ) is disseminated. We implement a packet buffer in dsr-rsendbuff.cc. The packet queue implements garbage collection of old packets and a queue size limit. When the packet is sent out from the send buffer, it will be queued in the maintenance buffer for next hop acknowledgment. ๐ซถ
The maintenance buffer then buffers the already sent out packets and waits for the notification of packet delivery. Protocol operation strongly depends on broken link detection mechanism. We implement the three heuristics recommended based on the RFC, as follows:
- First, we use link layer feedback when possible, which is also the fastest mechanism of these three to detect link errors. A link is considered to be broken if frame transmission results in a transmission failure for all retries. This mechanism is meant for active links and works much faster than in its absence. DSR is able to detect the link layer transmission failure and notify that as broken. Recalculation of routes will be triggered when needed. If user does not want to use link layer acknowledgment, it can be tuned by setting
"LinkAcknowledgment"attribute tofalsein"dsr-routing.cc". โจ - Second, passive acknowledgment should be used whenever possible. The node turns on
"promiscuous"receive mode, in which it can receive packets not destined for itself, and when the node assures the delivery of that data packet to its destination, it cancels the passive acknowledgment timer. ๐ - Last, we use a network layer acknowledge scheme to notify the receipt of a packet. Route request packet will not be acknowledged or retransmitted. ๐
The Route Cache implementation supports garbage collection of old entries and a state machine, as defined in the standard. It implements as an STL map container. The key is the destination IP address.
DSR operates with direct access to IP header, and operates between network and transport layer. When a packet is sent out from the transport layer, it passes itself to DSR and a DSR header is appended. ๐ฆ
We have two caching mechanisms: path cache and link cache. The path cache saves the whole path in the cache. The paths are sorted based on the hop count, and whenever one path is not able to be used, we change to the next path. The link cache is a slightly better design in the sense that it uses different subpaths and uses Implemented Link Cache using Dijkstra algorithm, and this part is implemented by Song Luan <lsuper@mail.ustc.edu.cn>. ๐
The following optional protocol optimizations aren't implemented:
- Flow state
- First Hop External (F), Last Hop External (L) flags
- Handling unknown DSR options
- Two types of error headers:
- flow state not supported option
- unsupported option (not going to happen in simulation)
๐ DSR update in ns-3.17 ๐
We originally used "TxErrHeader" in Ptr<WifiMac> to indicate the transmission error of a specific packet in link layer โ however, it was not working quite correctly since even when the packet was dropped, this header was not recorded in the trace file. We used to a different path on implementing the link layer notification mechanism. We look into the trace file by finding packet receive event. If we find one receive event for the data packet, we count that as the indicator for successful data delivery. ๐ญ (we love a glow-up fix)
๐ Useful parameters ๐
MaxSendBuffLenโ Maximum number of packets that can be stored in send buffer. Default:64MaxSendBuffTimeโ Maximum time packets can be queued in the send buffer. Default:Seconds(30)MaxMaintLenโ Maximum number of packets that can be stored in maintenance buffer. Default:50MaxMaintTimeโ Maximum time packets can be queued in maintenance buffer. Default:Seconds(30)MaxCacheLenโ Maximum number of route entries that can be stored in route cache. Default:64RouteCacheTimeoutโ Maximum time the route cache can be queued in route cache. Default:Seconds(300)RreqRetriesโ Maximum number of retransmissions for request discovery of a route. Default:16CacheTypeโ Use Link Cache or use Path Cache. Default:"LinkCache"LinkAcknowledgmentโ Enable Link layer acknowledgment mechanism. Default:True
๐ Implementation modification ๐
- The
DsrFsHeaderhas added 3 fields: message type, source id, destination id, and these changes are only for post-processing:- Message type is used to identify the data packet from control packet
- source id is used to identify the real source of the data packet since we have to deliver the packet hop-by-hop and the
Ipv4Headeris not carrying the real source and destination ip address as needed - destination id is for same reason of above
- Route Reply header is not word-aligned in DSR RFC, change it to word-aligned in implementation
- DSR works as a shim header between transport and network protocol, it needs its own forwarding mechanism, we are changing the packet transmission to hop-by-hop delivery, so we added two fields in
dsr fixed headerto notify packet delivery
๐ฆ Current Route Cache implementation ๐ฆ
This implementation used "path cache", which is simple to implement and ensures loop-free paths:
- the path cache has automatic expire policy
- the cache saves multiple route entries for a certain destination and sort the entries based on hop counts
- the
MaxEntriesEachDstcan be tuned to change the maximum entries saved for a single destination - when adding multiple routes for one destination, the route is compared based on hop-count and expire time, the one with less hop count or relatively new route is favored
- Future implementation may include
"link cache"as another possibility
โญ DSR Instructions โญ
The following should be kept in mind when running DSR as routing protocol:
NodeTraversalTimeis the time it takes to traverse two neighboring nodes and should be chosen to fit the transmission rangePassiveAckTimeoutis the time a packet in maintenance buffer wait for passive acknowledgment, normally set as two times ofNodeTraversalTimeRouteCacheTimeoutshould be set smaller value when the nodes' velocity become higher. The default value is300s.
๐ธ Helper ๐ธ
To have a node run DSR, the easiest way would be to use the DsrHelper and DsrMainHelpers in your simulation script. For instance:
DsrHelper dsr;
DsrMainHelper dsrMain;
dsrMain.Install (dsr, adhocNodes);
The example scripts inside src/dsr/examples/ demonstrate the use of DSR based nodes in different scenarios. The helper source can be found inside src/dsr/helper/dsr-main-helper.{h,cc} and src/dsr/helper/dsr-helper.{h,cc} ๐ซถ
๐ Examples ๐
The example can be found in src/dsr/examples/:
dsr.ccuse DSR as routing protocol within a traditional MANETs environment[3].
DSR is also built in the routing comparison case in examples/routing/:
manet-routing-compare.ccis a comparison case with built in MANET routing protocols and can generate its own results.
๐ฅ Validation ๐ฅ
This model has been tested as follows:
- Unit tests have been written to verify the internals of DSR. This can be found in
src/dsr/test/dsr-test-suite.cc. These tests verify whether the methods inside DSR module which deal with packet buffer, headers work correctly. - Simulation cases similar to [3] have been tested and have comparable results.
manet-routing-compare.cchas been used to compare DSR with three of other routing protocols.
A paper was presented on these results at the Workshop on ns-3 in 2011. โจ
๐ Limitations ๐
The model is not fully compliant with RFC 4728. As an example, Dsr fixed size header has been extended and it is four octets longer then the RFC specification. As a consequence, the DSR headers can not be correctly decoded by Wireshark. ๐ญ
The model full compliance with the RFC is planned for the future. (manifesting ๐)
๐ง References ๐ง
[1] Original paper: http://www.monarch.cs.rice.edu/monarch-papers/dsr-chapter00.pdf
[2] RFC 4728 http://www6.ietf.org/rfc/rfc4728.txt
[3] Broch's comparison paper: http://www.monarch.cs.rice.edu/monarch-papers/mobicom98.ps
๐ EMULATION OVERVIEW ๐
ok so bestie, ns-3 was literally designed to get shoved into testbeds and virtual machine environments, and the way we pulled that off is by giving you two kinds of net devices. let me introduce you ๐
the first kind is a file descriptor net device (FdNetDevice), a generic device type that can read from and write to a file descriptor. and here's the slay: by associating that file descriptor with different things on the host system, you get different capabilities. for instance, FdNetDevice can be associated with an underlying packet socket to provide emulation capabilities โ which means ns-3 simulations can send data on a "real" network. iconic.
the second kind, called a TapBridge NetDevice, lets a "real" host participate in an ns-3 simulation as if it were one of the simulated nodes. and you can build an ns-3 simulation with any combination of simulated or emulated devices. mix and match, no cap. ๐ฆ
โ ๏ธ Note: Prior tons-3.17, the emulation capability was provided by a special device called anEmuNetDevice; theEmuNetDevice has been replaced by theFdNetDevice. so if you're reading ancient lore, that's why. ๐
one of the use-cases we want to support is that of a testbed. a concrete example of an environment of this kind is the ORBIT testbed. ORBIT is a laboratory emulator/field trial network arranged as a two dimensional grid of 400 802.11 radio nodes. we integrate with ORBIT by using their "imaging" process to load and run ns-3 simulations on the ORBIT array. we can use our EmuFdNetDevice to drive the hardware in the testbed, and we can accumulate results either using the ns-3 tracing and logging functions, or the native ORBIT data gathering techniques. see http://www.orbit-lab.org/ for details on the ORBIT testbed. โจ
a simulation of this kind is shown in the following figure:
[image] Example Implementation of Testbed Emulation..UNINDENT
you can see that there are separate hosts, each running a subset of a "global" simulation. instead of an ns-3 channel connecting the hosts, we use real hardware provided by the testbed. this allows ns-3 applications and protocol stacks attached to a simulation node to communicate over real hardware. periodt. ๐
we expect the primary use for this configuration will be to generate repeatable experimental results in a real-world network environment that includes all of the ns-3 tracing, logging, visualization and statistics gathering tools.
and now for the plot twist ๐ โ in what can be viewed as essentially an inverse configuration, we allow "real" machines running native applications and protocol stacks to integrate with an ns-3 simulation. this allows for the simulation of large networks connected to a real machine, and also enables virtualization. a simulation of this kind is shown in the following figure:
[image] Implementation overview of emulated channel..UNINDENT
here, you will see that there is a single host with a number of virtual machines running on it. an ns-3 simulation is shown running in the virtual machine shown in the center of the figure. this simulation has a number of nodes with associated ns-3 applications and protocol stacks that are talking to an ns-3 channel through native simulated ns-3 net devices.
there are also two virtual machines shown at the far left and far right of the figure. these VMs are running native (Linux) applications and protocol stacks. the VM is connected into the simulation by a Linux Tap net device. the user-mode handler for the Tap device is instantiated in the simulation and attached to a proxy node that represents the native VM in the simulation. these handlers allow the Tap devices on the native VMs to behave as if they were ns-3 net devices in the simulation VM. this, in turn, allows the native software and protocol suites in the native VMs to believe that they are connected to the simulated ns-3 channel. mind = blown, fr fr ๐ญ
we expect the typical use case for this environment will be to analyze the behavior of native applications and protocol suites in the presence of large simulated ns-3 networks.
the basic testbed mode of emulation uses raw sockets. two other variants (netmap-based and DPDK-based emulation) have been recently added; these make use of more recent network interface cards that make use of directly-mapped memory capabilities to improve packet processing efficiency. efficiency girlies, rise ๐
for more details:
File Descriptor NetDevice ๐
the src/fd-net-device module provides the FdNetDevice class, which is able to read and write traffic using a file descriptor provided by the user. this file descriptor can be associated to a TAP device, to a raw socket, to a user space process generating/consuming traffic, etc. the user has full freedom to define how external traffic is generated and ns-3 traffic is consumed. main character energy, honestly. ๐
different mechanisms to associate a simulation to external traffic can be provided through helper classes. three specific helpers are provided:
EmuFdNetDeviceHelper(to associate the ns-3 device with a physical device in the host machine)TapFdNetDeviceHelper(to associate the ns-3 device with the file descriptor from a tap device in the host machine)PlanteLabFdNetDeviceHelper(to automate the creation of tap devices in PlanetLab nodes, enabling ns-3 simulations that can send and receive traffic though the Internet using PlanetLab resource.
Model Description ๐ฆ
the source code for this module lives in the directory src/fd-net-device.
the FdNetDevice is a special type of ns-3 NetDevice that reads traffic to and from a file descriptor. that is, unlike pure simulation NetDevice objects that write frames to and from a simulated channel, this FdNetDevice directs frames out of the simulation to a file descriptor. the file descriptor may be associated to a Linux TUN/TAP device, to a socket, or to a user-space process.
it is up to the user of this device to provide a file descriptor. the type of file descriptor being provided determines what is being modelled. for instance, if the file descriptor provides a raw socket to a WiFi card on the host machine, the device being modelled is a WiFi device. iykyk ๐ธ
from the conceptual "top" of the device looking down, it looks to the simulated node like a device supporting a 48-bit IEEE MAC address that can be bridged, supports broadcast, and uses IPv4 ARP or IPv6 Neighbor Discovery, although these attributes can be tuned on a per-use-case basis.
Design โจ
the FdNetDevice implementation makes use of a reader object, extended from the FdReader class in the ns-3 src/core module, which manages a separate thread from the main ns-3 execution thread, in order to read traffic from the file descriptor. yes bestie, threads. we're threading. ๐งต
upon invocation of the StartDevice method, the reader object is initialized and starts the reading thread. before device start, a file descriptor must be previously associated to the FdNetDevice with the SetFileDescriptor invocation.
the creation and configuration of the file descriptor can be left to a number of helpers, described in more detail below. when this is done, the invocation of SetFileDescriptor is responsibility of the helper and must not be directly invoked by the user. hands off, bestie ๐
upon reading an incoming frame from the file descriptor, the reader will pass the frame to the ReceiveCallback method, whose task it is to schedule the reception of the frame by the device as a ns-3 simulation event. since the new frame is passed from the reader thread to the main ns-3 simulation thread, thread-safety issues are avoided by using the ScheduleWithContext call instead of the regular Schedule call. safety first, always ๐
in order to avoid overwhelming the scheduler when the incoming data rate is too high, a counter is kept with the number of frames that are currently scheduled to be received by the device. if this counter reaches the value given by the RxQueueSize attribute in the device, then the new frame will be dropped silently. ๐
the actual reception of the new frame by the device occurs when the scheduled FordwarUp method is invoked by the simulator. this method acts as if a new frame had arrived from a channel attached to the device. the device then decapsulates the frame, removing any layer 2 headers, and forwards it to upper network stack layers of the node. the ForwardUp method will remove the frame headers, according to the frame encapsulation type defined by the EncapsulationMode attribute, and invoke the receive callback passing an IP packet.
an extra header, the PI header, can be present when the file descriptor is associated to a TAP device that was created without setting the IFF_NO_PI flag. this extra header is removed if EncapsulationMode is set to DIXPI value. ๐ฅ
in the opposite direction, packets generated inside the simulation that are sent out through the device, will be passed to the Send method, which will in turn invoke the SendFrom method. the latter method will add the necessary layer 2 headers, and simply write the newly created frame to the file descriptor.
Scope and Limitations โ ๏ธ
users of this device are cautioned that there is no flow control across the file descriptor boundary, when using in emulation mode. that is, in a Linux system, if the speed of writing network packets exceeds the ability of the underlying physical device to buffer the packets, backpressure up to the writing application will be applied to avoid local packet loss. no such flow control is provided across the file descriptor interface, so users must be aware of this limitation. read that again bestie, it matters. ๐ญ
as explained before, the RxQueueSize attribute limits the number of packets that can be pending to be received by the device. frames read from the file descriptor while the number of pending packets is in its maximum will be silently dropped.
the mtu of the device defaults to the Ethernet II MTU value. however, helpers are supposed to set the mtu to the right value to reflect the characteristics of the network interface associated to the file descriptor. if no helper is used, then the responsibility of setting the correct mtu value for the device falls back to the user. the size of the read buffer on the file descriptor reader is set to the mtu value in the StartDevice method.
the FdNetDevice class currently supports three encapsulation modes, DIX for Ethernet II frames, LLC for 802.2 LLC/SNAP frames, and DIXPI for Ethernet II frames with an additional TAP PI header. this means that traffic traversing the file descriptor is expected to be Ethernet II compatible. IEEE 802.1q (VLAN) tagging is not supported. attaching an FdNetDevice to a wireless interface is possible as long as the driver provides Ethernet II frames to the socket API. note that to associate a FdNetDevice to a wireless card in ad-hoc mode, the MAC address of the device must be set to the real card MAC address, else any incoming traffic a fake MAC address will be discarded by the driver. ๐
okay so bestie, we literally just said this but lemme say it again for the people in the back โ the fd-net-device module comes with three helpers, and each individual helper (that's each file descriptor type, iykyk) might come with its own lil platform limitations. ๐ซถ
Like, threading? Real-time simulation mode? The ability to create TUN/TAP devices? All of those are prerequisites for using the helpers we're about to hand you. ๐
You can check whether your build has these modes enabled in the output of the waf configure step, like so:
Threading Primitives : enabled
Real Time Simulator : enabled
Emulated Net Device : enabled
Tap Bridge : enabled
And listen โ we gotta be honest with you. While testing the FdNetDevice we found an upper bound limit for TCP throughput when using 1Gb Ethernet links of 60Mbps. ๐ญ That limit is most likely just the processing power of the computers that were involved in the tests, not some fundamental law of the universe. no cap.
๐ ๏ธ Usage ๐ ๏ธ
The usage pattern for this type of device is honestly the same vibe as other net devices with helpers that install to node pointers or node containers. โจ
When you're using the base FdNetDeviceHelper, you (yes you, bestie) are responsible for creating and setting the file descriptor yourself. main character energy, fr.
FdNetDeviceHelper fd;
NetDeviceContainer devices = fd.Install (nodes);
// file descriptor generation
...
device->SetFileDescriptor (fd);
Most commonly, a FdNetDevice is gonna be used to interact with the host system. When that's the case, it's almost certain you'll wanna run in real-time emulation mode and enable checksum computations. The typical program statements look like this:
GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl"));
GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));
Now, the easiest way to set up an experiment that interacts with a Linux host system is to use the Emu and Tap helpers. And maybe the most unusual part of these helper implementations? They need some of the code to be executed with super-user permissions. ๐
But rather than force you to run the entire simulation as root (no thanks), we provide a small "creator" program that runs as root and does any required high-permission sockets work. And the easiest way to set the right privileges for those "creator" programs is by enabling the --enable-sudo flag when performing waf configure. ๐
We do a similar thing for both the Emu and the Tap devices. High-level view: the CreateFileDescriptor method creates a local interprocess (Unix) socket, forks, and executes the small creation program. That small program, which runs as suid root, creates a raw socket and sends back the raw socket file descriptor over the Unix socket that's passed to it as a parameter. And the raw socket? It gets passed as a control message (sometimes called ancillary data) of type SCM_RIGHTS. slay.
Helpers ๐
EmuFdNetDeviceHelper
The EmuFdNetDeviceHelper creates a raw socket to an underlying physical device and hands that socket descriptor over to the FdNetDevice. This is what lets the ns-3 simulation read frames from and write frames to a network device on the host. ๐ฅ
Basically, this emulation helper lets you transparently integrate a simulated ns-3 node into a network composed of real nodes. iconic.
+----------------------+ +-----------------------+
| host 1 | | host 2 |
+----------------------+ +-----------------------+
| ns-3 simulation | | |
+----------------------+ | Linux |
| ns-3 Node | | Network Stack |
| +----------------+ | | +----------------+ |
| | ns-3 TCP | | | | TCP | |
| +----------------+ | | +----------------+ |
| | ns-3 IP | | | | IP | |
| +----------------+ | | +----------------+ |
| | FdNetDevice | | | | | |
| | 10.1.1.1 | | | | | |
| +----------------+ | | + ETHERNET + |
| | raw socket | | | | | |
|--+----------------+--| | +----------------+ |
| | eth0 | | | | eth0 | |
+-------+------+-------+ +--------+------+-------+
10.1.1.11 10.1.1.12
| |
+----------------------------+
This helper replaces the functionality of the EmuNetDevice found in ns-3 prior to ns-3.17, by bringing this type of device into the common framework of the FdNetDevice. The EmuNetDevice was deprecated in favor of this new helper. ๐
The device is configured to perform MAC spoofing to separate simulation network traffic from other network traffic that may be flowing to and from the host.
You can use this helper in a testbed situation where the host on which the simulation is running has a specific interface of interest which drives the testbed hardware. You'd also need to set that specific interface into promiscuous mode and provide an appropriate device name to the ns-3 simulation. Additionally, hardware offloading of segmentation and checksums should be disabled. ๐ซ
The helper only works if the underlying interface is up and in promiscuous mode. Packets will be sent out over the device, but we use MAC spoofing. The MAC addresses will be generated (by default) using the Organizationally Unique Identifier (OUI) 00:00:00 as a base. This vendor code is not assigned to any organization and so should not conflict with any real hardware. โจ
It is always up to the user to determine that using these MAC addresses is okay on your network and won't conflict with anything else (including another simulation using such devices) on your network. ๐
If you're using the emulated FdNetDevice configuration in separate simulations, you must consider global MAC address assignment issues and ensure that MAC addresses are unique across all simulations. The emulated net device respects the MAC address provided in the Address attribute, so you can do this manually. For larger simulations, you may want to set the OUI in the MAC address allocation function.
Before invoking the Install method, the correct device name must be configured on the helper using the SetDeviceName method. The device name is required to identify which physical device should be used to open the raw socket.
EmuFdNetDeviceHelper emu;
emu.SetDeviceName (deviceName);
NetDeviceContainer devices = emu.Install (node);
Ptr<NetDevice> device = devices.Get (0);
device->SetAttribute ("Address", Mac48AddressValue (Mac48Address::Allocate ()));
TapFdNetDeviceHelper
A Tap device is a special type of Linux device where one end appears to the kernel as a virtual net_device, and the other end is provided as a file descriptor to user-space. That file descriptor can be passed to the FdNetDevice. Packets forwarded to the TAP device by the kernel will show up in the FdNetDevice in ns-3. ๐ธ
Heads up bestie: this usage of TAP devices is different than the one provided by theTapBridgeNetDevice found insrc/tap-bridge. ๐
The model in this helper is as follows:
+-------------------------------------+
| host |
+-------------------------------------+
| ns-3 simulation | |
+----------------------+ |
| ns-3 Node | |
| +----------------+ | |
| | ns-3 TCP | | |
| +----------------+ | |
| | ns-3 IP | | |
| +----------------+ | |
| | FdNetDevice | | |
|--+----------------+--+ +------+ |
| | TAP | | eth0 | |
| +------+ +------+ |
| 192.168.0.1 | |
+-------------------------------|-----+
|
|
------------ (Internet) -----
In the above, the configuration requires that the host be able to forward traffic generated by the simulation to the Internet.
The model in TapBridge (in another module) is as follows:
+--------+
| Linux |
| host | +----------+
| ------ | | ghost |
| apps | | node |
| ------ | | -------- |
| stack | | IP | +----------+
| ------ | | stack | | node |
| TAP | |==========| | -------- |
| device | <----- IPC ------> | tap | | IP |
+--------+ | bridge | | stack |
| -------- | | -------- |
| ns-3 | | ns-3 |
| net | | net |
| device | | device |
+----------+ +----------+
|| ||
+---------------------------+
| ns-3 channel |
+---------------------------+
In the above, packets instead traverse ns-3 NetDevices and Channels. ๐ฆ
The usage pattern for this example is that the user sets the MAC address and either (or both) the IPv4 and IPv6 addresses and masks on the device, and the PI header if needed. For example:
TapFdNetDeviceHelper helper;
helper.SetDeviceName (deviceName);
helper.SetModePi (modePi);
helper.SetTapIpv4Address (tapIp);
helper.SetTapIpv4Mask (tapMask);
...
helper.Install (node);
PlanetLabFdNetDeviceHelper
PlanetLab is a world wide distributed network testbed composed of nodes connected to the Internet. ๐ Running ns-3 simulations in PlanetLab nodes using the PlanetLabFdNetDeviceHelper allows you to send simulated traffic generated by ns-3 directly to the Internet. This setup can be useful to validate ns-3 Internet protocols or other future protocols implemented in ns-3. ๐ซถ
A PlanetLab account is literally the entry fee for running experiments on PlanetLab nodes, bestie. And no cap โ only members of PlanetLab partner institutions can even get one (for more info go peek at http://www.planet-lab.org/ or http://www.planet-lab.eu). ๐ป Once you've got the account, you have to request a PlanetLab slice to actually conduct experiments. A slice = an experiment unit tied to a group of PlanetLab users, and it can be associated to virtual machines across different PlanetLab nodes. You can also customize slices by adding configuration tags to them (that part is done by PlanetLab administrators, not you, so don't @ them about it ๐).
The PlanetLabFdNetDeviceHelper creates TAP devices on PlanetLab nodes using specific PlanetLab mechanisms (i.e. the vsys system), and associates the TAP device to a FdNetDevice in ns-3. The functionality this helper gives you is similar to what FdTapNetDeviceHelper gives you, except the underlying mechanisms used to create the TAP device are different. ๐ฏ
+-------------------------------------+
| PlanetLab host |
+-------------------------------------+
| ns-3 simulation | |
+----------------------+ |
| ns-3 Node | |
| +----------------+ | |
| | ns-3 TCP | | |
| +----------------+ | |
| | ns-3 IP | | |
| +----------------+ | |
| | FdNetDevice | | |
|--+----------------+--+ +------+ |
| | TAP | | eth0 | |
| +------+ +------+ |
| 192.168.0.1 | |
+-------------------------------|-----+
|
|
------------ (Internet) -----
So here's the tea: to be able to assign private IPv4 addresses to the TAP devices, account holders must request the vsys_vnet tag be added to their slice by PlanetLab administrators. The vsys_vnet tag is associated to a private network segment, and only addresses from that segment can be used in experiments. ๐ง
The syntax to create a TAP device with this helper is similar to the ones used for the helpers we already described:
PlanetLabFdNetDeviceHelper helper;
helper.SetTapIpAddress (tapIp);
helper.SetTapMask (tapMask);
...
helper.Install (node);
PlanetLab nodes run a Fedora based distribution, so ns-3 can be installed following the instructions for ns-3 Linux installation. ๐ง
โจ ATTRIBUTES โจ
The FdNetDevice provides a number of attributes, and they're giving:
Addressโ the MAC address of the deviceStartโ the simulation start time to spin up the device threadStopโ the simulation start time to stop the device threadEncapsulationModeโ link-layer encapsulation formatRxQueueSizeโ the buffer size of the read queue on the file descriptor thread (default of1000packets)
Start and Stop do not normally need to be specified, unless the user wants to limit the time during which this device is active. Address needs to be set to some kind of unique MAC address if the simulation will be interacting with other real devices somehow using real MAC addresses. Typical code, since you asked:
device->SetAttribute ("Address", Mac48AddressValue (Mac48Address::Allocate ()));
๐ก OUTPUT ๐ก
Ascii and PCAP tracing is provided similar to the other ns-3 NetDevice types, through the helpers, such as (e.g.):
EmuFdNetDeviceHelper emu; NetDeviceContainer devices =
emu.Install (node); โฆ emu.EnablePcap (โemu-pingโ, device, true);
The standard set of Mac-level NetDevice trace sources is provided. ๐
MaxTxโ trace source triggered when ns-3 provides the device with a new frame to sendMaxTxDropโ trace source if write to file descriptor failsMaxPromiscRxโ whenever any valid Mac frame is receivedMaxRxโ whenever a valid Mac frame is received for this deviceSnifferโ non-promiscuous packet snifferPromiscSnifferโ promiscuous packet sniffer (for tcpdump-like traces)
๐งช EXAMPLES ๐งช
Several examples are provided, and they ate, honestly:
dummy-network.ccโ this simple example creates two nodes and interconnects them with a Unix pipe by passing the file descriptors from thesocketpairinto theFdNetDeviceobjects of the respective nodes.realtime-dummy-network.ccโ same asdummy-network.ccbut uses the real time simulator implementnation instead of the default one.fd2fd-onoff.ccโ this example is aimed at measuring the throughput of theFdNetDevicein a pure simulation. For this purpose twoFdNetDevices, attached to different nodes but in a same simulation, are connected using a socket pair. TCP traffic is sent at a saturating data rate.fd-emu-onoff.ccโ this example is aimed at measuring the throughput of theFdNetDevicewhen using theEmuFdNetDeviceHelperto attach the simulated device to a real device in the host machine. This is achieved by saturating the channel with TCP traffic.fd-emu-ping.ccโ this example uses theEmuFdNetDeviceHelperto send ICMP traffic over a real channel.fd-emu-udp-echo.ccโ this example uses theEmuFdNetDeviceHelperto send UDP traffic over a real channel.fd-planetlab-ping.ccโ this example shows how to set up an experiment to send ICMP traffic from a PlanetLab node to the Internet.fd-tap-ping.ccโ this example uses theTapFdNetDeviceHelperto send ICMP traffic over a real channel.
๐ NETMAP NETDEVICE ๐
The fd-net-device module provides the NetmapNetDevice class โ a class derived from the FdNetDevice which is able to read and write traffic using a netmap file descriptor. That netmap file descriptor must be associated to a real ethernet device in the host machine. And the NetmapNetDeviceHelper class supports the configuration of a NetmapNetDevice. ๐
netmap is a fast packet processing capability that bypasses the host networking stack and gains direct access to the network device. netmap was developed by Luigi Rizzo [Rizzo2012] and is maintained as an open source project on GitHub at https://github.com/luigirizzo/netmap. ๐
The NetmapNetDevice for ns-3 [Imputato2019] was developed by Pasquale Imputato in the 2017-19 timeframe. Using NetmapNetDevice requires that the host system has netmap support (and for best performance, the drivers must support netmap and must be using a netmap-enabled device driver). Users can expect that emulation support using Netmap will support higher packets per second than emulation using FdNetDevice with raw sockets (which pass through the Linux networking kernel). ๐
[Rizzo2012] Luigi Rizzo, โnetmap: A Novel Framework for Fast Packet I/Oโ, Proceedings of 2012 USENIX Annual Techincal Conference, June 2012.
[Imputato2019] Pasquale Imputato, Stefano Avallone, Enhancing the fidelity of network emulation through direct access to device buffers, Journal of Network and Computer Applications, Volume 130, 2019, Pages 63-75, (โ http://www.sciencedirect.com/science/article/pii/S1084804519300220)
๐ MODEL DESCRIPTION ๐
๐ ๏ธ DESIGN ๐ ๏ธ
Because netmap uses file descriptor based communication to interact with the real device, the straightforward approach to design a new NetDevice around netmap is to have it inherit from the existing FdNetDevice and implement a specialized version of the operations specific to netmap. The operations that require a specialized implementation are:
- the initialization, because the NIC has to be put in netmap mode, and
- the read/write methods, which have to make use of the netmap API to coordinate the exchange of packets with the netmap rings.
In the initialization stage, the network device is switched to netmap mode, so that ns-3 is able to send/receive packets to/from the real network device by writing/reading them to/from the netmap rings. Following the design of the FdNetDevice, a separate reading thread is started during the initialization. The task of the reading thread is to wait for new incoming packets in the netmap receiver rings, in order to schedule the events of packet reception. ๐งต
In the initialization of the NetmapNetDevice, an additional thread, the sync thread, is started. The sync thread is required because, in order to reduce the cost of the system calls, netmap does not automatically transfer a packet written to a slot of the netmap ring to the transmission ring or to the installed qdisc. It is up to the user process to periodically request a synchronization of the netmap ring. Therefore, the purpose of the sync thread is to periodically make a TXSYNC ioctl request, so that pending packets in the netmap ring are transferred to the transmission ring, if in native mode, or to the installed qdisc, if in generic mode. Also, as described further below, the sync thread is exploited to perform flow control and notify the BQL library about the amount of bytes that have been transferred to the network device. โฑ๏ธ
The read method is called by the reading thread to retrieve new incoming packets stored in the netmap receiver ring and pass them to the appropriate ns-3 protocol handler for further processing within the simulatorโs network stack. After retrieving packets, the reading thread also synchronizes the netmap receiver ring, so that the retrieved packets can be removed from the netmap receiver ring. ๐ฅ
The NetmapNetDevice also specializes the write method, i.e., the method used to transmit a packet received from the upper layer (the ns-3 traffic control layer). The write method uses the netmap API to write the packet to a free slot in the netmap transmission ring. After writing a packet, the write method checks whether there is enough room in the netmap transmission ring for another packet. If not, the NetmapNetDevice stops its queue so that the ns-3 traffic control layer does not attempt to send a packet that could not be stored in the netmap transmission ring. ๐ค
A stopped NetmapNetDevice queue needs to be restarted as soon as some room is made in the netmap transmission ring. The sync thread can be exploited for this purpose, given that it periodically synchronizes the netmap transmission ring. In particular, the sync thread also checks the number of free slots in the netmap transmission ring in case the NetmapNetDevice queue is stopped. If the number of free slots exceeds a configurable value, the sync thread restarts the NetmapNetDevice queue and wakes the associated ns-3 qdisc. The NetmapNetDevice also supports BQL: the write method notifies the BQL library of the amount of bytes that have been written to the netmap transmission ring, while the sync thread notifies the BQL library of the amount of bytes that have been removed from the netmap transmission ring and transferred to the NIC since the previous notification. ๐
๐ฆ Scope and Limitations ๐ฆ
The main scope of NetmapNetDevice is to support the flow-control between the physical device and the upper layer and using at best the computational resources to process packets. However, the (Linux) system and network device must support netmap to make use of this feature.
๐ Usage ๐
The installation of netmap itself on a host machine is out of scope for this document. Refer to the netmap GitHub README for instructions.
The ns-3 netmap code has only been tested on Linux; it is not clear whether other operating systems can be supported.
If ns-3 is able to detect the presence of netmap on the system, it will report that:
Netmap emulation FdNetDevice : not enabled
If not, it will report:
Netmap emulation FdNetDevice : not enabled (needs net/netmap_user.h)
To run FdNetDevice-enabled simulations, one must pass the --enable-sudo option to ./waf configure, or else run the simulations with root privileges. ๐
๐ซถ Helpers ๐ซถ
ns-3 netmap support uses a NetMapNetDeviceHelper helper object to install the NetmapNetDevice. In other respects, the API and use is similar to that of the EmuFdNetDeviceHelper.
โจ Attributes โจ
There is one attribute specialized to NetmapNetDevice, named SyncAndNotifyQueuePeriod. This value takes an integer number of microseconds, and is used as the period of time after which the device syncs the netmap ring and notifies queue status. The value should be close to the interrupt coalescence period of the real device. Users may want to tune this parameter for their own system; it should be a compromise between CPU usage and accuracy in the ring sync (if it is too high, the device goes into starvation and lower throughput occurs).
๐ Output ๐
The NetmapNetDevice does not provide any specialized output, but supports the FdNetDevice output and traces (such as a promiscuous sniffer trace).
๐ Examples ๐
Several examples are provided:
fd-emu-onoff.cc: This example is aimed at measuring the throughput of theNetmapNetDevicewhen using theNetmapNetDeviceHelperto attach the simulated device to a real device in the host machine. This is achieved by saturating the channel with TCP or UDP traffic.fd-emu-ping.cc: This example uses theNetmapNetDeviceto send ICMP traffic over a real device.fd-emu-tc.cc: This example configures a router on a machine with two interfaces in emulated mode through netmap. The aim is to explore different qdiscs behaviours on the backlog of a device emulated bottleneck side.fd-emu-send.cc: This example builds a node with a device in emulation mode through netmap. The aim is to measure the maximum transmit rate in packets per second (pps) achievable withNetmapNetDeviceon a specific machine.
Note that all the examples run in emulation mode through netmap (with NetmapNetDevice) and raw socket (with FdNetDevice). ๐
๐ DPDK NetDevice ๐
Data Plane Development Kit (DPDK) is a library hosted by The Linux Foundation to accelerate packet processing workloads (https://www.dpdk.org/).
The DpdkNetDevice class provides the implementation of a network device which uses DPDKโs fast packet processing abilities and bypasses the kernel. This class is included in the src/fd-net-device model. The DpdkNetDevice class inherits the FdNetDevice class and overrides the functions which are required by ns-3 to interact with DPDK environment.
The DpdkNetDevice for ns-3 [Patel2019] was developed by Harsh Patel, Hrishikesh Hiraskar and Mohit P. Tahiliani. They were supported by Intel Technology India Pvt. Ltd., Bangalore for this work. ๐ซถ
[Patel2019] Harsh Patel, Hrishikesh Hiraskar, Mohit P. Tahiliani, โExtending Network Emulation Support in ns-3 using DPDKโ, Proceedings of the 2019 Workshop on ns-3, ACM, Pages 17-24, (https://dl.acm.org/doi/abs/10.1145/3321349.3321358)
๐ธ Model Description ๐ธ
DpdkNetDevice is a network device which provides network emulation capabilities i.e. to allow simulated nodes to interact with real hosts and vice versa. The main feature of the DpdkNetDevice is that is uses the Environment Abstraction Layer (EAL) provided by DPDK to perform fast packet processing. EAL hides the device specific attributes from the applications and provides an interface via which the applications can interact directly with the Network Interface Card (NIC). This allows ns-3 to send/receive packets directly to/from the NIC without the kernel involvement. โญ
๐ง Design ๐ง
DpdkNetDevice is designed to act as an interface between ns-3 and DPDK environment. There are 3 main phases in the life cycle of DpdkNetDevice:
- Initialization
- Packet Transfer - Read and Write
- Termination
๐ Initialization ๐
DpdkNetDeviceHelper model is responsible for the initialization of DpdkNetDevice. After this, the EAL is initialized, a memory pool is allocated, access to the Ethernet port is obtained and it is initialized, reception (Rx) and transmission (Tx) queues are set up on the port, Rx and Tx buffers are set up and LaunchCore method is called which will launch the HandleRx method to handle reading of packets in burst.
๐ฆ Packet Transfer ๐ฆ
DPDK interacts with packet in the form of mbuf, a data structure provided by it, while ns-3 interacts with packets in the form of raw buffer. The packet transfer functions take care of converting DPDK mbufs to ns-3 buffers. The functions are read and write.
- Read:
HandleRxmethod takes care of reading the packets from NIC and transferring them to ns-3 Internet Stack. This function is called byLaunchCoremethod which is launched during initialization. It continuously polls the NIC using DPDK API for packets to read. It reads the mbuf packets in burst from NIC Rx ring, which are placed into Rx buffer upon read. For each mbuf packet in Rx buffer, it then converts it to ns-3 raw buffer and then forwards the packet to ns-3 Internet Stack. - Write: Write method handles transmission of packets. ns-3 provides this packet in the form of a buffer, which is converted to packet mbuf and then placed in the Tx buffer. These packets are then transferred to NIC Tx ring when the Tx buffer is full, from where they will be transmitted by the NIC. However, there might be a scenario where there are not enough packets to fill the Tx buffer. This will lead to stale packet mbufs in buffer. In such cases, the Write function schedules a manual flush of these stale packet mbufs to NIC Tx ring, which will occur upon a certain timeout period. The default value of this timeout is set to
2 ms.
๐ Termination ๐
When ns-3 is done using DpdkNetDevice, the DpdkNetDevice will stop polling for Rx, free the allocated mbuf packets and then the mbuf pool. Lastly, it will stop the Ethernet device and close the port.
๐ Scope and Limitations ๐
The current implementation supports only one NIC to be bound to DPDK with single Rx and Tx on the NIC. This can be extended to support multiple NICs and multiple Rx/Tx queues simultaneously. Currently there is no support for Jumbo frames, which can be added. Offloading, scheduling features can also be added. Flow control and support for qdisc can be added to provide a more extensive model for network testing.
โจ DPDK Installation โจ
This section contains information on downloading DPDK source code and setting up DPDK for DpdkNetDevice to work.
โญ Is my NIC supported by DPDK? โญ
Check Supported Devices.
๐ Not supported? Use Virtual Machine instead ๐
Install Oracle VM VirtualBox. Create a new VM and install Ubuntu on it. Open settings, create a network adapter with following configuration:
- Attached to: Bridged Adapter
- Name: The host network device you want to use
- In Advanced
- Adapter Type: Intel PRO/1000 MT Server (82545EM) or any other DPDK supported NIC
- Promiscuous Mode: Allow All
- Select Cable Connected
Then rest of the steps are same as follows.
DPDK can be installed in 2 ways:
- Install DPDK on Ubuntu
- Compile DPDK from source
๐ Install DPDK on Ubuntu ๐
To install DPDK on Ubuntu, run the following command:
apt-get install dpdk dpdk-dev libdpdk-dev dpdk-igb-uio-dkms
Ubuntu 20.04 has packaged DPDK v19.11 LTS which is tested with this module and DpdkNetDevice will only be enabled if this version is available.
๐ Compile from Source ๐
To compile DPDK from source, you need to perform the following 4 steps:
๐ 1. Download the source ๐
Visit the DPDK Downloads page to download the latest stable source. (This module has been tested with version 19.11 LTS and DpdkNetDevice will only be enabled if this version is available.)
๐ซถ 2. Configure DPDK as a shared library ๐ซถ
In the DPDK directory, edit the config/common_base file to change the following line to compile DPDK as a shared library:
# Compile to share library
CONFIG_RTE_BUILD_SHARED_LIB=y
๐ง 3. Install the source ๐ง
Refer to Installation for detailed instructions.
For a 64 bit linux machine with gcc, run:
make install T=x86_64-native-linuxapp-gcc DESTDIR=install
โญ 4. Export DPDK Environment variables โญ
Export the following environment variables:
RTE_SDKas the your DPDK source folder.RTE_TARGETas the build target directory.
For example:
export RTE_SDK=/home/username/dpdk/dpdk-stable-19.11.1
export RTE_TARGET=x86_64-native-linuxapp-gcc
(Note: In case DPDK is moved, ns-3 needs to be reconfigured using ./waf configure [options])
It is advisable that you export these variables in .bashrc or similar for reusability. ๐
๐ฅ Load DPDK Drivers to kernel ๐ฅ
Execute the following:
sudo modprobe uio_pci_generic
sudo modprobe uio
sudo modprobe vfio-pci
sudo modprobe igb_uio # for ubuntu package
# OR
sudo insmod $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko # for dpdk source
These should be done every time you reboot your system.
โจ Configure hugepages โจ
Okay bestie, for the full rundown on hugepages, check out System Requirements โ that's where the detailed instructions are. ๐
Wanna allocate hugepages at runtime? Write a value like 256 to this:
echo 256 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
Wanna do it at boot time instead? Edit /etc/default/grub and add this to GRUB_CMDLINE_LINUX_DEFAULT:
hugepages=256
We suggest a minimum of 256 to run our applications. (This is to test an application run at 1 Gbps on a 1 Gbps NIC.) You can use any number of hugepages based on your system capacity and application requirements. ๐ฆ
Then update the grub configurations using:
sudo update-grub
OR
sudo update-grub2
You'll need to reboot your system to see these changes. ๐
To check allocation of hugepages, run:
cat /proc/meminfo | grep HugePages
You'll see the number of hugepages allocated, and they should be equal to the number you used above.
Once the hugepage memory is reserved (at either runtime or boot time), to make the memory available for DPDK use, perform these steps:
sudo mkdir /mnt/huge
sudo mount -t hugetlbfs nodev /mnt/huge
The mount point can be made permanent across reboots by adding this line to the /etc/fstab file:
nodev /mnt/huge hugetlbfs defaults 0 0
โจ Usage โจ
The status of DPDK support shows up in the output of ./waf configure. If it's found, you should see:
DPDK NetDevice : enabled
The DpdkNetDeviceHelper class supports the configuration of DpdkNetDevice.
+----------------------+
| host 1 |
+----------------------+
| ns-3 simulation |
+----------------------+
| ns-3 Node |
| +----------------+ |
| | ns-3 TCP | |
| +----------------+ |
| | ns-3 IP | |
| +----------------+ |
| | DpdkNetDevice | |
| | 10.1.1.1 | |
| +----------------+ |
| | raw socket | |
|--+----------------+--|
| | eth0 | |
+-------+------+-------+
10.1.1.11
|
+-------------- ( Internet ) ----
Initialization of the DPDK driver requires initialization of EAL. EAL requires a PMD (Poll Mode Driver) Library for using the NIC. DPDK supports multiple Poll Mode Drivers and you can use one that works for your NIC. PMD Library can be set via DpdkNetDeviceHelper::SetPmdLibrary, like this:
DpdkNetDeviceHelper* dpdk = new DpdkNetDeviceHelper ();
dpdk->SetPmdLibrary("librte_pmd_e1000.so");
Also, the NIC should be bound to the DPDK Driver in order to be used with EAL. The default driver used is uio_pci_generic, which supports most of the NICs. You can change it using DpdkNetDeviceHelper::SetDpdkDriver, like this:
DpdkNetDeviceHelper* dpdk = new DpdkNetDeviceHelper ();
dpdk->SetDpdkDriver("igb_uio");
โจ Attributes โจ
The DpdkNetDevice provides a number of attributes:
TxTimeoutโ The time to wait before transmitting burst from Tx Buffer (in us). (default -2000) This attribute is only used to flush out buffer in case it is not filled. This attribute can be decrease for low data rate traffic. For high data rate traffic, this attribute needs no change. ๐คMaxRxBurstโ Size of Rx Burst. (default -64) This attribute can be increased for higher data rates. ๐MaxTxBurstโ Size of Tx Burst. (default -64) This attribute can be increased for higher data rates. ๐MempoolCacheSizeโ Size of mempool cache. (default -256) This attribute can be increased for higher data rates. ๐NbRxDescโ Number of Rx descriptors. (default -1024) This attribute can be increased for higher data rates. ๐NbTxDescโ Number of Tx descriptors. (default -1024) This attribute can be increased for higher data rates. ๐
Note: Default values work well with 1Gbps traffic. ๐
โจ Output โจ
Since DpdkNetDevice is inherited from FdNetDevice, all the output methods provided by FdNetDevice can be used directly.
โจ Examples โจ
The following examples are provided:
fd-emu-ping.cc: This example can be configured to use theDpdkNetDeviceto send ICMP traffic bypassing the kernel over a real channel. ๐กfd-emu-onoff.cc: This example can be configured to measure the throughput of theDpdkNetDeviceby sending traffic from the simulated node to a real device using thens3::OnOffApplicationwhile leveraging DPDK's fast packet processing abilities. This is achieved by saturating the channel with TCP/UDP traffic. ๐ฅ
โจ Tap NetDevice โจ
The Tap NetDevice can be used to allow a host system or virtual machines to interact with a simulation.
โจ TapBridge Model Overview โจ
The Tap Bridge is designed to integrate "real" internet hosts (or more precisely, hosts that support Tun/Tap devices) into ns-3 simulations. The goal is to make it appear to a "real" host node in that it has an ns-3 net device as a local device. The concept of a "real host" is a bit slippery since the "real host" may actually be virtualized using readily available technologies such as VMware, VirtualBox or OpenVZ. ๐
Since we are, in essence, connecting the inputs and outputs of an ns-3 net device to the inputs and outputs of a Linux Tap net device, we call this arrangement a Tap Bridge. ๐
There are three basic operating modes of this device available to users. Basic functionality is essentially identical, but the modes are different in details regarding how the arrangement is created and configured; and what devices can live on which side of the bridge.
We call these three modes the ConfigureLocal, UseLocal and UseBridge modes. The first "word" in the camel case mode identifier indicates who has the responsibility for creating and configuring the taps. For example, the "Configure" in ConfigureLocal mode indicates that it is the TapBridge that has responsibility for configuring the tap. In UseLocal mode and UseBridge modes, the "Use" prefix indicates that the TapBridge is asked to "Use" an existing configuration.
In other words, in ConfigureLocal mode, the TapBridge has the responsibility for creating and configuring the TAP devices. In UseBridge or UseLocal modes, the user provides a configuration and the TapBridge adapts to that configuration. ๐
โจ TapBridge ConfigureLocal Mode โจ
In the ConfigureLocal mode, the configuration of the tap device is ns-3 configuration-centric. Configuration information is taken from a device in the ns-3 simulation and a tap device matching the ns-3 attributes is automatically created. In this case, a Linux computer is made to appear as if it was directly connected to a simulated ns-3 network. ๐ง
This is illustrated below:
+--------+
| Linux |
| host | +----------+
| ------ | | ghost |
| apps | | node |
| ------ | | -------- |
| stack | | IP | +----------+
| ------ | | stack | | node |
| TAP | |==========| | -------- |
| device | <----- IPC ------> | tap | | IP |
+--------+ | bridge | | stack |
| -------- | | -------- |
| ns-3 | | ns-3 |
| net | | net |
| device | | device |
+----------+ +----------+
|| ||
+---------------------------+
| ns-3 channel |
+---------------------------+
In this case, the "ns-3 net device" in the "ghost node" appears as if it were actually replacing the TAP device in the Linux host. The ns-3 simulation creates the TAP device on the underlying Linux OS and configures the IP and MAC addresses of the TAP device to match the values assigned to the simulated ns-3 net device. The "IPC" link shown above is the network tap mechanism in the underlying OS. The whole arrangement acts as a conventional bridge; but a bridge between devices that happen to have the same shared MAC and IP addresses. ๐
Here, the user is not required to provide any configuration information specific to the tap. A tap device will be created and configured by ns-3 according to its defaults, and the tap device will have its name assigned by the underlying operating system according to its defaults.
If the user has a requirement to access the created tap device, he or she may optionally provide a "DeviceName" attribute. In this case, the created OS tap device will be named accordingly. ๐ท๏ธ
The ConfigureLocal mode is the default operating mode of the Tap Bridge.
โจ TapBridge UseLocal Mode โจ
The UseLocal mode is quite similar to the ConfigureLocal mode. The significant difference is, as the mode name implies, the TapBridge is going to "Use" an existing tap device previously created and configured by the user. This mode is particularly useful when a virtualization scheme automatically creates tap devices and ns-3 is used to provide simulated networks for those devices. ๐ซ
+--------+
| Linux |
| host | +----------+
| ------ | | ghost |
| apps | | node |
| ------ | | -------- |
| stack | | IP | +----------+
| ------ | | stack | | node |
| TAP | |==========| | -------- |
| device | <----- IPC ------> | tap | | IP |
| MAC X | | bridge | | stack |
+--------+ | -------- | | -------- |
| ns-3 | | ns-3 |
| net | | net |
| device | | device |
| MAC Y | | MAC Z |
+----------+ +----------+
|| ||
+---------------------------+
| ns-3 channel |
+---------------------------+
Okay bestie, so like, in this case the pre-configured MAC address of the โTap deviceโ (that's MAC X) is not gonna be the same as the bridged โns-3 net deviceโ (MAC Y) shown in the illustration above. ๐
And to bridge to ns-3 net devices that don't support SendFrom() (especially wireless STA nodes), we have this requirement: only one Linux device (with one unique MAC address โ here X) generates traffic that flows across the IPC link. Why? Because the MAC addresses of traffic across the IPC link get โspoofedโ or changed to make it look to Linux and ns-3 like they have the same address. So traffic moving from the Linux host to the ns-3 ghost node has its MAC address changed from X to Y, and traffic from the ghost node to the Linux host gets changed from Y to X. Since there's a one-to-one correspondence between devices, there may only be one MAC source flowing from the Linux side. This means Linux bridges with more than one net device added are incompatible with UseLocal mode. Periodt. ๐ซ
Big yikes: Linux bridges with more than one net device added are incompatible with UseLocal mode. ๐
In UseLocal mode, the user is expected to create and configure a tap device completely outside the scope of the ns-3 simulation using something like:
$ sudo tunctl -t tap0
$ sudo ifconfig tap0 hw ether 08:00:2e:00:00:01
$ sudo ifconfig tap0 10.1.1.1 netmask 255.255.255.0 up
To tell the TapBridge what's going on, the user will set either directly into the TapBridge or via the TapBridgeHelper, the DeviceName attribute. In the case of the configuration above, the DeviceName attribute would be set to tap0 and the Mode attribute would be set to UseLocal. โจ
One particular use case for this mode is in the OpenVZ environment. There it's possible to create a Tap device on the โHardware Nodeโ and move it into a Virtual Private Server. If the TapBridge is able to use an existing tap device, it's then possible to avoid the overhead of an OS bridge in that environment. Lowkey genius. ๐ก
๐ฆ TapBridge UseBridge Mode ๐ฆ
The simplest mode for those familiar with Linux networking is the UseBridge mode. Again, the โUseโ prefix indicates that the TapBridge is going to Use an existing configuration. In this case, the TapBridge is going to logically extend a Linux bridge into ns-3. It's giving bridge energy. ๐
This is illustrated below:
+---------+
| Linux | +----------+
| ------- | | ghost |
| apps | | node |
| ------- | | -------- |
| stack | | IP | +----------+
| ------- | +--------+ | stack | | node |
| Virtual | | TAP | |==========| | -------- |
| Device | | Device | <---- IPC -----> | tap | | IP |
+---------+ +--------+ | bridge | | stack |
|| || | -------- | | -------- |
+--------------------+ | ns-3 | | ns-3 |
| OS (brctl) Bridge | | net | | net |
+--------------------+ | device | | device |
+----------+ +----------+
|| ||
+---------------------------+
| ns-3 channel |
+---------------------------+
In this case, a computer running Linux applications, protocols, etc., is connected to a ns-3 simulated network in such a way as to make it appear to the Linux host that the TAP device is a real network device participating in the Linux bridge. No cap. ๐ฏ
In the ns-3 simulation, a TapBridge is created to match each TAP Device. The name of the TAP Device is assigned to the Tap Bridge using the DeviceName attribute. The TapBridge then logically extends the OS bridge to encompass the ns-3 net device. It's literally extending the vibe. ๐
Since this mode logically extends an OS bridge, there may be many Linux net devices on the non-ns-3 side of the bridge. Therefore, like a net device on any bridge, the ns-3 net device must deal with the possibility of many source addresses. Thus, ns-3 devices must support SendFrom() (NetDevice::SupportsSendFrom() must return true) in order to be configured for use in UseBridge mode. So like, if it can't send from, it's not invited to the party. ๐ซ
It is expected that the user will do something like the following to configure the bridge and tap completely outside ns-3:
$ sudo brctl addbr mybridge
$ sudo tunctl -t mytap
$ sudo ifconfig mytap hw ether 00:00:00:00:00:01
$ sudo ifconfig mytap 0.0.0.0 up
$ sudo brctl addif mybridge mytap
$ sudo brctl addif mybridge ...
$ sudo ifconfig mybridge 10.1.1.1 netmask 255.255.255.0 up
To tell the TapBridge what's going on, the user will set either directly into the TapBridge or via the TapBridgeHelper, the DeviceName attribute. In the case of the configuration above, the DeviceName attribute would be set to mytap and the Mode attribute would be set to UseBridge. Easy peasy. ๐
This mode is especially useful in the case of virtualization where the configuration of the virtual hosts may be dictated by another system and not be changeable to suit ns-3. For example, a particular VM scheme may create virtual vethx or vmnetx devices that appear local to virtual hosts. In order to connect to such systems, one would need to manually create TAP devices on the host system and brigde these TAP devices to the existing (VM) virtual devices. The job of the Tap Bridge in this case is to extend the bridge to join a ns-3 net device. VM drama? We handle it. ๐ช
๐ง TapBridge ConfigureLocal Operation ๐ง
In ConfigureLocal mode, the TapBridge and therefore its associated ns-3 net device appears to the Linux host computer as a network device just like any arbitrary eth0 or ath0 might appear. The creation and configuration of the TAP device is done by the ns-3 simulation and no manual configuration is required by the user. The IP addresses, MAC addresses, gateways, etc., for created TAP devices are extracted from the simulation itself by querying the configuration of the ns-3 device and the TapBridge Attributes. So it's like, auto-magic. โจ
Since the MAC addresses are identical on the Linux side and the ns-3 side, we can use Send() on the ns-3 device which is available on all ns-3 net devices. Since the MAC addresses are identical there is no requirement to hook the promiscuous callback on the receive side. Therefore there are no restrictions on the kinds of net device that are usable in ConfigureLocal mode. So inclusive. ๐
The TapBridge appears to an ns-3 simulation as a channel-less net device. This device must not have an IP address associated with it, but the bridged (ns-3) net device must have an IP address. Be aware that this is the inverse of an ns-3 BridgeNetDevice (or a conventional bridge in general) which demands that its bridge ports not have IP addresses, but allows the bridge device itself to have an IP address. So like, opposite day. ๐
The host computer will appear in a simulation as a โghostโ node that contains one TapBridge for each NetDevice that is being bridged. From the perspective of a simulation, the only difference between a ghost node and any other node will be the presence of the TapBridge devices. Note however, that the presence of the TapBridge does affect the connectivity of the net device to the IP stack of the ghost node. Spooky but useful. ๐ป
Configuration of address information and the ns-3 devices is not changed in any way if a TapBridge is present. A TapBridge will pick up the addressing information from the ns-3 net device to which it is connected (its โbridgedโ net device) and use that information to create and configure the TAP device on the real host. It's a lil thief, but in a cute way. ๐
The end result of this is a situation where one can, for example, use the standard ping utility on a real host to ping a simulated ns-3 node. If correct routes are added to the internet host (this is expected to be done automatically in future ns-3 releases), the routing systems in ns-3 will enable correct routing of the packets across simulated ns-3 networks. For an example of this, see the example program, tap-wifi-dumbbell.cc in the ns-3 distribution. Ping pong but make it network. ๐
The Tap Bridge lives in a kind of a gray world somewhere between a Linux host and an ns-3 bridge device. From the Linux perspective, this code appears as the user mode handler for a TAP net device. In ConfigureLocal mode, this Tap device is automatically created by the ns-3 simulation. When the Linux host writes to one of these automatically created /dev/tap devices, the write is redirected into the TapBridge that lives in the ns-3 world; and from this perspective, the packet write on Linux becomes a packet read in the Tap Bridge. In other words, a Linux process writes a packet to a tap device and this packet is redirected by the network tap mechanism toan ns-3 process where it is received by the TapBridge as a result of a read operation there. The TapBridge then writes the packet to the ns-3 net device to which it is bridged; and therefore it appears as if the Linux host sent a packet directly through an ns-3 net device onto an ns-3 network. It's giving interdimensional cable. ๐ก
In the other direction, a packet received by the ns-3 net device connected to the Tap Bridge is sent via a receive callback to the TapBridge. The TapBridge then takes that packet and writes it back to the host using the network tap mechanism. This write to the device will appear to the Linux host as if a packet has arrived on a net device; and therefore as if a packet received by the ns-3 net device during a simulation has appeared on a real Linux net device. Bidirectional slay. ๐
The upshot is that the Tap Bridge appears to bridge a tap device on a Linux host in the โreal worldโ to an ns-3 net device in the simulation. Because the TAP device and the bridged ns-3 net device have the same MAC address and the network tap IPC link is not externalized, this particular kind of bridge makes it appear that a ns-3 net device is actually installed in the Linux host. It's an illusion, Michael. ๐ฉ
In order to implement this on the ns-3 side, we need a โghost nodeโ in the simulation to hold the bridged ns-3 net device and the TapBridge. This node should not actually do anything else in the simulation since its job is simply to make the net device appear in Linux. This is not just arbitrary policy, it is because:
- Bits sent to the TapBridge from higher layers in the ghost node (using the TapBridge
Sendmethod) are completely ignored. The TapBridge is not, itself, connected to any network, neither in Linux nor in ns-3. You can never send nor receive data over a TapBridge from the ghost node. So like, don't try it. ๐ซ - The bridged ns-3 net device has its receive callback disconnected from the ns-3 node and reconnected to the Tap Bridge. All data received by a bridged device will then be sent to the Linux host and will not be received by the node. From the perspective of the ghost node, you can send over this device but you cannot ever receive. ๐ป it's giving ghosted, literally
Okay so plot twist โ if you actually understand all of the issues you can take control of your own destiny and do whatever you want โ we do not actively prevent you from using the ghost node for anything you decide. You will be able to perform typical ns-3 operations on the ghost node if you so desire. The internet stack, for example, must be there and functional on that node in order to participate in IP address assignment and global routing. However, as mentioned above, interfaces talking to any TapBridge or associated bridged net devices will not work completely. If you understand exactly what you are doing, you can set up other interfaces and devices on the ghost node and use them; or take advantage of the operational send side of the bridged devices to create traffic generators. We generally recommend that you treat this node as a ghost of the Linux host and leave it to itself, though. bestie just let the ghost be a ghost ๐
๐ TapBridge UseLocal Mode Operation ๐
As described in above, the TapBridge acts like a bridge from the "real" world into the simulated ns-3 world. In the case of the ConfigureLocal mode, life is easy since the IP address of the Tap device matches the IP address of the ns-3 device and the MAC address of the Tap device matches the MAC address of the ns-3 device; and there is a one-to-one relationship between the devices. matching outfits, matching energy โจ
Things are slightly complicated when a Tap device is externally configured with a different MAC address than the ns-3 net device. The conventional way to deal with this kind of difference is to use promiscuous mode in the bridged device to receive packets destined for the different MAC address and forward them off to Linux. In order to move packets the other way, the conventional solution is SendFrom() which allows a caller to "spoof" or change the source MAC address to match the different Linux MAC address.
We do have a specific requirement to be able to bridge Linux Virtual Machines onto wireless STA nodes. Unfortunately, the 802.11 spec doesn't provide a good way to implement SendFrom(), so we have to work around that problem. ๐ญ the 802.11 spec said no and we had to cope
To this end, we provided the UseLocal mode of the Tap Bridge. This mode allows you approach the problem as if you were creating a bridge with a single net device. A single allowed address on the Linux side is remembered in the TapBridge, and all packets coming from the Linux side are repeated out the ns-3 side using the ns-3 device MAC source address. All packets coming in from the ns-3 side are repeated out the Linux side using the remembered MAC address. This allows us to use Send() on the ns-3 device side which is available on all ns-3 net devices. main character energy: one address, remembered, slaying ๐
UseLocal mode is identical to the ConfigureLocal mode except for the creation and configuration of the tap device and the MAC address spoofing.
๐ฆ TapBridge UseBridge Operation ๐ฆ
As described in the ConfigureLocal mode section, when the Linux host writes to one of the /dev/tap devices, the write is redirected into the TapBridge that lives in the ns-3 world. In the case of the UseBridge mode, these packets will need to be sent out on the ns-3 network as if they were sent on a device participating in the Linux bridge. This means calling the SendFrom() method on the bridged device and providing the source MAC address found in the packet.
In the other direction, a packet received by an ns-3 net device is hooked via callback to the TapBridge. This must be done in promiscuous mode since the goal is to bridge the ns-3 net device onto the OS (brctl) bridge of which the TAP device is a part.
For these reasons, only ns-3 net devices that support SendFrom() and have a hookable promiscuous receive callback are allowed to participate in UseBridge mode TapBridge configurations. no callback, no promiscuous hook, no entry โ it's a vibe check fr fr
๐ธ Tap Bridge Channel Model ๐ธ
There is no channel model associated with the Tap Bridge. In fact, the intention is make it appear that the real internet host is connected to the channel of the bridged net device. no channel, just vibes ๐
โญ Tap Bridge Tracing Model โญ
Unlike most ns-3 devices, the TapBridge does not provide any standard trace sources. This is because the bridge is an intermediary that is essentially one function call away from the bridged device. We expect that the trace hooks in the bridged device will be sufficient for most users, ngl the bridged device is carrying the whole tracing load here and we're at peace with that ๐ซถ
๐ Using the TapBridge ๐
We expect that most users will interact with the TapBridge device through the TapBridgeHelper. Users of other helper classes, such as CSMA or Wifi, should be comfortable with the idioms used there. same energy, different helper, iykyk โจ
๐ฅ ENERGY FRAMEWORK ๐ฅ
Energy consumption is a key issue for wireless devices, and wireless network researchers often need to investigate the energy consumption at a node or in the overall network while running network simulations in ns-3. This requires ns-3 to support energy consumption modeling. Further, as concepts such as fuel cells and energy scavenging are becoming viable for low power wireless devices, incorporating the effect of these emerging technologies into simulations requires support for modeling diverse energy sources in ns-3. The ns-3 Energy Framework provides the basis for energy consumption, energy source and energy harvesting modeling. ๐ bestie we are tracking the battery, no cap
๐ Model Description ๐
The source code for the Energy Framework is currently at: src/energy.
๐ง Design ๐ง
The ns-3 Energy Framework is composed of 3 parts: Energy Source, Device Energy Model and Energy Harvester. The framework is implemented into the src/energy/models folder. three icons, one framework, periodt ๐
๐ Energy Source ๐
The Energy Source represents the power supply on each node. A node can have one or more energy sources, and each energy source can be connected to multiple device energy models. Connecting an energy source to a device energy model implies that the corresponding device draws power from the source. The basic functionality of the Energy Source is to provide energy for devices on the node. When energy is completely drained from the Energy Source, it notifies the devices on node such that each device can react to this event. Further, each node can access the Energy Source Objects for information such as remaining energy or energy fraction (battery level). This enables the implementation of energy aware protocols in ns-3.
In order to model a wide range of power supplies such as batteries, the Energy Source must be able to capture characteristics of these supplies. There are 2 important characteristics or effects related to practical batteries:
- Rate Capacity Effect โ Decrease of battery lifetime when the current draw is higher than the rated value of the battery.
- Recovery Effect โ Increase of battery lifetime when the battery is alternating between discharge and idle states.
the battery is dramatic and we respect it ๐
In order to incorporate the Rate Capacity Effect, the Energy Source uses current draw from all the devices on the same node to calculate energy consumption. Moreover, multiple Energy Harvesters can be connected to the Energy Source in order to replenish its energy. The Energy Source periodically polls all the devices and energy harvesters on the same node to calculate the total current drain and hence the energy consumption. When a device changes state, its corresponding Device Energy Model will notify the Energy Source of this change and new total current draw will be calculated. Similarly, every Energy Harvester update triggers an update to the connected Energy Source.
The Energy Source base class keeps a list of devices (Device Energy Model objects) and energy harvesters (Energy Harvester objects) that are using the particular Energy Source as power supply. When energy is completely drained, the Energy Source will notify all devices on this list. Each device can then handle this event independently, based on the desired behavior that should be followed in case of power outage. โ ๏ธ battery at zero, everybody on the list gets the notification, handle it how you want
โญ Device Energy Model โญ
The Device Energy Model is the energy consumption model of a device installed on the node. It is designed to be a state based model where each device is assumed to have a number of states, and each state is associated with a power consumption value. Whenever the state of the device changes, the corresponding Device Energy Model will notify the Energy Source of the new current draw of the device. The Energy Source will then calculate the new total current draw and update the remaining energy.
The Device Energy Model can also be used for devices that do not have finite number of states. For example, in an electric vehicle, the current draw of the motor is determined by its speed. Since the vehicle's speed can take continuous values within a certain range, it is infeasible to define a set of discrete states of operation. However, by converting the speed value into current directly, the same set of Device Energy Model APIs can still be used. ๐ no discrete states? just convert speed โ current and the same APIs ate, iconic
๐ฆ Energy Harvester ๐ฆ
The energy harvester represents the elements that harvest energy from the environment and recharge the Energy Source to which it is connected. The energy harvester includes the complete implementation of the actual energy harvesting device (e.g., a solar panel) and the environment (e.g., the solar radiation). This means that in implementing an energy harvester, the energy contribution of the environment and the additional energy requirements of the energy harvesting device such as the conversion efficiency and the internal power consumption of the device needs to be jointly modeled. โ๏ธ solar panel AND the sun AND the losses โ model the whole situation, bestie
๐ WiFi Radio Energy Model ๐
The WiFi Radio Energy Model is the energy consumption model of a Wifi net device. It provides a state for each of the available states of the PHY layer: Idle, CcaBusy, Tx, Rx, ChannelSwitch, Sleep, Off. Each of such states is associated with a value (in Ampere) of the current draw (see below for the corresponding attribute names). A Wifi Radio Energy Model PHY Listener is registered to the Wifi PHY in order to be notified of every Wifi PHY state transition. At every transition, the energy consumed in the previous state is computed and the energy source is notified in order to update its remaining energy. seven states, seven moods, one listener watching every glow-up ๐
Okay bestie, buckle up ๐ because we're still deep in the Energy Framework and it's about to get so specific. No cap.
The Wifi Tx Current Model gives you the possibility to compute the current draw in the transmit state as a function of the nominal tx power (in dBm), exactly like what was observed in several experimental measurements. To make that happen, the Wifi Radio Energy Model PHY Listener gets notified of the nominal tx power used to transmit the current frame, and it passes that value over to the Wifi Tx Current Model, which handles updating the current draw in the Tx state. So the energy consumption is computed correctly even if the Wifi Remote Station Manager is out here doing per-frame power control. Periodt. ๐
Currently, a Linear Wifi Tx Current Model is implemented, which computes the tx current as a linear function (according to parameters that you, the user, can specify) of the nominal tx power in dBm. โจ
The Wifi Radio Energy Model also offers the possibility to specify a callback that gets invoked when the energy source is depleted. If such a callback is not specified when the Wifi Radio Energy Model Helper is used to install the model on a device, then a callback is implicitly made so that the Wifi PHY is put in the OFF mode โ meaning no frame is transmitted nor received afterwards โ when the energy source is depleted. ๐ญ
Likewise, it's possible to specify a callback that is invoked when the energy source is recharged (which might occur in case an energy harvester is connected to the energy source). If such a callback is not specified when the Wifi Radio Energy Model Helper is used to install the model on a device, then a callback is implicitly made so that the Wifi PHY is resumed from the OFF mode when the energy source is recharged. ๐ซถ
๐ง Future Work
For Device Energy Models, we are planning to include support for other PHY layer models provided in ns-3 such as WiMAX, and to model the energy consumptions of other non communicating devices, like a generic sensor and a CPU. For Energy Sources, we are planning to include new types of Energy Sources such as Supercapacitor and Nickel-Metal Hydride (Ni-MH) battery. For the Energy Harvesters, we are planning to implement an energy harvester that recharges the energy sources according to the power levels defined in a user customizable dataset of real measurements. ๐
๐ References
- ns-2 Energy model:
http://www.cubinlab.ee.unimelb.edu.au/~jrid/Docs/Manuel-NS2/node204.html - H. Wu, S. Nabar and R. Poovendran. An Energy Framework for the Network Simulator 3 (ns-3).
- M. Handy and D. Timmermann. Simulation of mobile wireless networks with accurate modelling of non-linear battery effects. In Proc. of Applied simulation and Modeling (ASM), 2003.
- D. N. Rakhmatov and S. B. Vrudhula. An analytical high-level battery model for use in energy management of portable electronic systems. In Proc. of IEEE/ACM International Conference on Computer Aided Design (ICCADโ01), pages 488-493, November 2001.
- D. N. Rakhmatov, S. B. Vrudhula, and D. A. Wallach. Battery lifetime prediction for energy-aware computing. In Proc. of the 2002 International Symposium on Low Power Electronics and Design (ISLPEDโ02), pages 154-159, 2002.
- C. Tapparello, H. Ayatollahi and W. Heinzelman. Extending the Energy Framework for Network Simulator 3 (ns-3). Workshop on ns-3 (WNS3), Poster Session, Atlanta, GA, USA. May, 2014.
- C. Tapparello, H. Ayatollahi and W. Heinzelman. Energy Harvesting Framework for Network Simulator 3 (ns-3). 2nd International Workshop on Energy Neutral Sensing Systems (ENSsys), Memphis, TN, USA. November 6, 2014.
๐ ๏ธ Usage
The main way that ns-3 users will typically interact with the Energy Framework is through the helper API and through the publicly visible attributes of the framework. The helper API is defined in src/energy/helper/*.h. ๐
In order to use the energy framework, the user must install an Energy Source for the node of interest, the corresponding Device Energy Model for the network devices and, if necessary, the one or more Energy Harvester. Energy Source (objects) are aggregated onto each node by the Energy Source Helper. In order to allow multiple energy sources per node, we aggregate an Energy Source Container rather than directly aggregating a source object. ๐
The Energy Source object keeps a list of Device Energy Model and Energy Harvester objects using the source as power supply. Device Energy Model objects are installed onto the Energy Source by the Device Energy Model Helper, while Energy Harvester objects are installed by the Energy Harvester Helper. User can access the Device Energy Model objects through the Energy Source object to obtain energy consumption information of individual devices. Moreover, the user can access the Energy Harvester objects in order to gather information regarding the current harvestable power and the total energy harvested by the harvester. ๐
๐ Examples
The example directories, src/examples/energy and examples/energy, contain some basic code that shows how to set up the framework. โจ
๐งฐ Helpers
Energy Source Helper
Base helper class for Energy Source objects. This helper aggregates an Energy Source object onto a node. Child implementation of this class creates the actual Energy Source object.
Device Energy Model Helper
Base helper class for Device Energy Model objects. This helper attaches Device Energy Model objects onto Energy Source objects. Child implementation of this class creates the actual Device Energy Model object.
Energy Harvesting Helper
Base helper class for Energy Harvester objects. This helper attaches Energy Harvester objects onto Energy Source objects. Child implementation of this class creates the actual Energy Harvester object. ๐ธ
๐ Attributes
Attributes differ between Energy Sources, Devices Energy Models and Energy Harvesters implementations โ please look at the specific child class for details, bestie. ๐
Basic Energy Source
BasicEnergySourceInitialEnergyJ: Initial energy stored in basic energy source.BasicEnergySupplyVoltageV: Initial supply voltage for basic energy source.PeriodicEnergyUpdateInterval: Time between two consecutive periodic energy updates.
RV Battery Model
RvBatteryModelPeriodicEnergyUpdateInterval: RV battery model sampling interval.RvBatteryModelOpenCircuitVoltage: RV battery model open circuit voltage.RvBatteryModelCutoffVoltage: RV battery model cutoff voltage.RvBatteryModelAlphaValue: RV battery model alpha value.RvBatteryModelBetaValue: RV battery model beta value.RvBatteryModelNumOfTerms: The number of terms of the infinite sum for estimating battery level.
WiFi Radio Energy Model
IdleCurrentA: The default radio Idle current in Ampere.CcaBusyCurrentA: The default radio CCA Busy State current in Ampere.TxCurrentA: The radio Tx current in Ampere.RxCurrentA: The radio Rx current in Ampere.SwitchingCurrentA: The default radio Channel Switch current in Ampere.SleepCurrentA: The radio Sleep current in Ampere.TxCurrentModel: A pointer to the attached tx current model.
Basic Energy Harvester
PeriodicHarvestedPowerUpdateInterval: Time between two consecutive periodic updates of the harvested power.HarvestablePower: Random variables that represents the amount of power that is provided by the energy harvester.
๐ Tracing
Traced values differ between Energy Sources, Devices Energy Models and Energy Harvesters implementations โ again, please look at the specific child class for details. ๐
Basic Energy Source
RemainingEnergy: Remaining energy at BasicEnergySource.
RV Battery Model
RvBatteryModelBatteryLevel: RV battery model battery level.RvBatteryModelBatteryLifetime: RV battery model battery lifetime.
WiFi Radio Energy Model
TotalEnergyConsumption: Total energy consumption of the radio device.
Basic Energy Harvester
HarvestedPower: Current power provided by the BasicEnergyHarvester.TotalEnergyHarvested: Total energy harvested by the BasicEnergyHarvester.
โ Validation
Comparison of the Energy Framework against actual devices have not been performed. Current implementation of the Energy Framework is checked numerically for computation errors. The RV battery model is validated by comparing results with what was presented in the original RV battery model paper. ๐ (not in a bad way, just like, that's the honest vibe check)
๐ FLOW MONITOR ๐
๐ธ Model Description ๐ธ
okay bestie, so the source code for this new module lives in the directory src/flow-monitor. ๐
The Flow Monitor module's whole goal is to give you a flexible system to measure the performance of network protocols. It uses probes, installed in network nodes, to track the packets exchanged by the nodes, and it'll measure a whole bunch of parameters for you. Packets get divided according to the flow they belong to, where each flow is defined according to the probe's characteristics โ like, for IP, a flow is defined as the packets with the same {protocol, source (IP, port), destination (IP, port)} tuple. ๐ซถ
The statistics that are collected for each flow can be exported in XML format. And bonus: you can access the probes directly to request specific stats about each flow. โจ
๐ฆ Design ๐ฆ
Flow Monitor is designed in a modular way. You can extend it by subclassing ns3::FlowProbe and ns3::FlowClassifier. Typically, a subclass of ns3::FlowProbe works by listening to the appropriate class Traces, and then uses its own ns3::FlowClassifier subclass to classify the packets passing though each node. ๐
Each Probe can try to listen to other classes traces (e.g., ns3::Ipv4FlowProbe will try to use any ns3::NetDevice trace named TxQueue/Drop) but this is something that the user should not rely into blindly, because the trace is not guaranteed to be in every type of ns3::NetDevice. As an example, CsmaNetDevice and PointToPointNetDevice have a TxQueue/Drop trace, while WiFiNetDevice does not. ๐
The full module design is described in [FlowMonitor].
โจ Scope and Limitations โจ
At the moment, probes and classifiers are available only for IPv4 and IPv6.
IPv4 and IPv6 probes will classify packets in four points:
- When a packet is sent (
SendOutgoing IPv[4,6]traces) - When a packet is forwarded (
UnicastForward IPv[4,6]traces) - When a packet is received (
LocalDeliver IPv[4,6]traces) - When a packet is dropped (
Drop IPv[4,6]traces)
Since the packets are tracked at IP level, any retransmission caused by L4 protocols (e.g., TCP) will be seen by the probe as a new packet. ๐
A Tag will be added to the packet (ns3::Ipv[4,6]FlowProbeTag). The tag will carry basic packet's data, useful for the packet's classification.
It must be underlined that only L4 (TCP, UDP) packets are, so far, classified. Moreover, only unicast packets will be classified. These limitations may be removed in the future.
The data collected for each flow are:
timeFirstTxPacket: when the first packet in the flow was transmitted;timeLastTxPacket: when the last packet in the flow was transmitted;timeFirstRxPacket: when the first packet in the flow was received by an end node;timeLastRxPacket: when the last packet in the flow was received;delaySum: the sum of all end-to-end delays for all received packets of the flow;jitterSum: the sum of all end-to-end delay jitter (delay variation) values for all received packets of the flow, as defined in RFC 3393;txBytes,txPackets: total number of transmitted bytes / packets for the flow;rxBytes,rxPackets: total number of received bytes / packets for the flow;lostPackets: total number of packets that are assumed to be lost (not reported over 10 seconds);timesForwarded: the number of times a packet has been reportedly forwarded;delayHistogram,jitterHistogram,packetSizeHistogram: histogram versions for the delay, jitter, and packet sizes, respectively;packetsDropped,bytesDropped: the number of lost packets and bytes, divided according to the loss reason code (defined in the probe).
It is worth pointing out that the probes measure the packet bytes including IP headers. The L2 headers are not included in the measure. ๐ง
These stats will be written in XML form upon request (see the Usage section).
๐ญ The "lost" packets problem ๐ญ
At the end of a simulation, Flow Monitor could report about "lost" packets, i.e., packets that Flow Monitor have lost track of.
It is important to keep in mind that Flow Monitor records the packets statistics by intercepting them at a given network level โ let's say at IP level. When the simulation ends, any packet queued for transmission below the IP level will be considered as lost. ๐
It is strongly suggested to consider this point when using Flow Monitor. The user can choose to:
- Ignore the lost packets (if their number is a statistically irrelevant quantity), or
- Stop the Applications before the actual Simulation End time, leaving enough time between the two for the queued packets to be processed.
The second method is the suggested one. Usually a few seconds are enough (the exact value depends on the network type). โฐ
It is important to stress that "lost" packets could be anywhere in the network, and could count toward the received packets or the dropped ones. Ideally, their number should be zero or a minimal fraction of the other ones, i.e., they should be "statistically irrelevant". ๐
๐ References ๐
[FlowMonitor]
G. Carneiro, P. Fortuna, and M. Ricardo. 2009. FlowMonitor: a network monitoring framework for the network simulator 3 (NS-3). In Proceedings of the Fourth International ICST Conference on Performance Evaluation Methodologies and Tools (VALUETOOLS '09). http://dx.doi.org/10.4108/ICST.VALUETOOLS2009.7493 (Full text: https://dl.acm.org/doi/abs/10.4108/ICST.VALUETOOLS2009.7493)
๐ Usage ๐
The module usage is extremely simple. The helper will take care of about everything. obsessed.
The typical use is:
// Flow monitor
Ptr<FlowMonitor> flowMonitor;
FlowMonitorHelper flowHelper;
flowMonitor = flowHelper.InstallAll();
-yourApplicationsContainer-.Stop (Seconds (stop_time));;
Simulator::Stop (Seconds(stop_time+cleanup_time));
Simulator::Run ();
flowMonitor->SerializeToXmlFile("NameOfFile.xml", true, true);
the SerializeToXmlFile () function 2nd and 3rd parameters are used respectively to activate/deactivate the histograms and the per-probe detailed stats. Other possible alternatives can be found in the Doxygen documentation, while cleanup_time is the time needed by in-flight packets to reach their destinations. โจ
๐ Helpers ๐
The helper API follows the pattern usage of normal helpers. Through the helper you can install the monitor in the nodes, set the monitor attributes, and print the statistics.
One important thing is: the ns3::FlowMonitorHelper must be instantiated only once in the main. fr fr.
๐ Attributes ๐
The module provides the following attributes in ns3::FlowMonitor:
MaxPerHopDelay(Time, default10s) โ The maximum per-hop delay that should be considered;StartTime(Time, default0s) โ The time when the monitoring starts;DelayBinWidth(double, default0.001) โ The width used in the delay histogram;JitterBinWidth(double, default0.001) โ The width used in the jitter histogram;PacketSizeBinWidth(double, default20.0) โ The width used in the packetSize histogram;FlowInterruptionsBinWidth(double, default0.25) โ The width used in the flowInterruptions histogram;FlowInterruptionsMinTime(double, default0.5) โ The minimum inter-arrival time that is considered a flow interruption.
โญ Output โญ
The main model output is an XML formatted report about flow statistics. An example is:
<?xml version="1.0" ?>
<FlowMonitor>
<FlowStats>
<Flow flowId="1" timeFirstTxPacket="+0.0ns" timeFirstRxPacket="+20067198.0ns" timeLastTxPacket="+2235764408.0ns" timeLastRxPacket="+2255831606.0ns" delaySum="+138731526300.0ns" jitterSum="+1849692150.0ns" lastDelay="+20067198.0ns" txBytes="2149400" rxBytes="2149400" txPackets="3735" rxPackets="3735" lostPackets="0" timesForwarded="7466">
</Flow>
</FlowStats>
<Ipv4FlowClassifier>
<Flow flowId="1" sourceAddress="10.1.3.1" destinationAddress="10.1.2.2" protocol="6" sourcePort="49153" destinationPort="50000" />
</Ipv4FlowClassifier>
<Ipv6FlowClassifier>
</Ipv6FlowClassifier>
<FlowProbes>
<FlowProbe index="0">
<FlowStats flowId="1" packets="3735" bytes="2149400" delayFromFirstProbeSum="+0.0ns" >
</FlowStats>
</FlowProbe>
<FlowProbe index="2">
<FlowStats flowId="1" packets="7466" bytes="2224020" delayFromFirstProbeSum="+199415389258.0ns" >
</FlowStats>
</FlowProbe>
<FlowProbe index="4">
<FlowStats flowId="1" packets="3735" bytes="2149400" delayFromFirstProbeSum="+138731526300.0ns" >
</FlowStats>
</FlowProbe>
</FlowProbes>
</FlowMonitor>
The output was generated by a TCP flow from 10.1.3.1 to 10.1.2.2.
It is worth noticing that the index 2 probe is reporting more packets and more bytes than the other probes. That's a perfectly normal behaviour, as packets are fragmented at IP level in that node. ๐ซถ
It should also be observed that the receiving node's probe (index 4) doesn't count the fragments, as the reassembly is done before the probing point. ๐ฅ
๐ธ Examples ๐ธ
The examples are located in src/flow-monitor/examples.
Moreover, the following examples use the flow-monitor module:
examples/matrix-topology/matrix-topology.ccexamples/routing/manet-routing-compare.ccexamples/routing/simple-global-routing.ccexamples/tcp/tcp-variants-comparison.ccexamples/wireless/multirate.ccexamples/wireless/wifi-hidden-terminal.cc
๐ Troubleshooting ๐
Do not define more than one ns3::FlowMonitorHelper in the simulation. that's it, that's the tip.
๐ Validation ๐
The paper in the references contains a full description of the module validation against a test network.
Tests are provided to ensure the Histogram correct functionality. โจ
๐ INTERNET MODELS (IP, TCP, ROUTING, UDP, INTERNET APPLICATIONS) ๐
๐ฆ Internet Stack ๐ฆ
๐ Internet stack aggregation ๐
A bare class Node is not very useful as-is; other objects must be aggregated to it to provide useful node functionality.
The ns-3 source code directory src/internet provides implementation of TCP/IPv4- and IPv6-related components. These include IPv4, ARP, UDP, TCP, IPv6, Neighbor Discovery, and other related protocols.
Internet Nodes are not subclasses of class Node; they are simply Nodes that have had a bunch of IP-related objects aggregated to them. They can be put together by hand, or via a helper function InternetStackHelper::Install () which does the following to all nodes passed in as arguments:
okay so bestie, buckle up because this is the part where we peek under the hood of an IP-capable Node and see how the whole stack gets glued together. ๐
void
InternetStackHelper::Install (Ptr<Node> node) const
{
if (m_ipv4Enabled)
{
/* IPv4 stack */
if (node->GetObject<Ipv4> () != 0)
{
NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating "
"an InternetStack to a node with an existing Ipv4 object");
return;
}
CreateAndAggregateObjectFromTypeId (node, "ns3::ArpL3Protocol");
CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv4L3Protocol");
CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv4L4Protocol");
// Set routing
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
Ptr<Ipv4RoutingProtocol> ipv4Routing = m_routing->Create (node);
ipv4->SetRoutingProtocol (ipv4Routing);
}
if (m_ipv6Enabled)
{
/* IPv6 stack */
if (node->GetObject<Ipv6> () != 0)
{
NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating "
"an InternetStack to a node with an existing Ipv6 object");
return;
}
CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv6L3Protocol");
CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv6L4Protocol");
// Set routing
Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
Ptr<Ipv6RoutingProtocol> ipv6Routing = m_routingv6->Create (node);
ipv6->SetRoutingProtocol (ipv6Routing);
/* register IPv6 extensions and options */
ipv6->RegisterExtensions ();
ipv6->RegisterOptions ();
}
if (m_ipv4Enabled || m_ipv6Enabled)
{
/* UDP and TCP stacks */
CreateAndAggregateObjectFromTypeId (node, "ns3::UdpL4Protocol");
node->AggregateObject (m_tcpFactory.Create<Object> ());
Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
node->AggregateObject (factory);
}
}
the way that ns-3 has multiple implementations of stuff (TCP, IP routing) means those objects get bolted on by a factory object (that's TCP's job) or by a routing helper (that's m_routing, obviously). ๐ซถ
ngl the routing protocol is configured and set outside this function โ not here. And by default, these protocols are the ones that show up:
void InternetStackHelper::Initialize ()
{
SetTcp ("ns3::TcpL4Protocol");
Ipv4StaticRoutingHelper staticRouting;
Ipv4GlobalRoutingHelper globalRouting;
Ipv4ListRoutingHelper listRouting;
Ipv6ListRoutingHelper listRoutingv6;
Ipv6StaticRoutingHelper staticRoutingv6;
listRouting.Add (staticRouting, 0);
listRouting.Add (globalRouting, -10);
listRoutingv6.Add (staticRoutingv6, 0);
SetRoutingHelper (listRouting);
SetRoutingHelper (listRoutingv6);
}
And by default, IPv4 and IPv6 are enabled. both. at once. iconic. ๐
โจ Internet Node structure โจ
An IP-capable Node โ that's an ns-3 Node that got augmented by aggregation so it has one or more IP stacks โ has the internal structure below. ๐
๐ธ Layer-3 protocols ๐ธ
Down at the very lowest layer, chillin' right above the NetDevices, live the "layer 3" protocols: IPv4, IPv6, ARP and friends. The class Ipv4L3Protocol is an implementation class whose public interface is normally class Ipv4, but fr fr the Ipv4L3Protocol public API is also used internally right now.
Inside class Ipv4L3Protocol, one method is called Receive (), and it goes like this:
/**
* Lower layer calls this method after calling L3Demux::Lookup
* The ARP subclass needs to know from which NetDevice this
* packet is coming to:
* - implement a per-NetDevice ARP cache
* - send back arp replies on the right device
*/
void Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol,
const Address &from, const Address &to, NetDevice::PacketType packetType);
first things first: Receive () has a signature that matches the ReceiveCallback in class Node. This function pointer gets inserted into the Node's protocol handler when AddInterface () is called. The actual registration happens with a statement like this one:
RegisterProtocolHandler ( MakeCallback (&Ipv4Protocol::Receive, ipv4),
Ipv4L3Protocol::PROT_NUMBER, 0);
The Ipv4L3Protocol object is aggregated to the Node, and there is only one such Ipv4L3Protocol object. Higher-layer protocols that have a packet to send down to the Ipv4L3Protocol object can call GetObject<Ipv4L3Protocol> () to grab a pointer, like so:
Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> ();
if (ipv4 != 0)
{
ipv4->Send (packet, saddr, daddr, PROT_NUMBER);
}
This class is literally the poster child for two techniques ns-3 uses to bind objects together: callbacks and object aggregation. ๐
Once IPv4 routing has decided that a packet is for the local node, it forwards that packet up the stack. That's this function's whole job:
void
Ipv4L3Protocol::LocalDeliver (Ptr<const Packet> packet, Ipv4Header const&ip, uint32_t iif)
Step one: find the right Ipv4L4Protocol object, based on the IP protocol number. For example, TCP is registered in the demux as protocol number 6. And finally, the Receive() function on the Ipv4L4Protocol (like TcpL4Protocol::Receive) gets called.
We haven't introduced class Ipv4Interface yet. Basically, every NetDevice is paired with an IPv4 representation of that device. On Linux, this class Ipv4Interface roughly corresponds to the struct in_device; its main purpose is to hand over address-family specific info (the addresses) about an interface.
All these classes have the appropriate traces so you can track sent, received and lost packets. You're encouraged to use them so you can find out if (and where) a packet gets dropped. A super common mistake is forgetting about the effects of local queues when sending packets โ like, say, the ARP queue. This gets especially confusing when you're sending jumbo packets or packet bursts with UDP. The ARP cache pending queue is limited (3 datagrams) and IP packets might be fragmented, which easily overfills the ARP cache queue size. When that happens, it's useful to bump the ARP cache pending size up to a proper value, e.g.:
Config::SetDefault ("ns3::ArpCache::PendingQueueSize", UintegerValue (MAX_BURST_SIZE/L2MTU*3));
The IPv6 implementation follows a similar architecture. Dual-stacked nodes (ones with support for both IPv4 and IPv6) will let an IPv6 socket receive IPv4 connections, just like a standard dual-stacked system does. A socket bound and listening to an IPv6 endpoint can receive an IPv4 connection and will return the remote address as an IPv4-mapped address. Support for the IPV6_V6ONLY socket option does not currently exist. ๐ญ
๐ฆ Layer-4 protocols and sockets ๐ฆ
Next up: how the transport protocols, sockets, and applications all tie together. Short version โ every transport protocol implementation is a socket factory. An application that needs a new socketโฆ
For example, to create a UDP socket, an application would use a code snippet like this:
Ptr<Udp> udpSocketFactory = GetNode ()->GetObject<Udp> ();
Ptr<Socket> m_socket = socketFactory->CreateSocket ();
m_socket->Bind (m_local_address);
...
The above queries the node to get a pointer to its UDP socket factory, creates one such socket, and then uses that socket with an API similar to the C-based sockets API, like Connect () and Send (). The address you pass to the Bind (), Connect (), or Send () functions may be an Ipv4Address, an Ipv6Address, or an Address. If an Address gets passed in and contains anything other than an Ipv4Address or Ipv6Address, these functions will return an error. And the Bind (void) and Bind6 (void) functions bind to "0.0.0.0" and "::" respectively.
The socket can also be bound to a specific NetDevice through the BindToNetDevice (Ptr<NetDevice> netdevice) function. BindToNetDevice (Ptr<NetDevice> netdevice) will bind the socket to "0.0.0.0" and "::" (equivalent to calling Bind () and Bind6 ()), unless the socket has already been bound to a specific address. To summarize, the correct sequence is:
Ptr<Udp> udpSocketFactory = GetNode ()->GetObject<Udp> ();
Ptr<Socket> m_socket = socketFactory->CreateSocket ();
m_socket->BindToNetDevice (n_netDevice);
...
or:
Ptr<Udp> udpSocketFactory = GetNode ()->GetObject<Udp> ();
Ptr<Socket> m_socket = socketFactory->CreateSocket ();
m_socket->Bind (m_local_address);
m_socket->BindToNetDevice (n_netDevice);
...
The following raises an error ๐จ:
Ptr<Udp> udpSocketFactory = GetNode ()->GetObject<Udp> ();
Ptr<Socket> m_socket = socketFactory->CreateSocket ();
m_socket->BindToNetDevice (n_netDevice);
m_socket->Bind (m_local_address);
...
See the chapter on ns-3 sockets for more information.
So far we've described a socket factory (e.g. class Udp) and a socket, which may be specialized (e.g. class UdpSocket). There are a few more key objects involved in the very specialized task of demultiplexing a packet to one or more receiving sockets. The main character here is class Ipv4EndPointDemux. โจ This demultiplexer stores objects of class Ipv4EndPoint. This class holds the addressing/port tuple (local port, local address, destination port, destination address) associated with the socket, plus a receive callback. That receive callback has a receive function registered by the socket. The Lookup () function on Ipv4EndPointDemux returns a list of Ipv4EndPoint objects (there may be a list because more than one socket may match the packet). The layer-4 protocol copies the packet to each Ipv4EndPoint and calls its ForwardUp () method, which then calls the Receive () function registered by the socket.
An issue that comes up when working with the sockets API on real systems is the need to manage reading from a socket, using some type of I/O (e.g., blocking, non-blocking, asynchronous, โฆ). ns-3 implements an asynchronous model for socket I/O; the application sets a callback to get notified when received data is ready to be read, and that callback gets invoked by the transport protocol when data is available. This callback is specified like this:
void Socket::SetRecvCallback (Callback<void, Ptr<Socket>,
Ptr<Packet>,
const Address&> receivedData);
The data being received is conveyed in the Packet data buffer. An example usage is in class PacketSink:
m_socket->SetRecvCallback (MakeCallback(&PacketSink::HandleRead, this));
To summarize, internally, the UDP implementation is organized as follows: ๐โจ
โฆaaaand now the UDP side of the family, because she's got a whole squad ๐
- a
UdpImplclass that implements the UDP socket factory functionality - a
UdpL4Protocolclass that implements the protocol logic that is socket-independent - a
UdpSocketImplclass that implements socket-specific aspects of UDP - a class called
Ipv4EndPointthat stores the addressing tuple (local port, local address, destination port, destination address) associated with the socket, and a receive callback for the socket.
IP-capable node interfaces ๐ซถ
Okay so plot twist: a LOT of the implementation details โ or even the internal objects themselves โ of IP-capable Node objects are not exposed at the simulator public API. And that's on purpose, bestie, because it lets people swap in different implementations. Like, for instance, replacing the native ns-3 models with ported TCP/IP stack code. Iconic flexibility, no cap.
The C++ public APIs of all of these objects live in the src/network directory, including principally:
address.hsocket.hnode.hpacket.h
These are typically base class objects that implement the default values used in the implementation, implement access methods to get/set state variables, host attributes, and implement publicly-available methods exposed to clients such as CreateSocket. It's giving โจarchitectureโจ.
Example path of a packet ๐
These two figures show an example stack trace of how packets flow through the Internet Node objects.
- [image] Send path of a packet..UNINDENT
- [image] Receive path of a packet..UNINDENT
IPv4 ๐
This chapter describes the ns-3 IPv4 address assignment and basic components tracking.
IPv4 addresses assignment
So in order to use IPv4 on a network, the very first thing you gotta do is assign IPv4 addresses. Obviously. ๐
Any IPv4-enabled ns-3 node will have at least one NetDevice: the ns3::LoopbackNetDevice. The loopback device address is 127.0.0.1. All the other NetDevices will have one (or more) IPv4 addresses.
Heads up bestie: as today, ns-3 does not have a NAT module, and it does not follow the rules about filtering private addresses (RFC 1918):10.0.0.0/8,172.16.0.0/12, and192.168.0.0/16. These addresses are routed as any other address. This behaviour could change in the future. ๐
IPv4 global addresses can be:
- manually assigned
- assigned though DHCP
ns-3 can use both methods, and it's quite important to understand the implications of both. Like, actually important. Not just vibes.
Manually assigned IPv4 addresses ๐
This is probably the easiest and most used method. As an example:
Ptr<Node> n0 = CreateObject<Node> ();
Ptr<Node> n1 = CreateObject<Node> ();
NodeContainer net (n0, n1);
CsmaHelper csma;
NetDeviceContainer ndc = csma.Install (net);
NS_LOG_INFO ("Assign IPv4 Addresses.");
Ipv4AddressHelper ipv4;
ipv4.SetBase (Ipv4Address ("192.168.1.0"), NetMask ("/24"));
Ipv4InterfaceContainer ic = ipv4.Assign (ndc);
This method will add two global IPv4 addresses to the nodes.
Note that the addresses are assigned in sequence. As a consequence, the first Node / NetDevice will have โ192.168.1.1โ, the second โ192.168.1.2โ and so on. Cute and orderly, we love a deterministic queen. ๐
It is possible to repeat the above to assign more than one address to a node. However, due to the Ipv4AddressHelper singleton nature, one should first assign all the addresses of a network, then change the network base (SetBase), then do a new assignment. Don't skip steps, bestie, the singleton is watching. ๐
Alternatively, it is possible to assign a specific address to a node:
Ptr<Node> n0 = CreateObject<Node> ();
NodeContainer net (n0);
CsmaHelper csma;
NetDeviceContainer ndc = csma.Install (net);
NS_LOG_INFO ("Specifically Assign an IPv4 Address.");
Ipv4AddressHelper ipv4;
Ptr<NetDevice> device = ndc.Get (0);
Ptr<Node> node = device->GetNode ();
Ptr<Ipv4> ipv4proto = node->GetObject<Ipv4> ();
int32_t ifIndex = 0;
ifIndex = ipv4proto->GetInterfaceForDevice (device);
Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("192.168.1.42"), NetMask ("/24"));
ipv4proto->AddAddress (ifIndex, ipv4Addr);
DHCP assigned IPv4 addresses ๐
DHCP is available in the internet-apps module. In order to use DHCP you have to have a DhcpServer application in a node (the DHC server node) and a DhcpClient application in each of the nodes. Note that it not necessary that all the nodes in a subnet use DHCP. Some nodes can have static addresses. Mix and match, we support the chaos. ๐ฆ
All the DHCP setup is performed though the DhcpHelper class. A complete example is in src/internet-apps/examples/dhcp-example.cc.
Further info about the DHCP functionalities can be found in the internet-apps model documentation.
Tracing in the IPv4 Stack ๐
The internet stack provides a number of trace sources in its various protocol implementations. These trace sources can be hooked using your own custom trace code, or you can use our helper functions in some cases to arrange for tracing to be enabled. Either way, the tea is getting collected. ๐
Tracing in ARP
ARP provides two trace hooks, one in the cache, and one in the layer three protocol. The trace accessor in the cache is given the name โDrop.โ When a packet is transmitted over an interface that requires ARP, it is first queued for transmission in the ARP cache until the required MAC address is resolved. There are a number of retries that may be done trying to get the address, and if the maximum retry count is exceeded the packet in question is dropped by ARP. The single trace hook in the ARP cache is called,
- If an outbound packet is placed in the ARP cache pending address resolution and no resolution can be made within the maximum retry count, the outbound packet is dropped and this trace is fired;
A second trace hook lives in the ARP L3 protocol (also named โDropโ) and may be called for a number of reasons.
- If an ARP reply is received for an entry that is not waiting for a reply, the ARP reply packet is dropped and this trace is fired;
- If an ARP reply is received for a non-existent entry, the ARP reply packet is dropped and this trace is fired;
- If an ARP cache entry is in the
DEADstate (has timed out) and an ARP reply packet is received, the reply packet is dropped and this trace is fired. - Each ARP cache entry has a queue of pending packets. If the size of the queue is exceeded, the outbound packet is dropped and this trace is fired.
Tracing in IPv4
The IPv4 layer three protocol provides three trace hooks. These are the โTxโ (ns3::Ipv4L3Protocol::m_txTrace), โRxโ (ns3::Ipv4L3Protocol::m_rxTrace) and โDropโ (ns3::Ipv4L3Protocol::m_dropTrace) trace sources.
The โTxโ trace is fired in a number of situations, all of which indicate that a given packet is about to be sent down to a given ns3::Ipv4Interface.
- In the case of a packet destined for the broadcast address, the
Ipv4InterfaceListis iterated and for every interface that is up and can fragment the packet or has a large enough MTU to transmit the packet, the trace is hit. Seens3::Ipv4L3Protocol::Send. - In the case of a packet that needs routing, the โ
Txโ trace may be fired just before a packet is sent to the interface appropriate to the default gateway. Seens3::Ipv4L3Protocol::SendRealOut. - Also in the case of a packet that needs routing, the โ
Txโ trace may be fired just before a packet is sent to the outgoing interface appropriate to the discovered route. Seens3::Ipv4L3Protocol::SendRealOut.
The โRxโ trace is fired when a packet is passed from the device up to the ns3::Ipv4L3Protocol::Receive function.
- In the receive function, the
Ipv4InterfaceListis iterated, and if theIpv4Interfacecorresponding to the receiving device is found to be in theUPstate, the trace is fired.
The โDropโ trace is fired in any case where the packet is dropped (in both the transmit and receive paths). It's giving main character energy but make it tragic. ๐
- In the
ns3::Ipv4Interface::Receivefunction, the packet is dropped and the drop trace is hit if the interface corresponding to the receiving device is in theDOWNstate. - Also in the
ns3::Ipv4Interface::Receivefunction, the packet is dropped and the drop trace is hit if the checksum is found to be bad. - In
ns3::Ipv4L3Protocol::Send, an outgoing packet bound for the broadcast address is dropped and the โDropโ trace is fired if the โdon't fragmentโ bit is set and fragmentation is available and required. - Also in
ns3::Ipv4L3Protocol::Send, an outgoing packet destined for the broadcast address is dropped and the โDropโ trace is hit if fragmentation is not available and is required (MTU < packet size). - In the case of a broadcast address, an outgoing packet is cloned for each outgoing interface. If any of the interfaces is in the
DOWNstate, the โDropโ trace event fires with a reference to the copied packet. - In the case of a packet requiring a route, an outgoing packet is dropped and the โ
Dropโ trace event fires if no route to the remote host is found. - In
ns3::Ipv4L3Protocol::SendRealOut, an outgoing packet being routed is dropped and the โDropโ trace is fired if the โdon't fragmentโ bit is set and fragmentation is available and required. - Also in
ns3::Ipv4L3Protocol::SendRealOut, an outgoing packet being routed is dropped and the โDropโ trace is hit if fragmentation is not available and is required (MTU < packet size). - An outgoing packet being routed is dropped and the โ
Dropโ trace event fires if the requiredIpv4Interfaceis in theDOWNstate. - If a packet is being forwarded, and the TTL is exceeded (see
ns3::Ipv4L3Protocol::DoForward), the packet is dropped and the โDropโ trace event is fired.
Explicit Congestion Notification (ECN) bits ๐ธ
- In IPv4, ECN bits are the last 2 bits in TOS field and occupy 14th and 15th bits in the header.
- The IPv4 header class defines an
EcnTypeenum with all four ECN codepoints (ECN_NotECT,ECN_ECT1,ECN_ECT0,ECN_CE) mentioned in RFC 3168, and also a setter and getter method to handle ECN values in the TOS field.
Ipv4QueueDiscItem ๐ง
The traffic control sublayer in ns-3 handles objects of class QueueDiscItem which are used to hold an ns3::Packet and an ns3::Header. This is done to facilitate the marking of packets for Explicit Congestion Notification. The Mark () method is implemented in Ipv4QueueDiscItem. It returns true if marking the packet is successful, i.e., it successfully sets the CE bit in the IPv4 header. The Mark () method will return false, however, if the IPv4 header indicates the ECN_NotECT codepoint.
๐ RFC 6621 duplicate packet detection ๐ฐ๏ธ
okay so bestie, if ur doing mesh network protocols over broadcast-capable networks (like, say, Wi-Fi ๐), you're literally gonna want duplicate packet detection and filtering in ur life, because nodes in a network may receive multiple copies of flooded multicast packets arriving on different paths. messy, ik.
The Ipv4L3Protocol model in ns-3 has a model for hash-based duplicate packet detection (DPD) based on Section 6.2.2 of (RFC 6621). The model is disabled by default โ no cap โ and must be enabled by setting EnableRFC6621 to true. โจ
There's a second attribute too: DuplicateExpire sets the expiration delay for erasing the cache entry of a packet in the duplicate cache, and that delay value defaults to 1ms. periodt.
๐ IPv6 ๐
This chapter describes the ns-3 IPv6 model capabilities and limitations along with its usage and examples.
๐ฆ IPv6 model description ๐ฆ
The IPv6 model is loosely patterned after the Linux implementation. lowkey it is not complete โ some features of IPv6 are not of much interest to simulation studies, and some features of IPv6 are simply not modeled yet in ns-3. it's giving work-in-progress energy, fr fr.
The base class Ipv6 defines a generic API, while the class Ipv6L3Protocol is the actual class implementing the protocol. The actual classes used by the IPv6 stack are located mainly in the directory src/internet. ๐๏ธ
The implementation of IPv6 is contained in the following files:
src/internet/model/icmpv6-header.{cc,h}
src/internet/model/icmpv6-l4-protocol.{cc,h}
src/internet/model/ipv6.{cc,h}
src/internet/model/ipv6-address-generator.{cc,h}
src/internet/model/ipv6-autoconfigured-prefix.{cc,h}
src/internet/model/ipv6-end-point.{cc,h}
src/internet/model/ipv6-end-point-demux.{cc,h}
src/internet/model/ipv6-extension.{cc,h}
src/internet/model/ipv6-extension-demux.{cc,h}
src/internet/model/ipv6-extension-header.{cc,h}
src/internet/model/ipv6-header.{cc,h}
src/internet/model/ipv6-interface.{cc,h}
src/internet/model/ipv6-interface-address.{cc,h}
src/internet/model/ipv6-l3-protocol.{cc,h}
src/internet/model/ipv6-list-routing.{cc,h}
src/internet/model/ipv6-option.{cc,h}
src/internet/model/ipv6-option-demux.{cc,h}
src/internet/model/ipv6-option-header.{cc,h}
src/internet/model/ipv6-packet-info-tag.{cc,h}
src/internet/model/ipv6-pmtu-cache.{cc,h}
src/internet/model/ipv6-raw-socket-factory.{cc,h}
src/internet/model/ipv6-raw-socket-factory-impl.{cc,h}
src/internet/model/ipv6-raw-socket-impl.{cc,h}
src/internet/model/ipv6-route.{cc,h}
src/internet/model/ipv6-routing-protocol.{cc,h}
src/internet/model/ipv6-routing-table-entry.{cc,h}
src/internet/model/ipv6-static-routing.{cc,h}
src/internet/model/ndisc-cache.{cc,h}
src/network/utils/inet6-socket-address.{cc,h}
src/network/utils/ipv6-address.{cc,h}
Also some helpers are involved with IPv6:
src/internet/helper/internet-stack-helper.{cc,h}
src/internet/helper/ipv6-address-helper.{cc,h}
src/internet/helper/ipv6-interface-container.{cc,h}
src/internet/helper/ipv6-list-routing-helper.{cc,h}
src/internet/helper/ipv6-routing-helper.{cc,h}
src/internet/helper/ipv6-static-routing-helper.{cc,h}
The model files can be roughly divided into:
- protocol models (e.g.,
ipv6,ipv6-l3-protocol,icmpv6-l4-protocol, etc.) - routing models (i.e., anything with 'routing' in its name)
- sockets and interfaces (e.g.,
ipv6-raw-socket,ipv6-interface,ipv6-end-point, etc.) - address-related things
- headers, option headers, extension headers, etc.
- accessory classes (e.g.,
ndisc-cache)
๐ Usage ๐
The following description is based on using the typical helpers found in the example code.
IPv6 does not need to be activated in a node. it is automatically added to the available protocols once the Internet Stack is installed. iconic behaviour tbh.
In order to not install IPv6 along with IPv4, it is possible to use ns3::InternetStackHelper method SetIpv6StackInstall (bool enable) before installing the InternetStack in the nodes.
Note that to have an IPv6-only network (i.e., to not install the IPv4 stack in a node) one should use ns3::InternetStackHelper method SetIpv4StackInstall (bool enable) before the stack installation.
As an example, in the following code node 0 will have both IPv4 and IPv6, node 1 only IPv6 and node 2 only IPv4:
NodeContainer n;
n.Create (3);
InternetStackHelper internet;
InternetStackHelper internetV4only;
InternetStackHelper internetV6only;
internetV4only.SetIpv6StackInstall (false);
internetV6only.SetIpv4StackInstall (false);
internet.Install (n.Get (0));
internetV6only.Install (n.Get (1));
internetV4only.Install (n.Get (2));
๐ธ IPv6 addresses assignment ๐ธ
In order to use IPv6 on a network, the first thing to do is assigning IPv6 addresses. literally step one, bestie.
Any IPv6-enabled ns-3 node will have at least one NetDevice: the ns3::LoopbackNetDevice. The loopback device address is ::1. All the other NetDevices will have one or more IPv6 addresses:
- One link-local address:
fe80::interface ID, whereinterface IDis derived from the NetDevice MAC address. - Zero or more global addresses, e.g.,
2001:db8::1.
Typically the first address on an interface will be the link-local one, with the global address(es) being the following ones.
IPv6 global addresses might be:
- manually assigned
- auto-generated
ns-3 can use both methods, and it's quite important to understand the implications of both. ๐
๐ Manually assigned IPv6 addresses ๐
This is probably the easiest and most used method. As an example:
Ptr<Node> n0 = CreateObject<Node> ();
Ptr<Node> n1 = CreateObject<Node> ();
NodeContainer net (n0, n1);
CsmaHelper csma;
NetDeviceContainer ndc = csma.Install (net);
NS_LOG_INFO ("Assign IPv6 Addresses.");
Ipv6AddressHelper ipv6;
ipv6.SetBase (Ipv6Address ("2001:db8::"), Ipv6Prefix (64));
Ipv6InterfaceContainer ic = ipv6.Assign (ndc);
This method will add two global IPv6 addresses to the nodes. Note that, as usual for IPv6, all the nodes will also have a link-local address. Typically the first address on an interface will be the link-local one, with the global address(es) being the following ones.
Note that the global addresses will be derived from the MAC address. As a consequence, expect to have addresses similar to 2001:db8::200:ff:fe00:1.
It is possible to repeat the above to assign more than one global address to a node. However, due to the Ipv6AddressHelper singleton nature, one should first assign all the addresses of a network, then change the network base (SetBase), then do a new assignment.
Alternatively, it is possible to assign a specific address to a node:
Ptr<Node> n0 = CreateObject<Node> ();
NodeContainer net (n0);
CsmaHelper csma;
NetDeviceContainer ndc = csma.Install (net);
NS_LOG_INFO ("Specifically Assign an IPv6 Address.");
Ipv6AddressHelper ipv6;
Ptr<NetDevice> device = ndc.Get (0);
Ptr<Node> node = device->GetNode ();
Ptr<Ipv6> ipv6proto = node->GetObject<Ipv6> ();
int32_t ifIndex = 0;
ifIndex = ipv6proto->GetInterfaceForDevice (device);
Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:db8:f00d:cafe::42"), Ipv6Prefix (64));
ipv6proto->AddAddress (ifIndex, ipv6Addr);
โจ Auto-generated IPv6 addresses โจ
This is accomplished by relying on the RADVD protocol, implemented by the class Radvd. A helper class is available, which can be used to ease the most common tasks, e.g., setting up a prefix on an interface, if it is announced periodically, and if the router is the default router for that interface.
A fine grain configuration is possible though the RadvdInterface class, which allows to setup every parameter of the announced router advertisement on a given interface.
It is worth mentioning that the configurations must be set up before installing the application in the node. โ ๏ธ
Upon using this method, the nodes will acquire dynamically (i.e., during the simulation) one (or more) global address(es) according to the RADVD configuration. These addresses will be bases on the RADVD announced prefix and the node's EUI-64.
Examples of RADVD use are shown in examples/ipv6/radvd.cc and examples/ipv6/radvd-two-prefix.cc.
Note that the router (i.e., the node with Radvd) will have to have a global address, while the nodes using the auto-generated addresses (SLAAC) will have to have a link-local address. This is accomplished using Ipv6AddressHelper::AssignWithoutAddress, e.g.:
Ipv6AddressHelper ipv6;
NetDeviceContainer tmp;
tmp.Add (d1.Get (0)); /* n0 */
Ipv6InterfaceContainer iic1 = ipv6.AssignWithoutAddress (tmp); /* n0 interface */
๐ซถ Random-generated IPv6 addresses ๐ซถ
While IPv6 real nodes will use randomly generated addresses to protect privacy, ns-3 does NOT have this capability. This feature haven't been so far considered as interesting for simulation.
๐ฅ Networks with and without the onlink property ๐ฅ
IPv6 adds the concept of "on-link" for addresses and prefixes. Simplifying the concept, a network with the on-link property behaves roughly as IPv4: a node will assume that any address belonging to the on-link prefix is reachable on the link, so it uses Neighbor Discovery Protocol (NDP) to find the MAC address corresponding to the IPv6 address. If the prefix is not marked as "on-link", then any packet is sent to the default router.
Radvd can announce prefixes that have the on-link flag not set. Moreover, it is possible to add an address to a node without setting the on-link property for the prefix used in the address. The function to use is Ipv6AddressHelper::AssignWithoutOnLink.
๐ Duplicate Address Detection (DAD) ๐
Nodes will perform DAD (it can be disabled using an Icmpv6L4Protocol attribute). Upon receiving a DAD, however, nodes will not react to it. As is: DAD reaction is incomplete so far. The main reason relies on the missing random-generated address capability. Moreover, since ns-3 nodes will usually be well-behaving, there shouldn't be any Duplicate Address. This might be changed in the future, so as to avoid issues with real-world integrated simulations.
โญ Explicit Congestion Notification (ECN) bits in IPv6 โญ
- In IPv6, ECN bits are the last 2 bits of the Traffic class and occupy 10th and 11th bit in the header.
- The IPv6 header class defines an
EcnTypeenum with all four ECN codepoints (ECN_NotECT,ECN_ECT1,ECN_ECT0,ECN_CE) mentioned in RFC 3168, and also a setter and getter method to handle ECN values in the Traffic Class field.
Ipv6QueueDiscItem ๐
ok so the traffic control sublayer in ns-3 handles objects of class QueueDiscItem, and those cuties are what hold an ns3::Packet and an ns3::Header. Why tho? To make it easy to mark packets for Explicit Congestion Notification, bestie. That's the whole point.
The Mark () method lives in Ipv6QueueDiscItem. It returns true if marking the packet worked, i.e. it successfully set the CE bit in the IPv6 header. But โ plot twist โ Mark () returns false if the IPv6 header says the codepoint is ECN_NotECT. ๐
Host and Router behaviour in IPv6 and ns-3 ๐ฆ
In IPv6 there's a very clear line between routers and hosts. Like, routers can forward packets from one interface to another, while hosts just drop packets that aren't directed at them. no cap.
But here's the thing: forwarding is not the only thing this distinction messes with, and even forwarding itself can be fine-tuned โ e.g. you can forward packets coming in from one interface and drop packets from another one. โจ
In ns-3 a node is configured to be a host by default. There are two main ways to change that:
- Using
ns3::Ipv6InterfaceContainer SetForwarding(uint32_t i, bool router)whereiis the interface index in the container. - Changing the
ns3::Ipv6attributeIpForward.
Either one can be used during the simulation. ๐ซถ
And if you want a fine-grained setup, use ns3::Ipv6Interface SetForwarding (bool forward); which lets you change the behaviour on a per-interface basis. iconic.
Heads up: the node-wide configuration is really just a convenient way to enable/disable thens3::Ipv6Interfacespecific setting. AnIpv6Interfaceadded to a node with forwarding enabled will be set to forwarding too. This matters a LOT when a node has interfaces added during the simulation. ๐
According to the ns3::Ipv6Interface forwarding state, here's what goes down:
- Forwarding OFF
- The node will NOT reply to Router Solicitation
- The node will react to Router Advertisement
- The node will periodically send Router Solicitation
- Routing protocols MUST DROP packets not directed to the node
- Forwarding ON
- The node will reply to Router Solicitation
- The node will NOT react to Router Advertisement
- The node will NOT send Router Solicitation
- Routing protocols MUST forward packets
This behaviour matches ip-sysctl.txt (http://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt) with the difference that it's not possible to override the behaviour using esoteric settings (e.g., forwarding but accept router advertisements, accept_ra=2, or forwarding but send router solicitations forwarding=2). periodt.
Consider carefully the implications of packet forwarding, bestie. For example, a node will NOT send ICMPv6 PACKET_TOO_BIG messages from an interface with forwarding off. That's completely normal, since the Routing protocol will drop the packet before attempting to forward it. ๐
Helpers ๐ง
Typically the helpers used in IPv6 setup are:
ns3::InternetStackHelperns3::Ipv6AddressHelperns3::Ipv6InterfaceContainer
The use is almost identical to the corresponding IPv4 case, e.g.:
NodeContainer n;
n.Create (4);
NS_LOG_INFO ("Create IPv6 Internet Stack");
InternetStackHelper internetv6;
internetv6.Install (n);
NS_LOG_INFO ("Create channels.");
CsmaHelper csma;
NetDeviceContainer d = csma.Install (n);
NS_LOG_INFO ("Create networks and assign IPv6 Addresses.");
Ipv6AddressHelper ipv6;
ipv6.SetBase (Ipv6Address ("2001:db8::"), Ipv6Prefix (64));
Ipv6InterfaceContainer iic = ipv6.Assign (d);
Additionally, a common task is to enable forwarding on one of the nodes and to setup a default route toward it in the other nodes, e.g.:
iic.SetForwarding (0, true);
iic.SetDefaultRouteInAllNodes (0);
This will enable forwarding on the node 0 and will setup a default route in ns3::Ipv6StaticRouting on all the other nodes. Note that this requires that Ipv6StaticRouting is present in the nodes. ๐
The IPv6 routing helpers enable the user to perform specific tasks on the particular routing algorithm and to print the routing tables.
Attributes ๐ธ
Many classes in the ns-3 IPv6 implementation contain attributes. The most useful ones are:
ns3::Ipv6IpForward, boolean, defaultfalse. Globally enable or disable IP forwarding for all current and future IPv6 devices.MtuDiscover, boolean, defaulttrue. If disabled, every interface will have its MTU set to 1280 bytes.
ns3::Ipv6L3ProtocolDefaultTtl,uint8_t, default64. The TTL value set by default on all outgoing packets generated on this node.SendIcmpv6Redirect, boolean, defaulttrue. Send the ICMPv6 Redirect when appropriate.
ns3::Icmpv6L4ProtocolDAD, boolean, defaulttrue. Always do DAD (Duplicate Address Detection) check.
ns3::NdiscCacheUnresolvedQueueSize,uint32_t, default3. Size of the queue for packets pending an NA reply.
Output โญ
The IPv6 stack provides some useful trace sources:
ns3::Ipv6L3ProtocolTx, Send IPv6 packet to outgoing interface.Rx, Receive IPv6 packet from incoming interface.Drop, Drop IPv6 packet.
ns3::Ipv6ExtensionDrop, Drop IPv6 packet.
The latest trace source is generated when a packet contains an unknown option blocking its processing. ๐
Mind that ns3::NdiscCache could drop packets as well, and they are not logged in a trace source (yet). This might generate some confusion in the sent/received packets counters. ๐ญ
Advanced Usage ๐
IPv6 maximum transmission unit (MTU) and fragmentation ๐ซ
ns-3 NetDevices define the MTU according to the L2 simulated Device. IPv6 requires that the minimum MTU is 1280 bytes, so all NetDevices are required to support at least this MTU. This is the link-MTU.
In order to support different MTUs in a source-destination path, ns-3 IPv6 model can perform fragmentation. This can be either triggered by receiving a packet bigger than the link-MTU from the L4 protocols (UDP, TCP, etc.), or by receiving an ICMPv6 PACKET_TOO_BIG message. The model mimics RFC 1981, with the following notable exceptions:
- L4 protocols are not informed of the Path MTU change
- TCP can not change its Segment Size according to the Path-MTU.
Both limitations are going to be removed in due time. fr fr.
The Path-MTU cache is currently based on the source-destination IPv6 addresses. Further classifications (e.g., flow label) are possible but not yet implemented.
The Path-MTU default validity time is 10 minutes. After the cache entry expiration, the Path-MTU information is removed and the next packet will (eventually) trigger a new ICMPv6 PACKET_TOO_BIG message. Note that 1) this is consistent with the RFC specification and 2) L4 protocols are responsible for retransmitting the packets. ๐ซก
Examples ๐
The examples for IPv6 are in the directory examples/ipv6. These examples focus on the most interesting IPv6 peculiarities, such as fragmentation, redirect and so on. โจ
Moreover, most TCP and UDP examples located in examples/udp, examples/tcp, etc. have a command-line option to use IPv6 instead of IPv4.
Troubleshooting ๐ฉน
There are just a few pitfalls to avoid while using ns-3 IPv6.
Routing loops ๐
Since the only (so far) routing scheme available for IPv6 is ns3::Ipv6StaticRouting, default router have to be setup manually. When there are two or more routers in a network (e.g., node A and node B), avoid using the helper function SetDefaultRouteInAllNodes for more than one router.
The consequence would be to install a default route to B in A and a default route pointing to A in B, generating a loop. ๐
Global address leakage ๐จ
Remember that addresses in IPv6 are global by definition. When using IPv6 with an emulation ns-3 capability, avoid at all costs address leakage toward the global Internet. It is advisable to setup an external firewall to prevent leakage.
2001:DB8::/32 addresses ๐ท๏ธ
IPv6 standard (RFC 3849) defines the 2001:DB8::/32 address class for the documentation. This manual uses this convention. The addresses in this class are, however, only usable in a document, and routers should discard them.
Validation โ
The IPv6 protocols has not yet been extensively validated against real implementations. The actual tests involve mainly performing checks of the .pcap trace files with Wireshark, and the results are positive. ๐
Routing overview ๐บ๏ธ
ns-3 is intended to support traditional routing approaches and protocols, support ports of open source routing implementations, and facilitate research into unorthodox routing techniques. The overall routing architecture is described below in Routing architecture. Users who wish to just read about how to configure global routing for wired topologies can read Global centralized routing. Unicast routing protocols are described in Unicast routing. Multicast routing is documented in Multicast routing. ๐
Routing architecture ๐๏ธ
[image] Overview of routing.
Overview of routing shows the overall routing architecture for Ipv4. The key objects are Ipv4L3Protocol, Ipv4RoutingProtocol(s) (a class to which all routing/forwarding has been delegated from Ipv4L3Protocol), and Ipv4Route(s). ๐
Ipv4L3Protocol must have at least one Ipv4RoutingProtocol added to it at simulation setup time. This is done explicitly by calling Ipv4::SetRoutingProtocol ().
The abstract base class Ipv4RoutingProtocol () declares a minimal interface, consisting of two methods: RouteOutput () and RouteInput (). For packets traveling outbound from a host, the transport protocol will query Ipv4 for the Ipv4RoutingProtocol object interface, and will request a route via Ipv4RoutingProtocol::RouteOutput (). A Ptr to Ipv4Route object is returned. This is analogous to a dst_cache entry in Linux. The Ipv4Route is carried down to the Ipv4L3Protocol to avoid a second lookup there. However, some cases (e.g. Ipv4 raw sockets) will require a call to RouteOutput() directly from Ipv4L3Protocol. ๐ฆ
For packets received inbound for forwarding or delivery, the following steps occur. Ipv4L3Protocol::Receive() calls Ipv4RoutingProtocol::RouteInput(). This passes the packet ownership to the Ipv4RoutingProtocol object. There are four callbacks associated with this call:
LocalDeliverUnicastForwardMulticastForwardError
The Ipv4RoutingProtocol must eventually call one of these callbacks for each packet that it takes responsibility for. This is basically how the input routing process works in Linux. ๐
[image] Ipv4Routing specialization.
This whole architecture is built to flex for so many routing vibes, bestie. Like, future goals include a Linux-style policy-based routing setup, proactive and on-demand routing protocols, and even baby-simple routing protocols for when you literally could not care less about routing. It's giving versatility ๐
So the Ipv4Routing specialization is the blueprint, and it shows how all these routing protocols derive from that base class. There's a class called Ipv4ListRouting (the implementation class is Ipv4ListRoutingImpl) that gives you the list-routing approach we have in ns-3 rn. Its API is identical to the base class Ipv4Routing, except it can also stack multiple prioritized routing protocols โ that's Ipv4ListRouting::AddRoutingProtocol() and Ipv4ListRouting::GetRoutingProtocol() ๐ซถ
The deets on all these routing protocols live down in Unicast routing below. But first, let's kick off with a basic unicast routing capability that's meant to just globally build routing tables at simulation time t=0, for the girlies who don't care about dynamic routing at all.
โจ Unicast routing โจ
These are the unicast routing protocols defined for IPv4 and IPv6, periodt:
- classes
Ipv4ListRoutingandIpv6ListRouting(used to store a prioritized list of routing protocols) - classes
Ipv4StaticRoutingandIpv6StaticRouting(covering both unicast and multicast) - class
Ipv4GlobalRouting(used to store routes computed by the global route manager, if that is used) - class
Ipv4NixVectorRouting(a more efficient version of global routing that stores source routes in a packet header field) - class
Ripโ the IPv4 RIPv2 protocol (RFC 2453) - class
RipNgโ the IPv6 RIPng protocol (RFC 2080) - IPv4 Optimized Link State Routing (OLSR) (a MANET protocol defined in RFC 3626)
- IPv4 Ad Hoc On Demand Distance Vector (AODV) (a MANET protocol defined in RFC 3561)
- IPv4 Destination Sequenced Distance Vector (DSDV) (a MANET protocol)
- IPv4 Dynamic Source Routing (DSR) (a MANET protocol)
Looking ahead, this architecture should also let someone implement a Linux-like implementation with a routing cache, or a Click modular router โ but those are out of scope for now, bestie ๐
๐ธ Ipv[4,6]ListRouting ๐ธ
This bit describes the current default ns-3 Ipv[4,6]RoutingProtocol. Normally, multiple routing protocols live in user space and coordinate to write a single forwarding table in the kernel. But rn in ns-3, the implementation flips it: multiple routing protocols each build/keep their own routing state, and the IP implementation queries each one of them (in whatever order the simulation author decides) until it finds a route. Iconic behavior honestly ๐
Why this approach? Because it might make integrating disparate routing approaches easier โ especially ones that are hard to coordinate into a single table, ones that use more than just the destination IP address to figure out the next hop (source routing, hiii), and on-demand routing approaches where packets gotta be cached. It just makes sense ๐
๐ฆ Ipv[4,6]ListRouting::AddRoutingProtocol ๐ฆ
Classes Ipv4ListRouting and Ipv6ListRouting give you a pure virtual function declaration for the method that lets you add a routing protocol:
void AddRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol,
int16_t priority);
void AddRoutingProtocol (Ptr<Ipv6RoutingProtocol> routingProtocol,
int16_t priority);
These methods are implemented respectively by class Ipv4ListRoutingImpl and by class Ipv6ListRoutingImpl in the internet module, no cap.
That priority variable up there governs the order the routing protocols get inserted in. Heads up: it's a signed int. By default in ns-3, the helper classes instantiate an Ipv[4,6]ListRoutingImpl object and add to it an Ipv[4,6]StaticRoutingImpl object at priority zero. Internally there's a list of Ipv[4,6]RoutingProtocols stored, and each routing protocol gets consulted in decreasing order of priority to see if there's a match. So if you want your Ipv4RoutingProtocol to have priority lower than the static routing, insert it with a priority less than 0. Like so:
Ptr<MyRoutingProtocol> myRoutingProto = CreateObject<MyRoutingProtocol> ();
listRoutingPtr->AddRoutingProtocol (myRoutingProto, -10);
When someone calls RouteOutput() or RouteInput(), the list routing object searches the list of routing protocols in priority order until it finds a route. That routing protocol then invokes the appropriate callback and no further routing protocols get searched. Done, next ๐
๐ Global centralized routing ๐
Global centralized routing is sometimes called "God" routing and honestly? Deserved. It's a special implementation that walks the simulation topology, runs a shortest path algorithm, and populates each node's routing tables. Zero actual protocol overhead (on the simulated links) with this approach โ ate and left no crumbs โจ
But it does have a few constraints, bestie, listen up:
- Wired only: It is not intended for use in wireless networks.
- Unicast only: It does not do multicast.
- Scalability: Some users of this on large topologies (e.g. 1000 nodes) have noticed that the current implementation is not very scalable. The global centralized routing will be modified in the future to reduce computations and runtime performance.
Presently, global centralized IPv4 unicast routing over both point-to-point and shared (CSMA) links is supported ๐ซถ
By default, when using the ns-3 helper API and the default InternetStackHelper, global routing capability gets added to the node, and global routing gets inserted as a routing protocol with lower priority than the static routes โ meaning users can insert routes via the Ipv4StaticRouting API and those will take precedence over routes found by global routing. Slay ๐
โญ Global Unicast Routing API โญ
The public API is minimal, like, extremely low-effort queen. User scripts include this:
#include "ns3/internet-module.h"
If the default InternetStackHelper is used, then an instance of global routing gets aggregated to each node. Once IP addresses are configured, this function call makes all the nodes that have an Ipv4 interface receive forwarding tables entered automatically by the GlobalRouteManager:
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
Note: quick reminder that the wifi NetDevice will work but does not take any wireless effects into account. For wireless, we recommend OLSR dynamic routing described below.
You can also call this function again mid-simulation using this extra public function:
Ipv4GlobalRoutingHelper::RecomputeRoutingTables ();
which flushes the old tables, queries the nodes for new interface information, and rebuilds the routes. Fresh start energy ๐
For example, this scheduling call makes the tables rebuild at time 5 seconds:
Simulator::Schedule (Seconds (5),
&Ipv4GlobalRoutingHelper::RecomputeRoutingTables);
There are two attributes governing the behavior, bestie:
The first is Ipv4GlobalRouting::RandomEcmpRouting. If set to true, packets get randomly routed across equal-cost multipath routes. If set to false (the default), only one route is consistently used.
The second is Ipv4GlobalRouting::RespondToInterfaceEvents. If set to true, it dynamically recomputes the global routes upon Interface notification events (up/down, or add/remove address). If set to false (the default), routing may break unless the user manually calls RecomputeRoutingTables() after such events. The default is false to preserve legacy ns-3 program behavior. So like, watch out ๐ญ
๐ Global Routing Implementation ๐
This section is for the readers who care about how it's implemented. A singleton object (GlobalRouteManager) is responsible for populating the static routes on each node, using the public Ipv4 API of that node. It queries each node in the topology for a globalRouter interface. If found, it uses that interface's API to obtain a "link state advertisement (LSA)" for the router. Link State Advertisements are used in OSPF routing, and we follow their formatting. Respectfully, we're just copying OSPF's homework ๐ซถ
Super important to note: all of these computations are done before packets are flowing in the network. In particular, there are no overhead or control packets being exchanged when using this implementation. Instead, this global route manager just walks the list of nodes to build the necessary information and configure each node's routing table. No cap.
The GlobalRouteManager populates a link state database with LSAs gathered from the entire topology. Then, for each router in the topology, the GlobalRouteManager executes the OSPF shortest path first (SPF) computation on the database, and populates the routing tables on each node. Main character energy fr fr โจ
The quagga (http://www.quagga.net) OSPF implementation was used as the basis for the routing computation logic. One benefit of following an existing OSPF SPF implementation is that OSPF already has defined link state advertisements for all common types of network links:
- point-to-point (serial links)
- point-to-multipoint (Frame Relay, ad hoc wireless)
- non-broadcast multiple access (ATM)
- broadcast (Ethernet)
So we think enabling these other link types will be more straightforward now that the underlying OSPF SPF framework is in place. Vibe check: passed ๐
Presently, we can handle IPv4 point-to-point, numbered links, as well as shared broadcast (CSMA) links. Equal-cost multipath is also supported. Although wireless link types are supported by the implementation, note that due to the nature of this implementation, any channel effects will not be considered, and the routing tables will assume that every node on the same shared channel is reachable from every other node (i.e. it will be treated like a broadcast CSMA link). So like, don't come for us about wireless effects, bestie ๐
The GlobalRouteManager first walks the list of nodes and aggregates a GlobalRouter interface to each one, like this:
typedef std::vector < Ptr<Node> >::iterator Iterator;
for (Iterator i = NodeList::Begin (); i != NodeList::End (); i++)
{
Ptr<Node> node = *i;
Ptr<GlobalRouter> globalRouter = CreateObject<GlobalRouter> (node);
node->AggregateObject (globalRouter);
}
This interface is later queried and used to generate a Link State Advertisement for each router, and this link state database is fed into the OSPF shortest path computation logic. The Ipv4 API is finally used to populate the routes themselves. Chef's kiss ๐
๐ RIP and RIPng ๐
The RIPv2 protocol for IPv4 is described in the RFC 2453, and it consolidates a number of improvements over the base protocol defined in RFC 1058.
This IPv6 routing protocol (RFC 2080) is the evolution of the well-known RIPv1 (see RFC 1058 and RFC 1723) routing protocol for IPv4. Glow-up moment fr fr ๐ธ
The protocols are very simple, and are normally suitable for flat, simple network topologies. No drama, no chaos โ just vibes. ๐
RIPv1, RIPv2, and RIPng have literally the exact same goals and limitations. And here's the tea: RIP treats any route with a metric equal or greater than 16 as unreachable. Which means the maximum number of hops in the network must be less than 15 (the number of routers is not set โ that part's on you, bestie). Users are encouraged to read RFC 2080 and RFC 1058 to fully understand RIP behaviour and limitations. Like, actually read them. ๐โจ
๐ Routing convergence
RIP uses a Distance-Vector algorithm, and routes get updated according to the Bellman-Ford algorithm (sometimes known as the Ford-Fulkerson algorithm, iykyk). This algorithm has a convergence time of O(|V|*|E|), where |V| and |E| are the number of vertices (routers) and edges (links) respectively. And stress this: the convergence time is the number of steps in the algorithm, and each step is triggered by a message. Since Triggered Updates (i.e., when a route is changed) have a 1-5 seconds cooldown, the topology can require some time to be stabilized. Patience, queen. ๐งโโ๏ธ
Users should be aware that, during routing tables construction, the routers might drop packets. Data traffic should be sent only after a time long enough to allow RIP to build the network topology. Usually 80 seconds should be enough to have a suboptimal (but working) routing setup. That includes the time needed to propagate the routes to the most distant router (16 hops) with Triggered Updates. So yeah โ 80 seconds, don't @ me.
If the network topology is changed (e.g., a link is broken ๐), the recovery time might be quite high, and it might be even higher than the initial setup time. Not ideal! Moreover, the network topology recovery is affected by the Split Horizoning strategy.
The examples examples/routing/ripng-simple-network.cc and examples/routing/rip-simple-network.cc show both the network setup and network recovery phases. Go look at them, they ate. ๐ฅ
๐ Split Horizoning
Split Horizon is a strategy to prevent routing instability. Three options are possible:
- No Split Horizon
- Split Horizon
- Poison Reverse
In the first case, routes are advertised on all the router's interfaces. In the second case, routers will not advertise a route on the interface from which it was learned. Poison Reverse will advertise the route on the interface from which it was learned, but with a metric of 16 (infinity). For a full analysis of the three techniques, see RFC 1058, section 2.2. ๐
The examples are based on the network topology described in the RFC, but it does not show the effect described there.
The reason are the Triggered Updates, together with the fact that when a router invalidates a route, it will immediately propagate the route unreachability, thus preventing most of the issues described in the RFC. slay.
However, with complex topologies, it is still possible to have route instability phenomena similar to the one described in the RFC after a link failure. As a consequence, all the considerations about Split Horizon remains valid. So don't go thinking you're safe. ๐
๐ Default routes
RIP protocol should be installed only on routers. As a consequence, nodes will not know what is the default router. ๐ญ
To overcome this limitation, users should either install the default route manually (e.g., by resorting to Ipv4StaticRouting or Ipv6StaticRouting), or by using RADVd (in case of IPv6). RADVd is available in ns-3 in the Applications module, and it is strongly suggested. Like, take the suggestion. ๐ซถ
โจ Protocol parameters and options
The RIP ns-3 implementations allow to change all the timers associated with route updates and routes lifetime. Customize away, bestie.
Moreover, users can change the interface metrics on a per-node basis.
The type of Split Horizoning (to avoid routes back-propagation) can be selected on a per-node basis, with the choices being "no split horizon", "split horizon" and "poison reverse". See RFC 2080 for further details, and RFC 1058 for a complete discussion on the split horizoning strategies.
Moreover, it is possible to use a non-standard value for Link Down Value (i.e., the value after which a link is considered down). The default is value is 16. (Yes, that sentence reads a little cursed in the original too. We keep it. ๐)
๐ Limitations
There is no support for the Next Hop option (RFC 2080, Section 2.1.1). The Next Hop option is useful when RIP is not being run on all of the routers on a network. Support for this option may be considered in the future. ๐
There is no support for CIDR prefix aggregation. As a result, both routing tables and route advertisements may be larger than necessary. Prefix aggregation may be added in the future.
๐ง Other routing protocols
Other routing protocols documentation can be found under the respective modules sections, e.g.:
- AODV
- Click
- DSDV
- DSR
- NixVectorRouting
- OLSR
- etc.
๐ฐ๏ธ Multicast routing
The following function is used to add a static multicast route to a node:
void
Ipv4StaticRouting::AddMulticastRoute (Ipv4Address origin,
Ipv4Address group,
uint32_t inputInterface,
std::vector<uint32_t> outputInterfaces);
A multicast route must specify an origin IP address, a multicast group and an input network interface index as conditions and provide a vector of output network interface indices over which packets matching the conditions are sent.
Typically there are two main types of multicast routes:
- Routes used during forwarding, and
- Routes used in the originator node.
In the first case all the conditions must be explicitly provided. โ๏ธ
In the second case, the route is equivalent to a unicast route, and must be added through Ipv4StaticRouting::AddHostRouteTo.
Another command sets the default multicast route:
void
Ipv4StaticRouting::SetDefaultMulticastRoute (uint32_t outputInterface);
This is the multicast equivalent of the unicast version SetDefaultRoute. We tell the routing system what to do in the case where a specific route to a destination multicast group is not found. The system forwards packets out the specified interface in the hope that "something out there" knows better how to route the packet. This method is only used in initially sending packets off of a host. The default multicast route is not consulted during forwarding โ exact routes must be specified using AddMulticastRoute for that case. No cap, it's just not consulted.
Since we're basically sending packets to some entity we think may know better what to do, we don't pay attention to "subtleties" like origin address, nor do we worry about forwarding out multiple interfaces. If the default multicast route is set, it is returned as the selected route from LookupStatic irrespective of origin or multicast group if another specific route is not found.
Finally, a number of additional functions are provided to fetch and remove multicast routes:
uint32_t GetNMulticastRoutes (void) const;
Ipv4MulticastRoute *GetMulticastRoute (uint32_t i) const;
Ipv4MulticastRoute *GetDefaultMulticastRoute (void) const;
bool RemoveMulticastRoute (Ipv4Address origin,
Ipv4Address group,
uint32_t inputInterface);
void RemoveMulticastRoute (uint32_t index);
๐งต TCP models in ns-3
This chapter describes the TCP models available in ns-3. Buckle up, it's giving main character energy. ๐
๐ธ Overview of support for TCP
ns-3 was written to support multiple TCP implementations. The implementations inherit from a few common header classes in the src/network directory, so that user code can swap out implementations with minimal changes to the scripts. Mix and match, bestie. ๐
There are three important abstract base classes:
class TcpSocket: This is defined insrc/internet/model/tcp-socket.{cc,h}. This class exists for hostingTcpSocketattributes that can be reused across different implementations. For instance, the attributeInitialCwndcan be used for any of the implementations that derive fromclass TcpSocket.class TcpSocketFactory: This is used by the layer-4 protocol instance to create TCP sockets of the right type.class TcpCongestionOps: This supports different variants of congestion controlโ a key topic of simulation-based TCP research. (Yes, that dash situation is in the original. We preserve the artifacts. ๐)
There are presently two active and one legacy implementations of TCP available for ns-3.
- a natively implemented TCP for ns-3
- support for kernel implementations via Direct Code Execution (DCE)
- (legacy) support for kernel implementations for the Network Simulation Cradle (NSC)
NSC is no longer actively supported; it requires use of gcc-5 or gcc-4.9, and only covers up to Linux kernel version 2.6.29. Rip to NSC. ๐
Direct Code Execution is also limited in its support for newer kernels; at present, only Linux kernel 4.4 is supported. However, the TCP implementations in kernel 4.4 can still be used for ns-3 validation or for specialized simulation use cases.
It should also be mentioned that various ways of combining virtual machines with ns-3 makes available also some additional TCP implementations, but those are out of scope for this chapter. Not today. ๐ซ
๐ฅ ns-3 TCP
In brief, the native ns-3 TCP model supports a full bidirectional TCP with connection setup and close logic. Several congestion control algorithms are supported, with CUBIC the default, and NewReno, Westwood, Hybla, HighSpeed, Vegas, Scalable, Veno, Binary Increase Congestion Control (BIC), Yet Another HighSpeed TCP (YeAH), Illinois, H-TCP, Low Extra Delay Background Transport (LEDBAT), TCP Low Priority (TCP-LP), Data Center TCP (DCTCP) and Bottleneck Bandwidth and RTT (BBR) also supported. The model also supports Selective Acknowledgements (SACK), Proportional Rate Reduction (PRR) and Explicit Congestion Notification (ECN). Multipath-TCP is not yet supported in the ns-3 releases. ๐ญ
๐ฆ Model history
Until the ns-3.10 release, ns-3 contained a port of the TCP model from GTNetS, developed initially by George Riley and ported to ns-3 by Raj Bhattacharjea. This implementation was substantially rewritten by Adriam Tam for ns-3.10. In 2015, the TCP module was redesigned in order to create a better environment for creating and carrying out automated tests. One of the main changes involves congestion control algorithms, and how they are implemented. A glow-up, fr fr. โจ
Before the ns-3.25 release, a congestion control was considered as a stand-alone TCP through an inheritance relation: each congestion control (e.g. TcpNewReno) was a subclass of TcpSocketBase, reimplementing some inherited methods. The architecture was redone to avoid this inheritance, by making each congestion control a separate class, and defining an interface to exchange important data between TcpSocketBase and the congestion modules. The Linux tcp_congestion_ops interface was used as the design reference. Iconic architecture behaviour, honestly. ๐
okay so alongside congestion control, the Fast Retransmit and Fast Recovery algorithms got a glow-up too. in previous releases these algorithms were delegated to TcpSocketBase subclasses, but starting from ns-3.25 they've been merged inside TcpSocketBase. in future releases they can be extracted as separate modules, following the congestion control design. โจ
as of the ns-3.31 release, the default initial window was set to 10 segments (in previous releases, it was set to 1 segment). this aligns with the current Linux default, and is discussed further in RFC 6928. no cap. ๐
in the ns-3.32 release, the default recovery algorithm was set to Proportional Rate Reduction (PRR) from the classic ack-clocked Fast Recovery algorithm.
in the ns-3.34 release, the default congestion control algorithm was set to CUBIC from NewReno. the character development?? iconic. ๐
๐ซถ Acknowledgments ๐ซถ
as mentioned above, ns-3 TCP has had multiple authors and maintainers over the years, and it's giving collaborative masterpiece. several publications exist on aspects of ns-3 TCP, and users of ns-3 TCP are requested to cite one of the applicable papers when publishing new work. bestie, please cite, it's the least you can do. ๐
a general reference on the current architecture is found in the following paper:
- Maurizio Casoni, Natale Patriciello, Next-generation TCP for ns-3 simulator, Simulation Modelling Practice and Theory, Volume 66, 2016, Pages 81-93. (http://www.sciencedirect.com/science/article/pii/S1569190X15300939)
for an academic peer-reviewed paper on the SACK implementation in ns-3, please refer to:
- Natale Patriciello. 2017. A SACK-based Conservative Loss Recovery Algorithm for ns-3 TCP: a Linux-inspired Proposal. In Proceedings of the Workshop on ns-3 (WNS3 โ17). ACM, New York, NY, USA, 1-8. (https://dl.acm.org/citation.cfm?id=3067666)
๐ Usage ๐
in many cases, usage of TCP is set at the application layer by telling the ns-3 application which kind of socket factory to use. lowkey the whole vibe hinges on this.
using the helper functions defined in src/applications/helper and src/network/helper, here is how one would create a TCP receiver:
// Create a packet sink on the star "hub" to receive these packets
uint16_t port = 50000;
Address sinkLocalAddress(InetSocketAddress (Ipv4Address::GetAny (), port));
PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
ApplicationContainer sinkApp = sinkHelper.Install (serverNode);
sinkApp.Start (Seconds (1.0));
sinkApp.Stop (Seconds (10.0));
similarly, the below snippet configures OnOffApplication traffic source to use TCP:
// Create the OnOff applications to send TCP to the server
OnOffHelper clientHelper ("ns3::TcpSocketFactory", Address ());
the careful reader will note above that we have specified the TypeId of an abstract base class TcpSocketFactory. so how does the script tell ns-3 that it wants the native ns-3 TCP vs. some other one? great question, bestie โ well, when internet stacks are added to the node, the default TCP implementation that is aggregated to the node is the ns-3 TCP. this can be overridden as we show below when using Network Simulation Cradle. so, by default, when using the ns-3 helper API, the TCP that is aggregated to nodes with an Internet stack is the native ns-3 TCP. periodt. ๐
to configure behavior of TCP, a number of parameters are exported through the ns-3 attribute system. these are documented in the Doxygen for class TcpSocket. for example, the maximum segment size is a settable attribute. โจ
to set the default socket type before any internet stack-related objects are created, one may put the following statement at the top of the simulation program:
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue ("ns3::TcpNewReno"));
for users who wish to have a pointer to the actual socket (so that socket operations like Bind(), setting socket options, etc. can be done on a per-socket basis), Tcp sockets can be created by using the Socket::CreateSocket() method. the TypeId passed to CreateSocket() must be of type ns3::SocketFactory, so configuring the underlying socket type must be done by twiddling the attribute associated with the underlying TcpL4Protocol object. the easiest way to get at this would be through the attribute configuration system. in the below example, the Node container n0n1 is accessed to get the zeroth element, and a socket is created on this node:
// Create and bind the socket...
TypeId tid = TypeId::LookupByName ("ns3::TcpNewReno");
Config::Set ("/NodeList/*/$ns3::TcpL4Protocol/SocketType", TypeIdValue (tid));
Ptr<Socket> localSocket =
Socket::CreateSocket (n0n1.Get (0), TcpSocketFactory::GetTypeId ());
above, the * wild card for node number is passed to the attribute configuration system, so that all future sockets on all nodes are set to NewReno, not just on node n0n1.Get (0). if one wants to limit it to just the specified node, one would have to do something like:
// Create and bind the socket...
TypeId tid = TypeId::LookupByName ("ns3::TcpNewReno");
std::stringstream nodeId;
nodeId << n0n1.Get (0)->GetId ();
std::string specificNode = "/NodeList/" + nodeId.str () + "/$ns3::TcpL4Protocol/SocketType";
Config::Set (specificNode, TypeIdValue (tid));
Ptr<Socket> localSocket =
Socket::CreateSocket (n0n1.Get (0), TcpSocketFactory::GetTypeId ());
once a TCP socket is created, one will want to follow conventional socket logic and either connect() and send() (for a TCP client) or bind(), listen(), and accept() (for a TCP server). ๐ฆ please note that applications usually create the sockets they use automatically, and so it is not straightforward to connect directly to them using pointers. please refer to the source code of your preferred application to discover how and when it creates the socket. iykyk. ๐
๐ TCP Socket interaction and interface with Application layer ๐
in the following there is an analysis on the public interface of the TCP socket, and how it can be used to interact with the socket itself. an analysis of the callback fired by the socket is also carried out. please note that, for the sake of clarity, we will use the terminology โSenderโ and โReceiverโ to clearly divide the functionality of the socket. however, in TCP these two roles can be applied at the same time (i.e. a socket could be a sender and a receiver at the same time): our distinction does not lose generality, since the following definition can be applied to both sockets in case of full-duplex mode. main character energy on both ends fr fr. ๐
โญ TCP state machine (for commodity use) โญ
[image] TCP State machine.UNINDENT
in ns-3 we are fully compliant with the state machine depicted in Figure TCP State machine. slay. ๐
๐ Public interface for receivers (e.g. servers receiving data) ๐
Bind()โ bind the socket to an address, or to a general endpoint. a general endpoint is an endpoint with an ephemeral port allocation (that is, a random port allocation) on the0.0.0.0IP address. for instance, in current applications, data senders usually bind automatically after aConnect()over a random port. consequently, the connection will start from this random port towards the well-defined port of the receiver. the IP0.0.0.0is then translated by lower layers into the real IP of the device. ๐ซถBind6()โ same asBind(), but for IPv6.BindToNetDevice()โ bind the socket to the specifiedNetDevice, creating a general endpoint.Listen()โ listen on the endpoint for an incoming connection. please note that this function can be called only in the TCPCLOSEDstate, and transit in theLISTENstate. when an incoming request for connection is detected (i.e. the other peer invokedConnect()) the application will be signaled with the callbackNotifyConnectionRequest(set inSetAcceptCallback()beforehand). if the connection is accepted (the default behavior, when the associated callback is a null one) the Socket will fork itself, i.e. a new socket is created to handle the incoming data/connection, in the stateSYN_RCVD. please note that this newly created socket is not connected anymore to the callbacks on the โfatherโ socket (e.g.DataSent,Recv); the pointer of the newly created socket is provided in the CallbackNotifyNewConnectionCreated(set beforehand inSetAcceptCallback), and should be used to connect new callbacks to interesting events (e.g.Recvcallback). after receiving the ACK of the SYN-ACK, the socket will set the congestion control, move intoESTABLISHEDstate, and then notify the application withNotifyNewConnectionCreated. it's giving whole character arc in one function call. ๐ญShutdownSend()โ signal a termination of send, or in other words prevents data from being added to the buffer. after this call, if the buffer is already empty, the socket will send a FIN, otherwise FIN will go when the buffer empties. please note that this is useful only for modeling โSinkโ applications. if you have data to transmit, please refer to theSend()/Close()combination of API.GetRxAvailable()โ get the amount of data that could be returned by the Socket in one or multiple calls toRecvorRecvFrom. please use the Attribute system to configure the maximum available space on the receiver buffer (propertyRcvBufSize).Recv()โ grab data from the TCP socket. please remember that TCP is a stream socket, and it is allowed to concatenate multiple packets into bigger ones. if no data is present (i.e.GetRxAvailablereturns0) an empty packet is returned. set the callbackRecvCallbackthroughSetRecvCallback()in order to have the application automatically notified when some data is ready to be read. it's important to connect that callback to the newly created socket in case of forks. ๐งRecvFrom()โ same asRecv, but with the source address as parameter.
๐ฅ Public interface for senders (e.g. clients uploading data) ๐ฅ
Connect()โ set the remote endpoint, and try to connect to it. the local endpoint should be set before this call, or otherwise an ephemeral one will be created. the TCP then will be in theSYN_SENTstate. if a SYN-ACK is received, the TCP will setup the congestion control, and then call the callbackConnectionSucceeded. the way that it just goes and does all that. ๐GetTxAvailable()โ return the amount of data that can be stored in the TCP Tx buffer. set this property through the Attribute system (SndBufSize).Send()โ yeets your data into the TCP Tx buffer ๐. From there, the TCP rules get to decide if and when that data actually goes out on the wire. Okay but real talk bestie: if the tx buffer already has enough data to fill up the congestion (or the receiver) window, then dynamically varying the rate at which you inject data into the TCP buffer does not have any noticeable effect on how much data gets transmitted on the wire. That amount keeps being decided by the TCP rules. No cap.SendTo()โ same asSend(). That's it. That's the whole vibe. โจClose()โ terminates the local side of the connection by sending aFIN(and it waits until all the data in the tx buffer has been transmitted first, queen behavior). This does not stop the socket from receiving data, and it will still use the retransmit mechanism if it detects losses. If the application callsClose()while there's unread data sitting in its rx buffer, the socket sends a reset. And if the socket is in the stateSYN_SENT,CLOSING,LISTEN,FIN_WAIT_2, orLAST_ACK, then after that call the application gets notified withNotifyNormalClose(). In every other case, the notification is delayed (go look atNotifyNormalClose()for the tea ๐ซ).
๐ซ Public callbacks ๐ซ
These callbacks are called by the TCP socket to tell the application about interesting events. We're gonna refer to them using the protected name used in socket.h, but we'll also give you the API function to set the pointers to these callbacks. Double the access, double the slay.
NotifyConnectionSucceeded:SetConnectCallback, 1st argument โ called in theSYN_SENTstate, before moving toESTABLISHED. In other words: we sent theSYN, we got theSYN-ACKback, the socket prepares the sequence numbers, sends theACKfor theSYN-ACK, tries to send out more data (in another segment), and then invokes this callback. And right after this callback, it invokes theNotifySendcallback. the pipeline is real ๐NotifyConnectionFailed:SetConnectCallback, 2nd argument โ called after theSYNretransmission count hits 0. TheSYNpacket got lost multiple times, and the socket gives up. ๐ญNotifyNormalClose:SetCloseCallbacks, 1st argument โ a normal close is invoked. A rare case is when we receive anRSTsegment (or a segment with bad flags) in normal states. All the other cases are:- The application tries to
Connect()over an already connected socket - Received an
ACKfor theFINsent, with or without theFINbit set (we are inLAST_ACK) - The socket reaches the maximum amount of retries in retransmitting the
SYN(*) - We receive a timeout in the
LAST_ACKstate - Upon entering the
TIME_WAITstate, before waiting the2*Maximum Segment Lifetimeseconds to finally deallocate the socket.
- The application tries to
NotifyErrorClose:SetCloseCallbacks, 2nd argument โ invoked when we send anRSTsegment (for whatever reason) or when we reached the maximum amount of data retries. ๐NotifyConnectionRequest:SetAcceptCallback, 1st argument โ invoked in theLISTENstate, when we receive aSYN. The return value tells you whether the socket should accept the connection (returntrue) or ignore it (returnfalse). choose wisely โจNotifyNewConnectionCreated:SetAcceptCallback, 2nd argument โ invoked when the socket goes fromSYN_RCVDtoESTABLISHED, and after setting up the congestion control, the sequence numbers, and processing the incomingACK. If there's some space in the buffer,NotifySendgets called shortly after this callback. TheSocketpointer passed with this callback is the newly created socket, after aFork(). ๐ฆNotifyDataSent:SetDataSentCallbackโ theSocketnotifies the application that some bytes have been transmitted at the IP level. Those bytes could still get lost in the node (traffic control layer) or in the network. gone but not forgotten, maybe literallyNotifySend:SetSendCallbackโ invoked if there's some space in the tx buffer when entering theESTABLISHEDstate (e.g. after theACKforSYN-ACKis received), after the connection succeeds (e.g. after theSYN-ACKis received) and after each newACK(i.e. one that advancesSND.UNA).NotifyDataRecv:SetRecvCallbackโ called when there are in-order bytes in the receiver buffer, and when inFIN_WAIT_1orFIN_WAIT_2the socket receives an in-sequenceFIN(which can carry data).
๐ Congestion Control Algorithms ๐
Here comes the list of supported TCP congestion control algorithms, bestie. If you want an academic paper on a bunch of these, go read http://dl.acm.org/citation.cfm?id=2756518. ๐
NewReno
The NewReno algorithm introduces partial ACKs inside the well-established Reno algorithm. This and the other modifications are described in RFC 6582. We've got two possible congestion window increment strategies: slow start and congestion avoidance. Straight from RFC 5681:
During slow start, a TCP increments cwnd by at most SMSS bytes for each ACK received that cumulatively acknowledges new data. Slow start ends when cwnd exceeds ssthresh (or, optionally, when it reaches it, as noted above) or when congestion is observed. While traditionally TCP implementations have increased cwnd by precisely SMSS bytes upon receipt of an ACK covering new data, we RECOMMEND that TCP implementations increase cwnd, per Equation (1), where N is the number of previously unacknowledged bytes acknowledged in the incoming ACK.
cwnd += min (N, SMSS)
During congestion avoidance, cwnd is incremented by roughly 1 full-sized segment per round-trip time (RTT), and for each congestion event, the slow start threshold is halved. halved. brutal.
CUBIC
CUBIC (class TcpCubic) is the default TCP congestion control in Linux, macOS (since 2014), and Microsoft Windows (since 2017). ๐ CUBIC has two main differences compared to a more classic TCP congestion control like NewReno:
- During the congestion avoidance phase, the window size grows according to a cubic function (concave, then convex), and that latter convex portion is designed to allow for bandwidth probing.
- A hybrid slow start (HyStart) algorithm uses observations of delay increases in the slow start phase of window growth to try to exit slow start before window growth causes queue overflow. sneaky, elegant, iconic
CUBIC is documented in RFC 8312, and the ns-3 implementation is based on the RFC more so than the Linux implementation โ although the Linux 4.4 kernel implementation (through the Direct Code Execution environment) has been used to validate the behavior and is fairly well aligned (see the section on validation below).
Linux Reno
TCP Linux Reno (class TcpLinuxReno) is designed to provide a Linux-like implementation of TCP NewReno. The implementation of class TcpNewReno in ns-3 follows RFC standards, and increases cwnd more conservatively than Linux Reno does. Linux Reno modifies the slow start and congestion avoidance algorithms so that cwnd increases based on the number of bytes being acknowledged by each arriving ACK, rather than by the number of ACKs that arrive. Another major implementation difference: Linux maintains the congestion window in units of segments, while the RFCs define the congestion window in units of bytes. units drama, truly
In the slow start phase, on each incoming ACK at the TCP sender side, cwnd is increased by the number of previously unacknowledged bytes ACKed by that incoming acknowledgment. In contrast, in ns-3 NewReno, cwnd is increased by one segment per acknowledgment. In standards terminology, this difference is called Appropriate Byte Counting (RFC 3465); Linux follows Appropriate Byte Counting while ns-3 NewReno does not.
cwnd += segAcked * segmentSize
cwnd += segmentSize
In the congestion avoidance phase, the number of bytes that have been ACKed at the TCP sender side is stored in a bytes_acked variable in the TCP control block. When bytes_acked becomes greater than or equal to the value of the cwnd, bytes_acked is reduced by the value of cwnd. Next, cwnd is incremented by a full-sized segment (SMSS). In contrast, in ns-3 NewReno, cwnd is increased by (1/cwnd) with a rounding off due to type casting into int.
if (m_cWndCnt >= w)
{
uint32_t delta = m_cWndCnt / w;
m_cWndCnt -= delta * w;
tcb->m_cWnd += delta * tcb->m_segmentSize;
NS_LOG_DEBUG ("Subtracting delta * w from m_cWndCnt " << delta * w);
}
:label: linuxrenocongavoid
if (segmentsAcked > 0)
{
double adder = static_cast<double> (tcb->m_segmentSize * tcb->m_segmentSize) / tcb->m_cWnd.Get ();
adder = std::max (1.0, adder);
tcb->m_cWnd += static_cast<uint32_t> (adder);
NS_LOG_INFO ("In CongAvoid, updated to cwnd " << tcb->m_cWnd <<
" ssthresh " << tcb->m_ssThresh);
}
:label: newrenocongavoid
So yeah, there are two main differences between TCP Linux Reno and TCP NewReno in ns-3:
- In TCP Linux Reno, the delayed acknowledgement configuration does not affect congestion window growth, while in TCP NewReno, delayed acknowledgments cause a slower congestion window growth.
- In the congestion avoidance phase, the arithmetic for counting the number of segments acked and deciding when to increment the
cwndis different for TCP Linux Reno and TCP NewReno.
The following graphs show the behavior of window growth in TCP Linux Reno and TCP NewReno with delayed acknowledgement of 2 segments:
[image] ns-3 TCP NewReno vs. ns-3 TCP Linux Reno.UNINDENT
HighSpeed
TCP HighSpeed is designed for high-capacity channels or, in general, for TCP connections with large congestion windows. Conceptually, compared to the standard TCP, HighSpeed makes the cWnd grow faster during the probing phases and accelerates the cWnd recovery from losses. glow up on the recovery arc โจ This behavior is only executed when the window grows beyond a certain threshold, which lets TCP HighSpeed stay friendly with standard TCP in environments with heavy congestion, without introducing new dangers of congestion collapse. it's giving considerate
Mathematically:
cWnd = cWnd + \frac{a(cWnd)}{cWnd}
The function a() is calculated using a fixed RTT of the value 100 ms (the lookup table for this function is taken from RFC 3649). For each congestion event, the slow start threshold is decreased by a value that depends on the size of the slow start threshold itself. Then, the congestion window is set to that value.
cWnd = (1-b(cWnd)) \cdot cWnd
The lookup table for the function b() is taken from the same RFC. More information at: http://dl.acm.org/citation.cfm?id=2756518 ๐
Hybla ๐
okay so the whole key idea behind TCP Hybla is: you want long RTT connections to get the same instantaneous transmission rate as a reference TCP connection that has a lower RTT. bestie, that's the goal. ๐ฏ
And with analytical steps it's shown that this goal can be achieved by modifying the time scale, so that the throughput ends up being independent from the RTT. That independence? It's obtained through the use of a coefficient called rho. โจ
This coefficient is used to calculate both the slow start threshold and the congestion window when in slow start and in congestion avoidance, respectively.
More info at: http://dl.acm.org/citation.cfm?id=2756518 ๐
Westwood ๐ธ
Westwood and Westwood+ employ the AIAD (Additive Increase/Adaptive Decrease) congestion control paradigm. When a congestion episode happens, instead of halving the cwnd, these protocols try to estimate the network's bandwidth and use the estimated value to adjust the cwnd.
And the tea on the difference between them:
- Westwood performs the bandwidth sampling every ACK reception
- Westwood+ samples the bandwidth every RTT
More info at: http://dl.acm.org/citation.cfm?id=381704 and http://dl.acm.org/citation.cfm?id=2512757 ๐
Vegas ๐
TCP Vegas is a pure delay-based congestion control algorithm implementing a proactive scheme that tries to prevent packet drops by maintaining a small backlog at the bottleneck queue. so it's giving "prevention over reaction", iconic. ๐ซถ
Vegas continuously samples the RTT and computes the actual throughput a connection achieves using Equation (6), then compares it with the expected throughput calculated in Equation (7). The difference between these 2 sending rates in Equation (8) reflects the amount of extra packets being queued at the bottleneck. ๐
actual &= \frac{cWnd}{RTT}
expected &= \frac{cWnd}{BaseRTT}
diff &= expected - actual
To avoid congestion, Vegas linearly increases/decreases its congestion window to ensure the diff value falls between the two predefined thresholds, alpha and beta. And diff plus another threshold, gamma, are used to determine when Vegas should change from its slow-start mode to linear increase/decrease mode. ๐ฆ
Following the implementation of Vegas in Linux, we use 2, 4, and 1 as the default values of alpha, beta, and gamma, respectively โ but no cap, they can be modified through the Attribute system. โจ
More info at: http://dx.doi.org/10.1109/49.464716 ๐
Scalable ๐ฅ
Scalable improves TCP performance to better utilize the available bandwidth of a highspeed wide area network by altering the NewReno congestion window adjustment algorithm. ๐ซ
When congestion has not been detected, for each ACK received in an RTT, Scalable increases its cwnd per:
cwnd = cwnd + 0.01
Following the Linux implementation of Scalable, we use 50 instead of 100 to account for delayed ACK. iykyk. ๐
On the first detection of congestion in a given RTT, cwnd is reduced based on the following equation:
cwnd = cwnd - ceil(0.125 \cdot cwnd)
More info at: http://dl.acm.org/citation.cfm?id=956989 ๐
Veno ๐
TCP Veno enhances the Reno algorithm so it deals more effectively with random packet loss in wireless access networks, by employing Vegas's method of estimating the backlog at the bottleneck queue to distinguish between congestive and non-congestive states. ๐
The backlog (aka the number of packets accumulated at the bottleneck queue) is calculated using Equation (11):
N &= Actual \cdot (RTT - BaseRTT) \\
&= Diff \cdot BaseRTT
where:
Diff &= Expected - Actual \\
&= \frac{cWnd}{BaseRTT} - \frac{cWnd}{RTT}
Veno makes its decision on cwnd modification based on the calculated N and its predefined threshold beta. ๐
Specifically, it refines the additive increase algorithm of Reno so that the connection can stay longer in the stable state by incrementing cwnd by 1/cwnd for every other new ACK received after the available bandwidth has been fully utilized, i.e. when N exceeds beta. Otherwise, Veno increases its cwnd by 1/cwnd upon every new ACK receipt, just like in Reno.
Now for the multiplicative decrease algorithm: when Veno is in the non-congestive state, i.e. when N is less than beta, Veno decrements its cwnd by only 1/5, because the loss encountered is more likely a corruption-based loss than a congestion-based one. Only when N is greater than beta does Veno halve its sending rate, as in Reno. ๐
More info at: http://dx.doi.org/10.1109/JSAC.2002.807336 ๐
BIC โญ
BIC (class TcpBic) is a predecessor of TCP CUBIC. fr fr, the blueprint. ๐
In TCP BIC the congestion control problem is viewed as a search problem. Taking as a starting point the current window value and as a target point the last maximum window value (i.e. the cWnd value just before the loss event), a binary search technique can be used to update the cWnd value at the midpoint between the two โ either directly, or using an additive increase strategy if the distance from the current window is too large. ๐
This way, assuming a no-loss period, the congestion window logarithmically approaches the maximum value of cWnd until the difference between it and cWnd falls below a preset threshold. After reaching such a value (or if the maximum window is unknown, i.e. the binary search does not start at all), the algorithm switches to probing the new maximum window with a 'slow start' strategy. ๐ฑ
If a loss occurs in either of these phases, the current window (before the loss) can be treated as the new maximum, and the reduced (with a multiplicative decrease factor Beta) window size can be used as the new minimum.
More info at: http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=1354672 ๐
YeAH ๐ฆ
YeAH-TCP (Yet Another HighSpeed TCP) is a heuristic designed to balance various requirements of a state-of-the-art congestion control algorithm:
- fully exploit the link capacity of high BDP networks while inducing a small number of congestion events
- compete friendly with Reno flows
- achieve intra and RTT fairness
- robust to random losses
- achieve high performance regardless of buffer size
YeAH operates between 2 modes: Fast and Slow mode. In the Fast mode, when the queue occupancy is small and the network congestion level is low, YeAH increments its congestion window according to the aggressive HSTCP rule. But when the number of packets in the queue grows beyond a threshold and the network congestion level is high, YeAH enters its Slow mode, acting as Reno with a decongestion algorithm. ๐
YeAH employs Vegas's mechanism for calculating the backlog as in Equation (13). The estimation of the network congestion level is shown in Equation (14).
Q = (RTT - BaseRTT) \cdot \frac{cWnd}{RTT}
L = \frac{RTT - BaseRTT}{BaseRTT}
To ensure TCP friendliness, YeAH also implements an algorithm to detect the presence of legacy Reno flows. Upon the receipt of 3 duplicate ACKs, YeAH decreases its slow start threshold according to Equation (15) if it's not competing with Reno flows. Otherwise, the ssthresh is halved as in Reno:
ssthresh = min(max(\frac{cWnd}{8}, Q), \frac{cWnd}{2})
More info: http://www.csc.lsu.edu/~sjpark/cs7601/4-YeAH_TCP.pdf ๐
Illinois ๐
TCP Illinois is a hybrid congestion control algorithm designed for high-speed networks. Illinois implements a Concave-AIMD (or C-AIMD) algorithm that uses packet loss as the primary congestion signal to determine the direction of window update, and queueing delay as the secondary congestion signal to determine the amount of change. ๐ฏ
The additive increase and multiplicative decrease factors (denoted as alpha and beta, respectively) are functions of the current average queueing delay da, as shown in Equations (16) and (17). And to improve the protocol's robustness against sudden fluctuations in its delay sampling, Illinois allows the increment of alpha to alphaMax only if da stays below d1 for a some (theta) amount of time. โณ
alpha &=
\begin{cases}
\quad alphaMax & \quad \text{if } da <= d1 \\
\quad k1 / (k2 + da) & \quad \text{otherwise} \\ \end{cases}
beta &=
\begin{cases}
\quad betaMin & \quad \text{if } da <= d2 \\
\quad k3 + k4 \, da & \quad \text{if } d2 < da < d3 \\
\quad betaMax & \quad \text{otherwise} \end{cases}
where the calculations of k1, k2, k3, and k4 are shown in the following:
k1 &= \frac{(dm - d1) \cdot alphaMin \cdot alphaMax}{alphaMax - alphaMin}
k2 &= \frac{(dm - d1) \cdot alphaMin}{alphaMax - alphaMin} - d1
k3 &= \frac{alphaMin \cdot d3 - alphaMax \cdot d2}{d3 - d2}
k4 &= \frac{alphaMax - alphaMin}{d3 - d2}
Other parameters include da (the current average queueing delay), and Ta (the average RTT, calculated as sumRtt / cntRtt in the implementation) and Tmin (baseRtt in the implementation) which is the minimum RTT ever seen. dm is the maximum (average) queueing delay, and Tmax (maxRtt in the implementation) is the maximum RTT ever seen. ๐
da &= Ta - Tmin
dm &= Tmax - Tmin
d_i &= eta_i \cdot dm
Illinois only executes its adaptation of alpha and beta when cwnd exceeds a threshold called winThresh. Otherwise, it sets alpha and beta to the base values of 1 and 0.5, respectively.
Following the implementation of Illinois in the Linux kernel, we use the following default parameter settings:
alphaMin=0.3(0.1in the Illinois paper)alphaMax=10.0betaMin=0.125betaMax=0.5winThresh=15(10in the Illinois paper)theta=5eta1=0.01eta2=0.1eta3=0.8
More info: http://www.doi.org/10.1145/1190095.1190166 ๐
H-TCP ๐
H-TCP has been designed for high BDP (Bandwidth-Delay Product) paths. It's a dual mode protocol. ๐ซ
In normal conditions, it works like traditional TCP with the same rate of increment and decrement for the congestion window. However, in high BDP networks, when it finds no congestion on the path after deltal seconds, it increases the window size based on the alpha function in the following:
alpha(delta)=1+10(delta-deltal)+0.5(delta-deltal)^2
where deltal is a threshold in seconds for switching between the modes, and delta is the elapsed time from the last congestion. โฑ๏ธ
During congestion, it reduces the window size by multiplying by the beta function provided in the reference paper. The calculated throughput between the last two consecutive congestion events is considered for the beta calculation. ๐ฅ
...and honestly bestie, if you want to actually watch H-TCP do its thing, the transport TcpHtcp can be picked inside the program examples/tcp/tcp-variants-comparison.cc to run an experiment with H-TCP. Pro tip from the manpage itself: it's useful to bump the bandwidth in this example (like, e.g. to 20 Mb/s) so you get a higher BDP link, kinda like
./waf --run "tcp-variants-comparison --transport_prot=TcpHtcp --bandwidth=20Mbps --duration=10"
More info (paper): http://www.hamilton.ie/net/htcp3.pdf
More info (Internet Draft): https://tools.ietf.org/html/draft-leith-tcp-htcp-06
๐ LEDBAT
Low Extra Delay Background Transport (LEDBAT) is a whole experimental delay-based congestion control algorithm and its entire personality is: use the available bandwidth on an end-to-end path, but limit the queueing delay increase that comes with it. No cap. LEDBAT looks at changes in one-way delay measurements to cap the congestion that the flow itself is out here causing in the network. ๐
As a first approximation, the LEDBAT sender operates as shown below:
On receipt of an ACK:
currentdelay = acknowledgement.delay basedelay = min (basedelay, currentdelay) queuingdelay = currentdelay - basedelay offtarget = (TARGET - queuingdelay) / TARGET cWnd += GAIN * offtarget * bytesnewlyacked * MSS / cWnd
TARGET is the maximum queueing delay that LEDBAT itself may introduce into the network, and GAIN decides how fast the cwnd reacts to changes in queueing delay. offtarget is a normalized value that represents the difference between the measured current queueing delay and the predetermined TARGET delay. offtarget can be positive or negative, so cwnd goes up or down in proportion to it. Math is mathing. โจ
Following the recommendation of RFC 6817, the default values of the parameters are:
- TargetDelay = 100
- baseHistoryLen = 10
- noiseFilterLen = 4
- Gain = 1
To enable LEDBAT on all TCP sockets, you can use this config:
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpLedbat::GetTypeId ()));
To enable LEDBAT on one chosen TCP socket, you can use this config:
Config::Set ("$ns3::NodeListPriv/NodeList/1/$ns3::TcpL4Protocol/SocketType", TypeIdValue (TcpLedbat::GetTypeId ()));
The following unit tests have been written to validate the implementation of LEDBAT:
- LEDBAT should operate same as NewReno during slow start
- LEDBAT should operate same as NewReno if timestamps are disabled
- Test to validate cwnd increment in LEDBAT
In comparison to RFC 6817, the scope and limitations of the current LEDBAT implementation are:
- It assumes that the clocks on the sender side and receiver side are synchronised
- In line with Linux implementation, the one-way delay is calculated at the sender side by using the timestamps option in TCP header
- Only the MIN function is used for noise filtering
More information about LEDBAT is available in RFC 6817: https://tools.ietf.org/html/rfc6817
๐ TCP-LP
TCP-Low Priority (TCP-LP) is a delay based congestion control protocol where the low priority data only eats up the excess bandwidth available on an end-to-end path. TCP-LP uses one way delay measurements as its congestion indicator, because it does not influence cross-traffic in the reverse direction. Respectful queen behavior honestly. ๐
On receipt of an ACK:
One way delay = Receiver timestamp - Receiver timestamp echo reply
Smoothed one way delay = 7/8 * Old Smoothed one way delay + 1/8 * one way delay If smoothed one way delay > owdMin + 15 * (owdMax - owdMin) / 100
if LP_WITHIN_INF
cwnd = 1
else
cwnd = cwnd / 2
Inference timer is set
where owdMin and owdMax are the minimum and maximum one way delays experienced throughout the connection, and LP_WITHIN_INF indicates if TCP-LP is in inference phase or not.
More information (paper): http://cs.northwestern.edu/~akuzma/rice/doc/TCP-LP.pdf
๐ฆ Data Center TCP (DCTCP)
DCTCP, specified in RFC 8257 and implemented in Linux, is a TCP congestion control algorithm for data center networks. It leverages Explicit Congestion Notification (ECN) to give the end hosts way more fine-grained congestion feedback, and it's meant to work with routers that implement a shallow congestion marking threshold (like, on the order of a few milliseconds) so you get high throughput AND low latency in the datacenter. Slay. ๐
But โ and this is the important part, bestie โ because DCTCP does not react in the same way to notification of congestion experienced, there are coexistence (fairness) issues between it and legacy TCP congestion controllers. Which is exactly why it is recommended to only be used in controlled networking environments such as within data centers. Do not just casually deploy this in the wild, okay?
DCTCP extends the Explicit Congestion Notification signal to estimate the fraction of bytes that encounter congestion, rather than simply detecting that the congestion has occurred. Then DCTCP scales the congestion window based on this estimate. This approach achieves high burst tolerance, low latency, and high throughput with shallow-buffered switches. Iconic.
- Receiver functionality: If CE is observed in the IP header of an incoming packet at the TCP receiver, the receiver sends congestion notification to the sender by setting ECE in TCP header. This processing is different from standard receiver ECN processing which sets and holds the ECE bit for every ACK until it observes a CWR signal from the TCP sender.
- Sender functionality: The sender makes use of the modified receiver ECE semantics to maintain an estimate of the fraction of packets marked (\alpha) by using the exponential weighted moving average (EWMA) as shown below:
\alpha = (1 - g) * \alpha + g * F
In the above EWMA:
- g is the estimation gain (between 0 and 1)
- F is the fraction of packets marked in current RTT.
For send windows in which at least one ACK was received with ECE set, the sender should respond by reducing the congestion window as follows, once for every window of data:
cwnd = cwnd * (1 - \alpha / 2)
Following the recommendation of RFC 8257, the default values of the parameters are:
g = 0.0625 (i.e., 1/16)
initial alpha (\alpha) = 1
To enable DCTCP on all TCP sockets, you can use this config:
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpDctcp::GetTypeId ()));
To enable DCTCP on a selected node, one can set the โSocketTypeโ attribute on the TcpL4Protocol object of that node to the TcpDctcp TypeId.
The ECN is enabled automatically when DCTCP is used, even if the user has not explicitly enabled it. No need to ask, it just does that. ๐ซถ
DCTCP depends on a simple queue management algorithm in routers / switches to mark packets. The current implementation of DCTCP in ns-3 can use RED with a simple configuration to achieve the behavior of desired queue management algorithm.
To configure RED router for DCTCP:
Config::SetDefault ("ns3::RedQueueDisc::UseEcn", BooleanValue (true));
Config::SetDefault ("ns3::RedQueueDisc::QW", DoubleValue (1.0));
Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (16));
Config::SetDefault ("ns3::RedQueueDisc::MaxTh", DoubleValue (16));
There is also the option, when running CoDel or FqCoDel, to enable ECN on the queue and to set the โCeThresholdโ value to a low value such as 1ms. The following example uses CoDel:
Config::SetDefault ("ns3::CoDelQueueDisc::UseEcn", BooleanValue (true));
Config::SetDefault ("ns3::CoDelQueueDisc::CeThreshold", TimeValue (MilliSeconds (1)));
The following unit tests have been written to validate the implementation of DCTCP:
- ECT flags should be set for SYN, SYN+ACK, ACK and data packets for DCTCP traffic
- ECT flags should not be set for SYN, SYN+ACK and pure ACK packets, but should be set on data packets for ECN enabled traditional TCP flows
- ECE should be set only when CE flags are received at receiver and even if sender doesnโt send CWR, receiver should not send ECE if it doesnโt receive packets with CE flags
An example program, examples/tcp/tcp-validation.cc, can be used to experiment with DCTCP for long-running flows with different bottleneck link bandwidth, base RTTs, and queuing disciplines. A variant of this program has also been run using the ns-3 Direct Code Execution environment using DCTCP from Linux kernel 4.4, and the results were compared against ns-3 results. Nerdy AND thorough, we love to see it. ๐ฅ
An example program based on an experimental topology found in the original DCTCP SIGCOMM paper is provided in examples/tcp/dctcp-example.cc. This example uses a simple topology consisting of forty DCTCP senders and receivers and two ECN-enabled switches to examine throughput, fairness, and queue delay properties of the network.
This implementation was tested extensively against a version of DCTCP in the Linux kernel version 4.4 using the ns-3 direct code execution (DCE) environment. Some differences were noted:
- Linux maintains its congestion window in segments and not bytes, and the arithmetic is not floating point, so small differences in the evolution of congestion window have been observed.
- Linux uses pacing, where packets to be sent are paced out at regular intervals. However, if at any instant the number of segments that can be sent are less than two, Linux does not pace them and instead sends them back-to-back. Currently, ns-3 paces out all packets eligible to be sent in the same manner.
More information about DCTCP is available in the RFC 8257: https://tools.ietf.org/html/rfc8257
๐ฅ BBR
BBR (class TcpBbr) is a congestion control algorithm that regulates the sending rate by deriving an estimate of the bottleneck's available bandwidth and the RTT of the path. It's out here seeking to operate at an optimal point where the sender experiences maximum delivery rate with minimum RTT. Main character energy, truly. โจ
It creates a network model comprising maximum delivery rate with minimum RTT observed so far, and then estimates BDP (maximum bandwidth * minimum RTT) to control the maximum amount of inflight data. BBR controls congestion by limiting the rate at which packets are sent. It caps the cwnd to one BDP and paces out packets at a rate which is adjusted based on the latest estimate of delivery rate. BBR algorithm is agnostic to packet losses and ECN marks. It simply does not care. ๐
pacing_gain controls the rate of sending data and cwnd_gain controls the amount of data to send.
The following is a high level overview of BBR congestion control algorithm:
On receiving an ACK:
rtt = now - packet.sent_time update_minimum_rtt (rtt)
delivery_rate = estimate_delivery_rate (packet)
update_maximum_bandwidth (delivery_rate)
After transmitting a data packet:
bdp = max_bandwidth * min_rtt if (cwnd * bdp < inflight)
return
if (now > nextSendTime)
{ transmit (packet) nextSendTime = now + packet.size
/ (pacing_gain * max_bandwidth)
}
else return
Schedule (nextSendTime, Send)
๐ Turning BBR on ๐
Wanna flip BBR on for every single TCP socket? Bestie, it's literally one line:
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpBbr::GetTypeId ()));
But if you're a picky queen and only want it on one chosen socket, do this instead (and yes, you have to swap in a real Node ID โ don't be out here using 1 if 1 isn't your node, okay?):
Config::Set ("$ns3::NodeListPriv/NodeList/1/$ns3::TcpL4Protocol/SocketType", TypeIdValue (TcpBbr::GetTypeId ()));
The ns-3 implementation of BBR is based on its Linux implementation. The Linux 5.4 kernel implementation has been used to validate the behavior of the ns-3 implementation of BBR (see below section on Validation). iykyk ๐
Also, these unit tests were written to validate BBR in ns-3:
- BBR should enable (if not already done) TCP pacing feature.
- Test to validate the values of
pacing_gainandcwnd_gainin different phases of BBR.
There's an example program, examples/tcp/tcp-bbr-example.cc, if you wanna mess around with BBR for one long running flow. It uses a simple topology โ one sender, one receiver, two routers โ to examine congestion window, throughput and queue control. A program similar to this has been run using the Network Stack Tester (NeST) using BBR from Linux kernel 5.4, and the results were compared against ns-3 results. Science! ๐ฌโจ
More info about BBR lives in this Internet Draft: https://tools.ietf.org/html/draft-cardwell-iccrg-bbr-congestion-control-00
More info about Delivery Rate Estimation is in this draft: https://tools.ietf.org/html/draft-cheng-iccrg-delivery-rate-estimation-00
And for an academic peer-reviewed paper on the BBR implementation in ns-3, go read:
- Vivek Jain, Viyom Mittal and Mohit P. Tahiliani. โDesign and Implementation of TCP BBR in ns-3.โ In Proceedings of the 10th Workshop on ns-3, pp. 16-22. 2018. (โ
https://dl.acm.org/doi/abs/10.1145/3199902.3199911)
๐ฆ Support for Explicit Congestion Notification (ECN) ๐ฆ
ECN gives you end-to-end notification of network congestion without dropping packets. The way it works: two bits in the IP header โ ECN Capable Transport (the ECT bit) and Congestion Experienced (the CE bit) โ plus two bits in the TCP header: Congestion Window Reduced (CWR) and ECN Echo (ECE). Two plus two, iconic.
More info is available in RFC 3168: https://tools.ietf.org/html/rfc3168
These ECN states are declared in src/internet/model/tcp-socket-state.h:
typedef enum
{
ECN_DISABLED = 0, //!< ECN disabled traffic
ECN_IDLE, //!< ECN is enabled but currently there is no action pertaining to ECE or CWR to be taken
ECN_CE_RCVD, //!< Last packet received had CE bit set in IP header
ECN_SENDING_ECE, //!< Receiver sends an ACK with ECE bit set in TCP header
ECN_ECE_RCVD, //!< Last ACK received had ECE bit set in TCP header
ECN_CWR_SENT //!< Sender has reduced the congestion window, and sent a packet with CWR bit set in TCP header. This is used for tracing.
} EcnStates_t;
The current implementation of ECN is based on RFC 3168 and is referred to as Classic ECN.
This enum is the mode of ECN:
typedef enum
{
ClassicEcn, //!< ECN functionality as described in RFC 3168.
DctcpEcn, //!< ECN functionality as described in RFC 8257. Note: this mode is specific to DCTCP.
} EcnMode_t;
And here are some important ECN parameters, no cap:
// ECN parameters
EcnMode_t m_ecnMode {ClassicEcn}; //!< ECN mode
UseEcn_t m_useEcn {Off}; //!< Socket ECN capability
โจ Enabling ECN โจ
Okay so by default, ECN support is disabled in TCP sockets. To turn it on, change the value of the attribute ns3::TcpSocketBase::UseEcn to On. These are the supported values โ this functionality is aligned with Linux: https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt
typedef enum
{
Off = 0, //!< Disable
On = 1, //!< Enable
AcceptOnly = 2, //!< Enable only when the peer endpoint is ECN capable
} UseEcn_t;
For example:
Config::SetDefault ("ns3::TcpSocketBase::UseEcn", StringValue ("On"))
๐ ECN negotiation ๐
ECN capability gets negotiated during the three-way TCP handshake, bestie. Watch:
- Sender sends SYN + CWR + ECE
if (m_useEcn == UseEcn_t::On)
{
SendEmptyPacket (TcpHeader::SYN | TcpHeader::ECE | TcpHeader::CWR);
}
else
{
SendEmptyPacket (TcpHeader::SYN);
}
m_ecnState = ECN_DISABLED;
- Receiver sends SYN + ACK + ECE
if (m_useEcn != UseEcn_t::Off && (tcpHeader.GetFlags () & (TcpHeader::CWR | TcpHeader::ECE)) == (TcpHeader::CWR | TcpHeader::ECE))
{
SendEmptyPacket (TcpHeader::SYN | TcpHeader::ACK |TcpHeader::ECE);
m_ecnState = ECN_IDLE;
}
else
{
SendEmptyPacket (TcpHeader::SYN | TcpHeader::ACK);
m_ecnState = ECN_DISABLED;
}
- Sender sends ACK
if (m_useEcn != UseEcn_t::Off && (tcpHeader.GetFlags () & (TcpHeader::CWR | TcpHeader::ECE)) == (TcpHeader::ECE))
{
m_ecnState = ECN_IDLE;
}
else
{
m_ecnState = ECN_DISABLED;
}
Once the ECN-negotiation is successful, the sender sends data packets with ECT bits set in the IP header. slay.
Note: As mentioned in Section 6.1.1 of RFC 3168, ECT bits should not be set during ECN negotiation. The ECN negotiation implemented in ns-3 follows this guideline. ๐ซถ
๐ซ ECN State Transitions ๐ซ
- Initially both sender and receiver have their
m_ecnStateset asECN_DISABLED - Once the ECN negotiation is successful, their states are set to
ECN_IDLE - The receiverโs state changes to
ECN_CE_RCVDwhen it receives a packet with CE bit set. The state then moves toECN_SENDING_ECEwhen the receiver sends an ACK with ECE set. This state is retained until a CWR is received, following which, the state changes toECN_IDLE. - When the sender receives an ACK with ECE bit set from receiver, its state is set as
ECN_ECE_RCVD - The senderโs state changes to
ECN_CWR_SENTwhen it sends a packet with CWR bit set. It remains in this state until an ACK with valid ECE is received (i.e., ECE is received for a packet that belongs to a new window), following which, its state changes toECN_ECE_RCVD.
๐ฅ RFC 3168 compliance ๐ฅ
Based on the suggestions provided in RFC 3168, this behavior has been implemented:
- Pure ACK packets should not have the ECT bit set (Section 6.1.4).
- In the current implementation, the sender only sends ECT(0) in the IP header.
- The sender should should reduce the congestion window only once in each window (Section 6.1.2).
- The receiver should ignore the CE bits set in a packet arriving out of window (Section 6.1.5).
- The sender should ignore the ECE bits set in the packet arriving out of window (Section 6.1.2).
๐ Open issues ๐
The following issues are yet to be addressed:
- Retransmitted packets should not have the CWR bit set (Section 6.1.5).
- Despite the congestion window size being 1 MSS, the sender should reduce its congestion window by half when it receives a packet with the ECE bit set. The sender must reset the retransmit timer on receiving the ECN-Echo packet when the congestion window is one. The sending TCP will then be able to send a new packet only when the retransmit timer expires (Section 6.1.2).
- Support for separately handling the enabling of ECN on the incoming and outgoing TCP sessions (e.g. a TCP may perform ECN echoing but not set the ECT codepoints on its outbound data segments).
๐ Support for Dynamic Pacing ๐
TCP pacing is the sender-side practice of scheduling the transmission of a burst of eligible TCP segments across a time interval such as a TCP RTT, to avoid or reduce bursts. Historically, TCP used the natural ACK clocking mechanism to pace segments, but some network paths introduce aggregation (bursts of ACKs arriving) or ACK thinning, and either of those disrupts ACK clocking. Some latency-sensitive congestion controls under development (Prague, BBR) require pacing to operate effectively. periodt.
Until recently, the state of the art in Linux was to support pacing in one of two ways:
fq/pacingwithsch_fq- TCP internal pacing
The presentation by Dumazet and Cheng at IETF 88 summarizes it: https://www.ietf.org/proceedings/88/slides/slides-88-tcpm-9.pdf
The first option was most often used when offloading (TSO) was enabled and when the sch_fq scheduler was used at the traffic control (qdisc) sublayer. In this case, TCP was responsible for setting the socket pacing rate, but the qdisc sublayer would enforce it. When TSO was enabled, the kernel would break a large burst into smaller chunks, with dynamic sizing based on the pacing rate, and hand off the segments to the fq qdisc for pacing.
The second option was used if sch_fq was not enabled; TCP would be responsible for internally pacing.
In 2018, Linux switched to an Early Departure Model (EDM): https://lwn.net/Articles/766564/.
TCP pacing in Linux was added in kernel 3.12, and authors chose to allow a pacing rate of 200% against the current rate, to allow probing for optimal throughput even during slow start phase. Some refinements were added in https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=43e122b014c9, in which Google reported that it was better to apply a different ratio (120%) in Congestion Avoidance phase. Furthermore, authors found that after cwnd reduction, it was helpful to become more conservative and switch to the conservative ratio (120%) as soon as cwnd >= ssthresh/2, as the initial ramp up (when ssthresh is infinite) still allows doubling cwnd every other RTT. Linux also does not pace the initial window (IW), typically 10 segments in practice.
Linux has also been observed to not pace if the number of eligible segments to be sent is exactly two; they will be sent back to back. If three or more, the first two are sent immediately, and additional segments are paced at the current pacing rate. ๐
In ns-3, the model is as follows. There is no TSO/sch_fq model; only internal pacing according to current Linux policy.
Pacing? Oh bestie, pacing is the moment. ๐ You can turn it on for any TCP congestion control, and you can set a max pacing rate. On top of that, dynamic pacing is enabled for all TCP variants, following these lil guidelines:
- Pacing of the initial window (IW) is not done by default, but you can enable it separately if you want. ๐
- Pacing of the initial slow start (after IW) happens at a pacing rate of 200% of the current rate, so the window can grow. And yes, you can configure this rate to something other than 200%. โจ
- Pacing of the congestion avoidance phase happens at a pacing rate of 120% of the current rate. Also configurable to a value other than 120%. ๐
- Pacing of subsequent slow start follows this heuristic: if
cwnd < ssthresh/2โ like after a timeout or an idle period โ pace at the slow start rate (200%). Otherwise, pace at the congestion avoidance rate. ๐ง
Dynamic pacing is demoed by the example program examples/tcp/tcp-pacing.cc. Go run it, it's giving very much "watch me cook". ๐ฅ
๐ฆ Validation ๐ฆ
These tests live in the src/internet/test directory. In general, TCP tests inherit from a class called TcpGeneralTest, which hands you the common operations to set up test scenarios with TCP objects. Wanna write new ones? Check the section below on Writing TCP tests. iykyk. ๐
tcp: Basic transmission of string of data from client to servertcp-bytes-in-flight-test: TCP correctly estimates bytes in flight under loss conditionstcp-cong-avoid-test: TCP congestion avoidance for different packet sizestcp-datasentcb: Check TCP's 'data sent' callbacktcp-endpoint-bug2211-test: A test for an issue that was causing stack overflowtcp-fast-retr-test: Fast Retransmit testingtcp-header: Unit tests on the TCP headertcp-highspeed-test: Unit tests on the HighSpeed congestion controltcp-htcp-test: Unit tests on the H-TCP congestion controltcp-hybla-test: Unit tests on the Hybla congestion controltcp-vegas-test: Unit tests on the Vegas congestion controltcp-veno-test: Unit tests on the Veno congestion controltcp-scalable-test: Unit tests on the Scalable congestion controltcp-bic-test: Unit tests on the BIC congestion controltcp-yeah-test: Unit tests on the YeAH congestion controltcp-illinois-test: Unit tests on the Illinois congestion controltcp-ledbat-test: Unit tests on the LEDBAT congestion controltcp-lp-test: Unit tests on the TCP-LP congestion controltcp-dctcp-test: Unit tests on the DCTCP congestion controltcp-bbr-test: Unit tests on the BBR congestion controltcp-option: Unit tests on TCP optionstcp-pkts-acked-test: Unit test the number of time thatPktsAckedis calledtcp-rto-test: Unit test behavior after a RTO occurstcp-rtt-estimation-test: Check RTT calculations, including retransmission casestcp-slow-start-test: Check behavior of slow starttcp-timestamp: Unit test on the timestamp optiontcp-wscaling: Unit test on the window scaling optiontcp-zero-window-test: Unit test persist behavior for zero window conditionstcp-close-test: Unit test on the socket closing: both receiver and sender have to close their socket when all bytes are transferredtcp-ecn-test: Unit tests on Explicit Congestion Notificationtcp-pacing-test: Unit tests on dynamic TCP pacing rate
Some tests have dependencies outside of the internet module, so they live in a system test directory called src/test/ns3tcp. Three of these six tests involve the Network Simulation Cradle, and they get disabled if NSC isn't enabled in the build. No NSC, no vibes, sorry. ๐ญ
ns3-tcp-cwnd: Check to see that ns-3 TCP congestion control works againstliblinux2.6.26.soimplementationns3-tcp-interoperability: Check to see that ns-3 TCP interoperates withliblinux2.6.26.soimplementationns3-tcp-loss: Check behavior of ns-3 TCP upon packet lossesnsc-tcp-loss: Check behavior of NSC TCP upon packet lossesns3-tcp-no-delay: Check that ns-3 TCP Nagle's algorithm works correctly and that it can be disabledns3-tcp-socket: Check that ns-3 TCP successfully transfers an application data write of various sizesns3-tcp-state: Check the operation of the TCP state machine for several cases
A bunch of TCP validation test results are also chillin' in the wiki page describing this implementation. ๐ซถ
So the ns-3 implementation of TCP Linux Reno was validated against the NewReno implementation of Linux kernel 4.4.0 using ns-3 Direct Code Execution (DCE). DCE is a framework that lets users run kernel space protocol inside ns-3 without changing the source code. Iconic behavior honestly. ๐
In this validation, cwnd traces of DCE Linux reno were compared to those of ns-3 Linux Reno and NewReno for a delayed acknowledgement configuration of 1 segment (in the ns-3 implementation; Linux does not allow direct configuration of this setting). And the tea is: cwnd traces for ns-3 Linux Reno closely overlap with DCE reno, while for ns-3 NewReno there was deviation in the congestion avoidance phase. ๐ฌ
[image] DCE Linux Reno vs. ns-3 Linux Reno.
[image] DCE Linux Reno vs. ns-3 NewReno.
The difference in the cwnd in the early stage of this flow is because of the way cwnd is plotted. Since ns-3 provides a trace source for cwnd, an ns-3 Linux Reno cwnd sample is obtained every time the cwnd value changes, whereas for DCE Linux Reno, the kernel doesn't have a corresponding trace source. Instead, we use the "ss" command of the Linux kernel to obtain cwnd values. The "ss" samples cwnd at an interval of 0.5 seconds. (Sampling, not tracing. Different girl, different method. ๐
)
Figure DCTCP throughput for 10ms/50Mbps bottleneck, 1ms CE threshold shows a long-running file transfer using DCTCP over a 50 Mbps bottleneck (running CoDel queue disc with a 1ms CE threshold setting) with a 10 ms base RTT. The figure shows that DCTCP reaches link capacity very quickly and stays there for the duration with minimal change in throughput. In contrast, Figure DCTCP throughput for 80ms/50Mbps bottleneck, 1ms CE threshold plots the throughput for the same configuration except with an 80 ms base RTT. In this case, DCTCP exits slow start early and takes a long time to build the flow throughput to the bottleneck link capacity. DCTCP is not intended to be used at such a large base RTT, but this figure highlights the sensitivity to RTT (and can be reproduced using the Linux implementation). ๐
[image] DCTCP throughput for 10ms/50Mbps bottleneck, 1ms CE threshold.
[image] DCTCP throughput for 80ms/50Mbps bottleneck, 1ms CE threshold.
Similar to DCTCP, TCP CUBIC has been tested against the Linux kernel version 4.4 implementation. Figure CUBIC cwnd evolution for 50ms/50Mbps bottleneck, no ECN compares the congestion window evolution between ns-3 and Linux for a single flow operating over a 50 Mbps link with 50 ms base RTT and the CoDel AQM. Some differences can be observed between the peak of slow start window growth (ns-3 exits slow start earlier due to its HyStart implementation), and the window growth is a bit out-of-sync (likely due to different implementations of the algorithm), but the cubic concave/convex window pattern, and the signs of TCP CUBIC fast convergence algorithm (alternating patterns of cubic and concave window growth) can be observed. The ns-3 congestion window is maintained in bytes (unlike Linux which uses segments) but has been normalized to segments for these plots. Figure CUBIC cwnd evolution for 50ms/50Mbps bottleneck, with ECN displays the outcome of a similar scenario but with ECN enabled throughout. โจ
[image] CUBIC cwnd evolution for 50ms/50Mbps bottleneck, no ECN.
[image] CUBIC cwnd evolution for 50ms/50Mbps bottleneck, with ECN.
TCP ECN operation is tested in the ARED and RED tests that are documented in the traffic-control module documentation. ๐
Like DCTCP and TCP CUBIC, the ns-3 implementation of TCP BBR was validated against the BBR implementation of Linux kernel 5.4 using Network Stack Tester (NeST). NeST is a python package which allows the users to emulate kernel space protocols using Linux network namespaces. Figure Congestion window evolution: ns-3 BBR vs. Linux BBR (using NeST) compares the congestion window evolution between ns-3 and Linux for a single flow operating over a 10 Mbps link with 10 ms base RTT and FIFO queue discipline. ๐
[image] Congestion window evolution: ns-3 BBR vs. Linux BBR (using NeST).
It can be observed that the congestion window traces for ns-3 BBR closely overlap with Linux BBR. The periodic drops in congestion window every 10 seconds depict the PROBE_RTT phase of the BBR algorithm. In this phase, BBR algorithm keeps the congestion window fixed to 4 segments. No cap. ๐
The example program, examples/tcp-bbr-example.cc has been used to obtain the congestion window curve shown in Figure Congestion window evolution: ns-3 BBR vs. Linux BBR (using NeST). The detailed instructions to reproduce ns-3 plot and NeST plot can be found at: https://github.com/mohittahiliani/BBR-Validation ๐
๐ Writing a new congestion control algorithm ๐
Writing (or porting) a congestion control algorithms from scratch (or from other systems) is a process completely separated from the internals of TcpSocketBase. Bestie, you don't have to touch the scary parts. ๐ซถ
All operations that are delegated to a congestion control are contained in the class TcpCongestionOps. It mimics the structure tcp_congestion_ops of Linux, and the following operations are defined:
virtual std::string GetName () const;
virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb, uint32_t bytesInFlight);
virtual void IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
virtual void PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked,const Time& rtt);
virtual Ptr<TcpCongestionOps> Fork ();
virtual void CwndEvent (Ptr<TcpSocketState> tcb, const TcpSocketState::TcpCaEvent_t event);
The most interesting methods to write are GetSsThresh and IncreaseWindow. The latter is called when TcpSocketBase decides that it's time to increase the congestion window. Much information is available in the Transmission Control Block, and the method should increase cWnd and/or ssThresh based on the number of segments acked. ๐
GetSsThresh is called whenever the socket needs an updated value of the slow start threshold. This happens after a loss; congestion control algorithms are then asked to lower such value, and to return it. So like, loss happens, you get asked to bring the number down, and you hand it back. Periodt. ๐
PktsAcked shows up whenever the algorithm is being nosy about timing info (think RTT and friends), and it fires every single time an ACK lands.
CwndEvent is there for when the algorithm needs to peep the state of the socket during the different congestion window events.
TCP SACK and non-SACK
Okay bestie, the whole reason we did this: keeping two separate TCP cores alive โ RFC 6675 (TCP-SACK) and RFC 5681 (TCP congestion control) โ would mean duplicating code and signing up for the eternal struggle of maintaining both versions. So instead we merged RFC 6675 into the current code base. If the receiver supports the option, the sender bases its retransmissions over the received SACK info. But when that option is not there? Best it can do is follow the RFC 5681 spec (on Fast Retransmit/Recovery) and employ NewReno modifications when partial ACKs happen. ๐ซถ
Linux does a similar thing with the function tcp_add_reno_sack. Our implementation resides in the TcpTxBuffer class, which implements a scoreboard through two different lists of segments. TcpSocketBase actively uses the API provided by TcpTxBuffer to query the scoreboard; go read the Doxygen documentation (and the in-code comments) if you want to learn more about this implementation.
For an academic peer-reviewed paper on the SACK implementation in ns-3, please refer to https://dl.acm.org/citation.cfm?id=3067666.
Loss Recovery Algorithms
The following loss recovery algorithms are supported in ns-3 TCP. The current default (as of ns-3.32 release) is Proportional Rate Reduction (PRR), while the default for ns-3.31 and earlier was Classic Recovery. โจ
Classic Recovery
Classic Recovery refers to the combination of the NewReno algorithm described in RFC 6582 along with the SACK based loss recovery algorithm mentioned in RFC 6675. SACK based loss recovery is used when sender and receiver support SACK options. In the case when SACK options are disabled, the NewReno modification handles the recovery.
At the start of recovery phase the congestion window is reduced diffently for NewReno and SACK based recovery. For NewReno the reduction is done as given below:
cWnd = ssThresh
For SACK based recovery, this is done as follows:
cWnd = ssThresh + (dupAckCount * segmentSize)
While in the recovery phase, the congestion window is inflated by segmentSize on arrival of every ACK when NewReno is used. The congestion window is kept same when SACK based loss recovery is used.
Proportional Rate Reduction
Proportional Rate Reduction (PRR) is a loss recovery algorithm described in RFC 6937 and currently used in Linux. The design of PRR helps in avoiding excess window adjustments and aims to keep the congestion window as close as possible to ssThresh.
PRR updates the congestion window by comparing the values of bytesInFlight and ssThresh. If the value of bytesInFlight is greater than ssThresh, congestion window is updated as shown below:
sndcnt = CEIL(prrDelivered * ssThresh / RecoverFS) - prrOut
cWnd = pipe + sndcnt
where RecoverFS is the value of bytesInFlight at the start of recovery phase, prrDelivered is the total bytes delivered during recovery phase, prrOut is the total bytes sent during recovery phase and sndcnt represents the number of bytes to be sent in response to each ACK.
Otherwise, the congestion window is updated by either using Conservative Reduction Bound (CRB) or Slow Start Reduction Bound (SSRB) with SSRB being the default Reduction Bound. Each Reduction Bound calculates a maximum data sending limit. For CRB, the limit is calculated as shown below:
limit = prrDelivered - prr out
For SSRB, it is calculated as:
limit = MAX(prrDelivered - prrOut, DeliveredData) + MSS
where DeliveredData represets the total number of bytes delivered to the receiver as indicated by the current ACK and MSS is the maximum segment size.
After limit calculation, the cWnd is updated as given below:
sndcnt = MIN (ssThresh - pipe, limit)
cWnd = pipe + sndcnt
More information (paper): https://dl.acm.org/citation.cfm?id=2068832
More information (RFC): https://tools.ietf.org/html/rfc6937
Adding a new loss recovery algorithm in ns-3
Writing (or porting) a loss recovery algorithms from scratch (or from other systems) is a process completely separated from the internals of TcpSocketBase. ๐
All operations that are delegated to a loss recovery are contained in the class TcpRecoveryOps and are given below:
virtual std::string GetName () const;
virtual void EnterRecovery (Ptr<const TcpSocketState> tcb, uint32_t unAckDataCount,
bool isSackEnabled, uint32_t dupAckCount,
uint32_t bytesInFlight, uint32_t lastDeliveredBytes);
virtual void DoRecovery (Ptr<const TcpSocketState> tcb, uint32_t unAckDataCount,
bool isSackEnabled, uint32_t dupAckCount,
uint32_t bytesInFlight, uint32_t lastDeliveredBytes);
virtual void ExitRecovery (Ptr<TcpSocketState> tcb, uint32_t bytesInFlight);
virtual void UpdateBytesSent (uint32_t bytesSent);
virtual Ptr<TcpRecoveryOps> Fork ();
EnterRecovery is called when packet loss is detected and recovery is triggered. While in recovery phase, each time when an ACK arrives, DoRecovery is called which performs the necessary congestion window changes as per the recovery algorithm. ExitRecovery is called just prior to exiting recovery phase in order to perform the required congestion window ajustments. UpdateBytesSent is used to keep track of bytes sent and is called whenever a data packet is sent during recovery phase.
Delivery Rate Estimation
Current TCP implementation measures the approximate value of the delivery rate of inflight data based on Delivery Rate Estimation.
As high level idea, keep in mind that the algorithm keeps track of 2 variables:
delivered: Total amount of data delivered so far.deliveredStamp: Last timedeliveredwas updated.
When a packet is transmitted, the value of delivered (d0) and deliveredStamp (t0) is stored in its respective TcpTxItem.
When an acknowledgement comes for this packet, the value of delivered and deliveredStamp is updated to d1 and t1 in the same TcpTxItem.
After processing the acknowledgement, the rate sample is calculated and then passed to a congestion avoidance algorithm:
delivery_rate = (d1 - d0)/(t1 - t0)
The implementation to estimate delivery rate is a joint work between TcpTxBuffer and TcpRateOps. For more information, please take a look at their Doxygen documentation.
The implementation follows the Internet draft (Delivery Rate Estimation): https://tools.ietf.org/html/draft-cheng-iccrg-delivery-rate-estimation-00
Current limitations
TcpCongestionOpsinterface does not contain every possible Linux operation
Writing TCP tests
The TCP subsystem supports automated test cases on both socket functions and congestion control algorithms. To show how to write tests for TCP, here we explain the process of creating a test case that reproduces the Bug #1571. ๐
The bug concerns the zero window situation, which happens when the receiver cannot handle more data. In this case, it advertises a zero window, which causes the sender to pause transmission and wait for the receiver to increase the window.
The sender has a timer to periodically check the receiver's window: however, in modern TCP implementations, when the receiver has freed a "significant" amount of data, the receiver itself sends an "active" window update, meaning that the transmission could be resumed. Nevertheless, the sender timer is still necessary because window updates can be lost.
NOTE: During the text, we will assume some knowledge about the general design of the TCP test infrastructure, which is explained in detail into the Doxygen documentation. As a brief summary, the strategy is to have a class that sets up a TCP connection, and that calls protected members of itself. In this way, subclasses can implement the necessary members, which will be called by the mainTcpGeneralTestclass when events occur. For example, after processing an ACK, the methodProcessedAckwill be invoked. Subclasses interested in checking some particular things which must have happened during an ACK processing, should implement theProcessedAckmethod and check the interesting values inside the method. To get a list of available methods, please check the Doxygen documentation.
We describe the writing of two test cases, covering both situations: the sender's zero-window probing and the receiver "active" window update. Our focus will be on dealing with the reported problems, which are:
- an ns-3 receiver does not send "active" window update when its receive buffer is being freed;
- even if the window update is artificially crafted, the transmission does not resume.
However, other things should be checked in the test:
- Persistent timer setup
- Persistent timer teardown if rWnd increases
To construct the test case, one first derives from the TcpGeneralTest class:
The code is the following:
TcpZeroWindowTest::TcpZeroWindowTest (const std::string &desc)
: TcpGeneralTest (desc)
{
}
Then, one should define the general parameters for the TCP connection, which will be one-sided (one node is acting as SENDER, while the other is acting as RECEIVER):
- Application packet size set to 500, and 20 packets in total (meaning a stream of 10k bytes)
- Segment size for both SENDER and RECEIVER set to 500 bytes
- Initial slow start threshold set to
UINT32_MAX - Initial congestion window for the SENDER set to 10 segments (5000 bytes)
- Congestion control: NewReno
We have also to define the link properties, because the above definition does not work for every combination of propagation delay and sender application behavior.
- Link one-way propagation delay: 50 ms
- Application packet generation interval: 10 ms
- Application starting time: 20 s after the starting point
To define the properties of the environment (e.g. properties which should be set before the object creation, such as propagation delay) one next implements the method ConfigureEnvironment:
void
TcpZeroWindowTest::ConfigureEnvironment ()
{
TcpGeneralTest::ConfigureEnvironment ();
SetAppPktCount (20);
SetMTU (500);
SetTransmitStart (Seconds (2.0));
SetPropagationDelay (MilliSeconds (50));
}
okay so for other properties that you set after the object is created, you can use ConfigureProperties (). The difference is that some values โ like initial congestion window or initial slow start threshold โ are only applicable to a single instance, not to every instance we have. Usually, methods that require an id and a value are meant to be called inside ConfigureProperties (). Please see the Doxygen documentation for an exhaustive list of the tunable properties. ๐
void
TcpZeroWindowTest::ConfigureProperties ()
{
TcpGeneralTest::ConfigureProperties ();
SetInitialCwnd (SENDER, 10);
}
To see the default value for the experiment, please see the implementation of both methods inside TcpGeneralTest class. โจ
NOTE: If some configuration parameters are missing, add a method called โSetSomeValueโ which takes as input the value only (if it is meant to be called insideConfigureEnvironment) or the socket and the value (if it is meant to be called insideConfigureProperties).
To define a zero-window situation, we choose (by design) to initiate the connection with a 0-byte rx buffer. This implies that the RECEIVER, in its first SYN-ACK, advertises a zero window. This can be accomplished by implementing the method CreateReceiverSocket, setting an Rx buffer value of 0 bytes (at line 6 of the following code): ๐
Ptr<TcpSocketMsgBase>
TcpZeroWindowTest::CreateReceiverSocket (Ptr<Node> node)
{
Ptr<TcpSocketMsgBase> socket = TcpGeneralTest::CreateReceiverSocket (node);
socket->SetAttribute("RcvBufSize", UintegerValue (0));
Simulator::Schedule (Seconds (10.0),
&TcpZeroWindowTest::IncreaseBufSize, this);
return socket;
}
Even so, to check the active window update, we should schedule an increase of the buffer size. We do this at line 7 and 8, scheduling the function IncreaseBufSize. ๐
void
TcpZeroWindowTest::IncreaseBufSize ()
{
SetRcvBufSize (RECEIVER, 2500);
}
Which utilizes the SetRcvBufSize method to edit the RxBuffer object of the RECEIVER. As said before, check the Doxygen documentation for class TcpGeneralTest to be aware of the various possibilities that it offers. โจ
NOTE: By design, we choose to maintain a close relationship betweenTcpSocketBaseandTcpGeneralTest: they are connected by a friendship relation. Since friendship is not passed through inheritance, if one discovers that one needs to access or to modify a private (or protected) member ofTcpSocketBase, one can do so by adding a method in the classTcpGeneralSocket. An example of such method isSetRcvBufSize, which allowsTcpGeneralSocketsubclasses to forcefully set the RxBuffer size.
void
TcpGeneralTest::SetRcvBufSize (SocketWho who, uint32_t size)
{
if (who == SENDER)
{
m_senderSocket->SetRcvBufSize (size);
}
else if (who == RECEIVER)
{
m_receiverSocket->SetRcvBufSize (size);
}
else
{
NS_FATAL_ERROR ("Not defined");
}
}
Next, we can start to follow the TCP connection: ๐
- At time 0.0 s the connection is opened sender side, with a SYN packet sent from SENDER to RECEIVER
- At time 0.05 s the RECEIVER gets the SYN and replies with a SYN-ACK
- At time 0.10 s the SENDER gets the SYN-ACK and replies with a SYN.
While the general structure is defined, and the connection is started, we need to define a way to check the rWnd field on the segments. To this aim, we can implement the methods Rx and Tx in the TcpGeneralTest subclass, checking each time the actions of the RECEIVER and the SENDER. These methods are defined in TcpGeneralTest, and they are attached to the Rx and Tx traces in the TcpSocketBase. One should write small tests for every detail that one wants to ensure during the connection (it will prevent the test from changing over the time, and it ensures that the behavior will stay consistent through releases). We start by ensuring that the first SYN-ACK has 0 as advertised window size: ๐
void
TcpZeroWindowTest::Tx(const Ptr<const Packet> p, const TcpHeader &h, SocketWho who)
{
...
else if (who == RECEIVER)
{
NS_LOG_INFO ("\tRECEIVER TX " << h << " size " << p->GetSize());
if (h.GetFlags () & TcpHeader::SYN)
{
NS_TEST_ASSERT_MSG_EQ (h.GetWindowSize(), 0,
"RECEIVER window size is not 0 in the SYN-ACK");
}
}
....
}
Practically, we are checking that every SYN packet sent by the RECEIVER has the advertised window set to 0. The same thing is done also by checking, in the Rx method, that each SYN received by SENDER has the advertised window set to 0. Thanks to the log subsystem, we can print what is happening through messages. If we run the experiment, enabling the logging, we can see the following: ๐ฅ
./waf shell
gdb --args ./build/utils/ns3-dev-test-runner-debug --test-name=tcp-zero-window-test --stop-on-failure --fullness=QUICK --assert-on-failure --verbose
(gdb) run
0.00s TcpZeroWindowTestSuite:Tx(): 0.00 SENDER TX 49153 > 4477 [SYN] Seq=0 Ack=0 Win=32768 ns3::TcpOptionWinScale(2) ns3::TcpOptionTS(0;0) size 36
0.05s TcpZeroWindowTestSuite:Rx(): 0.05 RECEIVER RX 49153 > 4477 [SYN] Seq=0 Ack=0 Win=32768 ns3::TcpOptionWinScale(2) ns3::TcpOptionTS(0;0) ns3::TcpOptionEnd(EOL) size 0
0.05s TcpZeroWindowTestSuite:Tx(): 0.05 RECEIVER TX 4477 > 49153 [SYN|ACK] Seq=0 Ack=1 Win=0 ns3::TcpOptionWinScale(0) ns3::TcpOptionTS(50;0) size 36
0.10s TcpZeroWindowTestSuite:Rx(): 0.10 SENDER RX 4477 > 49153 [SYN|ACK] Seq=0 Ack=1 Win=0 ns3::TcpOptionWinScale(0) ns3::TcpOptionTS(50;0) ns3::TcpOptionEnd(EOL) size 0
0.10s TcpZeroWindowTestSuite:Tx(): 0.10 SENDER TX 49153 > 4477 [ACK] Seq=1 Ack=1 Win=32768 ns3::TcpOptionTS(100;50) size 32
0.15s TcpZeroWindowTestSuite:Rx(): 0.15 RECEIVER RX 49153 > 4477 [ACK] Seq=1 Ack=1 Win=32768 ns3::TcpOptionTS(100;50) ns3::TcpOptionEnd(EOL) size 0
(...)
The output is cut to show the threeway handshake. As we can see from the headers, the rWnd of RECEIVER is set to 0, and thankfully our tests are not failing. Now we need to test for the persistent timer, which should be started by the SENDER after it receives the SYN-ACK. Since the Rx method is called before any computation on the received packet, we should utilize another method, namely ProcessedAck, which is the method called after each processed ACK. In the following, we show how to check if the persistent event is running after the processing of the SYN-ACK: โจ
void
TcpZeroWindowTest::ProcessedAck (const Ptr<const TcpSocketState> tcb,
const TcpHeader& h, SocketWho who)
{
if (who == SENDER)
{
if (h.GetFlags () & TcpHeader::SYN)
{
EventId persistentEvent = GetPersistentEvent (SENDER);
NS_TEST_ASSERT_MSG_EQ (persistentEvent.IsRunning (), true,
"Persistent event not started");
}
}
}
Since we programmed the increase of the buffer size after 10 simulated seconds, we expect the persistent timer to fire before any rWnd changes. When it fires, the SENDER should send a window probe, and the receiver should reply reporting again a zero window situation. At first, we investigate on what the sender sends: ๐
if (Simulator::Now ().GetSeconds () <= 6.0)
{
NS_TEST_ASSERT_MSG_EQ (p->GetSize () - h.GetSerializedSize(), 0,
"Data packet sent anyway");
}
else if (Simulator::Now ().GetSeconds () > 6.0 &&
Simulator::Now ().GetSeconds () <= 7.0)
{
NS_TEST_ASSERT_MSG_EQ (m_zeroWindowProbe, false, "Sent another probe");
if (! m_zeroWindowProbe)
{
NS_TEST_ASSERT_MSG_EQ (p->GetSize () - h.GetSerializedSize(), 1,
"Data packet sent instead of window probe");
NS_TEST_ASSERT_MSG_EQ (h.GetSequenceNumber(), SequenceNumber32 (1),
"Data packet sent instead of window probe");
m_zeroWindowProbe = true;
}
}
We divide the events by simulated time. At line 1, we check everything that happens before the 6.0 seconds mark; for instance, that no data packets are sent, and that the state remains OPEN for both sender and receiver. ๐
Since the persist timeout is initialized at 6 seconds (exercise left for the reader: edit the test, getting this value from the Attribute system), we need to check (line 6) between 6.0 and 7.0 simulated seconds that the probe is sent. Only one probe is allowed, and this is the reason for the check at line 11. ๐ซ
if (Simulator::Now ().GetSeconds () > 6.0 &&
Simulator::Now ().GetSeconds () <= 7.0)
{
NS_TEST_ASSERT_MSG_EQ (h.GetSequenceNumber(), SequenceNumber32 (1),
"Data packet sent instead of window probe");
NS_TEST_ASSERT_MSG_EQ (h.GetWindowSize(), 0,
"No zero window advertised by RECEIVER");
}
For the RECEIVER, the interval between 6 and 7 seconds is when the zero-window segment is sent. ๐จ
Other checks are redundant; the safest approach is to deny any other packet exchange between the 7 and 10 seconds mark. ๐
else if (Simulator::Now ().GetSeconds () > 7.0 &&
Simulator::Now ().GetSeconds () < 10.0)
{
NS_FATAL_ERROR ("No packets should be sent before the window update");
}
The state checks are performed at the end of the methods, since they are valid in every condition: โ
NS_TEST_ASSERT_MSG_EQ (GetCongStateFrom (GetTcb(SENDER)), TcpSocketState::CA_OPEN,
"Sender State is not OPEN");
NS_TEST_ASSERT_MSG_EQ (GetCongStateFrom (GetTcb(RECEIVER)), TcpSocketState::CA_OPEN,
"Receiver State is not OPEN");
Now, the interesting part in the Tx method is to check that after the 10.0 seconds mark (when the RECEIVER sends the active window update) the value of the window should be greater than zero (and precisely, set to 2500): ๐ฅ
else if (Simulator::Now().GetSeconds() >= 10.0)
{
NS_TEST_ASSERT_MSG_EQ (h.GetWindowSize(), 2500,
"Receiver window not updated");
}
To be sure that the sender receives the window update, we can use the Rx method: ๐
if (Simulator::Now().GetSeconds() >= 10.0)
{
NS_TEST_ASSERT_MSG_EQ (h.GetWindowSize(), 2500,
"Receiver window not updated");
m_windowUpdated = true;
}
So basically we're checking every single packet after the 10 seconds mark to see whether it's got the window updated or not. And at line 5 we also flip a boolean variable to true, just to make sure we actually reach this test. Like, we're confirming we got here, bestie. ๐
Last but not least (๐ญ the phrase), we implement the NormalClose() method too, to verify the connection ends with a success:
void
TcpZeroWindowTest::NormalClose (SocketWho who)
{
if (who == SENDER)
{
m_senderFinished = true;
}
else if (who == RECEIVER)
{
m_receiverFinished = true;
}
}
This method only gets called if all the bytes are transmitted successfully. Then, in the FinalChecks() method, we check all the variables โ they should all be true, which means we have perfectly closed the connection โจ:
void
TcpZeroWindowTest::FinalChecks ()
{
NS_TEST_ASSERT_MSG_EQ (m_zeroWindowProbe, true,
"Zero window probe not sent");
NS_TEST_ASSERT_MSG_EQ (m_windowUpdated, true,
"Window has not updated during the connection");
NS_TEST_ASSERT_MSG_EQ (m_senderFinished, true,
"Connection not closed successfully (SENDER)");
NS_TEST_ASSERT_MSG_EQ (m_receiverFinished, true,
"Connection not closed successfully (RECEIVER)");
}
To run the test, the usual way is
./test.py -s tcp-zero-window-test
PASS: TestSuite tcp-zero-window-test
1 of 1 tests passed (1 passed, 0 skipped, 0 failed, 0 crashed, 0 valgrind errors)
And if you wanna see the INFO messages, use a combo of ./waf shell and gdb (lowkey really useful ๐ซถ):
./waf shell && gdb --args ./build/utils/ns3-dev-test-runner-debug --test-name=tcp-zero-window-test --stop-on-failure --fullness=QUICK --assert-on-failure --verbose
and then, hit "Run".
NOTE: This code magically runs without any reported errors; however, in real cases, when you discover a bug you should expect the existing test to fail (this could indicate a well-written test and a bad-writted model, or a bad-written test; hopefully the first situation). Correcting bugs is an iterative process. For instance, commits created to make this test case running without errors are 11633:6b74df04cf44, (others to be merged).
๐ง Network Simulation Cradle ๐ง
The Network Simulation Cradle (NSC) is a framework for wrapping real-world network code into simulators, which lets you simulate real-world behavior at basically little extra cost. Like, the way that this work has been validated is by comparing situations using a test network with the same situations in the simulator. And to date, it's been shown that the NSC is able to produce extremely accurate results. NSC supports four real world stacks: FreeBSD, OpenBSD, lwIP and Linux. Emphasis has been placed on not changing any of the network stacks by hand โ not a single line of code has been changed in the network protocol implementations of any of the above four stacks. However, a custom C parser was built to programmatically change source code. ๐ฎโ๐จ
NSC has previously been ported to ns-2 and OMNeT++, and was was added to ns-3 in September 2008 (ns-3.2 release). This section describes the ns-3 port of NSC and how to use it.
NSC has been obsoleted by the Linux kernel support within Direct Code Execution (DCE). But ngl, NSC is still available through the bake build system. NSC supports Linux kernels 2.6.18 and 2.6.26, and an experimental version of 2.6.29 exists on ns-3's code server (โ http://code.nsnam.org/fw/nsc-linux-2.6.29/), but newer versions of the kernel have not been ported. ๐
โจ Prerequisites โจ
Presently, NSC has been tested and shown to work on these platforms: Linux i386 and Linux x86-64. NSC does not support powerpc. Use on FreeBSD or OS X is unsupported (although it may be able to work). ๐
Building NSC requires the packages flex and bison.
NSC requires use of gcc-4.9 or gcc-5 series, and will not build on newer systems lacking the older compilers.
๐พ Configuring and Downloading ๐พ
NSC must either be downloaded separately from its own repository, or downloading when using the bake build system of ns-3.
For ns-3.17 through ns-3.28 releases, when using bake, one obtains NSC implicitly as part of an "allinone" configuration, such as:
$ cd bake
$ python bake.py configure -e ns-allinone-3.27
$ python bake.py download
$ python bake.py build
For ns-3.29 and later versions, including the 'ns-3-allinone' development version, one must explicitly add NSC (nsc-0.5.3) to the bake configuration, such as:
$ cd bake
$ python bake.py configure -e ns-allinone-3.29 -e nsc-0.5.3
$ python bake.py download
$ python bake.py build
Instead of a released version, one may use the ns-3 development version by specifying ns-3-allinone to the configure step above.
NSC may also be downloaded from its download site using Mercurial:
$ hg clone https://secure.wand.net.nz/mercurial/nsc
Prior to the ns-3.17 release, NSC was included in the allinone tarball and the released version did not need to be separately downloaded.
๐จ Building and validating ๐จ
NSC may be built as part of the bake build process; alternatively, one may build NSC by itself using its build system; e.g.:
$ cd nsc-dev
$ python scons.py
Once NSC has been built either manually or through the bake system, change into the ns-3 source directory and try running the following configuration:
$ ./waf configure
If NSC has been previously built and found by waf, then you will see:
Network Simulation Cradle : enabled
If NSC has not been found, you will see:
Network Simulation Cradle : not enabled (NSC not found (see option --with-nsc))
In this case, you must pass the relative or absolute path to the NSC libraries with the "โwith-nsc" configure option; e.g.
$ ./waf configure --with-nsc=/path/to/my/nsc/directory
For ns-3 releases prior to the ns-3.17 release, using the build.py script in ns-3-allinone directory, NSC will be built by default unless the platform does not support it. To explicitly disable it when building ns-3, type:
$ ./waf configure --enable-examples --enable-tests --disable-nsc
If waf detects NSC, then building ns-3 with NSC is performed the same way with waf as without it. Once ns-3 is built, try running the following test suite:
$ ./test.py -s ns3-tcp-interoperability
If NSC has been successfully built, the following test should show up in the results:
PASS TestSuite ns3-tcp-interoperability
This confirms that NSC is ready to use. ๐ slay.
๐ฆ Usage ๐ฆ
There are a few example files. Try:
$ ./waf --run tcp-nsc-zoo
$ ./waf --run tcp-nsc-lfn
These examples will deposit some .pcap files in your directory, which can be examined by tcpdump or wireshark.
Let's look at the examples/tcp/tcp-nsc-zoo.cc file for some typical usage. How does it differ from using native ns-3 TCP? There is one main configuration line, when using NSC and the ns-3 helper API, that needs to be set:
InternetStackHelper internetStack;
internetStack.SetNscStack ("liblinux2.6.26.so");
// this switches nodes 0 and 1 to NSCs Linux 2.6.26 stack.
internetStack.Install (n.Get(0));
internetStack.Install (n.Get(1));
The key line is the SetNscStack. This tells the InternetStack helper to aggregate instances of NSC TCP instead of native ns-3 TCP to the remaining nodes. It is important that this function be called before calling the Install() function, as shown above. โ ๏ธ
Which stacks are available to use? Presently, the focus has been on Linux 2.6.18 and Linux 2.6.26 stacks for ns-3. To see which stacks were built, one can execute the following find command at the ns-3 top level directory:
$ find nsc -name "*.so" -type f
nsc/linux-2.6.18/liblinux2.6.18.so
nsc/linux-2.6.26/liblinux2.6.26.so
This tells us that we may either pass the library name liblinux2.6.18.so or liblinux2.6.26.so to the above configuration step.
๐ธ Stack configuration ๐ธ
NSC TCP shares the same configuration attributes that are common across TCP sockets, as described above and documented in Doxygen
Additionally, NSC TCP exports a lot of configuration variables into the ns-3 attributes system, via a sysctl-like interface. In the examples/tcp/tcp-nsc-zoo example, you can see the following configuration:
// this disables TCP SACK, wscale and timestamps on node 1 (the attributes
represent sysctl-values).
Config::Set ("/NodeList/1/$ns3::Ns3NscStack<linux2.6.26>/net.ipv4.tcp_sack",
StringValue ("0"));
Config::Set ("/NodeList/1/$ns3::Ns3NscStack<linux2.6.26>/net.ipv4.tcp_timestamps",
StringValue ("0"));
Config::Set ("/NodeList/1/$ns3::Ns3NscStack<linux2.6.26>/net.ipv4.tcp_window_scaling",
StringValue ("0"));
These additional configuration variables are not available to native ns-3 TCP.
Also note that default values for TCP attributes in ns-3 TCP may differ from the NSC TCP implementation. Specifically in ns-3:
- TCP default MSS is 536
- TCP Delayed ACK count is 2
Therefore when making comparisons between results obtained using NSC and ns-3 TCP, care must be taken to ensure these values are set appropriately. See /examples/tcp/tcp-nsc-comparison.cc for an example.
๐ NSC API ๐
This subsection describes the API that NSC presents to ns-3 or any other simulator. NSC provides its API in the form of a number of classes that are defined in sim/sim_interface.h in the nsc directory.
- INetStack โ INetStack contains the 'low level' operations for the operating system network stack, e.g. in and output functions from and to the network stack (think of this as the 'network driver interface'). There are also functions to create new TCP or UDP sockets.
- ISendCallback โ This is called by NSC when a packet should be sent out to the network. This simulator should use this callback to re-inject the packet into the simulator so the actual data can be delivered/routed to its destination, where it will eventually be handed into
Receive()(and eventually back to the receivers NSC instance viaINetStack->if_receive()). - INetStreamSocket โ This is the structure defining a particular connection endpoint (file descriptor). It contains methods to operate on this endpoint, e.g. connect, disconnect, accept, listen,
send_data/read_data, โฆ IInterruptCallbackโ okay so this one's carrying thewakeup()callback, and NSC calls it whenever something of interest goes down. Think ofwakeup()as the glow-up replacement for the operating system's own wakeup function: whenever the OS would normally wake up a process that's been sitting there waiting for an operation to complete (like the TCP handshake duringconnect(), bestie ๐ ), NSC invokes thewakeup()callback so the simulator can go check for state changes in its connection endpoints. โจ
ns-3 implementation
The ns-3 implementation makes use of that NSC API from above, and it's built like this. ๐ ๏ธ
The three main parts are:
ns3::NscTcpL4Protocol: a subclass ofIpv4L4Protocol(and of two NSC classes too:ISendCallbackandIInterruptCallback)ns3::NscTcpSocketImpl: a subclass ofTcpSocketns3::NscTcpSocketFactoryImpl: a factory that makes new NSC sockets
src/internet/model/nsc-tcp-l4-protocol is the main character here ๐. Upon Initialization, it loads an NSC network stack to use (via dlopen()). Each instance of this class may use a different stack. The stack (= shared library) you use is set with the SetNscLibrary() method (at this time it's called indirectly via the internet stack helper). The NSC stack then gets set up accordingly (timers etc). The NscTcpL4Protocol::Receive() function hands the packet it receives (it must be a complete TCP/IP packet) to the NSC stack for further processing. To be able to send packets, this class implements the NSC send_callback() method. This method is called by NSC whenever the NSC stack wishes to send a packet out to the network. Its arguments are a raw buffer, containing a complete TCP/IP packet, and a length value. So this method has to convert the raw data into a Ptr<Packet> usable by ns-3. In order to avoid various IPv4 header issues, the NSC IP header is not included. Instead, the TCP header and the actual payload are put into the Ptr<Packet>, and after this the Packet is passed down to layer 3 for sending the packet out (no further special treatment is needed in the send code path). ๐
This class calls ns3::NscTcpSocketImpl both from the NSC wakeup() callback and from the receive path (to ensure that possibly queued data is scheduled for sending).
src/internet/model/nsc-tcp-socket-impl implements the NSC socket interface. Each instance has its own m_nscTcpSocket. Data that is sent will be handed to the NSC stack via m_nscTcpSocket->send_data() (and not to NscTcpL4Protocol โ this is the major difference compared to ns-3 TCP). The class also queues up data that is sent before the underlying descriptor has entered an ESTABLISHED state. This class is called from the NscTcpL4Protocol class, when the NscTcpL4Protocol wakeup() callback is invoked by NSC. NscTcpSocketImpl then checks the current connection state (SYN_SENT, ESTABLISHED, LISTENโฆ) and schedules appropriate callbacks as needed, e.g. a LISTEN socket will schedule accept() to see if a new connection must be accepted, an ESTABLISHED socket schedules any pending data for writing, schedule a read() callback, etc. ๐ธ
Note that ns3::NscTcpSocketImpl does not interact with NSC TCP directly: instead, data is redirected to NSC. NSC TCP calls the NSC TCP sockets of a node when its wakeup() callback is invoked by NSC.
Limitations
- NSC only works on single-interface nodes; attempting to run it on a multi-interface node will cause a program error. ๐ do not try it bestie
- Cygwin and OS X PPC are not supported; OS X Intel is not supported but may work
- The non-Linux stacks of NSC are not supported in ns-3
- Not all socket API callbacks are supported
For more information, see this wiki page.
UDP model in ns-3
This chapter describes the UDP model available in ns-3. ๐ฆ
Generic support for UDP
ns-3 supports a native implementation of UDP. It provides a connectionless, unreliable datagram packet service. Packets may be reordered or duplicated before they arrive. UDP calculates and checks checksums to catch transmission errors.
This implementation inherits from a few common header classes in the src/network directory, so that user code can swap out implementations with minimal changes to the scripts.
Here are the important abstract base classes: ๐ง
- class
UdpSocket: This is defined in:src/internet/model/udp-socket.{cc,h}This is an abstract base class of all UDP sockets. This class exists solely for hostingUdpSocketattributes that can be reused across different implementations, and for declaring UDP-specific multicast API. - class
UdpSocketImpl: This class subclassesUdpSocket, and provides a socket interface to ns-3's implementation of UDP. - class
UdpSocketFactory: This is used by the layer-4 protocol instance to create UDP sockets. - class
UdpSocketFactoryImpl: This class is derived fromSocketFactoryand implements the API for creating UDP sockets. - class
UdpHeader: This class contains fields corresponding to those in a network UDP header (port numbers, payload size, checksum) as well as methods for serialization to and deserialization from a byte buffer. - class
UdpL4Protocol: This is a subclass ofIpL4Protocoland provides an implementation of the UDP protocol.
ns-3 UDP
This is an implementation of the User Datagram Protocol described in RFC 768. UDP uses a simple connectionless communication model with a minimum of protocol mechanism. The implementation provides checksums for data integrity, and port numbers for addressing different functions at the source and destination of the datagram. It has no handshaking dialogues, and thus exposes the user's data to any unreliability of the underlying network. There is no guarantee of data delivery, ordering, or duplicate protection. ๐ญ no promises, fr fr
Usage
In many cases, usage of UDP is set at the application layer by telling the ns-3 application which kind of socket factory to use.
Using the helper functions defined in src/applications/helper, here is how one would create a UDP receiver:
// Create a packet sink on the receiver
uint16_t port = 50000;
Address sinkLocalAddress(InetSocketAddress (Ipv4Address::GetAny (), port));
PacketSinkHelper sinkHelper ("ns3::UdpSocketFactory", sinkLocalAddress);
ApplicationContainer sinkApp = sinkHelper.Install (serverNode);
sinkApp.Start (Seconds (1.0));
sinkApp.Stop (Seconds (10.0));
Similarly, the below snippet configures OnOffApplication traffic source to use UDP:
// Create the OnOff applications to send data to the UDP receiver
OnOffHelper clientHelper ("ns3::UdpSocketFactory", Address ());
clientHelper.SetAttribute ("Remote", remoteAddress);
ApplicationContainer clientApps = (clientHelper.Install (clientNode);
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (9.0));
For users who wish to have a pointer to the actual socket (so that socket operations like Bind(), setting socket options, etc. can be done on a per-socket basis), UDP sockets can be created by using the Socket::CreateSocket() method as given below:
Ptr<Node> node = CreateObject<Node> ();
InternetStackHelper internet;
internet.Install (node);
Ptr<SocketFactory> socketFactory = node->GetObject<UdpSocketFactory> ();
Ptr<Socket> socket = socketFactory->CreateSocket ();
socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), 80));
Once a UDP socket is created, we do not need an explicit connection setup before sending and receiving data. Being a connectionless protocol, all we need to do is to create a socket and bind it to a known port. For a client, simply create a socket and start sending data. The Bind() call allows an application to specify a port number and an address on the local machine. It allocates a local IPv4 endpoint for this socket. ๐
At the end of data transmission, the socket is closed using the Socket::Close(). It returns a 0 on success and -1 on failure.
Please note that applications usually create the sockets automatically. Please refer to the source code of your preferred application to discover how and when it creates the socket. ๐
UDP Socket interaction and interface with Application layer
The following is the description of the public interface of the UDP socket, and how the interface is used to interact with the socket itself.
Socket APIs for UDP connections:
Connect()โ This is called whenSend()is used instead ofSendTo()by the user. It sets the address of the remote endpoint which is used bySend(). If the remote address is valid, this method makes a callback toConnectionSucceeded.Bind()โ Bind the socket to an address, or to a general endpoint. A general endpoint is an endpoint with an ephemeral port allocation (that is, a random port allocation) on the0.0.0.0IP address. For instance, in current applications, data senders usually bind automatically after aConnect()over a random port. Consequently, the connection will start from this random port towards the well-defined port of the receiver. The IP0.0.0.0is then translated by lower layers into the real IP of the device.Bind6()โ Same asBind(), but for IPv6.BindToNetDevice()โ Bind the socket to the specified NetDevice. If set on a socket, this option will force packets to leave the bound device regardless of the device that IP routing would naturally choose. In the receive direction, only packets received from the bound interface will be delivered.ShutdownSend()โ Signals the termination of send, or in other words, prevents data from being added to the buffer.Recv()โ Grabs data from the UDP socket and forwards it to the application layer. If no data is present (i.e.m_deliveryQueue.empty()returns 0), an empty packet is returned.RecvFrom()โ Same asRecv(), but with the source address as parameter.SendTo()โ TheSendTo()API is the UDP counterpart of the TCP APISend(). It additionally specifies the address to which the message is to be sent because no prior connection is established in UDP communication. It returns the number of bytes sent or-1in case of failure.Close()โ The close API closes a socket and terminates the connection. This results in freeing all the data structures previously allocated.
Public callbacks
These callbacks are called by the UDP socket to notify the application of interesting events. We will refer to these with the protected name used in socket.h, but we will provide the API function to set the pointers to these callback as well. ๐ซถ
NotifyConnectionSucceededโ this is the 1st argument you hand toSetConnectCallback. It goes off whenConnect()succeeds and the remote address has been validated. โจNotifyConnectionFailedโ the 2nd argument ofSetConnectCallback. It's called insideConnect()when the remote address validation fails. ๐NotifyDataSentโ hooked up throughSetDataSentCallback. The socket is basically telling the app "bestie, some bytes have been transmitted at the IP layer." but likeโฆ those bytes could still be lost โ either in the node (that's the traffic control layer) or somewhere out in the network. ๐ญNotifySendโ set viaSetSendCallback. It gets invoked to grab the space available in the tx buffer, at the moment a packet (one that carries data, obviously) is sent. ๐คNotifyDataRecvโ the one you attach withSetRecvCallback. Called when the socket receives a packet (data-carrying, again) in the receiver buffer. ๐
Validation โจ
okay so the UDP implementation comes with these test cases, and they live in src/internet/test/udp-test.cc โ go look, they're right there:
UdpSocketImplTest: checks data received via UDP Socket over IPv4. ๐UdpSocketLoopbackTest: checks data received via UDP Socket Loopback over IPv4. ๐Udp6SocketImplTest: checks data received via UDP Socket over IPv6. ๐Udp6SocketLoopbackTest: checks data received via UDP Socket Loopback over IPv6 Test. ๐ธ
Limitations ๐
UDP_CORKis presently not part of this implementation. no cap, it's just not there.NotifyNormalClose,NotifyErrorClose,NotifyConnectionRequestandNotifyNewConnectionCreatedsocket API callbacks are not supported. ๐ซ
Internet Applications Module Documentation ๐ซถ
The goal of this module? Literally to hold all the Internet-specific applications โ and most notably some extremely specific ones (like ping) or daemons (like radvd). Other non-Internet-specific apps, packet generators for example, are chilling in other modules. not here.
The source code for the new module lives in the directory src/internet-apps. ๐
Every application has its own goals, limitations and scope, and we're gonna briefly explain each one below. ๐
All of these applications get used extensively in the top-level examples directories, so bestie โ please go check the scripts in there, it's genuinely the move if you want a clear overview of the various options and usage tricks. iykyk. ๐ฅ
V4Ping ๐ก
This app mimics a "ping" (ICMP Echo) but using IPv4. The application lets you set these attributes:
- Remote address
- Verbose mode
- Packet size (default 56 bytes)
- Packet interval (default 1 second)
Also โ and this is the cute part โ you can access the measured RTT value, because it's exposed as a Traced Source. ๐
Ping6 ๐
This app mimics a "ping" (ICMP Echo) but using IPv6. Attributes you can set:
- Remote address
- Local address (sender address)
- Packet size (default 56 bytes)
- Packet interval (default 1 second)
- Max number of packets to send
Radvd ๐ฐ๏ธ
This app mimics a "RADVD" daemon. Meaning: the daemon responsible for IPv6 routers advertisements. And fr fr, all the IPv6 routers should have a RADVD daemon installed. periodt.
The configuration of the Radvd application mimics the one of the radvd Linux program. same vibe, same config energy. ๐
DHCPv4 ๐
The ns-3 implementation of Dynamic Host Configuration Protocol (DHCP) follows the specifications of RFC 2131 and RFC 2132.
The source code for DHCP is located in src/internet-apps/model and consists of the following 6 files:
dhcp-server.h,dhcp-server.cc,dhcp-client.h,dhcp-client.cc,dhcp-header.handdhcp-header.cc
Helpers ๐ง
The following two files have been added to src/internet-apps/helper for DHCP:
dhcp-helper.handdhcp-helper.cc
Tests ๐งช
The tests for DHCP can be found at src/internet-apps/test/dhcp-test.cc
Examples ๐
The examples for DHCP can be found at src/internet-apps/examples/dhcp-example.cc
Scope and Limitations ๐ธ
The server should be provided with a network address, a mask, and a range of address for the pool. One client application can be installed on only one netdevice in a node, and it can configure an address for only that netdevice. that's the whole deal, no sneaking around it.
The following five basic DHCP messages are supported:
- DHCP DISCOVER
- DHCP OFFER
- DHCP REQUEST
- DHCP ACK
- DHCP NACK
Also, the following eight options of BootP are supported:
- 1 (Mask)
- 50 (Requested Address)
- 51 (Address Lease Time)
- 53 (DHCP message type)
- 54 (DHCP server identifier)
- 58 (Address renew time)
- 59 (Address rebind time)
- 255 (end)
The client identifier option (61) can be implemented in near future. ๐
In the current implementation, a DHCP client can obtain an IPv4 address dynamically from the DHCP server, and can renew it within a lease time period. ๐
Multiple DHCP servers can be configured, but the implementation does not support the use of a DHCP Relay yet. ๐
LOW-RATE WIRELESS PERSONAL AREA NETWORK (LR-WPAN) ๐ฆ
This chapter describes the implementation of ns-3 models for the low-rate, wireless personal area network (LR-WPAN) as specified by IEEE standard 802.15.4 (2006). โจ
Model Description
The source code for the lr-wpan module lives in the directory src/lr-wpan. ๐
Design
The model design closely follows the standard from an architectural standpoint. ๐๏ธ
๐ธ [image] Architecture and scope of lr-wpan models.
The grey areas in the figure (adapted from Fig 3. of IEEE Std. 802.15.4-2006) show the scope of the model. ๐
The Spectrum NetDevice from Nicola Baldo is the basis for the implementation. ๐ซถ
The implementation also plans to borrow from the ns-2 models developed by Zheng and Lee in the future. ๐ฎ
APIs
The APIs closely follow the standard, adapted for ns-3 naming conventions and idioms. They're organized around the concept of service primitives, as shown in the following figure adapted from Figure 14 of IEEE Std. 802.15.4-2006. ๐
๐ธ [image] Service primitives.
The APIs are organized around four conceptual services and service access points (SAP):
- MAC data service (MCPS)
- MAC management service (MLME)
- PHY data service (PD)
- PHY management service (PLME)
In general, primitives are standardized as follows (e.g. Sec 7.1.1.1.1 of IEEE 802.15.4-2006):
MCPS-DATA.request (
SrcAddrMode,
DstAddrMode,
DstPANId,
DstAddr,
msduLength,
msdu,
msduHandle,
TxOptions,
SecurityLevel,
KeyIdMode,
KeySource,
KeyIndex
)
This maps to ns-3 classes and methods such as:
struct McpsDataRequestParameters
{
uint8_t m_srcAddrMode;
uint8_t m_dstAddrMode;
...
};
void
LrWpanMac::McpsDataRequest (McpsDataRequestParameters params)
{
...
}
MAC
The MAC at present implements the unslotted CSMA/CA variant, without beaconing. Currently there is no support for coordinators and the relevant APIs. ๐ซ
The implemented MAC is similar to Contiki's NullMAC, i.e., a MAC without sleep features. The radio is assumed to be always active (receiving or transmitting), or completely shut down. Frame reception is not disabled while performing the CCA. ๐ป
The main API supported is the data transfer API (McpsDataRequest/Indication/Confirm). CSMA/CA according to Std 802.15.4-2006, section 7.5.1.4 is supported. Frame reception and rejection according to Std 802.15.4-2006, section 7.5.6.2 is supported, including acknowledgements. Only short addressing is completely implemented. Various trace sources are supported, and trace sources can be hooked to sinks. ๐
PHY
The physical layer components consist of a Phy model, an error rate model, and a loss model. ๐
The error rate model presently models the error rate for IEEE 802.15.4 2.4 GHz AWGN channel for OQPSK; the model description can be found in IEEE Std 802.15.4-2006, section E.4.1.7.
The Phy model is based on SpectrumPhy and it follows the specification described in section 6 of IEEE Std 802.15.4-2006. It models PHY service specifications, PPDU formats, PHY constants and PIB attributes. It currently only supports the transmit power spectral density mask specified in 2.4 GHz per section 6.5.3.1. The noise power density assumes uniformly distributed thermal noise across the frequency bands. The loss model can fully utilize all existing simple (non-spectrum phy) loss models. The Phy model uses the existing single spectrum channel model.
The physical layer is modeled on packet level, that is, no preamble/SFD detection is done. Packet reception will be started with the first bit of the preamble (which is not modeled), if the SNR is more than -5 dB, see IEEE Std 802.15.4-2006, appendix E, Figure E.2. Reception of the packet will finish after the packet was completely transmitted. Other packets arriving during reception will add up to the interference/noise. ๐ง
Currently the receiver sensitivity is set to a fixed value of -106.58 dBm. This corresponds to a packet error rate of 1% for 20 byte reference packets for this signal power, according to IEEE Std 802.15.4-2006, section 6.1.7. In the future we will provide support for changing the sensitivity to different values. ๐ฎ
๐ธ [image] Packet error rate vs. signal power.
NetDevice
Although it is expected that other technology profiles (such as 6LoWPAN and ZigBee) will write their own NetDevice classes, a basic LrWpanNetDevice is provided, which encapsulates the common operations of creating a generic LrWpan device and hooking things together. ๐งฉ
MAC addresses
Contrary to other technologies, an IEEE 802.15.4 has 2 different kind of addresses:
- Long addresses (64 bits)
- Short addresses (16 bits)
The 64-bit addresses are unique worldwide, and set by the device vendor (in a real device). The 16-bit addresses are not guaranteed to be unique, and they are typically either assigned during the devices deployment, or assigned dynamically during the device bootstrap. ๐ฒ
In ns-3 the device bootstrap is not (yet) present. Hence, both addresses are set when the device is created. ๐
The other relevant "address" to consider is the PanId (16 bits), which represents the PAN the device is attached to. ๐ท๏ธ
Due to the limited number of available bytes in a packet, IEEE 802.15.4 tries to use short addresses instead of long addresses, even though the two might be used at the same time. โจ
So basically for the whole "talking to the upper layers" thing โ and especially when it comes to generating those auto-configured IPv6 addresses โ every single NetDevice has to identify itself with a MAC address. ๐
And like, these MAC addresses also get used during packet reception, so bestie, you have to use them consistently or it's giving chaos. ๐
Zooming in on IPv6 Stateless address autoconfiguration (SLAAC), there are two relevant RFCs you gotta know: RFC 4944 and RFC 6282. And the way that they differ?? It's literally all about how you build the IPv6 address given the NetDevice address. ๐
RFC 4944 mandates that the IID part of the IPv6 address is calculated as YYYY:00ff:fe00:XXXX, while RFC 6282 mandates that the IID part is calculated as 0000:00ff:fe00:XXXX where XXXX is the device short address, and YYYY is the PanId. In both cases the U/L bit must be set to local, so in the RFC 4944 the PanId might have one bit flipped. ๐ฆ
Now, to facilitate interoperability (iconic) and to avoid unwanted module dependencies (also iconic), the ns-3 implementation moves the IID calculation into LrWpanNetDevice::GetAddress (), which will return an Address formatted properly, i.e.:
- The Long address (a
Mac64Address) if the Short address has not been set, or - A properly formatted 48-bit pseudo-address (a
Mac48Address) if the short address has been set.
The 48-bit pseudo-address is generated according to either RFC 4944 or RFC 6282 depending on the configuration of an Attribute (PseudoMacAddressMode). โจ
The default is to use RFC 6282 style addresses.
Heads up bestie ๐ โ on reception, a packet might contain either a short or a long address. This is reflected in the upper-layer notification callback, which can contain either the pseudo-address (48 bits) or the long address (64 bit) of the sender.
Also, lowkey important: RFC 4944 and RFC 6282 are the RFCs defining the IPv6 address compression formats (HC1andIPHCrespectively). It is defintely not a good idea to either mix devices using different pseudo-address format or compression types in the same network. ๐ซ This point is further discussed in the sixlowpan module documentation.
Scope and Limitations ๐
Future versions of this document will contain a PICS proforma similar to Appendix D of IEEE 802.15.4-2006. The current emphasis is on the unslotted mode of 802.15.4 operation for use in Zigbee, and the scope is limited to enabling a single mode (CSMA/CA) with basic data transfer capabilities. Association with PAN coordinators is not yet supported, nor the use of extended addressing. ๐ญ Interference is modeled as AWGN but this is currently not thoroughly tested.
The NetDevice Tx queue is not limited, i.e., packets are never dropped due to queue becoming full. They may be dropped due to excessive transmission retries or channel access failure. ๐
References ๐
- Wireless Medium Access Control (MAC) and Physical Layer (PHY) Specifications for Low-Rate Wireless Personal Area Networks (WPANs), IEEE Computer Society, IEEE Std 802.15.4-2006, 8 September 2006.
- J. Zheng and Myung J. Lee, "A comprehensive performance study of IEEE 802.15.4," Sensor Network Operations, IEEE Press, Wiley Interscience, Chapter 4, pp. 218-237, 2006.
Usage ๐
Enabling lr-wpan
Add lr-wpan to the list of modules built with ns-3. Simple as that, periodt. ๐
Helper
The helper is patterned after other device helpers. In particular, tracing (ascii and pcap) is enabled similarly, and enabling of all lr-wpan log components is performed similarly. Use of the helper is exemplified in examples/lr-wpan-data.cc. For ascii tracing, the transmit and receive traces are hooked at the Mac layer.
The default propagation loss model added to the channel, when this helper is used, is the LogDistancePropagationLossModel with default parameters. โจ
Examples
The following examples have been written, which can be found in src/lr-wpan/examples/:
lr-wpan-data.cc: A simple example showing end-to-end data transfer.lr-wpan-error-distance-plot.cc: An example to plot variations of the packet success ratio as a function of distance.lr-wpan-error-model-plot.cc: An example to test the phy.lr-wpan-packet-print.cc: An example to print out the MAC header fields.lr-wpan-phy-test.cc: An example to test the phy.
In particular, the module enables a very simplified end-to-end data transfer scenario, implemented in lr-wpan-data.cc. The figure shows a sequence of events that are triggered when the MAC receives a DataRequest from the higher layer. It invokes a Clear Channel Assessment (CCA) from the PHY, and if successful, sends the frame down to the PHY where it is transmitted over the channel and results in a DataIndication on the peer node.
(there's a lil image here: Data example for simple LR-WPAN data transfer end-to-end.) ๐ผ๏ธ
The example lr-wpan-error-distance-plot.cc plots the packet success ratio (PSR) as a function of distance, using the default LogDistance propagation loss model and the 802.15.4 error model. The channel (default 11), packet size (default 20 bytes) and transmit power (default 0 dBm) can be varied by command line arguments. The program outputs a file named 802.15.4-psr-distance.plt. Loading this file into gnuplot yields a file 802.15.4-psr-distance.eps, which can be converted to pdf or other formats. The default output is shown below.
(and here's another image: Default output of the program lr-wpan-error-distance-plot.cc.) ๐ผ๏ธ
Tests ๐งช
The following tests have been written, which can be found in src/lr-wpan/tests/:
lr-wpan-ack-test.cc: Check that acknowledgments are being used and issued in the correct order.lr-wpan-collision-test.cc: Test correct reception of packets with interference and collisions.lr-wpan-error-model-test.cc: Check that the error model gives predictable values.lr-wpan-packet-test.cc: Test the 802.15.4 MAC header/trailer classeslr-wpan-pd-plme-sap-test.cc: Test the PLME and PD SAP per IEEE 802.15.4lr-wpan-spectrum-value-helper-test.cc: Test that the conversion between power (expressed as a scalar quantity) and spectral power, and back again, falls within a 25% tolerance across the range of possible channels and input powers.
Validation ๐
The model has not been validated against real hardware. The error model has been validated against the data in IEEE Std 802.15.4-2006, section E.4.1.7 (Figure E.2). The MAC behavior (CSMA backoff) has been validated by hand against expected behavior. The below plot is an example of the error model validation and can be reproduced by running lr-wpan-error-model-plot.cc:
(image time: Default output of the program lr-wpan-error-model-plot.cc.) ๐ผ๏ธ
๐ LTE MODULE ๐
Design Documentation ๐
Overview
An overview of the LTE-EPC simulation model is depicted in the figure Overview of the LTE-EPC simulation model. There are two main components:
- the LTE Model. This model includes the LTE Radio Protocol stack (RRC, PDCP, RLC, MAC, PHY). These entities reside entirely within the UE and the eNB nodes.
- the EPC Model. This model includes core network interfaces, protocols and entities. These entities and protocols reside within the SGW, PGW and MME nodes, and partially within the eNB nodes.
(and yes bestie, there's a figure: Overview of the LTE-EPC simulation model.) ๐ผ๏ธ
Design Criteria ๐ฏ
LTE Model
The LTE model has been designed to support the evaluation of the following aspects of LTE systems:
- Radio Resource Management
- QoS-aware Packet Scheduling
- Inter-cell Interference Coordination
- Dynamic Spectrum Access
In order to model LTE systems to a level of detail that is sufficient to allow a correct evaluation of the above mentioned aspects, the following requirements have been considered:
- At the radio level, the granularity of the model should be at least that of the Resource Block (RB). In fact, this is the fundamental unit being used for resource allocation. Without this minimum level of granularity, it is not possible to model accurately packet scheduling and inter-cell-interference. The reason is that, since packet scheduling is done on a per-RB basis, an eNB might transmit on a subset only of all the available RBs, hence interfering with other eNBs only on those RBs where it is transmitting. Note that this requirement rules out the adoption of a system level simulation approach, which evaluates resource allocation only at the granularity of call/bearer establishment.
- The simulator should scale up to tens of eNBs and hundreds of User Equipment (UEs). This rules out the use of a link level simulator, i.e., a simulator whose radio interface is modeled with a granularity up to the symbol level. This is because to have a symbol level model it is necessary to implement all the PHY layer signal processing, whose huge computational complexity severely limits simulation. In fact, link-level simulators are normally limited to a single eNB and one or a few UEs. ๐
- It should be possible within the simulation to configure different cells so that they use different carrier frequencies and system bandwidths. The bandwidth used by different cells should be allowed to overlap, in order to support dynamic spectrum licensing solutions such as those described in
[Ofcom2600MHz]and[RealWireless]. The calculation of interference should handle appropriately this case. - To be more representative of the LTE standard, as well as to be as close as possible to real-world implementations, the simulator should support the MAC Scheduler API published by the FemtoForum
[FFAPI]. This interface is expected to be used by femtocell manufacturers for the implementation of scheduling and Radio Resource Management (RRM) algorithms. By introducing support for this interface in the simulator, we make it possible for LTE equipment vendors and operators to test in a simulative environment exactly the same algorithms that would be deployed in a real system. ๐ฅ - The LTE simulation model needs to ship its own implementation of the API defined in
[FFAPI], okay? Like, don't expect binary or data structure compatibility with vendor-specific implementations of that same interface โ so whenever a vendor-specific MAC scheduler wants to play, you gotta interpose a compatibility layer. This requirement is necessary so the simulator can stay independent from vendor-specific implementations of this interface spec. And ps:[FFAPI]is a logical specification only, and its implementation (e.g., translation to some specific programming language) is left to the vendors. Not our problem. ๐ - The model gets used to simulate the transmission of IP packets by the upper layers. And with that in mind โ bestie, listen โ in LTE the Scheduling and Radio Resource Management do not work with IP packets directly. They work with RLC PDUs, which come from segmentation and concatenation of IP packets done by the RLC entities. So yeah, these functionalities of the RLC layer should be modeled accurately. No shortcuts. โจ
๐ฆ EPC Model ๐ฆ
The main objective of the EPC model is to provide the means for simulating end-to-end IP connectivity over the LTE model. To this aim, it supports the interconnection of multiple UEs to the Internet, via a radio access network of multiple eNBs connected to the core network, as shown in Figure Overview of the LTE-EPC simulation model. ๐ซถ
The following design choices have been made for the EPC model:
- The Packet Data Network (PDN) type supported is both IPv4 and IPv6. In other words, the end-to-end connections between the UEs and the remote hosts can be IPv4 and IPv6. However, the networks between the core network elements (MME, SGWs and PGWs) are IPv4-only. Periodt.
- The SGW and PGW functional entities are implemented in different nodes, which are hence referred to as the SGW node and PGW node, respectively.
- The MME functional entities are implemented as a network node, which is hence referred to as the MME node.
- The scenarios with inter-SGW mobility are not of interest. But several SGW nodes may be present in simulations scenarios.
- A requirement for the EPC model is that it can be used to simulate the end-to-end performance of realistic applications. So it should be possible to use with the EPC model any regular ns-3 application working on top of
TCPorUDP. - Another requirement is the possibility of simulating network topologies with the presence of multiple eNBs, some of which might be equipped with a backhaul connection with limited capabilities. In order to simulate such scenarios, the user data plane protocols being used between the eNBs and the SGW should be modeled accurately. ๐
- It should be possible for a single UE to use different applications with different QoS profiles. Hence, multiple EPS bearers should be supported for each UE. This includes the necessary classification of TCP/UDP traffic over IP done at the UE in the uplink and at the PGW in the downlink.
- The initial focus of the EPC model is mainly on the EPC data plane. The accurate modeling of the EPC control plane is, for the time being, not a requirement โ but the necessary control plane interactions among the different network nodes of the core network are realized by implementing control protocols/messages among them. Direct interaction among the different simulation objects via the provided helper objects should be avoided as much as possible. ๐
- The focus of the EPC model is on simulations of active users in ECM connected mode. Hence, all the functionality that is only relevant for ECM idle mode (in particular, tracking area update and paging) are not modeled at all. Gone. Not here. ๐
- The model should allow the possibility to perform an X2-based handover between two eNBs.
๐ Architecture ๐
โญ LTE Model โญ
๐ UE architecture ๐
The architecture of the LTE radio protocol stack model of the UE is represented in the figures LTE radio protocol stack architecture for the UE on the data plane and LTE radio protocol stack architecture for the UE on the control plane which highlight respectively the data plane and the control plane. ๐ฆ
[image] LTE radio protocol stack architecture for the UE on the data plane.
[image] LTE radio protocol stack architecture for the UE on the control plane.
The architecture of the PHY/channel model of the UE is represented in figure PHY and channel model architecture for the UE.
[image] PHY and channel model architecture for the UE.
๐ง eNB architecture ๐ง
The architecture of the LTE radio protocol stack model of the eNB is represented in the figures LTE radio protocol stack architecture for the eNB on the data plane and LTE radio protocol stack architecture for the eNB on the control plane which highlight respectively the data plane and the control plane. โจ
[image] LTE radio protocol stack architecture for the eNB on the data plane.
[image] LTE radio protocol stack architecture for the eNB on the control plane.
The architecture of the PHY/channel model of the eNB is represented in figure PHY and channel model architecture for the eNB.
[image] PHY and channel model architecture for the eNB.
๐ EPC Model ๐
๐ธ EPC data plane ๐ธ
In Figure LTE-EPC data plane protocol stack, we represent the end-to-end LTE-EPC data plane protocol stack as it is modeled in the simulator. The figure shows all nodes in the data path, i.e. UE, eNB, SGW, PGW and a remote host in the Internet. All protocol stacks (S5 protocol stack, S1-U protocol stack and the LTE radio protocol stack) specified by 3GPP are present. All of them. Every single one. ๐ซถ
[image] LTE-EPC data plane protocol stack.
๐ EPC control plane ๐
The architecture of the implementation of the control plane model is shown in figure LTE-EPC control plane protocol stack. The control interfaces that are modeled explicitly are the S1-MME, the S11, and the S5 interfaces. The X2 interface is also modeled explicitly and it is described in more detail in section X2. ๐
The S1-MME, the S11 and the S5 interfaces are modeled using protocol data units sent over its respective links. These interfaces use the SCTP protocol as transport protocol but currently, the SCTP protocol is not modeled in the ns-3 simulator, so the UDP protocol is used instead of the SCTP protocol. iykyk. ๐
[image] LTE-EPC control plane protocol stack.
๐ Channel and Propagation ๐
For channel modeling purposes, the LTE module uses the SpectrumChannel interface provided by the spectrum module. At the time of this writing, two implementations of such interface are available: SingleModelSpectrumChannel and MultiModelSpectrumChannel, and the LTE module requires the use of the MultiModelSpectrumChannel in order to work properly. This is because of the need to support different frequency and bandwidth configurations. All the propagation models supported by MultiModelSpectrumChannel can be used within the LTE module. ๐
๐๏ธ Use of the Buildings model with LTE ๐๏ธ
The recommended propagation model to be used with the LTE module is the one provided by the Buildings module, which was in fact designed specifically with LTE (though it can be used with other wireless technologies as well). Please refer to the documentation of the Buildings module for generic information on the propagation model it provides. ๐
In this section we will highlight some considerations that specifically apply when the Buildings module is used together with the LTE module.
The naming convention used in the following will be:
- User equipment: UE
- Macro Base Station: MBS
- Small cell Base Station (e.g., pico/femtocell): SC
The LTE module considers FDD only, and implements downlink and uplink propagation separately. As a consequence, the following pathloss computations are performed:
MBS <-> UE(indoor and outdoor)SC(indoor and outdoor)<-> UE(indoor and outdoor)
The LTE model does not provide the following pathloss computations:
UE <-> UEMBS <-> MBSMBS <-> SCSC <-> SC
The Buildings model does not know the actual type of the node; i.e., it is not aware of whether a transmitter node is a UE, a MBS, or a SC. Rather, the Buildings model only cares about the position of the node: whether it is indoor and outdoor, and what is its z-axis respect to the rooftop level. As a consequence, for an eNB node that is placed outdoor and at a z-coordinate above the rooftop level, the propagation models typical of MBS will be used by the Buildings module. Conversely, for an eNB that is placed outdoor but below the rooftop, or indoor, the propagation models typical of pico and femtocells will be used. ๐ฆ
For communications involving at least one indoor node, the corresponding wall penetration losses will be calculated by the Buildings model. This covers the following use cases:
MBS <-> indoor UEoutdoor SC <-> indoor UEindoor SC <-> indoor UEindoor SC <-> outdoor UE
Please refer to the documentation of the Buildings module for details on the actual models used in each case. โจ
๐ซ Fading Model ๐ซ
The LTE module includes a trace-based fading model derived from the one developed during the GSoC 2010 [Piro2011]. The main characteristic of this model is the fact that the fading evaluation during simulation run-time is based on pre-calculated traces. This is done to limit the computational complexity of the simulator. On the other hand, it needs huge structures for storing the traces; therefore, a trade-off between the number of possible parameters and the memory occupancy has to be found. The most important ones are:
- users' speed: relative speed between users (affects the Doppler frequency, which in turns affects the time-variance property of the fading)
- number of taps (and relative power): number of multiple paths considered, which affects the frequency property of the fading.
- time granularity of the trace: sampling time of the trace.
- frequency granularity of the trace: number of values in frequency to be evaluated.
- length of trace: ideally large as the simulation time, might be reduced by windowing mechanism.
- number of users: number of independent traces to be used (ideally one trace per user).
okay so when it comes to the actual mathematical channel propagation model, our rec is the one that Matlab's rayleighchan function gives you ๐ซ โ it's a well-accepted channel modelization in both the time and frequency domain, which is exactly the energy we want. want more deets? the reader gets pointed to [mathworks]. ๐
The simulator ships a matlab script โ src/lte/model/fading-traces/fading-trace-generator.m โ that generates traces in the format the simulator actually uses ๐. Here's the tea: the channel object you create with rayleighchan filters a discrete-time impulse signal so you get the channel impulse response. You repeat that filtering for different TTIs, which yields a bunch of subsequent time-correlated channel responses (one per TTI, exactly). Then that channel response gets processed with the pwelch function to grab its power spectral density values, and those get saved into a file in the proper format that plays nice with the simulator model. slay โจ
Now โ since the number of variables is pretty high, generating traces while considering all of them might give you a high number of traces that are also huge in size ๐ญ. So on that front, here are the parameter assumptions we made, based on the 3GPP fading propagation conditions (peep Annex B.2 of [TS36104]):
- users' speed: typically only a few discrete values get considered, i.e.:
- 0 and 3 kmph for pedestrian scenarios
- 30 and 60 kmph for vehicular scenarios
- 0, 3, 30 and 60 for urban scenarios
- channel taps: only a limited number of sets of channel taps are normally considered โ for example, three models are mentioned in Annex B.2 of [TS36104].
- time granularity: we need one fading value per TTI, i.e., every 1 ms (because that's the granularity in time of the ns-3 LTE PHY model).
- frequency granularity: we need one fading value per RB (which is the frequency granularity of the spectrum model used by the ns-3 LTE model).
- length of the trace: the simulator includes the windowing mechanism implemented during the GSoC 2011, which consists of picking up a window of the trace each window length in a random fashion.
- per-user fading process: users share the same fading trace, but for each user a different starting point in that trace is randomly picked up ๐ฒ. this choice was made so we don't have to provide one fading trace per user.
According to the parameters we considered, here's the formula that expresses in detail the total size S_{traces} of the fading traces:
S_{traces} = S_{sample} \times N_{RB} \times
\frac{T_{trace}}{T_{sample}} \times N_{scenarios} \mbox{ [bytes]}
where S_{sample} is the size in bytes of the sample (e.g., 8 for double precision, 4 for float precision), N_{RB} is the number of RB or set of RBs to be considered, T_{trace} is the total length of the trace, T_{sample} is the time resolution of the trace (1 ms), and N_{scenarios} is the number of fading scenarios you want (i.e., combinations of different sets of channel taps and user speed values). We provide traces for 3 different scenarios, one for each taps configuration defined in Annex B.2 of [TS36104]:
- Pedestrian: with nodes' speed of 3 kmph.
- Vehicular: with nodes' speed of 60 kmph.
- Urban: with nodes' speed of 3 kmph.
so N_{scenarios} = 3 ๐. All traces have T_{trace} = 10 s and RB_{NUM} = 100. That lands you at a total 24 MB bytes of traces. iconic.
Antennas ๐ฆ
Since it's based on the SpectrumPhy, the LTE PHY model supports antenna modeling through the ns-3 AntennaModel class ๐ก. Which means any model based on this class can be associated with any eNB or UE instance. For example, using the CosineAntennaModel with an eNB device lets you model one sector of a macro base station. And by default? The IsotropicAntennaModel is what's used for both eNBs and UEs. ๐
PHY ๐
Overview
The physical layer model provided in this LTE simulator is based on the one described in [Piro2011], with these modifications: the model now includes the inter cell interference calculation, plus the simulation of uplink traffic โ and that includes both packet transmission and CQI generation. ๐ฅ
Subframe Structure
The subframe is divided into a control part and a data part, just like in Figure LTE subframe division..
[image] LTE subframe division..
Considering the granularity of the simulator based on RB, the control and the reference signaling have to be modeled with that constraint in mind. According to the standard [TS36211], the downlink control frame starts at the beginning of each subframe and lasts up to three symbols across the whole system bandwidth โ where the actual duration is provided by the Physical Control Format Indicator Channel (PCFICH). The information on the allocation is then mapped into the remaining resources, up to the duration defined by the PCFICH, in the so-called Physical Downlink Control Channel (PDCCH). A PDCCH transports a single message called Downlink Control Information (DCI) that comes from the MAC layer, where the scheduler indicates the resource allocation for a specific user.
The PCFICH and PDCCH are modeled with the transmission of the control frame at a fixed duration of 3/14 of milliseconds, spanning the whole available bandwidth, since the scheduler does not estimate the size of the control region. This implies that a single transmission block models the entire control frame with a fixed power (i.e., the one used for the PDSCH) across all the available RBs. And because of that feature, this transmission also represents valuable support for the Reference Signal (RS) ๐ซ. This allows you to have, every TTI, an evaluation of the interference scenario, since all the eNBs are transmitting (simultaneously) the control frame over their respective available bandwidths. One thing to note: the model does not include power boosting, because it doesn't reflect any improvement in the implemented model of the channel estimation.
The Sounding Reference Signal (SRS) is modeled similar to the downlink control frame. The SRS is periodically placed in the last symbol of the subframe across the whole system bandwidth. The RRC module already includes an algorithm for dynamically assigning the periodicity as a function of the actual number of UEs attached to an eNB, according to the UE-specific procedure (see Section 8.2 of [TS36213]). ๐
MAC to Channel delay
To model the latency of real MAC and PHY implementations, the PHY model simulates a MAC-to-channel delay in multiples of TTIs (1ms). Both data and control packets get delayed by this amount. โฑ๏ธ
CQI feedback
The generation of CQI feedback is done according to what's specified in [FFAPI]. In detail, we considered the generation of periodic wideband CQI (i.e., a single value of channel state that is deemed representative of all RBs in use) and inband CQIs (i.e., a set of values representing the channel state for each RB).
The CQI index to be reported is obtained by first grabbing a SINR measurement and then passing that SINR measurement to the Adaptive Modulation and Coding module, which will map it to the CQI index.
In downlink, the SINR used to generate CQI feedback can be calculated two different ways:
- Ctrl method: SINR is calculated combining the signal power from the reference signals (which in the simulation is equivalent to the PDCCH) and the interference power from the PDCCH. This approach results in considering any neighboring eNB as an interferer โ regardless of whether that eNB is actually performing any PDSCH transmission, and regardless of the power and RBs used for eventual interfering PDSCH transmissions.
- Mixed method: SINR is calculated combining the signal power from the reference signals (which in the simulation is equivalent to the PDCCH) and the interference power from the PDSCH. This approach results in considering as interferers only those neighboring eNBs that are actively transmitting data on the PDSCH, and it allows you to generate inband CQIs that account for different amounts of interference on different RBs according to the actual interference level. In the case that no PDSCH transmission is performed by any eNB, this method considers that interference is zero, i.e., the SINR will be calculated as the ratio of signal to noise only.
To switch between these two CQI generation approaches, LteHelper::UsePdschForCqiGeneration needs to be configured: false for the first approach and true for the second approach (and true is the default value):
Config::SetDefault ("ns3::LteHelper::UsePdschForCqiGeneration", BooleanValue (true));
In uplink, two types of CQIs are implemented:
- SRS based, periodically sent by the UEs.
- PUSCH based, calculated from the actual transmitted data.
The scheduler interface includes an attribute system called UlCqiFilter for managing the filtering of the CQIs according to their nature. In detail:
SRS_UL_CQIfor storing only SRS based CQIs.PUSCH_UL_CQIfor storing only PUSCH based CQIs.
ngl, one thing has to be noted: the FfMacScheduler provides only the interface, and it's a matter of the actual scheduler implementation to include the code for managing these attributes (see the scheduler related section for more information on this matter).
Interference Model
The PHY model is based on the well-known Gaussian interference models, according to which the powers of interfering signals (in linear units) are summed up together to determine the overall interference power. โจ
The sequence diagram of Figure Sequence diagram of the PHY interference calculation procedure shows how interfering signals are processed to calculate the SINR, and how SINR is then used for the generation of CQI feedback.
[image] Sequence diagram of the PHY interference calculation procedure.
๐ LTE Spectrum Model ๐
So the way eNBs and UEs use radio spectrum in LTE is described in [TS36101]. In the simulator, spectrum usage is modeled like this, bestie, stay with me ๐
Let f_c be the LTE Absolute Radio Frequency Channel Number โ it's the thing that identifies the carrier frequency on a 100 kHz raster. And let B be the Transmission Bandwidth Configuration, measured in number of Resource Blocks.
For every single pair (f_c,B) used in the simulation, we define a corresponding SpectrumModel using the functionality provided by the sec-spectrum-module model, which uses the Spectrum framework described in [Baldo2009]. Both f_c and B can be configured for every eNB you instantiate in the simulation, so like, each eNB can run a totally different spectrum model. And every UE? It automatically uses the spectrum model of the eNB it's attached to. Obsessed with the convenience honestly.
Using the MultiModelSpectrumChannel described in [Baldo2009], the interference among eNBs that use different spectrum models is properly accounted for. This lets you simulate dynamic spectrum access policies โ for example the spectrum licensing policies discussed in [Ofcom2600MHz]. It's giving very main character regulatory energy ๐
โจ Data PHY Error Model โจ
The simulator includes an error model of the data plane (aka PDSCH and PUSCH) according to the standard link-to-system mapping (LSM) techniques. This choice is aligned with the standard system simulation methodology of OFDMA radio transmission technology. Thanks to LSM we keep a good level of accuracy and at the same time limit the computational complexity increase. Iconic, honestly. It's based on mapping the single link layer performance obtained via link level simulators onto system (in our case, network) simulators.
Specifically: the link layer simulator generates the performance of a single link from a PHY layer perspective, usually in terms of code block error rate (BLER), under specific static conditions. LSM then lets you use these parameters in more complex scenarios โ the typical system/network simulator vibe โ where we've got more links, interference, and "colored" channel propagation phenomena (e.g., frequency selective fading).
To do all of this, the Vienna LTE Simulator [ViennaLteSim] was used for the extraction of link layer performance, plus the Mutual Information Based Effective SINR (MIESM) as the LSM mapping function, using part of the work recently published by the Signet Group of University of Padua [PaduaPEM]. ๐
๐ MIESM ๐
The specific LSM method adopted is the one based on a mutual information metric, commonly referred to as the mutual information per coded bit (MIB, or MMIB when a mean of multiples MIBs is involved). Another option would be the Exponential ESM (EESM); however, recent studies demonstrate that MIESM outperforms EESM in terms of accuracy [LozanoCost]. Not me choosing the accurate one ๐
[image] MIESM computational procedure diagram.
The mutual information (MI) is dependent on the constellation mapping and can be calculated per transport block (TB) basis, by evaluating the MI over the symbols and the subcarrier. BUT โ that would be way too complex for a network simulator. Hence, in our implementation a flat channel response within the RB has been considered; therefore the overall MI of a TB is calculated by averaging the MI evaluated per each RB used in the TB.
In detail, the implemented scheme is depicted in Figure MIESM computational procedure diagram, where we see that the model starts by evaluating the MI value for each RB, represented in the figure by the SINR samples. Then the equivalent MI is evaluated per TB basis by averaging the MI values. Finally, a further step has to be done, since the link level simulator returns the performance of the link in terms of block error rate (BLER) in a additive white gaussian noise (AWGN) channel, where the blocks are the code blocks (CBs) independently encoded/decoded by the turbo encoder. On this matter the standard 3GPP segmentation scheme has been used for estimating the actual CB size (described in section 5.1.2 of [TS36212]).
This scheme divides the TB in N_{K_-} blocks of size K_- and N_{K+} blocks of size K_+. Therefore the overall TB BLER (TBLER) can be expressed as
TBLER = 1- \prod\limits_{i=1}^{C}(1-CBLER_i)
where the CBLER_i is the BLER of the CB i obtained according to the link level simulator CB BLER curves. For estimating the CBLER_i, the MI evaluation has been implemented according to its numerical approximation defined in [wimaxEmd]. Moreover, for reducing the complexity of the computation, the approximation has been converted into lookup tables.
In detail, a Gaussian cumulative model has been used for approximating the AWGN BLER curves with three parameters, which provides a close fit to the standard AWGN performances, in formula:
CBLER_i =
\frac{1}{2}\left[1-erf\left(\frac{x-b_{ECR}}{\sqrt{2}c_{ECR}} \right) \right]
where x is the MI of the TB, b_{ECR} represents the "transition center" and c_{ECR} is related to the "transition width" of the Gaussian cumulative distribution for each Effective Code Rate (ECR), which is the actual transmission rate according to the channel coding and MCS.
For limiting the computational complexity of the model we considered only a subset of the possible ECRs โ in fact we would have potentially 5076 possible ECRs (i.e., 27 MCSs and 188 CB sizes). On this respect, we will limit the CB sizes to some representative values (i.e., 40, 140, 160, 256, 512, 1024, 2048, 4032, 6144), while for the others the worst one approximating the real one will be used (i.e., the smaller CB size value available respect to the real one).
This choice is aligned to the typical performance of turbo codes, where the CB size is not strongly impacting on the BLER. However, it is to be noted that for CB sizes lower than 1000 bits the effect might be relevant (i.e., till 2 dB); therefore, we adopt this unbalanced sampling interval for having more precision where it is necessary. This behaviour is confirmed by the figures presented in the Annes Section. ๐ฆ
๐ธ BLER Curves ๐ธ
On this respect, we reused part of the curves obtained within [PaduaPEM]. In detail, we introduced the CB size dependency to the CB BLER curves with the support of the developers of [PaduaPEM] and of the LTE Vienna Simulator. In fact, the module released provides the link layer performance only for what concerns the MCSs (i.e., with a given fixed ECR).
In detail the new error rate curves for each have been evaluated with a simulation campaign with the link layer simulator for a single link with AWGN noise and for CB size of 104, 140, 256, 512, 1024, 2048, 4032 and 6144. These curves have been mapped with the Gaussian cumulative model formula presented above for obtaining the correspondents b_{ECR} and c_{ECR} parameters.
The BLER performance of all MCS obtained with the link level simulator are plotted in the following figures (blue lines) together with their correspondent mapping to the Gaussian cumulative distribution (red dashed lines). ๐
[image] BLER for MCS 1, 2, 3 and 4.
[image] BLER for MCS 5, 6, 7 and 8.
[image] BLER for MCS 9, 10, 11 and 12.
[image] BLER for MCS 13, 14, 15 and 16.
[image] BLER for MCS 17, 17, 19 and 20.
[image] BLER for MCS 21, 22, 23 and 24.
[image] BLER for MCS 25, 26, 27 and 28.
[image] BLER for MCS 29.
โญ Integration of the BLER curves in the ns-3 LTE module โญ
The model implemented uses the curves for the LSM of the recently LTE PHY Error Model released in the ns3 community by the Signet Group [PaduaPEM] and the new ones generated for different CB sizes.
The LteSpectrumPhy class is in charge of evaluating the TB BLER thanks to the methods provided by the LteMiErrorModel class, which is in charge of evaluating the TB BLER according to the vector of the perceived SINR per RB, the MCS and the size, in order to properly model the segmentation of the TB in CBs.
In order to obtain the vector of the perceived SINRs for data and control signals, two instances of LteChunkProcessor (dedicated to evaluate the SINR for obtaining physical error performance) have been attached to UE downlink and eNB uplink LteSpectrumPhy modules for evaluating the error model distribution of PDSCH (UE side) and ULSCH (eNB side).
The model can be disabled for working with a zero-losses channel by setting the DataErrorModelEnabled attribute of the LteSpectrumPhy class (by default is active). This can be done according to the standard ns3 attribute system procedure, that is:
Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
๐ Control Channels PHY Error Model ๐
The simulator includes the error model for downlink control channels (PCFICH and PDCCH), while in uplink it is assumed an ideal error-free channel. The model is based on the MIESM approach presented before, for considering the effects of the frequency selective channel, since most of the control channels span the whole available bandwidth.
๐ง PCFICH + PDCCH Error Model ๐ง
The model adopted for the error distribution of these channels is based on an evaluation study carried out in the RAN4 of 3GPP, where different vendors investigated the demodulation performance of the PCFICH jointly with PDCCH. This is due to the fact that the PCFICH is the channel in charge of communicating to the UEs the actual dimension of the PDCCH (which spans between 1 and 3 symbols); therefore the correct decodification of the DCIs depends on the correct interpretation of both ones.
In 3GPP this problem have been evaluated for improving the cell-edge performance [FujitsuWhitePaper], where the interference among neighboring cells can be relatively high due to signal degradation. A similar problem has been noticed in femto-cell scenario and, more in general, in HetNet scenarios the bottleneck has been detected mainly as the PCFICH channel [Bharucha2011], where in case of many eNBs are deployed in the same service area, this channel may collide in frequency, making impossible the correct detection of the PDCCH channel, too. ๐
In the simulator, the SINR you clock during reception has been estimated with the MIESM model we talked about above, specifically so we can evaluate the error distribution of PCFICH and PDCCH. In detail: the SINR samples of all the RBs get folded into the evaluation of the MI associated to the control frame, and from those values the effective SINR (eSINR) comes out by inverting the MI evaluation process. ๐ Little note, bestie โ in case of MIMO transmission, both PCFICH and the PDCCH always use the transmit diversity mode as defined by the standard. No exceptions, no vibes-based deviation.
Based on the eSINR perceived, the decodification error probability can be estimated as a function of the results in [R4-081920]. And if an error does occur? The DCI is discarded and therefore the UE will be not able to receive the correspondent Tbs, so it's just... lost. ๐ญ
โจ MIMO Model โจ
Using multiple antennas both at the transmitter and the receiver side โ known as multiple-input and multiple-output (MIMO) โ is a problem that's been well studied in literature for the past years. Most of the work concentrates on evaluating analytically the gain that the different MIMO schemes might have in terms of capacity; however, someones provide also information of the gain in terms of received power [CatreuxMIMO]. ๐ซถ
So according to the considerations above, a more flexible model can be obtained by considering the gain that MIMO schemes bring into the system from a statistical point of view. As highlighted before, [CatreuxMIMO] presents the statistical gain of several MIMO solutions respect to the SISO one in case of no correlation between the antennas. In that work the gain is presented as the cumulative distribution function (CDF) of the output SINR for what concerns SISO, MIMO-Alamouti, MIMO-MMSE, MIMO-OSIC-MMSE and MIMO-ZF schemes. Elaborating on the results, the output SINR distribution can be approximated with a log-normal one, with different mean and variance as a function of the scheme considered. However, the variances are not so different, and they're approximatively equal to the one of the SISO mode already included in the shadowing component of the BuildingsPropagationLossModel. In detail, bestie: ๐
- SISO:
\mu = 13.5and\sigma = 20 [dB]. - MIMO-Alamouti:
\mu = 17.7and\sigma = 11.1 [dB]. - MIMO-MMSE:
\mu = 10.7and\sigma = 16.6 [dB]. - MIMO-OSIC-MMSE:
\mu = 12.6and\sigma = 15.5 [dB]. - MIMO-ZF:
\mu = 10.3and\sigma = 12.6 [dB].
Therefore the PHY layer implements the MIMO model as the gain perceived by the receiver when using a MIMO scheme respect to the one obtained using the SISO one. ๐ We note that these gains refer to a case where there is no correlation between the antennas in the MIMO scheme; therefore they do not model degradation due to paths correlation. Keep that in mind, okay?
๐ธ UE PHY Measurements Model ๐ธ
According to [TS36214], the UE has to report a set of measurements of the eNBs that the device is able to perceive: the reference signal received power (RSRP) and the reference signal received quality (RSRQ). The former is a measure of the received power of a specific eNB, while the latter includes also channel interference and thermal noise. The UE has to report the measurements jointly with the physical cell identity (PCI) of the cell. Both the RSRP and RSRQ measurements are performed during the reception of the RS, while the PCI is obtained with the Primary Synchronization Signal (PSS). The PSS is sent by the eNB each 5 subframes, and in detail in the subframes 1 and 6. โญ
In real systems, only 504 distinct PCIs are available, and hence it could occur that two nearby eNBs use the same PCI. However, in the simulator we model PCIs using simulation metadata, and we allow up to 65535 distinct PCIs โ thereby avoiding PCI collisions provided that less than 65535 eNBs are simulated in the same scenario. Iconic behavior honestly. ๐
According to [TS36133] sections 9.1.4 and 9.1.7, RSRP is reported by the PHY layer in dBm while RSRQ in dB. The values of RSRP and RSRQ are provided to higher layers through the C-PHY SAP (by means of the UeMeasurementsParameters struct) every 200 ms as defined in [TS36331]. Layer 1 filtering is performed by averaging all the measurements collected during the last window slot. The periodicity of reporting can be adjusted for research purposes by means of the LteUePhy::UeMeasurementsFilterPeriod attribute. ๐ฅ
The formulas of the RSRP and RSRQ can be simplified considering the assumption of the PHY layer that the channel is flat within the RB, the finest level of accuracy. In fact, this implies that all the REs within a RB have the same power, therefore:
RSRP = \frac{\sum_{k=0}^{K-1}\frac{\sum_{m=0}^{M-1}(P(k,m))}{M}}{K}
= \frac{\sum_{k=0}^{K-1}\frac{(M \times P(k))}{M}}{K}
= \frac{\sum_{k=0}^{K-1}(P(k))}{K}
where P(k,m) represents the signal power of the RE m within the RB k, which, as observed before, is constant within the same RB and equal to P(k), M is the number of REs carrying the RS in a RB and K is the number of RBs. It is to be noted that P(k), and in general all the powers defined in this section, is obtained in the simulator from the PSD of the RB (which is provided by the LteInterferencePowerChunkProcessor), in detail:
P(k) = PSD_{RB}(k)*180000/12
where PSD_{RB}(k) is the power spectral density of the RB k, 180000 is the bandwidth in Hz of the RB and 12 is the number of REs per RB in an OFDM symbol. Similarly, for RSSI we have
RSSI = \sum_{k=0}^{K-1} \frac{\sum_{s=0}^{S-1} \sum_{r=0}^{R-1}(
P(k,s,r) + I(k,s,r) + N(k,s,r))}{S}
where S is the number of OFDM symbols carrying RS in a RB and R is the number of REs carrying a RS in a OFDM symbol (which is fixed to 2), while P(k,s,r), I(k,s,r) and N(k,s,r) represent respectively the perceived power of the serving cell, the interference power and the noise power of the RE r in symbol s. As for RSRP, the measurements within a RB are always equals among each others according to the PHY model; therefore P(k,s,r) = P(k), I(k,s,r) = I(k) and N(k,s,r) = N(k), which implies that the RSSI can be calculated as:
RSSI = \sum_{k=0}^{K-1} \frac{S \times 2 \times ( P(k) + I(k) + N(k))}{S}
= \sum_{k=0}^{K-1} 2 \times ( P(k) + I(k) + N (k))
Considering the constraints of the PHY reception chain implementation, and in order to maintain the level of computational complexity low, only RSRP can be directly obtained for all the cells. This is due to the fact that LteSpectrumPhy is designed for evaluating the interference only respect to the signal of the serving eNB. This implies that the PHY layer is optimized for managing the power signals information with the serving eNB as a reference. However, RSRP and RSRQ of neighbor cell i can be extracted by the current information available of the serving cell j, as detailed in the following: ๐
RSRP_i = \frac{\sum_{k=0}^{K-1}(P_i(k))}{K}
RSSI_i = RSSI_j = \sum_{k=0}^{K-1} 2 \times ( I_j(k) + P_j(k) + N_j(k) )
RSRQ_i^j = K \times RSRP_i / RSSI_j
where RSRP_i is the RSRP of the neighbor cell i, P_i(k) is the power perceived at any RE within the RB k, K is the total number of RBs, RSSI_i is the RSSI of the neighbor cell i when the UE is attached to cell j (which, since it is the sum of all the received powers, coincides with RSSI_j), I_j(k) is the total interference perceived by UE in any RE of RB k when attached to cell i (obtained by the LteInterferencePowerChunkProcessor), P_j(k) is the power perceived of cell j in any RE of the RB k and N is the power noise spectral density in any RE.
The sample is considered as valid in case of the RSRQ evaluated is above the LteUePhy::RsrqUeMeasThreshold attribute. โ ๏ธ
๐ HARQ ๐
The HARQ scheme implemented is based on an incremental redundancy (IR) solutions combined with multiple stop-and-wait processes for enabling a continuous data flow. In detail, the solution adopted is the soft combining hybrid IR Full incremental redundancy (also called IR Type II), which implies that the retransmissions contain only new information respect to the previous ones. The resource allocation algorithm of the HARQ has been implemented within the respective scheduler classes (i.e., RrFfMacScheduler and PfFfMacScheduler โ refer to their correspondent sections for more info), while the decodification part of the HARQ has been implemented in the LteSpectrumPhy and LteHarqPhy classes, which will be detailed in this section. ๐ฆ
According to the standard, the UL retransmissions are synchronous and therefore are allocated 7 ms after the original transmission. On the other hand, for the DL, they are asynchronous and therefore can be allocated in a more flexible way starting from 7 ms, and it is a matter of the specific scheduler implementation. The HARQ processes behavior is depicted in Figure:ref:fig-harq-processes-scheme. โจ
At the MAC layer, the HARQ entity residing in the scheduler is in charge of controlling the 8 HARQ processes for generating new packets and managing the retransmissions both for the DL and the UL. The scheduler collects the HARQ feedback from eNB and UE PHY layers (respectively for UL and DL connection) by means of the FF API primitives SchedUlTriggerReq and SchedUlTriggerReq. According to the HARQ feedback and the RLC buffers status, the scheduler generates a set of DCIs including both retransmissions of HARQ blocks received erroneous and new transmissions, in general giving priority to the former. ๐ซก
On this matter, the scheduler has to take into consideration one constraint when allocating the resource for HARQ retransmissions: it must use the same modulation order of the first transmission attempt (i.e., QPSK for MCS \in [0..9], 16QAM for MCS \in [10..16] and 64QAM for MCS \in [17..28]). This restriction comes from the specification of the rate matcher in the 3GPP standard [ TS36212]_, where the algorithm fixes the modulation order for generating the different blocks of the redundancy versions.
The PHY Error Model model (i.e., the LteMiErrorModel class already presented before) has been extended for considering IR HARQ according to [wimaxEmd], where the parameters for the AWGN curves mapping for MIESM mapping in case of retransmissions are given by: ๐
R_{eff} = \frac{X}{\sum\limits_{i=1}^q C_i}
M_{I eff} = \frac{\sum\limits_{i=1}^q C_i M_i}{\sum\limits_{i=1}^q C_i}
where <pink>X</pink> is the number of original information bits, <pink>C_i</pink> are the number of coded bits, and <pink>M_i</pink> is the mutual information per HARQ block that got received over the total number of <pink>q</pink> retransmissions. ๐
So basically, for the error model implemented in the simulator to be able to hand the error probability back to you, it evaluates <hotpink>R_{eff}</hotpink> and <hotpink>MI_{I eff}</hotpink>, and returns the error probability value of the ECR of the same modulation with the closest lower rate with respect to <pink>R_{eff}</pink>. โจ
And to actually account for the effect of HARQ retransmissions, a whole new set of curves has been integrated, on top of the standard ones used for the original MCS. These new curves exist to cover the cases where the most conservative MCS of a modulation gets used โ which implies generating an <pink>R_{eff}</pink> that's lower than the one of standard MCSs. On that note: the curves for 1, 2 and 3 retransmissions have been evaluated for 10 and 17. For MCS 0 we only considered the first retransmission, because the code rate it produces is already so conservative (i.e., 0.04) and returns an error rate robust enough for the reception (i.e., the downturn of the BLER is centered around -18 dB). ๐
๐ Mark this down: the size of the first TB transmission has been assumed as containing all the information bits to be coded; therefore<pink>X</pink>is equal to the size of the first TB sent of an HARQ process. The model assumes that the eventual presence of parity bits in the codewords is already considered in the link level curves. This implies that as soon as the minimum<pink>R_{eff}</pink>is reached, the model is not including the gain due to the transmission of further parity bits.
๐ผ๏ธ Figure: HARQ processes behavior in LTE.
The part of HARQ devoted to managing the decodification of the HARQ blocks has been implemented in the LteHarqPhy and LteSpectrumPhy classes, bestie. The former is in charge of maintaining the HARQ information for each active process. The latter interacts with the LteMiErrorModel class to evaluate whether the blocks received are correct, and it includes the messaging algorithm in charge of communicating the result of the decodifications to the HARQ entity in the scheduler. These messages are encapsulated in dlInfoListElement for DL and ulInfoListElement for UL, and sent through the PUCCH and the PHICH respectively, with an ideal error free model according to the assumptions in their implementation. A sketch of the iteration between HARQ and the LTE protocol stack is represented in Figure:ref:fig-harq-architecture. ๐ฆ
Finally โ and this is lowkey the important bit โ the HARQ engine is always active both at MAC and PHY layer; but in case the scheduler doesn't support HARQ, the system will just continue to work with the HARQ functions inhibited (i.e., buffers are filled but not used). This implementation characteristic is what gives you backward compatibility with schedulers implemented before HARQ integration. ๐
๐ผ๏ธ Figure: Interaction between HARQ and LTE protocol stack.
๐ MAC ๐
๐ Resource Allocation Model
Okay so real quick, let's talk about how resource allocation is handled in LTE, and how it's modeled in the simulator. The scheduler is in charge of generating these specific structures called Data Control Indication (DCI), which are then transmitted by the PHY of the eNB to the connected UEs, so it can inform them about the resource allocation on a per subframe basis. When it does this in the downlink direction, the scheduler has to fill some specific fields of the DCI structure with all the info โ like the Modulation and Coding Scheme (MCS) to be used, the MAC Transport Block (TB) size, and the allocation bitmap, which identifies which RBs will contain the data the eNB is transmitting to each user. ๐ก
For the mapping of resources to physical RBs, we adopt a localized mapping approach (see [Sesia2009], Section 9.2.2.1); hence in a given subframe each RB is always allocated to the same user in both slots. The allocation bitmap can be coded in different formats; in this implementation, we considered the Allocation Type 0 defined in [TS36213], according to which the RBs are grouped in Resource Block Groups (RBG) of different size, determined as a function of the Transmission Bandwidth Configuration in use.
For certain bandwidth values, not all the RBs are usable, since the group size isn't a common divisor of the group. This is for instance the case when the bandwidth is equal to 25 RBs, which results in a RBG size of 2 RBs, and therefore 1 RB will result not addressable. ๐ญ In uplink the format of the DCIs is different, since only adjacent RBs can be used because of the SC-FDMA modulation. As a consequence, all RBs can be allocated by the eNB regardless of the bandwidth configuration. โจ
๐ Adaptive Modulation and Coding
The simulator provides two Adaptive Modulation and Coding (AMC) models: one based on the GSoC model [Piro2011] and one based on the physical error model (described in the following sections). Both of them are eating, ngl.
The former model is a modified version of the model described in [Piro2011], which in turn is inspired from [Seo2004]. Our version is described in the following. Let <pink>i</pink> denote the generic user, and let <pink>\gamma_i</pink> be its SINR. We get the spectral efficiency <pink>\eta_i</pink> of user <pink>i</pink> using the following equations:
\mathrm{BER} = 0.00005
\Gamma = \frac{ -\ln{ (5 * \mathrm{BER}) } }{ 1.5}
\eta_i = \log_2 { \left( 1 + \frac{ {\gamma}_i }{ \Gamma } \right)}
The procedure described in [R1-081483] is used to get the corresponding MCS scheme. The spectral efficiency is quantized based on the channel quality indicator (CQI), rounding to the lowest value, and is mapped to the corresponding MCS scheme. ๐ง
And finally, bestie, heads up โ there are some discrepancies between the MCS index in [R1-081483] and the one indicated by the standard: [TS36213] Table 7.1.7.1-1 says that the MCS index goes from 0 to 31, and 0 appears to be a valid MCS scheme (TB size is not 0) but in [R1-081483] the first useful MCS index is 1. Hence, to get the value as intended by the standard we need to subtract 1 from the index reported in [R1-081483]. ๐
The alternative model is based on the physical error model developed for this simulator and explained in the following subsections. This scheme is able to adapt the MCS selection to the actual PHY layer performance according to the specific CQI report. According to their definition, a CQI index is assigned when a single PDSCH TB with the modulation coding scheme and code rate correspondent to that CQI index in table 7.2.3-1 of [TS36213] can be received with an error probability less than 0.1. In case of wideband CQIs, the reference TB includes all the RBGs available, so you have a reference based on the whole available resources; while, for subband CQIs, the reference TB is sized as the RBGs. ๐
๐ Transport Block model
The model of the MAC Transport Blocks (TBs) provided by the simulator is simplified with respect to the 3GPP specifications. In particular, a simulator-specific class (PacketBurst) is used to aggregate MAC SDUs in order to achieve the simulator's equivalent of a TB, without the corresponding implementation complexity. The multiplexing of different logical channels to and from the RLC layer is performed using a dedicated packet tag (LteRadioBearerTag), which performs a functionality that is partially equivalent to that of the MAC headers specified by 3GPP. ๐ซถ
๐ The FemtoForum MAC Scheduler Interface
This section describes the ns-3 specific version of the LTE MAC Scheduler Interface Specification published by the FemtoForum [FFAPI]. It's giving very official, and we love that for us.
We implemented the ns-3 specific version of the FemtoForum MAC Scheduler Interface [FFAPI] as a set of C++ abstract classes; in particular, each primitive is translated to a C++ method of a given class. The term implemented here is used with the same meaning adopted in [FFAPI], and hence refers to the process of translating the logical interface specification to a particular programming language. The primitives in [FFAPI] are grouped in two groups: the CSCHED primitives, which deal with scheduler configuration, and the SCHED primitives, which deal with the execution of the scheduler. Furthermore, [FFAPI] defines primitives of two different kinds: those of type REQ go from the MAC to the Scheduler, and those of type IND/CNF go from the scheduler to the MAC. ๐ฅ
To translate these characteristics into C++, we define the following abstract classes that implement Service Access Points (SAPs), to be used to issue the primitives:
- the
FfMacSchedSapProviderclass defines all the C++ methods that correspond to SCHED primitives of type REQ; - the
FfMacSchedSapUserclass defines all the C++ methods that correspond to SCHED primitives of type CNF/IND; - the
FfMacCschedSapProviderclass defines all the C++ methods that correspond to CSCHED primitives of type REQ; - the
FfMacCschedSapUserclass defines all the C++ methods that correspond to CSCHED primitives of type CNF/IND;
There are 3 blocks involved in the MAC Scheduler interface: Control block, Subframe block and Scheduler block. Each of these blocks provides one part of the MAC Scheduler interface. The figure below shows the relationship between the blocks and the SAPs defined in our implementation of the MAC Scheduler Interface.
๐ผ๏ธ (figure)
In addition to the above principles, the following design choices have been taken:
- The definition of the MAC Scheduler interface classes follows the naming conventions of the ns-3 Coding Style. In particular, we follow the CamelCase convention for the primitive names. For example, the primitive
CSCHED_CELL_CONFIG_REQis translated toCschedCellConfigReqin the ns-3 code. - The same naming conventions are followed for the primitive parameters. As the primitive parameters are member variables of classes, they are also prefixed with a
m_. - regarding the use of vectors and lists in data structures, we note that
[FFAPI]is a pretty much C-oriented API. However, considered that C++ is used in ns-3, and that the use of C arrays is discouraged, we used STL vectors (std::vector) for the implementation of the MAC Scheduler Interface, instead of using C arrays as implicitly suggested by the way[FFAPI]is written. - In C++, members with constructors and destructors are not allow in unions. Hence all those data structures that are said to be unions in
[FFAPI]have been defined as structs in our code.
The figure below shows how the MAC Scheduler Interface is used within the eNB. ๐
๐ผ๏ธ (figure)
The User side of both the CSCHED SAP and the SCHED SAP is implemented within the eNB MAC, i.e., in the file lte-enb-mac.cc. The eNB MAC can be used with different scheduler implementations without modifications. The same figure also shows, as an example, how the Round Robin Scheduler is implemented: to interact with the MAC of the eNB, the Round Robin scheduler implements the Provider side of the SCHED SAP and CSCHED SAP interfaces. A similar approach can be used to implement other schedulers as well. A description of each of the scheduler implementations that we provide as part of our LTE simulation module is provided in the following subsections.
๐ก Round Robin (RR) Scheduler
The Round Robin (RR) scheduler is probably the simplest scheduler found in the literature. It works by dividing the available resources among the active flows, i.e., those logical channels which have a non-empty RLC queue. If the number of RBGs is greater than the number of active flows, all the flows can be allocated in the same subframe. Otherwise, if the number of active flows is greater than the number of RBGs, not all the flows can be scheduled in a given subframe; then, in the next subframe the allocation will start from the last flow that was not allocated. The MCS to be adopted for each user is done according to the received wideband CQIs.
For what concern the HARQ, RR implements the non adaptive version, which implies that in allocating the retransmission attempts RR uses the same allocation configuration of the original block, which means maintaining the same RBGs and MCS. UEs that are allocated for HARQ retransmissions are not considered for the transmission of new data in case they have a transmission opportunity available in the same TTI. Finally, HARQ can be disabled with ns3 attribute system for maintaining backward compatibility with old test cases and code, in detail:
Config::SetDefault ("ns3::RrFfMacScheduler::HarqEnabled", BooleanValue (false));
The scheduler implements the filtering of the uplink CQIs according to their nature with UlCqiFilter attribute, in detail:
SRS_UL_CQI: only SRS based CQI are stored in the internal attributes.PUSCH_UL_CQI: only PUSCH based CQI are stored in the internal attributes.
๐ Proportional Fair (PF) Scheduler
The Proportional Fair (PF) scheduler [Sesia2009] works by scheduling a user when its instantaneous channel quality is high relative to its own average channel condition over time. Let i,j denote generic users; let t be the subframe index, and k be the resource block index; let M_{i,k}(t) be MCS usable by user i on resource block k according to what reported by the AMC model (see Adaptive Modulation and Coding); finally, let S(M, B) be the TB size in bits as defined in [TS36213] for the case where a number B of resource blocks is used. The achievable rate R_{i}(k,t) in bit/s for user i on resource block group k at subframe t is defined as
R_{i}(k,t) = \frac{S\left( M_{i,k}(t), 1\right)}{\tau}
where \tau is the TTI duration. At the start of each subframe t, each RBG is assigned to a certain user. In detail, the index \widehat{i}_{k}(t) to which RBG k is assigned at time t is determined as
\widehat{i}_{k}(t) = \underset{j=1,...,N}{\operatorname{argmax}}
\left( \frac{ R_{j}(k,t) }{ T_\mathrm{j}(t) } \right)
where T_{j}(t) is the past througput performance perceived by the user j. According to the above scheduling algorithm, a user can be allocated to different RBGs, which can be either adjacent or not, depending on the current condition of the channel and the past throughput performance T_{j}(t). The latter is determined at the end of the subframe t using the following exponential moving average approach:
T_{j}(t) =
(1-\frac{1}{\alpha})T_{j}(t-1) +\frac{1}{\alpha} \widehat{T}_{j}(t)
where \alpha is the time constant (in number of subframes) of the exponential moving average, and \widehat{T}_{j}(t) is the actual throughput achieved by the user i in the subframe t. \widehat{T}_{j}(t) is measured according to the following procedure. First we determine the MCS \widehat{M}_j(t) actually used by user j:
\widehat{M}_j(t) = \min_{k: \widehat{i}_{k}(t) = j}{M_{j,k}(t)}
then we determine the total number \widehat{B}_j(t) of RBGs allocated to user j:
\widehat{B}_j(t) = \left| \{ k : \widehat{i}_{k}(t) = j \} \right|
where |\cdot| indicates the cardinality of the set; finally,
\widehat{T}_{j}(t) = \frac{S\left( \widehat{M}_j(t), \widehat{B}_j(t)
\right)}{\tau}
For what concern the HARQ, PF implements the non adaptive version, which implies that in allocating the retransmission attempts the scheduler uses the same allocation configuration of the original block, which means maintaining the same RBGs and MCS. UEs that are allocated for HARQ retransmissions are not considered for the transmission of new data in case they have a transmission opportunity available in the same TTI. Finally, HARQ can be disabled with ns3 attribute system for maintaining backward compatibility with old test cases and code, in detail:
Config::SetDefault ("ns3::PfFfMacScheduler::HarqEnabled", BooleanValue (false));
โก Maximum Throughput (MT) Scheduler
The Maximum Throughput (MT) scheduler [FCapo2012] aims to maximize the overall throughput of eNB. It allocates each RB to the user that can achieve the maximum achievable rate in the current TTI. Currently, MT scheduler in NS-3 has two versions: frequency domain (FDMT) and time domain (TDMT). In FDMT, every TTI, MAC scheduler allocates RBGs to the UE who has highest achievable rate calculated by subband CQI. In TDMT, every TTI, MAC scheduler selects one UE which has highest achievable rate calculated by wideband CQI. Then MAC scheduler allocates all RBGs to this UE in current TTI. The calculation of achievable rate in FDMT and TDMT is as same as the one in PF. Let i,j denote generic users; let t be the subframe index, and k be the resource block index; let M_{i,k}(t) be MCS usable by user i on resource block k according to what reported by the AMC model (see Adaptive Modulation and Coding); finally, let S(M, B) be the TB size in bits as defined in [TS36213] for the case where a number B of resource blocks is used. The achievable rate R_{i}(k,t) in bit/s for user i on resource block k at subframe t is defined as
R_{i}(k,t) = \frac{S\left( M_{i,k}(t), 1\right)}{\tau}
where \tau is the TTI duration. At the start of each subframe t, each RB is assigned to a certain user. In detail, the index \widehat{i}_{k}(t) to which RB k is assigned at time t is determined as
\widehat{i}_{k}(t) = \underset{j=1,...,N}{\operatorname{argmax}}
\left( { R_{j}(k,t) } \right)
When there are several UEs having the same achievable rate, current implementation always selects the first UE created in script. Although MT can maximize cell throughput, it cannot provide fairness to UEs in poor channel condition.
๐ฆ Throughput to Average (TTA) Scheduler
The Throughput to Average (TTA) scheduler [FCapo2012] can be considered as an intermediate between MT and PF. The metric used in TTA is calculated as follows:
\widehat{i}_{k}(t) = \underset{j=1,...,N}{\operatorname{argmax}}
\left( \frac{ R_{j}(k,t) }{ R_{j}(t) } \right)
Here, R_{i}(k,t) in bit/s represents the achievable rate for user i on resource block k at subframe t. The calculation method already is shown in MT and PF. Meanwhile, R_{i}(t) in bit/s stands for the achievable rate for i at subframe t. The difference between those two achievable rates is how to get MCS. For R_{i}(k,t), MCS is calculated by subband CQI while R_{i}(t) is calculated by wideband CQI. TTA scheduler can only be implemented in frequency domain (FD) because the achievable rate of particular RBG is only related to FD scheduling.
๐ธ Blind Average Throughput Scheduler
The Blind Average Throughput scheduler [FCapo2012] aims to provide equal throughput to all UEs under eNB. The metric used in TTA is calculated as follows:
\widehat{i}_{k}(t) = \underset{j=1,...,N}{\operatorname{argmax}}
\left( \frac{ 1 }{ T_\mathrm{j}(t) } \right)
where T_{j}(t) is the past throughput performance perceived by the user j and can be calculated by the same method in PF scheduler. In the time domain blind average throughput (TD-BET), the scheduler selects the UE with largest priority metric and allocates all RBGs to this UE. On the other hand, in the frequency domain blind average throughput (FD-BET), every TTI, the scheduler first selects one UE with lowest pastAverageThroughput (largest priority metric). Then scheduler assigns one RBG to this UE, it calculates expected throughput of this UE and uses it to compare with past average throughput T_{j}(t) of other UEs. The scheduler continues to allocate RBG to this UE until its expected throughput is not the smallest one among past average throughput T_{j}(t) of all UE. Then the scheduler will use the same way to allocate RBG for a new UE which has the lowest past average throughput T_{j}(t) until all RBGs are allocated to UEs. The principle behind this is that, in every TTI, the scheduler tries the best to achieve the equal throughput among all UEs.
๐ช Token Bank Fair Queue Scheduler
Token Bank Fair Queue (TBFQ) is a QoS aware scheduler which derives from the leaky-bucket mechanism. In TBFQ, a traffic flow of user i is characterized by following parameters:
t_{i}: packet arrival rate (byte/sec )r_{i}: token generation rate (byte/sec)p_{i}: token pool size (byte)E_{i}: counter that records the number of token borrowed from or given to the token bank by flow i ; E_{i} can be smaller than zero
Each K bytes data consumes k tokens. Also, TBFQ maintains a shared token bank (B) so as to balance the traffic between different flows. If token generation rate r_{i} is bigger than packet arrival rate t_{i}, then tokens overflowing from token pool are added to the token bank, and E_{i} is increased by the same amount. Otherwise, flow i needs to withdraw tokens from token bank based on a priority metric frac{E_{i}}{r_{i}}, and E_{i} is decreased. Obviously, the user contributes more on token bank has higher priority to borrow tokens; on the other hand, the user borrows more tokens from bank has lower priority to continue to withdraw tokens. Therefore, in case of several users having the same token generation rate, traffic rate and token pool size, user suffers from higher interference has more opportunity to borrow tokens from bank. In addition, TBFQ can police the traffic by setting the token generation rate to limit the throughput. Additionally, TBFQ also maintains following three parameters for each flow:
- Debt limit
d_{i}โ ifE_{i}drops below this threshold, useriliterally cannot borrow any more tokens from the bank. It's giving bouncer-at-the-club energy ๐ซ and its whole job is stopping a malicious UE from borrowing wayyy too many tokens. - Credit limit
c_{i}โ the max number of tokens UEican borrow from the bank in one single go. One trip, one scoop ๐. - Credit threshold
Cโ onceE_{i}hits the debt limit, UEihas to storeCtokens back into the bank before it's allowed to borrow again. Pay your tab first bestie ๐ .
LTE in NS-3 ships two versions of the TBFQ scheduler: frequency domain TBFQ (FD-TBFQ) and time domain TBFQ (TD-TBFQ). In FD-TBFQ, the scheduler always picks the UE with the highest metric and allocates the RBG with the highest subband CQI until there are no packets left in that UE's RLC buffer or all RBGs are allocated [FABokhari2009]. In TD-TBFQ, after picking the UE with the maximum metric, it hands all RBGs to that UE using the wideband CQI [WKWong2004]. Same vibe, different domain, no cap โจ
๐ธ Priority Set Scheduler ๐ธ
Priority set scheduler (PSS) is a QoS aware scheduler that fuses time domain (TD) and frequency domain (FD) packet scheduling operations into one single scheduler [GMonghal2008]. It keeps the fairness among UEs in check via a specified Target Bit Rate (TBR). Queen behavior honestly ๐
In the TD scheduler part, PSS first selects UEs with a non-empty RLC buffer and then splits them into two sets based on the TBR:
- set 1: UE whose past average throughput is smaller than TBR; the TD scheduler calculates their priority metric in Blind Equal Throughput (BET) style:
\widehat{i}_{k}(t) = \underset{j=1,...,N}{\operatorname{argmax}}
\left( \frac{ 1 }{ T_\mathrm{j}(t) } \right)
- set 2: UE whose past average throughput is larger (or equal) than TBR; the TD scheduler calculates their priority metric in Proportional Fair (PF) style:
\widehat{i}_{k}(t) = \underset{j=1,...,N}{\operatorname{argmax}}
\left( \frac{ R_{j}(k,t) }{ T_\mathrm{j}(t) } \right)
UEs in set 1 have higher priority than the ones in set 2, periodt. Then PSS selects N_{mux} UEs with the highest metric across the two sets and forwards those UEs to the FD scheduler. In PSS, the FD scheduler allocates RBG k to the UE n that maximums the chosen metric. Two PF schedulers get used inside the PF scheduler:
- Proportional Fair scheduled (PFsch)
\widehat{Msch}_{k}(t) = \underset{j=1,...,N}{\operatorname{argmax}}
\left( \frac{ R_{j}(k,t) }{ Tsch_\mathrm{j}(t) } \right)
- Carrier over Interference to Average (CoIta)
\widehat{Mcoi}_{k}(t) = \underset{j=1,...,N}{\operatorname{argmax}}
\left( \frac{ CoI[j,k] }{ \sum_{k=0}^{N_{RBG}} CoI[j,k] } \right)
where Tsch_{j}(t) is a similar past throughput performance perceived by the user j, except it only gets updated when the i-th user is actually served. CoI[j,k] is an estimation of the SINR on RBG k of UE j. Both PFsch and CoIta exist to decouple the FD metric from the TD scheduler. On top of that, the PSS FD scheduler also hands out a weight metric W[n] that helps control fairness when there are only a few UEs around.
W[n] = max (1, \frac{TBR}{ T_{j}(t) })
where T_{j}(t) is the past throughput performance perceived by the user j. So on RBG k, the FD scheduler picks the UE j that maximizes the product of the frequency domain metric (Msch, MCoI) by the weight W[n]. This strategy guarantees the throughput of a lower quality UE tends towards the TBR. Manifesting it fr fr ๐ฆ
Config::SetDefault ("ns3::PfFfMacScheduler::HarqEnabled", BooleanValue (false));
The scheduler implements the filtering of the uplink CQIs according to their nature with the UlCqiFilter attribute. In detail:
SRS_UL_CQI: only SRS based CQI are stored in the internal attributes.PUSCH_UL_CQI: only PUSCH based CQI are stored in the internal attributes.
๐ Channel and QoS Aware Scheduler ๐
The Channel and QoS Aware (CQA) Scheduler [Bbojovic2014] is an LTE MAC downlink scheduling algorithm that thinks about the head of line (HOL) delay, the GBR parameters and the channel quality over different subbands. The CQA scheduler is based on joint TD and FD scheduling. It really said "why not both" ๐
In the TD (at each TTI) the CQA scheduler groups users by priority. The purpose of the grouping is to force the FD scheduling to consider first the flows with the highest HOL delay. The grouping metric m_{td} for user j=1,...,N is defined in the following way:
m_{td}^{j}(t) = \lceil\frac{d_{hol}^{j}(t)}{g}\rceil \;,
where d_{hol}^{j}(t) is the current value of the HOL delay of flow j, and g is a grouping parameter that determines the granularity of the groups, i.e. the number of the flows that will be considered in the FD scheduling iteration.
The groups of flows selected in the TD iteration get forwarded to the FD scheduling starting from the flows with the highest value of the m_{td} metric until all RBGs are assigned in the corresponding TTI. In the FD, for each RBG k=1,...,K, the CQA scheduler assigns the current RBG to the user j that has the maximum value of the FD metric, which we define in the following way:
m_{fd}^{(k,j)}(t) = d_{HOL}^{j}(t) \cdot m_{GBR}^j(t) \cdot
m_{ca}^{k,j}(t) \;,
where m_{GBR}^j(t) is calculated as follows:
m_{GBR}^j(t)=\frac{GBR^j}{\overline{R^j}(t)}=\frac{GBR^j}{(1-\alpha)\cdot\overline{R^j}(t-1)+\alpha
\cdot r^j(t)} \;,
where GBR^j is the bit rate specified in the EPS bearer of the flow j, \overline{R^j}(t) is the past averaged throughput that is calculated with a moving average, r^{j}(t) is the throughput achieved at the time t, and \alpha is a coefficient such that 0 \le \alpha \le1.
For m_{ca}^{(k,j)}(t) we consider two different metrics: m_{pf}^{(k,j)}(t) and m_{ff}^{(k,j)}(t). m_{pf} is the Proportional Fair metric which is defined as follows:
m_{pf}^{(k,j)}(t) = \frac{R_e^{(k,j)}}{\overline{R^j}(t)} \;,
where R_e^{(k,j)}(t) is the estimated achievable throughput of user j over RBG k, calculated by the Adaptive Modulation and Coding (AMC) scheme that maps the channel quality indicator (CQI) value to the transport block size in bits.
The other channel awareness metric we consider is m_{ff}, which is proposed in [GMonghal2008] and represents the frequency selective fading gains over RBG k for user j. It's calculated in the following way:
m_{ff}^{(k,j)}(t) = \frac{CQI^{(k,j)}(t)}{\sum_{k=1}^{K}CQI(t)^{(k,j)}} \;,
where CQI^{(k,j)}(t) is the last reported CQI value from user j for the k-th RBG.
You can pick whether m_{pf} or m_{ff} gets used by setting the attribute ns3::CqaFfMacScheduler::CqaMetric to "CqaPf" or "CqaFf" respectively. Your scheduler, your rules ๐
โญ Random Access โญ
The LTE model includes a model of the Random Access procedure based on some simplifying assumptions, which are detailed in the following for each of the messages and signals described in the specs [TS36321].
- Random Access (RA) preamble: in real LTE systems this corresponds to a Zadoff-Chu (ZC) sequence using one of several formats available, sent in the PRACH slots which could in principle overlap with PUSCH. PRACH Configuration Index 14 is assumed, i.e., preambles can be sent on any system frame number and subframe number. The RA preamble is modeled using the
LteControlMessageclass, i.e., as an ideal message that does not consume any radio resources. The collision of preamble transmission by multiple UEs in the same cell is modeled using a protocol interference model, i.e., whenever two or more identical preambles are transmitted in the same cell at the same TTI, no one of these identical preambles will be received by the eNB. Other than this collision model, no error model is associated with the reception of a RA preamble. - Random Access Response (RAR): in real LTE systems, this is a special MAC PDU sent on the DL-SCH. Since MAC control elements are not accurately modeled in the simulator (only RLC and above PDUs are), the RAR is modeled as an
LteControlMessagethat does not consume any radio resources. Still, during the RA procedure, theLteEnbMacwill request from the scheduler the allocation of resources for the RAR using the FF MAC Scheduler primitiveSCHED_DL_RACH_INFO_REQ. Hence, an enhanced scheduler implementation (not available at the moment) could allocate radio resources for the RAR, thus modeling the consumption of Radio Resources for the transmission of the RAR. - Message 3: in real LTE systems, this is an RLC TM SDU sent over resources specified in the UL Grant in the RAR. In the simulator, this is modeled as a real RLC TM RLC PDU whose UL resources are allocated by the scheduler upon call to
SCHED_DL_RACH_INFO_REQ. - Contention Resolution (CR): in real LTE systems, the CR phase is needed to address the case where two or more UEs sent the same RA preamble in the same TTI, and the eNB was able to detect this preamble in spite of the collision. Since this event does not occur due to the protocol interference model used for the reception of RA preambles, the CR phase is not modeled in the simulator, i.e., the CR MAC CE is never sent by the eNB and the UEs consider the RA to be successful upon reception of the RAR. As a consequence, the radio resources consumed for the transmission of the CR MAC CE are not modeled.
Figure Sequence diagram of the Contention-based MAC Random Access procedure and Sequence diagram of the Non-contention-based MAC Random Access procedure shows the sequence diagrams of respectively the contention-based and non-contention-based MAC random access procedure, highlighting the interactions between the MAC and the other entities.
๐ธ [image] Sequence diagram of the Contention-based MAC Random Access procedure.
๐ธ [image] Sequence diagram of the Non-contention-based MAC Random Access procedure.
๐ RLC ๐
๐ Overview ๐
The RLC entity is specified in the 3GPP technical specification [TS36322], and comprises three different types of RLC: Transparent Mode (TM), Unacknowledged Mode (UM) and Acknowledged Mode (AM). The simulator includes one model for each of these entities. Three for three, iconic โจ
The RLC entities provide the RLC service interface to the upper PDCP layer and the MAC service interface to the lower MAC layer. The RLC entities use the PDCP service interface from the upper PDCP layer and the MAC service interface from the lower MAC layer. Up and down, she's a connector bestie ๐ซถ
Figure Implementation Model of PDCP, RLC and MAC entities and SAPs shows the implementation model of the RLC entities and its relationship with all the other entities and services in the protocol stack.
๐ธ [image] Implementation Model of PDCP, RLC and MAC entities and SAPs.
๐ฆ Service Interfaces ๐ฆ
๐ RLC Service Interface ๐
The RLC service interface is divided into two parts:
- the
RlcSapProviderpart is provided by the RLC layer and used by the upper PDCP layer and - the
RlcSapUserpart is provided by the upper PDCP layer and used by the RLC layer.
Both the UM and the AM RLC entities provide the same RLC service interface to the upper PDCP layer. ๐
๐ธ RLC Service Primitives ๐ธ
Here's the receipts on which service primitives the RLC service interfaces hand out, bestie:
RlcSapProvider::TransmitPdcpPdu- The PDCP entity uses this primitive to send a PDCP PDU to the lower RLC entity in the transmitter peer
RlcSapUser::ReceivePdcpPdu- The RLC entity uses this primitive to send a PDCP PDU to the upper PDCP entity in the receiver peer
๐ MAC Service Interface ๐
The MAC service interface is split into two parts, no cap:
- the
MacSapProviderpart is provided by the MAC layer and used by the upper RLC layer and - the
MacSapUserpart is provided by the upper RLC layer and used by the MAC layer.
๐ MAC Service Primitives ๐
The following list specifies which service primitives are provided by the MAC service interfaces:
MacSapProvider::TransmitPdu- The RLC entity uses this primitive to send a RLC PDU to the lower MAC entity in the transmitter peer
MacSapProvider::ReportBufferStatus- The RLC entity uses this primitive to report the MAC entity the size of pending buffers in the transmitter peer
MacSapUser::NotifyTxOpportunity- The MAC entity uses this primitive to notify the RLC entity a transmission opportunity
MacSapUser::ReceivePdu- The MAC entity uses this primitive to send an RLC PDU to the upper RLC entity in the receiver peer
๐ AM RLC ๐
The processing of the data transfer in the Acknowledge Mode (AM) RLC entity is explained in section 5.1.3 of [TS36322]. In this section we describe some details of the implementation of the RLC entity. โจ
๐ฆ Buffers for the transmit operations ๐ฆ
Our implementation of the AM RLC entity maintains 3 buffers for the transmit operations, and yes she's organized:
- Transmission Buffer: it is the RLC SDU queue. When the AM RLC entity receives a SDU in the
TransmitPdcpPduservice primitive from the upper PDCP entity, it enqueues it in the Transmission Buffer. We put a limit on the RLC buffer size and theLteRlcTxDroptrace source is called when a drop due to a full buffer occurs. - Transmitted PDUs Buffer: it is the queue of transmitted RLC PDUs for which an ACK/NACK has not been received yet. When the AM RLC entity sends a PDU to the MAC entity, it also puts a copy of the transmitted PDU in the Transmitted PDUs Buffer.
- Retransmission Buffer: it is the queue of RLC PDUs which are considered for retransmission (i.e., they have been NACKed). The AM RLC entity moves this PDU to the Retransmission Buffer, when it retransmits a PDU from the Transmitted Buffer.
๐ Transmit operations in downlink ๐
The following sequence diagram shows the interactions between the different entities (RRC, PDCP, AM RLC, MAC and MAC scheduler) of the eNB in the downlink to perform data communications.
Figure Sequence diagram of data PDU transmission in downlink shows how the upper layers send data PDUs and how the data flow is processed by the different entities/services of the LTE protocol stack.
[image] Sequence diagram of data PDU transmission in downlink.
The PDCP entity calls the Transmit_PDCP_PDU service primitive in order to send a data PDU. The AM RLC entity processes this service primitive according to the AM data transfer procedures defined in section 5.1.3 of [TS36322].
When the Transmit_PDCP_PDU service primitive is called, the AM RLC entity performs the following operations:
- Put the data SDU in the Transmission Buffer.
- Compute the size of the buffers (how the size of buffers is computed will be explained afterwards).
- Call the
Report_Buffer_Statusservice primitive of the eNB MAC entity in order to notify to the eNB MAC entity the sizes of the buffers of the AM RLC entity. Then, the eNB MAC entity updates the buffer status in the MAC scheduler using theSchedDlRlcBufferReqservice primitive of the FF MAC Scheduler API.
Afterwards, when the MAC scheduler decides that some data can be sent, the MAC entity notifies it to the RLC entity, i.e. it calls the Notify_Tx_Opportunity service primitive, then the AM RLC entity does the following:
- Create a single data PDU by segmenting and/or concatenating the SDUs in the Transmission Buffer.
- Move the data PDU from the Transmission Buffer to the Transmitted PDUs Buffer.
- Update state variables according section 5.1.3.1.1 of
[TS36322]. - Call the
Transmit_PDUprimitive in order to send the data PDU to the MAC entity.
๐ Retransmission in downlink ๐
The sequence diagram of Figure Sequence diagram of data PDU retransmission in downlink shows the interactions between the different entities (AM RLC, MAC and MAC scheduler) of the eNB in downlink when data PDUs must be retransmitted by the AM RLC entity.
[image] Sequence diagram of data PDU retransmission in downlink.
The transmitting AM RLC entity can receive STATUS PDUs from the peer AM RLC entity. STATUS PDUs are sent according section 5.3.2 of [TS36322] and the processing of reception is made according section 5.2.1 of [TS36322].
When a data PDUs is retransmitted from the Transmitted PDUs Buffer, it is also moved to the Retransmission Buffer.
๐ง Transmit operations in uplink ๐ง
The sequence diagram of Figure Sequence diagram of data PDU transmission in uplink shows the interactions between the different entities of the UE (RRC, PDCP, RLC and MAC) and the eNB (MAC and Scheduler) in uplink when data PDUs are sent by the upper layers.
[image] Sequence diagram of data PDU transmission in uplink.
It is similar to the sequence diagram in downlink; the main difference is that in this case the Report_Buffer_Status is sent from the UE MAC to the MAC Scheduler in the eNB over the air using the control channel.
๐ Retransmission in uplink ๐
The sequence diagram of Figure Sequence diagram of data PDU retransmission in uplink shows the interactions between the different entities of the UE (AM RLC and MAC) and the eNB (MAC) in uplink when data PDUs must be retransmitted by the AM RLC entity.
[image] Sequence diagram of data PDU retransmission in uplink.
โญ Calculation of the buffer size โญ
The Transmission Buffer contains RLC SDUs. A RLC PDU is one or more SDU segments plus an RLC header. The size of the RLC header of one RLC PDU depends on the number of SDU segments the PDU contains.
The 3GPP standard (section 6.1.3.1 of [TS36321]) says clearly that, for the uplink, the RLC and MAC headers are not considered in the buffer size that is to be report as part of the Buffer Status Report. For the downlink, the behavior is not specified. Neither [FFAPI] specifies how to do it. Our RLC model works by assuming that the calculation of the buffer size in the downlink is done exactly as in the uplink, i.e., not considering the RLC and MAC header size.
We note that this choice affects the interoperation with the MAC scheduler, since, in response to the Notify_Tx_Opportunity service primitive, the RLC is expected to create a PDU of no more than the size requested by the MAC, including RLC overhead. Hence, unneeded fragmentation can occur if (for example) the MAC notifies a transmission exactly equal to the buffer size previously reported by the RLC. We assume that it is left to the Scheduler to implement smart strategies for the selection of the size of the transmission opportunity, in order to eventually avoid the inefficiency of unneeded fragmentation.
๐ซถ Concatenation and Segmentation ๐ซถ
The AM RLC entity generates and sends exactly one RLC PDU for each transmission opportunity even if it is smaller than the size reported by the transmission opportunity. So for instance, if a STATUS PDU is to be sent, then only this PDU will be sent in that transmission opportunity.
The segmentation and concatenation for the SDU queue of the AM RLC entity follows the same philosophy as the same procedures of the UM RLC entity but there are new state variables (see [TS36322] section 7.1) only present in the AM RLC entity.
It is noted that, according to the 3GPP specs, there is no concatenation for the Retransmission Buffer.
๐ Re-segmentation ๐
The current model of the AM RLC entity does not support the re-segmentation of the retransmission buffer. Rather, the AM RLC entity just waits to receive a big enough transmission opportunity. She's patient like that.
๐ Unsupported features ๐
We do not support the following procedures of [TS36322]:
- "Send an indication of successful delivery of RLC SDU" (See section 5.1.3.1.1)
- "Indicate to upper layers that max retransmission has been reached" (See section 5.2.1)
- "SDU discard procedures" (See section 5.3)
- "Re-establishment procedure" (See section 5.4)
We do not support any of the additional primitives of RLC SAP for AM RLC entity. In particular:
- no SDU discard notified by PDCP
- no notification of successful / failed delivery by AM RLC entity to PDCP entity
๐ธ UM RLC ๐ธ
In this section we describe the implementation of the Unacknowledged Mode (UM) RLC entity.
๐ Transmit operations in downlink ๐
The transmit operations of the UM RLC are similar to those of the AM RLC previously described in Section Transmit operations in downlink, with the difference that, following the specifications of [TS36322], retransmission are not performed, and there are no STATUS PDUs.
โจ Transmit operations in uplink โจ
The transmit operations in the uplink are similar to those of the downlink, with the main difference that the Report_Buffer_Status is sent from the UE MAC to the MAC Scheduler in the eNB over the air using the control channel.
๐ Calculation of the buffer size ๐
The calculation of the buffer size for the UM RLC is done using the same approach of the AM RLC, please refer to section Calculation of the buffer size for the corresponding description.
๐ TM RLC ๐
In this section we describe the implementation of the Transparent Mode (TM) RLC entity.
๐ซ Transmit operations in downlink
okay so first, bestie: inside the simulator the TM RLC still hands the upper layers the exact same service interface that the AM and UM RLC entities hand to the PDCP layer. In practice that interface gets used by an RRC entity (not a PDCP entity, mind you) to ship out RLC SDUs. Why tho? Because the services TM RLC gives the upper layers, per [TS36322], are literally a subset of the ones the UM and AM RLC entities give to the PDCP layer โ so the devs reused the same interface for simplicity. iconic behavior fr.
Downlink transmit ops go like this. When the Transmit_PDCP_PDU service primitive gets called by the upper layers, the TM RLC does:
- put the SDU in the Transmission Buffer
- compute the size of the Transmission Buffer
- call the
Report_Buffer_Statusservice primitive of the eNB MAC entity
After that, once the MAC scheduler decides some data can be sent by the logical channel the TM RLC entity belongs to, the MAC entity lets it know by calling the Notify_Tx_Opportunity service primitive. On receiving that primitive, the TM RLC entity does:
- if the TX opportunity has a size that is greater than or equal to the size of the head-of-line SDU in the Transmission Buffer
- dequeue the head-of-line SDU from the Transmission Buffer
- create one RLC PDU that contains entirely that SDU, without any RLC header
- call the
Transmit_PDUprimitive in order to send the RLC PDU to the MAC entity.
๐ซ Transmit operations in uplink
Uplink is basically downlink's twin ๐ธ โ the big difference is that a transmission opportunity can also pop up from the assignment of the UL GRANT as part of the Random Access procedure, with no explicit Buffer Status Report issued by the TM RLC entity. no cap.
๐ซ Calculation of the buffer size
As per the specs [TS36322], the TM RLC adds zero RLC headers to the PDUs it transmits. Because of that, the buffer size reported up to the MAC layer is computed just by summing the size of every packet sitting in the transmission buffer โ so the MAC gets told the exact buffer size. math is mathing. โจ
๐ซ SM RLC
So alongside the AM, UM and TM implementations modeled after the 3GPP specs, there's a simplified RLC model too: the Saturation Mode (SM) RLC. This one does not accept PDUs from any above layer (like PDCP, bestie, nope). Instead, the SM RLC handles generating RLC PDUs in response to transmission opportunities notified by the MAC. Basically, the SM RLC simulates saturation conditions โ it assumes the RLC buffer is always full and can generate a new PDU whenever the scheduler pings it. ๐
The SM RLC is for simplified simulation scenarios where only the LTE Radio model is used โ no EPC, and therefore no IP networking support at all. And yes, we know the SM RLC is an unrealistic traffic model, but it still lets you correctly simulate scenarios with multiple flows belonging to different (non real-time) QoS classes, so you can test the QoS performance different schedulers give you. This works because it's the Scheduler's job to assign transmission resources based on the characteristics (e.g., Guaranteed Bit Rate) of each Radio Bearer, which get specified when each Bearer is defined inside the simulation program. ๐ซถ
Now, for schedulers built to work with real-time QoS traffic that has delay constraints? The SM RLC is probably not the move. Why? Because there are no actual RLC SDUs (they got replaced by the artificial generation of Buffer Status Reports), so it's not possible to give the Scheduler meaningful head-of-line-delay information โ and that's often the metric of choice for scheduling policies on real-time traffic flows. For simulating and testing those schedulers, pls use either the UM or the AM RLC models instead. ๐
๐ PDCP
PDCP Model Overview
The reference doc for the PDCP entity spec is [TS36323]. Compared to that spec, the PDCP model in the simulator supports only these features:
- transfer of data (user plane or control plane);
- maintenance of PDCP SNs;
- transfer of SN status (for use upon handover);
And these features are currently not supported (rip):
- header compression and decompression of IP data flows using the ROHC protocol;
- in-sequence delivery of upper layer PDUs at re-establishment of lower layers;
- duplicate elimination of lower layer SDUs at re-establishment of lower layers for radio bearers mapped on RLC AM;
- ciphering and deciphering of user plane data and control plane data;
- integrity protection and integrity verification of control plane data;
- timer based discard;
- duplicate discarding.
PDCP Service Interface
The PDCP service interface splits into two parts:
- the
PdcpSapProviderpart is provided by the PDCP layer and used by the upper layer, and - the
PdcpSapUserpart is provided by the upper layer and used by the PDCP layer.
PDCP Service Primitives
Here's the full list of which service primitives the PDCP service interfaces provide:
PdcpSapProvider::TransmitPdcpSdu- the RRC entity uses this primitive to send an RRC PDU to the lower PDCP entity in the transmitter peer
PdcpSapUser::ReceivePdcpSdu- the PDCP entity uses this primitive to send an RRC PDU to the upper RRC entity in the receiver peer
๐ RRC
Features
The RRC model implemented in the simulator brings you this functionality:
- generation (at the eNB) and interpretation (at the UE) of System Information (in particular the Master Information Block and, at the time of this writing, only System Information Block Type 1 and 2)
- initial cell selection
- RRC connection establishment procedure
- RRC reconfiguration procedure, supporting the following use cases: + reconfiguration of the SRS configuration index + reconfiguration of the PHY TX mode (MIMO) + reconfiguration of UE measurements + data radio bearer setup + handover
- RRC connection re-establishment, supporting the following use cases: + handover
Architecture
The RRC model breaks down into these components:
- the RRC entities
LteUeRrcandLteEnbRrc, which implement the state machines of the RRC entities at the UE and the eNB respectively; - the RRC SAPs
LteUeRrcSapProvider,LteUeRrcSapUser,LteEnbRrcSapProvider,LteEnbRrcSapUser, which let the RRC entities send and receive RRC messages and information elements; - the RRC protocol classes
LteUeRrcProtocolIdeal,LteEnbRrcProtocolIdeal,LteUeRrcProtocolReal,LteEnbRrcProtocolReal, which implement two different models for the transmission of RRC messages.
On top of that, the RRC components use various other SAPs to interact with the rest of the protocol stack. You can see a representation of every SAP that's used in these figures: LTE radio protocol stack architecture for the UE on the data plane, LTE radio protocol stack architecture for the UE on the control plane, LTE radio protocol stack architecture for the eNB on the data plane and LTE radio protocol stack architecture for the eNB on the control plane. ๐
UE RRC State Machine
In the Figure UE RRC State Machine we represent the state machine as implemented in the RRC UE entity. ๐ฆ
All the states are transient, however, the UE in "CONNECTED_NORMALLY" state will only switch to the IDLE state if the downlink SINR is below a defined threshold, which would lead to radio link failure (Radio Link Failure). On the other hand, the UE would not be able to switch to IDLE mode due to a handover failure, as mentioned in X2. ๐ญ
ENB RRC State Machine
The eNB RRC keeps the state for each UE that's attached to the cell. From an implementation point of view, each UE's state lives inside an instance of the UeManager class. The state machine is represented in the Figure ENB RRC State Machine for each UE. ๐
Initial Cell Selection
Initial cell selection is an IDLE mode procedure, done by the UE when it hasn't yet camped or attached to an eNodeB. The goal of the procedure: find a suitable cell and attach to it so it can gain access to the cellular network. ๐ฐ๏ธ
It's typically done at the beginning of simulation, as shown in the Figure Sample runs of initial cell selection in UE and timing of related events below. The time diagram on the left illustrates the case where initial cell selection succeeds on the first try, while the diagram on the right is the case where it fails on the first try and succeeds on the second. That timing assumes the use of the real RRC protocol model (see RRC protocol models) and no transmission error.
The functionality is based on 3GPP IDLE mode specifications, like in [TS36300], [TS36304], and [TS36331]. However, a proper implementation of IDLE mode is still missing in the simulator, so we're reserving several simplifying assumptions:
- multiple carrier frequency is not supported;
- multiple Public Land Mobile Network (PLMN) identities (i.e. multiple network operators) is not supported;
- RSRQ measurements are not utilized;
- stored information cell selection is not supported;
- "Any Cell Selection" state and camping to an acceptable cell is not supported;
- marking a cell as barred or reserved is not supported;
- Idle cell reselection is not supported, hence it is not possible for UE to camp to a different cell after the initial camp has been placed; and
- UE's Closed Subscriber Group (CSG) white list contains only one CSG identity.
Also note, bestie: initial cell selection is only available for EPC-enabled simulations. LTE-only simulations have to use the manual attachment method. See section sec-network-attachment of the User Documentation for more info on their differences in usage. ๐
The next subsections cover different parts of initial cell selection, namely cell search, broadcast of system information, and cell selection evaluation.
โจ Cell Search โจ
okay so bestie, cell search is literally the UE's little "hey who's out there??" moment ๐ it goes around detecting the surrounding cells and measuring how strong the received signal is from each one of them. one of these cells is gonna become the UE's entry point to join the cellular network, no cap.
the measurements are based on the RSRP of the received PSS, averaged by Layer 1 filtering, and performed by the PHY layer โ we already spilled all the deets on that in the section UE PHY Measurements Model. PSS gets transmitted by the eNodeB over the central 72 sub-carriers of the DL channel (Section 5.1.7.3 [TS36300]), so that's why we model cell search to operate using a DL bandwidth of 6 RBs. lowkey important: measurements of RSRQ are not available at this point of time in simulation ๐ญ which means the LteUePhy::RsrqUeMeasThreshold attribute does not apply during cell search. periodt.
so by using the measured RSRP, the PHY entity is able to generate a list of detected cells, each one with its corresponding cell ID and averaged RSRP. this list is periodically pushed via CPHY SAP to the RRC entity as a measurement report ๐ฌ
then the RRC entity inspects the report and just... chooses the cell with the strongest RSRP, as also indicated in Section 5.2.3.1 of [TS36304]. iconic. then it instructs back the PHY entity to synchronize to this particular cell. the actual operating bandwidth of the cell is still unknown at this time, so the PHY entity listens only to the minimum bandwidth of 6 RBs ๐ซถ nevertheless, the PHY entity will be able to receive the system broadcast message from this particular eNodeB, which is literally the topic of the next subsection, so stay tuned.
๐ Broadcast of System Information ๐
system information blocks are broadcasted by the eNodeB to UEs at predefined time intervals, adapted from Section 5.2.1.2 of [TS36331]. the supported system information blocks are, and bestie you're gonna want to screenshot this:
- Master Information Block (MIB) โ contains parameters related to the PHY layer, generated during cell configuration and broadcasted every 10 ms at the beginning of the radio frame as a control message.
- System Information Block Type 1 (SIB1) โ contains information regarding network access, broadcasted every 20 ms at the middle of the radio frame as a control message. not used in manual attachment method. UE must have decoded MIB before it can receive SIB1. no skipping steps bestie ๐
- System Information Block Type 2 (SIB2) โ contains UL- and RACH-related settings, scheduled to transmit via RRC protocol at 16 ms after cell configuration, and then repeats every 80 ms (configurable through the
LteEnbRrc::SystemInformationPeriodicityattribute). UE must be camped to a cell in order to be able to receive its SIB2.
reception of system information is fundamental for the UE to advance in its lifecycle, fr fr. MIB enables the UE to increase the initial DL bandwidth of 6 RBs to the actual operating bandwidth of the network. SIB1 provides information necessary for cell selection evaluation (explained in the next section, keep scrolling ๐). and finally SIB2 is required before the UE is allowed to switch to CONNECTED state.
๐ธ Cell Selection Evaluation ๐ธ
UE RRC reviews the measurement report produced in Cell Search and the cell access information provided by SIB1. once both pieces of info are available for a specific cell, the UE triggers the evaluation process. the purpose of this process is to determine whether the cell is a suitable cell to camp to. vibe check, basically.
the evaluation process is a slightly simplified version of Section 5.2.3.2 of [TS36304]. it consists of the following criteria:
- Rx level criterion; and
- closed subscriber group (CSG) criterion.
the first criterion, Rx level, is based on the cell's measured RSRP Q_{rxlevmeas}, which has to be higher than a required minimum Q_{rxlevmin} in order to pass the criterion:
Q_{rxlevmeas} - Q_{rxlevmin} > 0
where Q_{rxlevmin} is determined by each eNodeB and is obtainable by the UE from SIB1.
the last criterion, CSG, is a combination of a true-or-false parameter called CSG indication and a simple number called CSG identity. the basic rule is that the UE shall not camp to an eNodeB with a different CSG identity. but this rule is only enforced when CSG indication is valued as true ๐ more details are provided in Section sec-network-attachment of the User Documentation.
when the cell passes all the above criteria, the cell is deemed as suitable. then UE camps to it (IDLE_CAMPED_NORMALLY state). slay.
after this, the upper layer may request the UE to enter CONNECTED mode. please refer to section RRC connection establishment for details on this.
on the other hand, when the cell does not pass the CSG criterion, then the cell is labeled as acceptable (Section 10.1.1.1 [TS36300]). in this case, the RRC entity will tell the PHY entity to synchronize to the second strongest cell and repeat the initial cell selection procedure using that cell. as long as no suitable cell is found, the UE will repeat these steps while avoiding cells that have been identified as acceptable. it's giving persistence honestly ๐ช
๐ Radio Admission Control ๐
Radio Admission Control is supported by having the eNB RRC reply to an RRC CONNECTION REQUEST message sent by the UE with either an RRC CONNECTION SETUP message or an RRC CONNECTION REJECT message, depending on whether the new UE is to be admitted or not. in the current implementation, the behavior is determined by the boolean attribute ns3::LteEnbRrc::AdmitRrcConnectionRequest. there is currently no Radio Admission Control algorithm that dynamically decides whether a new connection shall be admitted or not. that's just how it is bestie ๐คท
๐ฆ Radio Bearer Configuration ๐ฆ
some implementation choices have been made in the RRC regarding the setup of radio bearers:
- three Logical Channel Groups (out of four available) are configured for uplink buffer status report purposes, according to the following policy:
- LCG 0 is for signaling radio bearers
- LCG 1 is for GBR data radio bearers
- LCG 2 is for Non-GBR data radio bearers
๐ Radio Link Failure ๐
in real LTE networks, Radio link failure (RLF) can happen due to several reasons. it can be triggered if a UE is unable to decode PDCCH due to poor signal quality, upon maximum RLC retransmissions, RACH problems and other reasons. 3GPP only specifies guidelines to detect RLF at the UE side, in [TS36331] and [TS36133]. on the other hand, the eNB implementation is expected to be vendor specific. to implement the RLF functionality in ns-3, we have assumed the following simplifications:
- The RLF detection procedure at eNodeB is not implemented. instead, a direct function call by using the SAP between UE and eNB RRC (for both ideal and real RRC) is used to notify the eNB about the RLF.
- No RRC connection re-establishment procedure is implemented, thus the UE directly goes to the
IDLEstate upon RLF. this is in fact as per the standard [TS36331] sec 5.3.11.3, since, at this stage the LTE module does not support the Access Stratum (AS) security.
the above mentioned RLF specifications can be divided into the following two categories:
- RLF detection
- Actions upon RLF detection
in the following, we will explain the RLF implementation in context of these two categories.
๐ฅ RLF detection implementation ๐ฅ
the RLF detection at the UE is implemented as per [TS36133], i.e., by monitoring the radio link quality based on the reference signals (which in the simulation is equivalent to the PDCCH) in the downlink. thus, it is independent of the method used for the downlink CQI computation, i.e., Ctrl method and Mixed method. moreover, when using FFR, especially for hard-FFR, and CQIs based on Mixed method, UEs might experience relatively good performance and RLF simultaneously ๐ญ this is due to the fact that the interference in PDSCH is affected by the actual data transmissions on the specific RBs and the power control. therefore, UEs might experience good SINR in PDSCH, while bad SINR in the PDCCH channel. for more details about these methods please refer to CQI feedback. also, it does not matter if the DL control error model is disabled โ a UE can still detect the RLF since the SINR based on the control channel is reported to the LteUePhy class, using a callback hooked in LteHelper while installing a UE device.
RLF detection kicks in the second the RRC connection is established between UE and eNodeB โ like, the UE is sitting in โCONNECTED_NORMALLYโ state โ and that's the moment the RLF parameters get configured (peep LteUePhy::DoConfigureRadioLinkFailureDetection). โจ
In real networks, these parameters are transmitted by the eNB using IE UE-TimersAndConstants or RLF-TimersAndConstants. But bestie, for the sake of simplification, in the simulator they're presented as the attributes of the LteUePhy and LteUeRrc classes. ๐
And now, carrier aggregation tea: when a UE is configured with multiple component carriers, the RLF detection is only performed by the primary component carrier, i.e. component carrier id 0 (see LteUePhy::DoNotifyConnectionSuccessful). ๐ซถ
In the LteUePhy class, CQI calculation is triggered for every downlink subframe received, and the average SINR value is measured across all resource blocks. For the RLF detection, these SINR values are averaged over a downlink frame, and if the result is less than a defined threshold Qout (default: -5dB), the frame cannot be decoded (see LteUePhy::RadioLinkFailureDetection). ๐ญ
The Qout threshold corresponds to 10% block error rate (BLER) of a hypothetical PDCCH transmission taking into account the PCFICH errors [R4-081920] (also refer to Control Channels PHY Error Model).
Once the UE is unable to decode 20 consecutive frames, i.e. the Qout evaluation period (200ms) is reached, an out-of-sync indication is sent to the UE RRC layer (see LteUeRrc::DoNotifyOutOfSync). Else, the counter for the unsuccessfully decoded frames is reset to zero. ๐
At the LteUeRrc, when the number of consecutive out-of-sync indications matches with the value of N310 parameter, the T310 timer is started and LteUePhy is notified to start measuring for in-sync indications (see LteUePhy::DoStartInSnycDetection). We note that the UE RRC state is not changed till the expiration of the T310 timer. โณ
If the resultant SINR values averaged over a downlink frame is greater than a defined threshold Qin (default: -3.8dB), the frame is considered to be successfully decoded. Qin corresponds to 2% BLER [R4-081920] of a hypothetical PDCCH transmission taking into account the PCFICH errors.
Once the UE is able to decode 10 consecutive frames, an in-sync indication is sent to the UE RRC layer (see LteUeRrc::DoNotifyInSync). Else, the counter for the successfully decoded frames is reset to zero.
If prior to the T310 timer expiry, the number of consecutive in-sync indications matches with N311 parameter of LteUeRRC, the UE is considered back in-sync. At this stage, the related parameters are reset to initiate the radio link failure detection from the beginning (see LteUePhy::DoConfigureRadioLinkFailureDetection). ๐ฆ
On the other hand โ and this is the main character plot twist โ if the T310 timer expires, the UE considers that a RLF has occurred (see LteUeRrc::RadioLinkFailureDetected). ๐
โจ Actions upon RLF โจ
Once the T310 timer is expired, a UE is considered to be in RLF; upon which the UE RRC:
- Sends a request to the eNB RRC to remove the UE context
- Moves to โCONNECTED_PHY_PROBLEMโ state
- Notifies the UE NAS layer about the release of RRC connection.
Then, after getting the notification from the UE RRC, the NAS does the following:
- Delete all the TFTs
- Reset the bearer counter
- Restore the bearer list, which is used to activate the bearers for the next RRC connection. This restoration of the bearers is achieved by maintaining an additional list, i.e.,
m_bearersToBeActivatedListForReconnectioninEpcUeNasclass - Switch the NAS state to
OFFby callingEpcUeNas::Disconnect - Tells the UE RRC to disconnect
The UE RRC, upon receiving the call to disconnect from the EpcUeNas class, performs the action as specified by [TS36331] 5.3.11.3, and finally leaves the connected state, i.e., its RRC state is changed from โCONNECTED_PHY_PROBLEMโ to โIDLE_STARTโ to perform cell selection as shown in figures UE RRC State Machine and UE procedures after radio link failure. ๐
At this stage, the LTE module does not support the paging functionality, therefore, to allow a UE to read SIB2 message after camping on a suitable cell after RLF, a workaround is used in LteUeRrc::EvaluateCellForSelection method. As per this workaround, the UE RRC invokes the call to LteUeRrc::DoConnect method, which enables the UE to switch its state from โIDLE_CAMPED_NORMALLYโ to โIDLE_WAIT_SIB2โ, thus, allowing it to perform the random access. ๐
[image] UE procedures after radio link failure.
The eNB RRC, after receiving the notification from the UE RRC, starts the procedure of UE context deletion, which also involves the deletion of the UE context removal from EPC and the eNB stack. We note that the UE context at the MME is not removed since, bearers are only added at the start of a simulation in MME, and cannot be added again unless scheduled for addition during a simulation. ๐
[image] UE context removal from EPC.
[image] UE context removal from eNB stack.
๐ UE RRC Measurements Model ๐
๐ธ UE RRC measurements support ๐ธ
The UE RRC entity provides support for UE measurements; in particular, it implements the procedures described in Section 5.5 of [TS36331], with the following simplifying assumptions:
- only E-UTRA intra-frequency measurements are supported, which implies:
- only one measurement object is used during the simulation;
- measurement gaps are not needed to perform the measurements;
- Event B1 and B2 are not implemented;
- only
reportStrongestCellspurpose is supported, whilereportCGIandreportStrongestCellsForSONpurposes are not supported; s-Measureis not supported;- carrier aggregation is now supported in the LTE module โ Event A6 is not implemented;
- speed dependent scaling of time-to-trigger (Section
5.5.6.2of[TS36331]) is not supported.
๐ฆ Overall design ๐ฆ
The model is based on the concept of UE measurements consumer, which is an entity that may request an eNodeB RRC entity to provide UE measurement reports. Consumers are, for example, Handover algorithm, which compute handover decision based on UE measurement reports. Test cases and user's programs may also become consumers. Figure Relationship between UE measurements and its consumers depicts the relationship between these entities. โจ
[image] Relationship between UE measurements and its consumers.
The whole UE measurements function at the RRC level is divided into 4 major parts:
- Measurement configuration (handled by
LteUeRrc::ApplyMeasConfig) - Performing measurements (handled by
LteUeRrc::DoReportUeMeasurements) - Measurement report triggering (handled by
LteUeRrc::MeasurementReportTriggering) - Measurement reporting (handled by
LteUeRrc::SendMeasurementReport)
The following sections will describe each of the parts above. ๐
๐ Measurement configuration ๐
An eNodeB RRC entity configures UE measurements by sending the configuration parameters to the UE RRC entity. This set of parameters are defined within the MeasConfig Information Element (IE) of the RRC Connection Reconfiguration message (RRC connection reconfiguration).
The eNodeB RRC entity implements the configuration parameters and procedures described in Section 5.5.2 of [TS36331], with the following simplifying assumption:
- configuration (i.e. addition, modification, and removal) can only be done before the simulation begins;
- all UEs attached to the eNodeB will be configured the same way, i.e. there is no support for configuring specific measurement for specific UE; and
- it is assumed that there is a one-to-one mapping between the PCI and the E-UTRAN Global Cell Identifier (EGCI). This is consistent with the PCI modeling assumptions described in UE PHY Measurements Model.
The eNodeB RRC instance here acts as an intermediary between the consumers and the attached UEs. At the beginning of simulation, each consumer provides the eNodeB RRC instance with the UE measurements configuration that it requires. After that, the eNodeB RRC distributes the configuration to attached UEs. ๐ซถ
Users may customize the measurement configuration using several methods. Please refer to Section sec-configure-ue-measurements of the User Documentation for the description of these methods.
โญ Performing measurements โญ
UE RRC receives both RSRP and RSRQ measurements on periodical basis from UE PHY, as described in UE PHY Measurements Model. Layer 3 filtering will be applied to these received measurements. The implementation of the filtering follows Section 5.5.3.2 of [TS36331]:
F_n = (1 - a) \times F_{n-1} + a \times M_n
where:
M_nis the latest received measurement result from the physical layer;F_nis the updated filtered measurement result;F_{n-1}is the old filtered measurement result, whereF_0 = M_1(i.e. the first measurement is not filtered); anda = (\frac{1}{2})^{\frac{k}{4}}, wherekis the configurablefilterCoefficentprovided by theQuantityConfig;
k = 4 is the default value, but can be configured by setting the RsrpFilterCoefficient and RsrqFilterCoefficient attributes in LteEnbRrc.
Therefore k = 0 will disable Layer 3 filtering. On the other hand, past measurements can be granted more influence on the filtering results by using larger value of k. ๐
๐ Measurement reporting triggering ๐
In this part, UE RRC will go through the list of active measurement configuration and check whether the triggering condition is fulfilled in accordance with Section 5.5.4 of [TS36331]. When at least one triggering condition from all the active measurement configuration is fulfilled, the measurement reporting procedure (described in the next subsection) will be initiated. ๐ฅ
3GPP defines two kinds of triggerType: periodical and event-based. At the moment, only event-based criterion is supported. There are various events that can be selected, which are briefly described in the table below:
๐ฏ List of supported event-based triggering criteria
okay bestie, here's the whole roster of event-based triggers this model actually gets behind โ no cap, this is the full list:
- Event A1 โ Serving cell becomes better than threshold
- Event A2 โ Serving cell becomes worse than threshold
- Event A3 โ Neighbour becomes offset dB better than serving cell
- Event A4 โ Neighbour becomes better than threshold
- Event A5 โ Serving becomes worse than threshold1 AND neighbour becomes better than threshold2
Two main conditions to be checked in an event-based trigger are the entering condition and the leaving condition. More details on these two can be found in Section 5.5.4 of [TS36331]. iykyk ๐
An event-based trigger can be further configured by introducing hysteresis and time-to-trigger. Hysteresis (Hys) defines the distance between the entering and leaving conditions in dB. Similarly, time-to-trigger introduces delay to both entering and leaving conditions, but as a unit of time. โฑ๏ธ
The periodical type of reporting trigger is not supported, but its behavior can be easily obtained by using an event-based trigger. This can be done by configuring the measurement in such a way that the entering condition is always fulfilled, for example, by setting the threshold of Event A1 to zero (the minimum level). As a result, the measurement reports will always be triggered at every certain interval, as determined by the reportInterval field within LteRrcSap::ReportConfigEutra, therefore producing the same behaviour as periodical reporting. literally free real estate ๐ธ
As a limitation with respect to 3GPP specifications, the current model does not support any cell-specific configuration. These configuration parameters are defined in measurement object. As a consequence, incorporating a list of black cells into the triggering process is not supported. Moreover, cell-specific offset (i.e., O_{cn} and O_{cp} in Event A3, A4, and A5) are not supported as well. The value equal to zero is always assumed in place of them. ๐
๐จ Measurement reporting
This part handles the submission of measurement report from the UE RRC entity to the serving eNodeB entity via RRC protocol. Several simplifying assumptions have been adopted, and bestie, they are what they are:
reportAmountis not applicable (i.e. always assumed to be infinite); ๐- in measurement reports, the
reportQuantityis always assumed to be BOTH, i.e., both RSRP and RSRQ are always reported, regardless of thetriggerQuantity. ๐ซถ
๐ถ Handover
The RRC model supports UE mobility in CONNECTED mode by invoking the X2-based handover procedure. The model is intra-EUTRAN and intra-frequency, as based on Section 10.1.2.1 of [TS36300].
This section focuses on the process of triggering a handover. The handover execution procedure itself is covered in Section X2.
There are two ways to trigger the handover procedure:
- explicitly (or manually) triggered by the simulation program by scheduling an execution of the method
LteEnbRrc::SendHandoverRequest; or - automatically triggered by the eNodeB RRC entity based on UE measurements and according to the selected handover algorithm. ๐ค
Section sec-x2-based-handover of the User Documentation provides some examples on using both explicit and automatic handover triggers in simulation. The next subsection will take a closer look on the automatic method, by describing the design aspects of the handover algorithm interface and the available handover algorithms. โจ
๐ง Handover algorithm
Handover in 3GPP LTE has the following properties, and honestly, the way this is structured? iconic:
- UE-assisted
- The UE provides input to the network in the form of measurement reports. This is handled by the UE RRC Measurements Model.
- Network-controlled
- The network (i.e. the source eNodeB and the target eNodeB) decides when to trigger the handover and oversees its execution.
The handover algorithm operates at the source eNodeB and is responsible in making handover decisions in an โautomaticโ manner. It interacts with an eNodeB RRC instance via the Handover Management SAP interface. These relationships are illustrated in Figure Relationship between UE measurements and its consumers from the previous section.
The handover algorithm interface consists of the following methods:
AddUeMeasReportConfigForHandover- (Handover Algorithm -> eNodeB RRC) Used by the handover algorithm to request measurement reports from the eNodeB RRC entity, by passing the desired reporting configuration. The configuration will be applied to all future attached UEs.
ReportUeMeas- (eNodeB RRC -> Handover Algorithm) Based on the UE measurements configured earlier in
AddUeMeasReportConfigForHandover, UE may submit measurement reports to the eNodeB. The eNodeB RRC entity uses theReportUeMeasinterface to forward these measurement reports to the handover algorithm.
- (eNodeB RRC -> Handover Algorithm) Based on the UE measurements configured earlier in
TriggerHandover- (Handover Algorithm -> eNodeB RRC) After examining the measurement reports (but not necessarily), the handover algorithm may declare a handover. This method is used to notify the eNodeB RRC entity about this decision, which will then proceed to commence the handover procedure. ๐ฅ
One note for the AddUeMeasReportConfigForHandover. The method will return the measId (measurement identity) of the newly created measurement configuration. Typically a handover algorithm would store this unique number. It may be useful in the ReportUeMeas method, for example when more than one configuration has been requested and the handover algorithm needs to differentiate incoming reports based on the configuration that triggered them. ๐
A handover algorithm is implemented by writing a subclass of the LteHandoverAlgorithm abstract superclass and implementing each of the above mentioned SAP interface methods. Users may develop their own handover algorithm this way, and then use it in any simulation by following the steps outlined in Section sec-x2-based-handover of the User Documentation.
Alternatively, users may choose to use one of the 3 built-in handover algorithms provided by the LTE module: no-op, A2-A4-RSRQ, and strongest cell handover algorithm. They are ready to be used in simulations or can be taken as an example of implementing a handover algorithm. Each of these built-in algorithms is covered in each of the following subsections. ๐
๐ด No-op handover algorithm
The no-op handover algorithm (NoOpHandoverAlgorithm class) is the simplest possible implementation of handover algorithm. It basically does nothing, i.e., does not call any of the Handover Management SAP interface methods. Users may choose this handover algorithm if they wish to disable automatic handover trigger in their simulation. main character energy of doing absolutely nothing and being valid for it ๐
โจ A2-A4-RSRQ handover algorithm
The A2-A4-RSRQ handover algorithm provides the functionality of the default handover algorithm originally included in LENA M6 (ns-3.18), ported to the Handover Management SAP interface as the A2A4RsrqHandoverAlgorithm class.
As the name implies, the algorithm utilizes the Reference Signal Received Quality (RSRQ) measurements acquired from Event A2 and Event A4. Thus, the algorithm will add 2 measurement configuration to the corresponding eNodeB RRC instance. Their intended use are described as follows:
- Event A2 (serving cellโs RSRQ becomes worse than threshold) is leveraged to indicate that the UE is experiencing poor signal quality and may benefit from a handover.
- Event A4 (neighbour cellโs RSRQ becomes better than threshold) is used to detect neighbouring cells and acquire their corresponding RSRQ from every attached UE, which are then stored internally by the algorithm. By default, the algorithm configures Event A4 with a very low threshold, so that the trigger criteria are always true. ๐ฏ
Figure A2-A4-RSRQ handover algorithm below summarizes this procedure.
[image] A2-A4-RSRQ handover algorithm.
Two attributes can be set to tune the algorithm behaviour:
ServingCellThreshold- The threshold for Event A2, i.e. a UE must have an RSRQ lower than this threshold to be considered for a handover.
NeighbourCellOffset- The offset that aims to ensure that the UE would receive better signal quality after the handover. A neighbouring cell is considered as a target cell for the handover only if its RSRQ is higher than the serving cellโs RSRQ by the amount of this offset.
The value of both attributes are expressed as RSRQ range (Section 9.1.7 of [TS36133]), which is an integer between 0 and 34, with 0 as the lowest RSRQ. ๐
๐ช Strongest cell handover algorithm
The strongest cell handover algorithm, or also sometimes known as the traditional power budget (PBGT) algorithm, is developed using [Dimou2009] as reference. The idea is to provide each UE with the best possible Reference Signal Received Power (RSRP). This is done by performing a handover as soon as a better cell (i.e. with stronger RSRP) is detected. ๐ฆ
Event A3 (aka the neighbour cell's RSRP becomes better than serving cell's RSRP) is the moment we pick to make this whole concept actually happen. And boom โ the A3RsrpHandoverAlgorithm class is literally the baby that came out of that idea. ๐ Handover gets triggered for the UE to the best cell in the measurement report. Slay.
Ngl tho, a simulation running this algorithm is usually more vulnerable to ping-pong handover (that's consecutive handover to the previous source eNodeB within a short period of time, messy behaviour fr), especially when the Fading Model is enabled. The classic glow-up fix is to just introduce a certain delay to the handover. And the algorithm does exactly that by including hysteresis and time-to-trigger parameters (Section 6.3.5 of [TS36331]) to the UE measurements configuration. โจ
Hysteresis (a.k.a. handover margin) delays the handover in regard of RSRP. The value is expressed in dB, ranges between 0 to 15 dB, and has a 0.5 dB accuracy โ so like, an input value of 2.7 dB is rounded to 2.5 dB. It's giving "close enough bestie." ๐
Time-to-trigger on the other hand delays the handover in regard of time. 3GPP defines 16 valid values for it (all in milliseconds): 0, 40, 64, 80, 100, 128, 160, 256, 320, 480, 512, 640, 1024, 1280, 2560, and 5120. Periodt. ๐
The difference between hysteresis and time-to-trigger is illustrated in Figure Effect of hysteresis and time-to-trigger in strongest cell handover algorithm below, which is taken from the lena-x2-handover-measures example. It depicts the perceived RSRP of serving cell and a neighbouring cell by a UE which moves pass the border of the cells. ๐ฆ
[image] Effect of hysteresis and time-to-trigger in strongest cell handover algorithm.
By default, the algorithm uses a hysteresis of 3.0 dB and time-to-trigger of 256 ms. These values can be tuned through the Hysteresis and TimeToTrigger attributes of the A3RsrpHandoverAlgorithm class. ๐ฅ
๐ Neighbour Relation
The LTE module supports a simplified Automatic Neighbour Relation (ANR) function. This is handled by the LteAnr class, which interacts with an eNodeB RRC instance through the ANR SAP interface.
๐ Neighbour Relation Table
The ANR holds a Neighbour Relation Table (NRT), similar to the description in Section 22.3.2a of [TS36300]. Each entry in the table is called a Neighbour Relation (NR) and represents a detected neighbouring cell, which contains the following boolean fields:
No Removeโ Indicates that the NR shall not be removed from the NRT. This istrueby default for user-provided NR andfalseotherwise.No X2โ Indicates that the NR shall not use an X2 interface in order to initiate procedures towards the eNodeB parenting the target cell. This isfalseby default for user-provided NR, andtrueotherwise.No HOโ Indicates that the NR shall not be used by the eNodeB for handover reasons. This istruein most cases, except when the NR is both user-provided and network-detected.
Each NR entry may have at least one of the following properties:
- User-provided โ This type of NR is created as instructed by the simulation user. For example, a NR is created automatically upon a user-initiated establishment of X2 connection between 2 eNodeBs, e.g. as described in Section
sec-x2-based-handover. Another way to create a user-provided NR is to call theAddNeighbourRelationfunction explicitly. ๐ - Network-detected โ This type of NR is automatically created during the simulation as a result of the discovery of a nearby cell.
In order to automatically create network-detected NR, ANR utilizes UE measurements. In other words, ANR is a consumer of UE measurements, as depicted in Figure Relationship between UE measurements and its consumers. RSRQ and Event A4 (neighbour becomes better than threshold) are used for the reporting configuration. The default Event A4 threshold is set to the lowest possible, i.e., maximum detection capability, but can be changed by setting the Threshold attribute of LteAnr class. Note that the A2-A4-RSRQ handover algorithm also utilizes a similar reporting configuration. Despite the similarity, when both ANR and this handover algorithm are active in the eNodeB, they use separate reporting configuration. No sharing besties, they each get their own. ๐
Also note that automatic setup of X2 interface is not supported. This is the reason why the No X2 and No HO fields are true in a network-detected but not user-detected NR.
๐ธ Role of ANR in Simulation
The ANR SAP interface provides the means of communication between ANR and eNodeB RRC. Some interface functions are used by eNodeB RRC to interact with the NRT, as shown below:
AddNeighbourRelationโ (eNodeB RRC -> ANR) Add a new user-provided NR entry into the NRT.GetNoRemoveโ (eNodeB RRC -> ANR) Get the value ofNo Removefield of an NR entry of the given cell ID.GetNoHoโ (eNodeB RRC -> ANR) Get the value ofNo HOfield of an NR entry of the given cell ID.GetNoX2โ (eNodeB RRC -> ANR) Get the value ofNo X2field of an NR entry of the given cell ID.
Other interface functions exist to support the role of ANR as a UE measurements consumer, as listed below:
AddUeMeasReportConfigForAnrโ (ANR -> eNodeB RRC) Used by the ANR to request measurement reports from the eNodeB RRC entity, by passing the desired reporting configuration. The configuration will be applied to all future attached UEs.ReportUeMeasโ (eNodeB RRC -> ANR) Based on the UE measurements configured earlier inAddUeMeasReportConfigForAnr, UE may submit measurement reports to the eNodeB. The eNodeB RRC entity uses theReportUeMeasinterface to forward these measurement reports to the ANR.
Please refer to the corresponding API documentation for LteAnrSap class for more details on the usage and the required parameters. ๐
The ANR is utilized by the eNodeB RRC instance as a data structure to keep track of the situation of nearby neighbouring cells. The ANR also helps the eNodeB RRC instance to determine whether it is possible to execute a handover procedure to a neighbouring cell. This is realized by the fact that eNodeB RRC will only allow a handover procedure to happen if the NR entry of the target cell has both No HO and No X2 fields set to false. Gatekeeping the handover, iconic behaviour honestly. ๐ชโจ
ANR is enabled by default in every eNodeB instance in the simulation. It can be disabled by setting the AnrEnabled attribute in LteHelper class to false.
๐ฆ RRC sequence diagrams
In this section we provide some sequence diagrams that explain the most important RRC procedures being modeled.
โจ RRC connection establishment
Figure Sequence diagram of the RRC Connection Establishment procedure shows how the RRC Connection Establishment procedure is modeled, highlighting the role of the RRC layer at both the UE and the eNB, as well as the interaction with the other layers.
[image] Sequence diagram of the RRC Connection Establishment procedure.
There are several timeouts related to this procedure, which are listed in the following Table Timers in RRC connection establishment procedure. If any of these timers expired, the RRC connection establishment procedure is terminated in failure ๐ญ. At the UE side, if T300 timer has expired a consecutive connEstFailCount times on the same cell it performs the cell selection again [TS36331]. Else, the upper layer (UE NAS) will immediately attempt to retry the procedure.
โฐ Timers in RRC connection establishment procedure
- Connection request timeout
- Location:
eNodeB RRC - Timer starts: New UE context added
- Timer stops: Receive RRC CONNECTION REQUEST
- Default duration:
15 ms (Max) - When timer expired: Remove UE context
- Location:
- Connection timeout (T300 timer)
- Location:
UE RRC - Timer starts: Send RRC CONNECTION REQUEST
- Timer stops: Receive RRC CONNECTION SETUP or REJECT
- Default duration:
100 ms - When timer expired: Reset UE MAC
- Location:
- Connection setup timeout
- Location:
eNodeB RRC - Timer starts: Send RRC CONNECTION SETUP
- Timer stops: Receive RRC CONNECTION SETUP COMPLETE
- Default duration:
100 ms - When timer expired: Remove UE context
- Location:
- Connection rejected timeout
- Location:
eNodeB RRC - Timer starts: Send RRC CONNECTION REJECT
- Timer stops: Never
- Default duration:
30 ms - When timer expired: Remove UE context
- Location:
Note bestie, this one's important: the value of the connection request timeout timer at the eNB RRC should not be higher than theT300timer at the UE RRC. Why? So we can be sure the UE context is already removed at the eNB by the time the UE does its cell selection thing after hitting theconnEstFailCountcount. ๐ And also โ at the time of writing this document the Cell Selection Evaluation does not include theQoffset_{temp}parameter, so yeah, it's simply not applied when you're selecting the same cell again. ๐
๐ Counters in RRC connection establishment procedure
There's literally one counter here, so let's give it the main character treatment:
- Name:
ConnEstFailCount- Location: eNB MAC
- Msg:
RachConfigCommoninSIB2,HO REQandHO Ack - Monitored by: UE RRC
- Default value:
1 - Limit not reached: Increment the local counter. Invalided the prev
SIB2msg, and try random access with the same cell. - Limit reached: Reset the local counter and perform cell selection.
๐ธ RRC connection reconfiguration
The figure Sequence diagram of the RRC Connection Reconfiguration procedure shows how the RRC Connection Reconfiguration procedure is modeled for the case where MobilityControlInfo is not provided โ aka, no handover happening, we're just chilling. โจ
[image] Sequence diagram of the RRC Connection Reconfiguration procedure.
And the figure Sequence diagram of the RRC Connection Reconfiguration procedure for the handover case shows how it's modeled when MobilityControlInfo is provided โ i.e., handover is about to go down. ๐ฆ
[image] Sequence diagram of the RRC Connection Reconfiguration procedure
for the handover case.
As specified in [TS36331], after receiving the handover message, the UE attempts to access the target cell at the first available RACH occasion according to Random Access resource selection defined in [TS36321]_, i.e. the handover is asynchronous. Consequently, when allocating a dedicated preamble for the random access in the target cell, E-UTRA shall ensure it is available from the first RACH occasion the UE may use. Upon successful completion of the handover, the UE sends a message used to confirm the handover. Note that the random access procedure in this case is non-contention based, hence in a real LTE system it differs slightly from the one used in RRC connection established. Also note that the RA Preamble ID is signaled via the Handover Command included in the X2 Handover Request ACK message sent from the target eNB to the source eNB; in particular, the preamble is included in the RACH-ConfigDedicated IE which is part of MobilityControlInfo. ๐ซถ
๐ RRC protocol models
As previously anticipated, we provide two different models for the transmission and reception of RRC messages: Ideal and Real. Each of them gets its own subsection below, because they're both iconic in their own way. ๐
โจ Ideal RRC protocol model
According to this model, implemented in the classes LteUeRrcProtocolIdeal and LteEnbRrcProtocolIdeal, all RRC messages and information elements are transmitted between the eNB and the UE in an ideal fashion โ no radio resources consumed, no errors, just vibes. ๐ From an implementation point of view, this is achieved by passing the RRC data structure directly between the UE and eNB RRC entities, without involving the lower layers (PDCP, RLC, MAC, scheduler). No cap.
๐ฅ Real RRC protocol model
This model is implemented in the classes LteUeRrcProtocolReal and LteEnbRrcProtocolReal and aims at modeling the transmission of RRC PDUs as commonly performed in real LTE systems. In particular:
- for every RRC message being sent, a real RRC PDU is created following the ASN.1 encoding of RRC PDUs and information elements (IEs) specified in
[TS36331]. Some simplification are made with respect to the IEs included in the PDU, i.e., only those IEs that are useful for simulation purposes are included. For a detailed list, please see the IEs defined inlte-rrc-sap.hand compare with[TS36331]. - the encoded RRC PDUs are sent on Signaling Radio Bearers and are subject to the same transmission modeling used for data communications, thus including scheduling, radio resource consumption, channel errors, delays, retransmissions, etc. ๐ญ the whole nine yards.
๐ง Signaling Radio Bearer model
Okay so now we describe the Signaling Radio Bearer model that is used for the Real RRC protocol model.
- SRB0 messages (over CCCH):
RrcConnectionRequest: in real LTE systems, this is an RLC TM SDU sent over resources specified in the UL Grant in the RAR (not in UL DCIs); the reason is thatC-RNTIis not known yet at this stage. In the simulator, this is modeled as a real RLC TM RLC PDU whose UL resources are allocated by the scheduler upon call toSCHED_DL_RACH_INFO_REQ.RrcConnectionSetup: in the simulator this is implemented as in real LTE systems, i.e., with an RLC TM SDU sent over resources indicated by a regular UL DCI, allocated withSCHED_DL_RLC_BUFFER_REQtriggered by the RLC TM instance that is mapped toLCID 0(the CCCH).
- SRB1 messages (over DCCH):
- All the SRB1 messages modeled in the simulator (e.g.,
RrcConnectionCompleted) are implemented as in real LTE systems, i.e., with a real RLC SDU sent over RLC AM using DL resources allocated via Buffer Status Reports. See the RLC model documentation for details.
- All the SRB1 messages modeled in the simulator (e.g.,
- SRB2 messages (over DCCH):
- According to
[TS36331], "SRB1 is for RRC messages (which may include a piggybacked NAS message) as well as for NAS messages prior to the establishment of SRB2, all using DCCH logical channel", whereas "SRB2 is for NAS messages, using DCCH logical channel" and "SRB2 has a lower-priority than SRB1 and is always configured by E-UTRAN after security activation". Modeling security-related aspects is not a requirement of the LTE simulation model, hence we always use SRB1 and never activate SRB2. Periodt. ๐
- According to
๐ ASN.1 encoding of RRC IE's
The messages defined in RRC SAP, common to all Ue/Enb SAP Users/Providers, are transported in a transparent container to/from a Ue/Enb. The encoding format for the different Information Elements are specified in [TS36331], using ASN.1 rules in the unaligned variant. The implementation in Ns3/Lte has been divided in the following classes:
Asn1Header: Contains the encoding / decoding of basic ASN typesRrcAsn1Header: InheritsAsn1Headerand contains the encoding / decoding of common IE's defined in[TS36331]- Rrc specific messages/IEs classes : A class for each of the messages defined in RRC SAP header
๐ Asn1Header class - Implementation of base ASN.1 types
This class implements the methods to Serialize / Deserialize the ASN.1 types being used in [TS36331], according to the packed encoding rules in ITU-T X.691. The types considered are:
Boolean: a boolean value uses a single bit (1=true,0=false).Integer: a constrained integer (with min and max values defined) uses the minimum amount of bits to encode its range (max-min+1).Bitstring: a bitstring will be copied bit by bit to the serialization buffer.Octetstring: not being currently used.Sequence: the sequence generates a preamble indicating the presence of optional and default fields. It also adds a bit indicating the presence of extension marker.Sequence...Of: thesequence...oftype encodes the number of elements of the sequence as an integer (the subsequent elements will need to be encoded afterwards).Choice: indicates which element among the ones in the choice set is being encoded.Enumeration: is serialized as an integer indicating which value is used, among the ones in the enumeration, with the number of elements in the enumeration as upper bound.Null: the null value is not encoded, although its serialization function is defined to provide a clearer map between specification and implementation.
The class inherits from ns-3 Header, but Deserialize() function is declared pure virtual, thus inherited classes having to implement it. The reason is that deserialization will retrieve the elements in RRC messages, each of them containing different information elements. Slay. ๐
...and also, quick PSA bestie: the byte length of a specific type/message can vary, depending on whether optional fields are hanging around and because of the optimized encoding. So the serialized bits get run through the PreSerialize() function first, and the result gets parked in the m_serializationResult Buffer. Since the methods for reading/writing in an ns3 buffer are defined on a byte basis, those serialization bits sit in the m_serializationPendingBits attribute until all 8 bits are set and can finally be written to the buffer iterator. And then, when you invoke Serialize(), the contents of the m_serializationResult attribute get copied over to the Buffer::Iterator parameter. Chef's kiss. โจ
๐ RrcAsn1Header : Common IEs ๐
Since some Information Elements get reused across several RRC messages, this class implements the following common IEs:
SrbToAddModListDrbToAddModListLogicalChannelConfigRadioResourceConfigDedicatedPhysicalConfigDedicatedSystemInformationBlockType1SystemInformationBlockType2RadioResourceConfigCommonSIB
๐ Rrc specific messages/IEs classes ๐
These RRC SAP have been implemented, bestie โ the whole lineup:
RrcConnectionRequestRrcConnectionSetupRrcConnectionSetupCompletedRrcConnectionReconfigurationRrcConnectionReconfigurationCompletedHandoverPreparationInfoRrcConnectionReestablishmentRequestRrcConnectionReestablishmentRrcConnectionReestablishmentCompleteRrcConnectionReestablishmentRejectRrcConnectionRelease
๐ธ NAS ๐ธ
Okay so the LTE-EPC model is obsessed with the NAS Active state โ that's the one that corresponds to EMM Registered, ECM connected, and RRC connected. And because that's the whole vibe, here are the simplifications they made:
- EMM and ECM are not modeled explicitly. Instead, the NAS entity at the UE interacts directly with the MME to perform actions that are equivalent (with gross simplifications, no cap) to taking the UE to the states EMM Connected and ECM Connected.
- The NAS also handles multiplexing uplink data packets coming from the upper layers into the appropriate EPS bearer, using the Traffic Flow Template classifier (
TftClassifier). - The NAS does not support PLMN and CSG selection.
- The NAS does not support any location update/paging procedure in idle mode.
Figure: Sequence diagram of the attach procedure โ shows how the simplified NAS model implements the attach procedure. And heads up: both the default and eventual dedicated EPS bearers are activated as part of this procedure. ๐ซถ
[image] Sequence diagram of the attach procedure.
โญ S1, S5 and S11 โญ
๐ฆ S1-U and S5 (user plane) ๐ฆ
The S1-U and S5 interfaces are modeled in a realistic way, by encapsulating data packets over GTP/UDP/IP โ exactly like real LTE-EPC systems do it. The corresponding protocol stack shows up in Figure LTE-EPC data plane protocol stack. And the way that figure works, there are two different layers of IP networking going on:
The first one is the end-to-end layer, which provides end-to-end connectivity to the users. This layer involves the UEs, the PGW and the remote host (including any eventual internet routers and hosts in between), but does not involve the eNB and the SGW. In this version of LTE, the EPC supports both IPv4 and IPv6 type users. The 3GPP unique 64 bit IPv6 prefix allocation process for each UE and PGW is followed here. Each EPC is assigned a unique 16 bit IPv4 and a 48 bit IPv6 network address from the pool of 7.0.0.0/8 and 7777:f00d::/32 respectively. In the end-to-end IP connection between UE and PGW, all addresses are configured using these prefixes. The PGW's address is used by all UEs as the gateway to reach the internet. ๐
The second layer of IP networking is the EPC local area network. This involves all eNB nodes, SGW nodes and PGW nodes. This network is implemented as a set of point-to-point links which connect each eNB with its corresponding SGW node, plus a point-to-point link which connects each SGW node with its corresponding PGW node. So basically each SGW has a set of point-to-point devices, each one providing connectivity to a different eNB. By default, a 10.x.y.z/30 subnet is assigned to each point-to-point link (and a /30 subnet is the smallest subnet that allows for two distinct host addresses, iykyk).
As specified by 3GPP, the end-to-end IP communications is tunneled over the local EPC IP network using GTP/UDP/IP. So here's how that tunneling is implemented in the EPC model โ explained by walking through the end-to-end flow of data packets. ๐
[image] Data flow in the downlink between the internet and the UE.
To begin with, let's do the downlink case, depicted in Figure Data flow in the downlink between the internet and the UE. Downlink IPv4/IPv6 packets are generated from a generic remote host, and addressed to one of the UE device. Internet routing takes care of forwarding the packet to the generic NetDevice of the PGW node which is connected to the internet (this is the Gi interface according to 3GPP terminology). The PGW has a VirtualNetDevice which is assigned the base IPv4 address of the EPC network; hence, static routing rules will cause the incoming packet from the internet to be routed through this VirtualNetDevice. In case of IPv6 address as destination, a manual route towards the VirtualNetDevice is inserted in the routing table, containing the 48 bit IPv6 prefix from which all the IPv6 addresses of the UEs and PGW are configured. Such device starts the GTP/UDP/IP tunneling procedure, by forwarding the packet to a dedicated application in the PGW node which is called EpcPgwApplication. This application does the following operations:
- it determines the SGW node to which it must route the traffic for this UE, by looking at the IP destination address (which is the address of the UE);
- it classifies the packet using Traffic Flow Templates (TFTs) to identify to which EPS Bearer it belongs. EPS bearers have a one-to-one mapping to S5 Bearers, so this operation returns the GTP-U Tunnel Endpoint Identifier (TEID) to which the packet belongs;
- it adds the corresponding GTP-U protocol header to the packet;
- finally, it sends the packet over a UDP socket to the S5 point-to-point NetDevice, addressed to the appropriate SGW.
As a consequence, the end-to-end IP packet with newly added IP, UDP and GTP headers is sent through one of the S5 links to the SGW, where it is received and delivered locally (as the destination address of the outermost IP header matches the SGW IP address). The local delivery process will forward the packet, via an UDP socket, to a dedicated application called EpcSgwApplication. This application then performs the following operations:
- it determines the eNB node to which the UE is attached, by looking at the S5 TEID;
- it maps the S5 TEID to get the S1 TEID. EPS bearers have a one-to-one mapping to S1-U Bearers, so this operation returns the S1 GTP-U Tunnel Endpoint Identifier (TEID) to which the packet belongs;
- it adds a new GTP-U protocol header to the packet;
- finally, it sends the packet over a UDP socket to the S1-U point-to-point NetDevice, addressed to the eNB to which the UE is attached.
Finally โ the end-to-end IP packet with newly added IP, UDP and GTP headers is sent through one of the S1 links to the eNB, where it is received and delivered locally (as the destination address of the outermost IP header matches the eNB IP address). The local delivery process will forward the packet, via an UDP socket, to a dedicated application called EpcEnbApplication. This application then performs the following operations:
- it removes the GTP header and retrieves the S1 TEID which is contained in it;
- leveraging on the one-to-one mapping between S1-U bearers and Radio Bearers (which is a 3GPP requirement), it determines the Bearer ID (BID) to which the packet belongs;
- it records the BID in a dedicated tag called
EpsBearerTag, which is added to the packet; - it forwards the packet to the
LteEnbNetDeviceof the eNB node via a raw packet socket.
Now, at this point the outermost header of the packet is the end-to-end IP header, since the IP/UDP/GTP headers of the S1 protocol stack have already been stripped. Upon reception of the packet from the EpcEnbApplication, the LteEnbNetDevice will retrieve the BID from the EpsBearerTag, and based on the BID will determine the Radio Bearer instance (and the corresponding PDCP and RLC protocol instances) which are then used to forward the packet to the UE over the LTE radio interface. And finally, the LteUeNetDevice of the UE will receive the packet, and deliver it locally to the IP protocol stack, which will in turn deliver it to the application of the UE โ which is the end point of the downlink communication. ๐
[image] Data flow in the uplink between the UE and the internet.
The uplink case is depicted in Figure Data flow in the uplink between the UE and the internet. Uplink IP packets are generated by a generic application inside the UE, and forwarded by the local TCP/IP stack to the LteUeNetDevice of the UE. The LteUeNetDevice then performs the following operations:
- it classifies the packet using TFTs and determines the Radio Bearer to which the packet belongs (and the corresponding RBID);
- it identifies the corresponding PDCP protocol instance, which is the entry point of the LTE Radio Protocol stack for this packet;
- it sends the packet to the eNB over the LTE Radio Protocol stack.
The eNB receives the packet via its LteEnbNetDevice. Since there is a single PDCP and RLC protocol instance for each Radio Bearer, the LteEnbNetDevice is able to determine the BID of the packet. This BID is then recorded onto an EpsBearerTag, which is added to the packet. The LteEnbNetDevice then forwards the packet to the EpcEnbApplication via a raw packet socket.
Upon receiving the packet, the EpcEnbApplication performs the following operations:
- it retrieves the BID from the
EpsBearerTagin the packet; - it determines the corresponding EPS Bearer instance and GTP-U TEID by leveraging on the one-to-one mapping between S1-U bearers and Radio Bearers;
- it adds a GTP-U header on the packet, including the TEID determined previously;
- it sends the packet to the SGW node via the UDP socket connected to the S1-U point-to-point net device.
At this point the packet is carrying the S1-U IP, UDP and GTP headers stacked on top of the original end-to-end IP header. When the matching S1-U point-to-point NetDevice of the SGW node receives it, it gets delivered locally โ because the destination address of the outmost IP header matches the address of the point-to-point net device, iykyk ๐. That local delivery process forwards the packet to the EpcSgwApplication via the corresponding UDP socket. And then EpcSgwApplication goes off:
- it removes the GTP header and retrieves the S1-U TEID;
- it maps the S1-U TEID to get the S5 TEID to which the packet belongs;
- it determines the PGW to which it must send the packet from the TEID mapping;
- it adds a new GTP-U protocol header to the packet;
- finally, it sends the packet over a UDP socket to the S5 point-to-point NetDevice, addressed to the corresponding PGW.
Now the packet is stacked with the S5 IP, UDP and GTP headers on top of the original end-to-end IP header. When the corresponding S5 point-to-point NetDevice of the PGW node receives it, it's delivered locally (the destination address of the outmost IP header matches the address of the point-to-point net device, bestie, that's the whole trick โจ). The local delivery process forwards the packet to the EpcPgwApplication via the corresponding UDP socket. Then EpcPgwApplication removes the GTP header and forwards the packet to the VirtualNetDevice. At this point the outmost header of the packet is the end-to-end IP header. So if the destination address inside that header is a remote host on the internet, the packet goes out to the internet through the corresponding NetDevice of the PGW. And in the event that the packet is addressed to another UE, the IP stack of the PGW will redirect the packet again to the VirtualNetDevice, and it goes through the downlink delivery process to reach its destination UE. ๐ฅ
Heads up: the EPS Bearer QoS is not enforced on the S1-U and S5 links. The model just assumes that overprovisioning the link bandwidth is enough to meet the QoS requirements of all the bearers. ๐ซถ
โจ S1AP โจ
The S1-AP interface is where the eNB and the MME do their control plane interaction ๐ฌ. In the simulator this interface is modeled in a realistic fashion, transmitting the encoded S1AP messages and information elements specified in [TS36413] on the S1-MME link.
The S1-AP primitives that are modeled are:
- INITIAL UE MESSAGE
- INITIAL CONTEXT SETUP REQUEST
- INITIAL CONTEXT SETUP RESPONSE
- PATH SWITCH REQUEST
- PATH SWITCH REQUEST ACKNOWLEDGE
๐ธ S5 and S11 ๐ธ
The S5 interface provides control plane interaction between the SGW and the PGW. The S11 interface provides control plane interaction between the SGw and the MME. Both interfaces use the GPRS Tunneling Protocol (GTPv2-C) to tunnel signalling messages [TS29274] and use UDP as transport protocol. In the simulator, these interfaces and protocol are modeled in a realistic fashion transmitting the encoded GTP-C messages. Periodt. ๐
The GTPv2-C primitives that are modeled are:
- CREATE SESSION REQUEST
- CREATE SESSION RESPONSE
- MODIFY BEARER REQUEST
- MODIFY BEARER RESPONSE
- DELETE SESSION REQUEST
- DELETE SESSION RESPONSE
- DELETE BEARER COMMAND
- DELETE BEARER REQUEST
- DELETE BEARER RESPONSE
Of these primitives, the first two are used upon initial UE attachment for the establishment of the S1-U and S5 bearers. The section on NAS shows the implementation of the attach procedure. The other primitives get used during the handover, to switch the S1-U bearers from the source eNB to the target eNB, as a consequence of the MME receiving a PATH SWITCH REQUEST S1-AP message. ๐
๐ฆ X2 ๐ฆ
The X2 interface interconnects two eNBs [TS36420]. Logically speaking, the X2 interface is a point-to-point interface between the two eNBs. In a real E-UTRAN, that logical point-to-point interface should be feasible even when there's no physical direct connection between the two eNBs. In the X2 model implemented in the simulator, though, the X2 interface is a point-to-point link between the two eNBs. A point-to-point device is created in both eNBs, and the two point-to-point devices are attached to the point-to-point link. ๐
For a representation of how the X2 interface fits into the overall architecture of the LENA simulation model, the reader is referred to the figure Overview of the LTE-EPC simulation model.
The X2 interface implemented in the simulator provides a detailed implementation of the following elementary procedures of the Mobility Management functionality [TS36423]:
- Handover Request procedure
- Handover Request Acknowledgement procedure
- SN Status Transfer procedure
- UE Context Release procedure
These procedures are involved in the X2-based handover. You can find the detailed description of the handover in section 10.1.2.1 of [TS36300]. Note that the simulator model currently supports only the seamless handover as defined in Section 2.6.3.1 of [Sesia2009]; specifically, lossless handover as described in Section 2.6.3.2 of [Sesia2009] is not supported at the time of this writing. ๐ญ
The figure Sequence diagram of the X2-based handover below shows the interaction of the entities of the X2 model in the simulator. The shaded labels indicate the moments when the UE or eNodeB transition to another RRC state.
[image] Sequence diagram of the X2-based handover.
The figure also shows two timers within the handover procedure: the handover leaving timer is maintained by the source eNodeB, while the handover joining timer is maintained by the target eNodeB. The duration of the timers can be configured in the HandoverLeavingTimeoutDuration and HandoverJoiningTimeoutDuration attributes of the respective LteEnbRrc instances. When one of these timers expires, the handover procedure is considered as failed.
โ ๏ธ Real talk though: there is no proper handling of handover failure in the current version of the LTE module. Users should tune the simulation properly in order to avoid handover failure, otherwise unexpected behaviour may occur. Please refer to the section sec-tuning-handover-simulation of the User Documentation for some tips regarding this matter. ๐
The X2 model is an entity that uses services from:
- the X2 interfaces,
- They are implemented as Sockets on top of the point-to-point devices.
- They are used to send/receive X2 messages through the X2-C and X2-U interfaces (i.e. the point-to-point device attached to the point-to-point link) towards the peer eNB.
- the S1 application.
- Currently, it is the
EpcEnbApplication. - It is used to get some information needed for the Elementary Procedures of the X2 messages.
- Currently, it is the
and it provides services to:
- the RRC entity (X2 SAP)
- to send/receive RRC messages. The X2 entity sends the RRC message as a transparent container in the X2 message. This RRC message is sent to the UE.
The figure Implementation Model of X2 entity and SAPs shows the implementation model of the X2 entity and its relationship with all the other entities and services in the protocol stack.
[image] Implementation Model of X2 entity and SAPs.
The RRC entity manages the initiation of the handover procedure. This is done in the Handover Management submodule of the eNB RRC entity. The target eNB may perform some Admission Control procedures. This is done in the Admission Control submodule. Initially, this submodule will accept any handover request. โจ
๐ X2 interfaces ๐
The X2 model contains two interfaces:
- the X2-C interface. It is the control interface and it is used to send the X2-AP PDUs (i.e. the elementary procedures).
- the X2-U interface. It is used to send the bearer data when there is DL forwarding.
The figure X2 interface protocol stacks shows the protocol stacks of the X2-U interface and X2-C interface modeled in the simulator.
[image] X2 interface protocol stacks.
๐ X2-C ๐
The X2-C interface is the control part of the X2 interface and it is used to send the X2-AP PDUs (i.e. the elementary procedures).
In the original X2 interface control plane protocol stack, SCTP is used as the transport protocol, but currently the SCTP protocol is not modeled in the ns-3 simulator and its implementation is out-of-scope of the project. The UDP protocol is used as the datagram oriented protocol instead of the SCTP protocol. ๐
โญ X2-U โญ
The X2-U interface is used to send the bearer data when there is DL forwarding during the execution of the X2-based handover procedure. Just like what's done for the S1-U interface, data packets are encapsulated over GTP/UDP/IP when being sent over this interface.
Note that the EPS Bearer QoS is not enforced on the X2-U links either โ again, it's assumed that overprovisioning the link bandwidth is sufficient to meet the QoS requirements of all bearers. ๐ซถ
๐ง X2 Service Interface ๐ง
The X2 service interface is used by the RRC entity to send and receive messages of the X2 procedures. It is divided into two parts:
- the
EpcX2SapProviderpart is provided by the X2 entity and used by the RRC entity and - the
EpcX2SapUserpart is provided by the RRC entity and used by the RRC enity.
The primitives that are supported in our X2-C model are described in the following subsections. ๐
๐ X2-C primitives for handover execution ๐
The following primitives are used for the X2-based handover:
- HANDOVER REQUEST
- HANDOVER REQUEST ACK
- HANDOVER PREPARATION FAILURE
- SN STATUS STRANSFER
- UE CONTEXT RELEASE
All of the above primitives are used by the currently implemented RRC model during the preparation and execution of the handover procedure. Their usage interacts with the RRC state machine; therefore, they are not meant to be used for code customization โ at least unless you actually want to modify the RRC state machine. ๐
๐ X2-C SON primitives ๐
The following primitives can be used to implement Self-Organized Network (SON) functionalities:
- LOAD INFORMATION
- RESOURCE STATUS UPDATE
Note that the current RRC model does not actually use these primitives โ they're included in the model just to make it possible to develop SON algorithms inside the RRC logic that make use of them. ๐ธ
As a first example, we show here how the load information primitive can be used. We assume that the LteEnbRrc has been modified to include the following new member variables:
std::vector<EpcX2Sap::UlInterferenceOverloadIndicationItem>
m_currentUlInterferenceOverloadIndicationList;
std::vector <EpcX2Sap::UlHighInterferenceInformationItem>
m_currentUlHighInterferenceInformationList;
EpcX2Sap::RelativeNarrowbandTxBand m_currentRelativeNarrowbandTxBand;
okay so bestie, for the full tea on what these variable types actually are, go read the file epc-x2-sap.h, the doxygen docs that match it, and the references inside those pointing at the relevant sections of 3GPP TS 36.423. iykyk. ๐
Now โจimagineโจ that at run time these variables have already been set to meaningful values per those specs we just mentioned. Then you can drop the following code into the LteEnbRrc class implementation to send a load information primitive:
EpcX2Sap::CellInformationItem cii;
cii.sourceCellId = m_cellId;
cii.ulInterferenceOverloadIndicationList = m_currentUlInterferenceOverloadIndicationList;
cii.ulHighInterferenceInformationList = m_currentUlHighInterferenceInformationList;
cii.relativeNarrowbandTxBand = m_currentRelativeNarrowbandTxBand;
EpcX2Sap::LoadInformationParams params;
params.targetCellId = cellId;
params.cellInformationList.push_back (cii);
m_x2SapProvider->SendLoadInformation (params);
That code right there lets the source eNB send the message, slay. The method LteEnbRrc::DoRecvLoadInformation gets called when the target eNB receives the message. So the processing you want to happen on the load information? That goes inside that method. ๐
In the second example, let's show how the resource status update primitive is used. We assume LteEnbRrc has been modified to include this new member variable:
EpcX2Sap::CellMeasurementResultItem m_cmri;
Same deal as before: we point you at epc-x2-sap.h and the references inside it for the detailed info about this variable type. And again, we're assuming the variable has already been set to a meaningful value. Then you can add the following code to send a resource status update:
EpcX2Sap::ResourceStatusUpdateParams params;
params.targetCellId = cellId;
params.cellMeasurementResultList.push_back (m_cmri);
m_x2SapProvider->SendResourceStatusUpdate (params);
The method eEnbRrc::DoRecvResourceStatusUpdate gets called when the target eNB receives the resource status update message. So whatever processing you want on that message should be implemented inside that method. ๐ซถ
And finally, bestie, a lil heads-up: setting and processing the appropriate values for the variable passed to those primitives we just described? That's considered specific to the SON algorithm you're implementing, so it is not covered by this documentation. That part's on you. ๐ญ
โจ Unsupported primitives โจ
Mobility Robustness Optimization primitives โ like Radio Link Failure indication and Handover Report โ are not supported at this stage. not me, not you, not nobody. ๐
๐ S11 ๐
The S11 interface gives you control plane interaction between the SGW and the MME, using the GTPv2-C protocol specified in [TS29274]. In the simulator this interface is modeled in an ideal fashion โ the SGW and MME objects talk directly to each other, without actually implementing the encoding of the messages and without actually transmitting any PDU on any link. no packets were harmed in the making of this interface. โจ
The S11 primitives that are modeled are:
- CREATE SESSION REQUEST
- CREATE SESSION RESPONSE
- MODIFY BEARER REQUEST
- MODIFY BEARER RESPONSE
Out of these, the first two get used upon initial UE attachment for the establishment of the S1-U bearers. The other two get used during handover to switch the S1-U bearers from the source eNB to the target eNB โ and that happens as a consequence of the MME receiving a PATH SWITCH REQUEST S1-AP message. ๐ฆ
โก Power Control โก
This section describes the ns-3 implementation of Downlink and Uplink Power Control. (yes we're power controlling both directions, we're doing the most, we're that girl.) ๐
๐ Downlink Power Control ๐
Since some of the Frequency Reuse Algorithms require Downlink Power Control, this feature was also implemented in ns-3. the FR algorithms said "we need this" and ns-3 said "say less." ๐
[image] Sequence diagram of Downlink Power Control.
Figure Sequence diagram of Downlink Power Control shows the sequence diagram of setting downlink P_A value for UE, highlighting the interactions between the RRC and the other entities. FR algorithm triggers RRC to change P_A values for UE. Then RRC startsRrcConnectionReconfigurationfunction to inform UE about new configuration. After successfulRrcConnectionReconfiguration, RRC can set P_A value for UE by calling functionSetPafromCphySap, value is saved in new mapm_paMapwhich contain P_A values for each UE served by eNb.
WhenLteEnbPhystarts new subframe, DCI control messages are processed to get vector of used RBs. Now alsoGeneratePowerAllocationMap(uint16_t rnti, int rbId)function is also called. This function check P_A value for UE, generate power for each RB and store it inm_dlPowerAllocationMap. Then this map is used byCreateTxPowerSpectralDensityWithPowerAllocationfunction to createPtr<SpectrumValue> txPsd.
PdschConfigDedicated(TS 36.331, 6.3.2 PDSCH-Config) was added inLteRrcSap::PhysicalConfigDedicatedstruct, which is used inRrcConnectionReconfigurationprocess.
๐ธ Uplink Power Control ๐ธ
Uplink power control controls the transmit power of the different uplink physical channels. This functionality is described in 3GPP TS 36.213 section 5. ๐
Uplink Power Control is enabled by default, and can be disabled via the attribute system:
Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (false));
Two Uplink Power Control mechanisms are implemented:
- Open Loop Uplink Power Control: the UE transmission power depends on estimation of the downlink path-loss and channel configuration
- Closed Loop Uplink Power Control: as in Open Loop, in addition eNB can control the UE transmission power by means of explicit Transmit Power Control TPC commands transmitted in the downlink.
To switch between these two mechanism types, one should change the parameter:
Config::SetDefault ("ns3::LteUePowerControl::ClosedLoop", BooleanValue (true));
By default, Closed Loop Power Control is enabled. (default on, iconic behaviour fr fr) โ
Two modes of Closed Loop Uplink Power Control are available:
- Absolute mode: TxPower is computed with absolute TPC values
- Accumulative mode: TxPower is computed with accumulated TPC values
To switch between these two modes, one should change the parameter:
Config::SetDefault ("ns3::LteUePowerControl::AccumulationEnabled", BooleanValue (true));
By default, Accumulation Mode is enabled and TPC commands in DL-DCI are set by all schedulers to 1, what is mapped to value of 0 in Accumulation Mode. ๐
๐ Uplink Power Control for PUSCH ๐
The setting of the UE Transmit power for a Physical Uplink Shared Channel (PUSCH) transmission is defined as follows:
- If the UE transmits PUSCH without a simultaneous PUCCH for the serving cell c, then the UE transmit power P_{PUSCH,c}(i) for PUSCH transmission in subframe i for the serving cell c is given by:
P_{PUSCH,c}(i)=\min\begin{Bmatrix}
P_{CMAX,c}(i)\\
10\log_{10}(M_{PUSCH,c}(i))+ P_{O\_PUSCH,c}(j)
+ \alpha_{c} (j) * PL_{c} + \Delta_{TF,c}(i) + f_{c}(i)
\end{Bmatrix} [dBm]
- If the UE transmits PUSCH simultaneous with PUCCH for the serving cell c, then the UE transmit power P_{PUSCH,c}(i) for the PUSCH transmission in subframe i for the serving cell c is given by:
P_{PUSCH,c}(i)=\min\begin{Bmatrix}
10\log_{10}(\hat{P}_{CMAX,c}(i) - \hat{P}_{PUCCH}(i))\\
10\log_{10}(M_{PUSCH,c}(i))+ P_{O\_PUSCH,c}(j)
+ \alpha_{c} (j) * PL_{c} + \Delta_{TF,c}(i) + f_{c}(i)
\end{Bmatrix} [dBm]
Since Uplink Power Control for PUCCH is not implemented, this case is not implemented as well. (bestie we simply don't do that one ๐)
- If the UE is not transmitting PUSCH for the serving cell c, for the accumulation of TPC command received with DCI format 3/3A for PUSCH, the UE shall assume that the UE transmit power P_{PUSCH,c}(i) for the PUSCH transmission in subframe i for the serving cell c is computed by
P_{PUSCH,c}(i)=\min\begin{Bmatrix}
{P}_{CMAX,c}(i)\\
P_{O\_PUSCH,c}(1) + \alpha_{c} (1) * PL_{c} + f_{c}(i)
\end{Bmatrix} [dBm]
where:
- P_{CMAX,c}(i) is the configured UE transmit power defined in 3GPP 36.101. Table 6.2.2-1 in subframe i for serving cell c and \hat{P}_{CMAX,c}(i) is the linear value of P_{CMAX,c}(i). Default value for P_{CMAX,c}(i) is
23 dBm - M_{PUSCH,c}(i) is the bandwidth of the PUSCH resource assignment expressed in number of resource blocks valid for subframe i and serving cell c .
- P_{O_PUSCH,c}(j) is a parameter composed of the sum of a component P_{O_NOMINAL_PUSCH,c}(j) provided from higher layers for j={0,1} and a component P_{O_UE_PUSCH,c}(j) provided by higher layers for j={0,1} for serving cell c. SIB2 message needs to be extended to carry these two components, but currently they can be set via the attribute system:
Config::SetDefault ("ns3::LteUePowerControl::PoNominalPusch", IntegerValue (-90));
Config::SetDefault ("ns3::LteUePowerControl::PoUePusch", IntegerValue (7));
- \alpha_{c} (j) is a 3-bit parameter provided by higher layers for serving cell c. For j=0,1, \alpha_c \in \left { 0, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1 \right } For j=2, \alpha_{c} (j) = 1. This parameter is configurable by attribute system:
Config::SetDefault ("ns3::LteUePowerControl::Alpha", DoubleValue (0.8));
- PL_{c} is the downlink pathloss estimate calculated in the UE for serving cell c in dB and PL_{c} = referenceSignalPower โ higher layer filtered RSRP, where referenceSignalPower is provided by higher layers and RSRP. referenceSignalPower is provided in SIB2 message
- \Delta_{TF,c}(i) = 10\log_{10}((2^{BPRE\cdot K_s}-1)\cdot\beta_{offset}^{PUSCH} ) for K_{s} = 1.25 and \Delta_{TF,c}(i) = 0 for K_{s} = 0. Only second case is implemented. (the other one said "not today" ๐)
- f_{c}(i) is component of Closed Loop Power Control. It is the current PUSCH power control adjustment state for serving cell c.
If Accumulation Mode is enabled f_{c}(i) is given by:
f_{c}(i) = f_{c}(i-1) + \delta_{PUSCH,c}(i - K_{PUSCH})
where: \delta_{PUSCH,c} is a correction value, also referred to as a TPC command and is included in PDCCH with DCI; \delta_{PUSCH,c}(i - K_{PUSCH}) was signalled on PDCCH/EPDCCH with DCI for serving cell c on subframe (i - K_{PUSCH}); K_{PUSCH} = 4 for FDD. bestie this is just the receipt for how the power got adjusted, ok ๐
If UE has reached P_{CMAX,c}(i) for serving cell c, positive TPC commands for serving cell c are not be accumulated. If UE has reached minimum power, negative TPC commands are not be accumulated. Minimum UE power is defined in TS36.101 section 6.2.3. Default value is -40 dBm. yes, negative forty, that's the floor, do not pass go ๐ง
If Accumulation Mode is not enabled f_{c}(i) is given by:
f_{c}(i) = \delta_{PUSCH,c}(i - K_{PUSCH})
where: \delta_{PUSCH,c} is a correction value, also referred to as a TPC command and is included in PDCCH with DCI; \delta_{PUSCH,c}(i - K_{PUSCH}) was signalled on PDCCH/EPDCCH with DCI for serving cell c on subframe (i - K_{PUSCH}); K_{PUSCH} = 4 for FDD.
Mapping of TPC Command Field in DCI format 0/3/4 to absolute and accumulated \delta_{PUSCH,c} values is defined in TS36.231 section 5.1.1.1 Table 5.1.1.1-2. iykyk ๐
๐ซถ Uplink Power Control for PUCCH ๐ซถ
Since all uplink control messages are an ideal messages and do not consume any radio resources, Uplink Power Control for PUCCH is not needed and it is not implemented. so there's literally nothing here to do. we said what we said. periodt ๐
๐ฆ Uplink Power Control for SRS ๐ฆ
The setting of the UE Transmit power P_{SRS} for the SRS transmitted on subframe i for serving cell c is defined by ok here comes the big one, deep breath ๐ธ
P_{PUSCH,c}(i)=\min\begin{Bmatrix}
{P}_{CMAX,c}(i)\\
P_{SRS\_OFFSET,c}(m) + 10\log_{10}(M_{SRS,c})+
P_{O\_PUSCH,c}(j) + \alpha_{c}(j) * PL_{c} + f_{c}(i)
\end{Bmatrix} [dBm]
where:
P_{CMAX,c}(i)is the configured UE transmit power defined in3GPP 36.101. Table 6.2.2-1. Default value forP_{CMAX,c}(i)is23 dBmtwenty three, iconic, no cap ๐P_{SRS\_OFFSET,c}(m)is semi-statically configured by higher layers form=0,1for serving cell c . For SRS transmission given trigger type0thenm=0,1and for SRS transmission given trigger type1thenm=1. ForK_{s} = 0P_Srs_Offset_Valueis computed with equation:
P_{SRS\_OFFSET,c}(m)value = -10.5 + P_{SRS\_OFFSET,c}(m) * 1.5 [dBm]
This parameter is configurable by attribute system: ooh a config snippet, we love a config snippet โจ
Config::SetDefault ("ns3::LteUePowerControl::PsrsOffset", IntegerValue (7));
M_{SRS,c}is the bandwidth of the SRS transmission in subframe i for serving cell c expressed in number of resource blocks. In current implementation SRS is sent over entire UL bandwidth. the whole thing. all of it. she takes up space and that's her right ๐f_{c}(i)is the current PUSCH power control adjustment state for serving cell c, as defined in Uplink Power Control for PUSCH โ yes, the section we just did, go scroll back bestie ๐P_{O\_PUSCH,c}(j)and\alpha_{c}(j)are parameters as defined in Uplink Power Control for PUSCH, wherej = 1.
๐ Fractional Frequency Reuse ๐
โญ Overview โญ
This section describes the ns-3 support for Fractional Frequency Reuse algorithms. All implemented algorithms are described in [ASHamza2013]. Currently 7 FR algorithms are implemented: seven!! a whole squad!! ๐
ns3::LteFrNoOpAlgorithmns3::LteFrHardAlgorithmns3::LteFrStrictAlgorithmns3::LteFrSoftAlgorithmns3::LteFfrSoftAlgorithmns3::LteFfrEnhancedAlgorithmns3::LteFfrDistributedAlgorithm
New LteFfrAlgorithm class was created and it is a abstract class for Frequency Reuse algorithms implementation. Also, two new SAPs between FR-Scheduler and FR-RRC were added. two new SAPs, they're new here, be nice to them ๐ซถ
[image] Sequence diagram of Scheduling with FR algorithm.
Figure Sequence diagram of Scheduling with FR algorithm shows the sequence diagram of scheduling process with FR algorithm. In the beginning of scheduling process, scheduler asks FR entity for available RBGs. According to implementation FR returns all RBGs available in cell or filter them based on its policy. Then when trying to assign some RBG to UE, scheduler asks FR entity if this RBG is allowed for this UE. When FR returns true, scheduler can assign this RBG to this UE, if not scheduler is checking another RBG for this UE. Again, FR response depends on implementation and policy applied to UE. tl;dr: scheduler keeps asking "can i have this one?" and FR keeps saying yes or no. it's giving permission slip energy ๐
๐ Supported FR algorithms ๐
๐ No Frequency Reuse ๐
The NoOp FR algorithm (LteFrNoOpAlgorithm class) is implementation of Full Frequency Reuse scheme, that means no frequency partitioning is performed between eNBs of the same network (frequency reuse factor, FRF equals 1). eNBs uses entire system bandwidth and transmit with uniform power over all RBGs. It is the simplest scheme and is the basic way of operating an LTE network. This scheme allows for achieving the high peak data rate. But from the other hand, due to heavy interference levels from neighbouring cells, cell-edge users performance is greatly limited. ngl the cell-edge girlies are STRUGGLING and it's not their fault ๐ญ
Figure Full Frequency Reuse scheme below presents frequency and power plan for Full Frequency Reuse scheme.
[image] Full Frequency Reuse scheme.
In ns-3, the NoOp FR algorithm always allows scheduler to use full bandwidth and allows all UEs to use any RBG. It simply does nothing new (i.e. it does not limit eNB bandwidth, FR algorithm is disabled), it is the simplest implementation of FrAlgorithm class and is installed in eNb by default. it's the default, it literally does nothing, and honestly? relatable ๐
๐ฅ Hard Frequency Reuse ๐ฅ
The Hard Frequency Reuse algorithm provides the simplest scheme which allows to reduce inter-cell interference level. In this scheme whole frequency bandwidth is divided into few (typically 3, 4, or 7) disjoint sub-bands. Adjacent eNBs are allocated with different sub-band. Frequency reuse factor equals the number of sub-bands. This scheme allows to significantly reduce ICI at the cell edge, so the performance of cell-users is improved. But due to the fact, that each eNB uses only one part of whole bandwidth, peak data rate level is also reduced by the factor equal to the reuse factor. tradeoff city, population: you โ๏ธ
Figure Hard Frequency Reuse scheme below presents frequency and power plan for Hard Frequency Reuse scheme.
[image] Hard Frequency Reuse scheme.
In our implementation, the Hard FR algorithm has only vector of RBGs available for eNB and pass it to MAC Scheduler during scheduling functions. When scheduler ask, if RBG is allowed for specific UE it always return true. she's a yes-girl fr fr โ
๐ธ Strict Frequency Reuse ๐ธ
Strict Frequency Reuse scheme is combination of Full and Hard Frequency Reuse schemes. It consists of dividing the system bandwidth into two parts which will have different frequency reuse. One common sub-band of the system bandwidth is used in each cell interior (frequency reuse-1), while the other part of the bandwidth is divided among the neighboring eNBs as in hard frequency reuse (frequency reuse-N, N>1), in order to create one sub-band with a low inter-cell interference level in each sector. Center UEs will be granted with the fully-reused frequency chunks, while cell-edge UEs with orthogonal chunks. It means that interior UEs from one cell do not share any spectrum with edge UEs from second cell, which reduces interference for both. As can be noticed, Strict FR requires a total of N + 1 sub-bands, and allows to achieve RFR in the middle between 1 and 3. it's both schemes holding hands. bestie collab of the century ๐ซถ
Figure Strict Frequency Reuse scheme below presents frequency and power plan for Strict Frequency Reuse scheme with a cell-edge reuse factor of N = 3.
[image] Strict Frequency Reuse scheme.
In our implementation, Strict FR algorithm has two maps, one for each sub-band. If UE can be served within private sub-band, its RNTI is added to m_privateSubBandUe map. If UE can be served within common sub-band, its RNTI is added to m_commonSubBandUe map. Strict FR algorithm needs to decide within which sub-band UE should be served. It uses UE measurements provided by RRB and compare them with signal quality threshold (this parameter can be easily tuned by attribute mechanism). Threshold has influence on interior to cell radius ratio. two maps, two moods, one very important threshold ๐บ๏ธ
๐ Soft Frequency Reuse ๐
In Soft Frequency Reuse (SFR) scheme each eNb transmits over the entire system bandwidth, but there are two sub-bands, within UEs are served with different power level. Since cell-center UEs share the bandwidth with neighboring cells, they usually transmit at lower power level than the cell-edge UEs. SFR is more bandwidth efficient than Strict FR, because it uses entire system bandwidth, but it also results in more interference to both cell interior and edge users. more bandwidth, more interference, we contain multitudes โจ
There are two possible versions of SFR scheme:
- In first version, the sub-band dedicated for the cell-edge UEs may also be used by the cell-center UEs but with reduced power level and only if it is not occupied by the cell-edge UEs. Cell-center sub-band is available to the centre UEs only. Figure Soft Frequency Reuse scheme version 1 below presents frequency and power plan for this version of Soft Frequency Reuse scheme.
[image] Soft Frequency Reuse scheme version 1.
- In second version, cell-center UEs do not have access to cell-edge sub-band. In this way, each cell can use the whole system bandwidth while reducing the interference to the neighbors cells. From the other hand, lower ICI level at the cell-edge is achieved at the expense of lower spectrum utilization. Figure Soft Frequency Reuse scheme version 2 below presents frequency and power plan for this version of Soft Frequency Reuse scheme.
[image] Soft Frequency Reuse scheme version 2.
SFR algorithm maintain two maps. If UE should be served with lower power level, its RNTI is added to m_lowPowerSubBandUe map. If UE should be served with higher power level, its RNTI is added to m_highPowerSubBandUe map. To decide with which power level UE should be served SFR algorithm utilize UE measurements, and compares them to threshold. Signal quality threshold and PdschConfigDedicated (i.e. P_A value) for inner and outer area can be configured by attributes system. SFR utilizes Downlink Power Control described here. low power map, high power map โ choose your fighter ๐
Soft Fractional Frequency Reuse
okay so Soft Fractional Frequency Reuse โ say it with me, SFFR โ is literally a combo meal of Strict and Soft Frequency Reuse. ๐ Here's the deal: Strict FR does not use the subbands allocated for the outer region in the adjacent cells, but soft FFR does use those subbands for the inner UEs, just with low transmit power. So as a result, SFFR โ like SFR โ uses the subband with high transmit power level and the subband with low transmit power level. ๐ But unlike Soft FR, and like Strict FR, Soft FFR uses the common sub-band, which can enhance the throughput of the inner users. ate.
The figure below โ Soft Fractional Fractional Frequency Reuse scheme โ shows the frequency and power plan for Soft Fractional Frequency Reuse. ๐
[image] Soft Fractional Fractional Frequency Reuse scheme.
Enhanced Fractional Frequency Reuse
Enhanced Fractional Frequency Reuse (EFFR), as described in [ZXie2009], defines 3 cell-types for directly neighboring cells in a cellular system, and reserves for each cell-type a part of the whole frequency band called the Primary Segment โ and between different type cells, that thing has to be orthogonal, no cap. The remaining subchannels make up the Secondary Segment. The Primary Segment of a cell-type is at the same time a part of the Secondary Segments belonging to the other two cell-types. ๐
Each cell can occupy all subchannels of its Primary Segment at will, whereas only a part of subchannels in the Secondary Segment can be used by this cell โ and only in an interference-aware manner. The Primary Segment of each cell is divided into a reuse-3 part and a reuse-1 part. The reuse-1 part can be reused by all types of cells in the system, whereas the reuse-3 part can only be exclusively reused by other same type cells (i.e. the reuse-3 subchannels cannot be reused by directly neighboring cells). On the Secondary Segment, a cell acts as a guest ๐ซถ, and occupying secondary subchannels is actually reusing the primary subchannels belonging to the directly neighboring cells โ so reuse on the Secondary Segment by each cell should conform to two rules:
- monitor before use
- resource reuse based on SINR estimation
Each cell listens on every secondary subchannel all the time (not me, that's just the algorithm ๐). And before occupation, it makes an SINR evaluation according to the gathered channel quality information (CQI) and chooses resources with the best estimation values for reuse. If the CQI value for an RBG is above the configured threshold for some user, transmission for this user can be performed using this RBG. โจ
In [ZXie2009] the scheduling process is described โ it consists of three steps and two scheduling polices. Since none of the currently implemented schedulers allow for this behaviour, some simplification were applied. In our implementation, reuse-1 subchannels can be used only by cell center users. Reuse-3 subchannels can be used by edge users, and only if there is no edge user, transmission for cell center users can be served in reuse-3 subchannels.
The figure below โ Enhanced Fractional Fractional Frequency Reuse scheme โ presents the frequency and power plan for Enhanced Fractional Frequency Reuse. ๐
[image] Enhanced Fractional Fractional Frequency Reuse scheme.
Distributed Fractional Frequency Reuse
This Distributed Fractional Frequency Reuse algorithm was presented in [DKimura2012]. It automatically optimizes cell-edge sub-bands by focusing on user distribution (in particular, receive-power distribution). ๐ฅ This algorithm adaptively selects RBs for the cell-edge sub-band on the basis of coordination information from adjecent cells and notifies the base stations of the adjacent cells which RBs it selected to use in the edge sub-band. The base station of each cell uses the received information and the following equation to compute the cell-edge-band metric A_{k} for each RB. ๐งฎ
A_{k} = \sum_{j\in J}w_{j}X_{j,k}
where J is a set of neighbor cells, X_{j,k}=\{0,1\} is the RNTP from the j-th neighbor cell. It takes a value of 1 when the k-th RB in the j-th neighbor cell is used as a cell-edge sub-band and 0 otherwise. The symbol w_{j} denotes weight with respect to adjacent cell j, that is, the number of users for which the difference between the power of the signal received from the serving cell i and the power of the signal received from the adjacent cell j is less than a threshold value (i.e., the number of users near the cell edge in the service cell). A large received power difference means that cell-edge users in the i-th cell suffer strong interference from the j-th cell. ๐ญ
The RB for which metric A_{k} is smallest is considered to be least affected by interference from another cell. Serving cell selects a configured number of RBs as cell-edge sub-band in ascending order of A_{k}. As a result, the RBs in which a small number of cell-edge users receive high interference from adjacent base stations are selected. ๐
The updated RNTP is then sent to all the neighbor cells. In order to avoid the meaningless oscillation of cell-edge-band selection, a base station ignores an RNTP from another base station that has larger cell ID than the base station. ๐ซ
Repeating this process across all cells enables the allocation of RBs to cell-edge areas to be optimized over the system and to be adjusted with changes in user distribution. it's giving โจadaptiveโจ.
The figure below โ Sequence diagram of Distributed Frequency Reuse Scheme โ presents the sequence diagram of the Distributed Fractional Frequency Reuse Scheme. ๐ฆ
[image] Sequence diagram of Distributed Frequency Reuse Scheme.
Carrier Aggregation
Overview
This section describes the ns-3 support for Carrier Aggregation. The references in the standard are [TS36211], [TS36213] and [TS36331]. ๐
Note: Carrier Aggregation was introduced in release 3.27 and currently, only works in downlink. โ ๏ธ
3GPP standardizes, in release R10, the Carrier Aggregation (CA) technology.
This technology consists of the possibility to aggregate radio resources belonging to different carriers, in order to have more bandwidth available, and to achieve a higher throughput. ๐
Carrier Aggregation as defined by 3GPP can be used with both TDD and FDD. Since ns-3 only supports FDD LTE implementation, we will consider only this case in this section. Each aggregated carrier is referred to as a component carrier, CC. The component carrier can have a bandwidth of 1.4, 3, 5, 10, 15 or 20 MHz and a maximum of five component carriers can be aggregated, hence the maximum aggregated bandwidth is 100 MHz. ๐ In FDD the number of aggregated carriers can be different in DL and UL. However, the number of UL component carriers is always equal to or lower than the number of DL component carriers. The individual component carriers can also be of different bandwidths. When carrier aggregation is used there are a number of serving cells, one for each component carrier. The coverage of the serving cells may differ, for example due to that CCs on different frequency bands will experience different pathloss. The RRC connection is only handled by one cell, the Primary serving cell, served by the Primary component carrier (DL and UL PCC). It is also on the DL PCC that the UE receives NAS information, such as security parameters. ๐
3GPP defines three different CA bandwidth classes in releases 10 and 11 (where ATBC is Aggregated Transmission Bandwidth Configuration):
- Class A:
ATBC \leq 100, maximum number of CC = 1 - Class B:
ATBC \leq 100, maximum number of CC = 2 - Class C:
100 \leq ATBC \leq 200, maximum number of CC = 2
The figure CA impact on different layers of LTE protocol stack (from 3gpp.org) (from 3gpp.org) shows the main impact of CA technology on the different layers of the LTE protocol stack. Introduction of carrier aggregation influences mainly the MAC and new RRC messages are introduced. In order to keep R8/R9 compatibility the protocol changes will be kept to a minimum. Basically each component carrier is treated as an R8 carrier. However some changes are required, such as new RRC messages in order to handle the secondary component carrier (SCC), and MAC must be able to handle scheduling on a number of CCs. In the following we describe the impact of the carrier aggregation implementation on the different layers of the LTE protocol stack in ns-3. ๐
[image] CA impact on different layers of LTE protocol stack (from 3gpp.org).
Impact on RRC layer
The main impacts on the RRC layer are related to secondary carrier configuration and measurements reporting. To enable these features we have enhanced the already existing procedures for the RRC Connection Reconfiguration and UE RRC Measurements Model. ๐ซถ
The carrier aggregation enabling procedure is shown in figure A schematic overview of the secondary carrier enabling procedure. So per 3GPP's own definition, a secondary cell is a cell operating on a secondary frequency, and it can be configured once an RRC connection is established, and it can be used to hand out extra radio resources. So basically the whole thing kicks off when the UE is in the CONNECTED_NORMALLY state (peep the RRC state machine description, bestie). This chunk of the procedure? Same as the previous architecture, no notes. But to keep the implementation simple, the UE Capability Inquiry and UE Capability Information are not implemented. Which means we just assume every UE can support carrier aggregation, and also support any specific configuration the eNB it's attached to decides to hand it. The eNB RRC sends the secondary carrier configuration parameters to the UE through the RRC Connection Reconfiguration procedure. That procedure is lowkey a multitasker โ it gets used for all sorts of RRC connection modifications, like establishing, modifying or releasing RBs, doing handover, setting up, modifying or releasing measurements, and adding, modifying and releasing secondary cells (SCells). ๐
On the UE side, the RRC is extended to configure the lower layers so that the SCell(s) actually get considered. Once the carriers are configured, the Reconfiguration Completed message goes back to the eNB RRC, telling both the eNB RRC and the CCM that the secondary carriers have been properly configured. The RRC layer on both the UE and the eNB sides is extended so measurement reporting works for the secondary carriers too. And finally, to make configuration and measurement reporting procedures possible, the RRC gets enhanced to support serialization and deserialization of the RRC message structures carrying secondary-carrier info โ like, if the RRCConnectionReconfiguration message includes the sCellToAddModList structure, then SCell addition or modification gets performed, or if it contains measConfig, then measurement reporting gets configured. โจ
To allow transmission of all that, these structures are implemented for the sCell: RadioResourceConfigCommonSCell, RadioResourceConfigDedicatedSCell, PhysicalConfigDedicatedSCell and NonCriticalExtensionConfiguration. RadioResourceConfigCommonSCell and RadioResourceConfigDedicatedSCell handle SCell addition and modification (see TS 36.331, 5.3.10.3b). PhysicalConfigDedicatedSCell handles physical channel reconfiguration (see TS 36.331, 5.3.10.6). And NonCriticalExtensionConfiguration carries the info of sCellToAddModeList and sCellToReleaseList, which is a modified structure compared to TS 36.331, 6.6.2 โ because according to that spec, these live directly in the root of the RRCConnectionReconfiguration message. Measurement reporting gets extended with the measResultSCell structure so it can include RSRP and RSRQ measurements for every configured SCell. But heads up: the measurement report triggering event A6 (neighbour becomes offset better than SCell) is not implemented yet. ๐ซ
[image] A schematic overview of the secondary carrier enabling procedure.
๐ธ Impact on PCDCP layer ๐ธ
There is no impact on PDCP layer. That's it, that's the section. Ate and left no crumbs. ๐
๐ Impact on RLC layer ๐
The impact on the RLC layer is relatively small, bestie. There's some impact on configuration of the buffer and on the usage of SAP interfaces between RLC and MAC. Since the capacity of the lower layers increases with carrier aggregation, you gotta adjust the size of the RLC buffer to match. But honestly the impact on the actual RLC layer implementation is very small, and that's thanks to a design choice that lets the CCM manager serve the different RLC instances through the LteMacSapProvider interface. Because of that choice, the RLC is using the same interface as in the earlier LTE module architecture โ the LteMacSapProvider โ but the actual SAP provider in the new architecture is the CCM (some class that inherits LteEnbComponentCarrierManager). The CCM is basically acting as a proxy: it receives function calls meant for the MAC and forwards them to the MAC of the different component carriers. Plus it uses the info about the UEs and the logical channels for its own functionalities. โจ
๐ฅ Impact on MAC layer ๐ฅ
The impact on the MAC layer depends on which CA scheduling scheme is in use. Two different scheduling schemes are proposed in R10, and they're shown in figure CA scheduling schemes (from 3gpp.org).
[image] CA scheduling schemes (from 3gpp.org).
The CIF (Carrier Indicator Field) on PDCCH โ that's the red area โ tells you on which carrier the scheduled resource is located. Now let's describe both the schemes:
a. scheduling grant and resources on the same carrier. One PDCCH is supported per carrier.
b. cross-carrier scheduling: it is used to schedule resources on the secondary carrier without PDCCH.
The current implementation covers only option 1, so there is no cross-carrier scheduling, periodt. The MAC layer of the eNodeB has suffered minor changes, and they're mainly related to adding component carrier information in the message exchange between layers.
๐ Impact on PHY layer ๐
The impact on PHY layer is minor, ngl. There's one instance of PHY layer per each component carrier, and the SAP interface functions remain unchanged. As shown in CA scheduling schemes (from 3gpp.org), the difference is that since there are multiple PHY instances, there are also multiple instances of PDCCH, HARQ, ACK/NACK and CSI per carrier. So at the eNB PHY, the changes are about adding the component carrier id information. At the UE PHY, the Component Carrier info gets used for some functionalities that depend on the Component Carrier the PHY instance belongs to. For example, the UE PHY is extended to allow disabling of the sounding reference signal (SRS) at the secondary carriers. This is necessary because there's one UE PHY instance per component carrier, but according to CA scheduling schemes (from 3gpp.org), only a single carrier is used and the uplink traffic is transmitted only over the primary carrier. ๐
๐ฆ Code Structure Design ๐ฆ
This section briefly introduces the software design and implementation of the carrier aggregation functionality.
Both LteEnbNetDevice and LteUeNetDevice are created by the LteHelper using the method InstallSingleEnbDevice and InstallSingleUeDevice. These functions are now extended to allow the carrier aggregation configuration. Below we explain the main differences compared to the previous architecture.
Figure Changes in LteEnbNetDevice to support CA shows the attributes and associations of the LteEnbNetDevice that are affected by the implementation, or are created in order to support the carrier aggregation functionality. Since LteEnbNetDevice may have several component carriers, the attributes that were formerly part of the LteEnbNetDevice and are carrier specific get migrated to the ComponentCarrier class, e.g. physical layer configuration parameters. The attributes that are specific for the eNB component carrier get migrated to ComponentCarrierEnb, e.g. pointers to MAC, PHY, scheduler, fractional frequency reuse instances. LteEnbNetDevice can contain pointers to several ComponentCarrierEnb instances. This architecture lets each CC have its own configuration for PHY, MAC, scheduling algorithm and franctional frequency reuse algorithm. These attributes are currently maintained also in the LteEnbNetDevice for backward compatibility purpose. By default the LteEnbNetDevice attributes are the same as the primary carrier attributes.
[image] Changes in LteEnbNetDevice to support CA.
Figure Changes in LteUeNetDevice to support CA shows the attributes and associations of LteUeNetDevice that are affected by the carrier aggregation implementation. Similarly to the changes in LteEnbNetDevice, pointers that are specific to UE component carrier get migrated to the ComponentCarrierUe class. LteUeNetDevice has maintained m_dlEarfcn for initial cell selection purposes.
[image] Changes in LteUeNetDevice to support CA.
๐ CA impact on data plane of eNodeB ๐
Figure eNB Data Plane Architecture shows the class diagram of the data plane at the eNB.
The main impact is the insertion of the LteEnbComponentCarrierManager class in the middle of the LTE protocol stack. During the design phase it was decided to keep the same SAP interfaces design that existed between MAC and RLC, so nobody would have to make unnecessary changes in these parts of the protocol stack. To achieve this, the LteEnbComponentCarrierManager implements all functions that were previously exposed by RLC to MAC through the LteMacSapUser interface. It also implements functions that were previously exposed by MAC to RLC through the LteMacSapProvider interface. This way, the carrier aggregation is transparent to the upper and lower layers. The only difference is that the MAC instance now sees only one LteMacSapUser, whereas formerly it was seeing only one LteMacSapUser per RLC instance.
The LteEnbComponentCarrierManager is responsible for forwarding messages in both directions. In the current implementation, a PDCP and an RLC instance are activated each time a new data radio bearer is configured. The correspondence between a new data radio bearer and an RLC instance is one to one. To maintain the same behavior, when a new logical channel is activated, the logical channel configuration is propagated to each MAC layer object in "as is" fashion. ๐
[image] eNB Data Plane Architecture.
Figure Sequence Diagram of downlink buffer status reporting (BSR) with CA shows a sequence diagram of downlink buffer status reporting with a carrier aggregation implementation of only one secondary carrier. Each time an RLC instance sends a buffer status report (BSR), the LteEnbComponentCarrierManager propagates the BSR to the MAC instances. The LteEnbComponentCarrierManager may modify a BSR before sending it to the MAC instances. This modification depends on the traffic split algorithm implemented in the CCM class that inherits LteEnbComponentCarrierManager.
[image] Sequence Diagram of downlink buffer status reporting (BSR) with CA.
โจ CA impact on control plane of eNodeB โจ
Figure eNB Control Plane Architecture shows the class diagram of the control plane at the eNB. So during the design phase, bestie, it was decided to keep the same hooks as in the former architecture ๐
. To do that, at each component carrier the PHY and the MAC are directly associated to the RRC instance. BUT โ and this is the plot twist โ the RRC instance is additionally connected to the LteEnbComponentCarrierManager, which is the one responsible for enabling and disabling the component carriers ๐. When the simulation starts, the number of component carriers is fixed, but only the primary carrier component is enabled. Depending on the LteEnbComponentCarrierManager algorithm, the other carrier components could be activated or not.
[image] eNB Control Plane Architecture.
Figure Sequence Diagram of Data Radio Bearer Setup shows how the Radio Bearer are configured.
[image] Sequence Diagram of Data Radio Bearer Setup.
๐ธ CA impact on data plane of UE ๐ธ
Figure UE Data Plane Architecture shows the relation between the different classes related to the UE data plane. The UE data plane architecture is similar to the eNB data plane implementation, lowkey twins fr fr. The LteUeComponentCarrierManager is responsible to (re)map each MacSapUserProvider to the corresponding RLC instance or to the proper MAC instance. The channel remapping depends on the algorithm used as LteUeComponentCarrierManager.
A particular case is represented by the UE buffer status report (BSR) to eNB. And the way that this goes is: since i) the standard does not specify how the BSR has to be reported on each component carrier and ii) it is decided to map one-to-one the logical channel to each MAC layer, the only way to send BSRs to the eNB is through the primary carrier ๐ค. Figure Uplink buffer status reporting with CA shows the sequence diagram. Each time a BSR is generated, the LteUeComponentCarrierManager sends it through the primary carrier component. When the primary component carrier at the eNB receives the BSR, it sends it to LteEnbComponentCarrierManager. The latter, according to algorithm dependent policies, forwards a BSR to component carriers. The communication between the LteEnbMac and the LteEnbComponentCarrierManager is done through a specific set of SAP functions which are implemented in the LteUlCcmRrcSapUser and the LteUlCcmRrcSapProvider.
[image] UE Data Plane Architecture. [image] Uplink buffer status reporting with CA.
๐ CA impact on control plane of UE ๐
Figure UE Control Plane Architecture shows the relation between the different classes associated to the UE control plane. The control plane implementation at the UE is basically the same as the eNB control plane implementation, no cap. Each component carrier control SAP (both for PHY and MAC layer objects) is linked in a one-to-one fashion directly to the RRC instance. The Ue RRC instance is then connected to the LteUeComponentCarrierManager in the same way as in the eNB.
[image] UE Control Plane Architecture.
CCHelper is the class that is implemented to help the configuration of the physical layer parameters, such as uplink and downlink,bandwidth and EARFCN of each carrier.
๐ CCM RRC MAC interfaces ๐
The Component carrier manager (CCM) is also developed by using the SAP interface design. The following SAP interfaces are implemented for CCM and MAC:
- the
LteCcmMacSapUserpart is provided by MAC and is used by the CCM - the
LteCcmMacSapProviderpart is provided by CCM and is used by the MAC layer
When the primary component carrier receives an uplink BSR it uses the LteCcmMacSapUser to forward it to the CCM, which should decide how to split the traffic corresponding to this BSR among carriers. Once this decision is made, the CCM uses the LteCcmMacSapProvider interface to send back an uplink BSR to some of the MAC instances. Additionally, the LteCcmMacSapUser can be used by the MAC to notify about the PRB occupancy in the downlink to the CCM. This information may be used by the CCM to decide how to split the traffic and whether to use the secondary carriers. Iconic behaviour honestly ๐
๐ฆ CCM RRC SAP interfaces ๐ฆ
The following SAP interfaces are implemented for CCM and RRC:
- the
LteCcmRrcSapProvideris provided by the CCM and is used by the RRC layer - the
LteCcmRrcSapUseris provided by RRC and is used by the CCM
By using the LteCcmRrcSapUser the CCM may request a specific measurement reporting configuration to be fulfilled by the UEs attached to the eNB. When a UE measurement report is received, as a result of this configuration, the eNB RRC entity shall forward this report to the CCM through the LteCcmRrcSapProvider::ReportUeMeas SAP function. Additionally, the LteCcmRrcSapProvider offers different functions to the RRC that can be used to add and remove of UEs, setup or release of radio bearer, configuration of the signalling bearer, etc.
๐ Component carrier managers ๐
Currently, there are two component carrier manager implementations available. The first one is the NoOpComponentCarrierManager, which is the default CCM choice. When this CCM is used the carrier aggregation feature is disabled ๐ซ. This CCM forwards all traffic, the uplink and the downlink, over the primary carrier, and does not use secondary carriers. Another implementation is the RrComponentCarrierManager, which splits the traffic equally among carriers, by diving the buffer status report among different carriers. SRB0 and SRB1 flows will be forwarded only over primary carrier.
๐ง Helpers ๐ง
Two helper objects are used to setup simulations and configure the various components. These objects are:
LteHelper, which takes care of the configuration of the LTE radio access network, as well as of coordinating the setup and release of EPS bearers. TheLteHelperclass provides both the API definition and its implementation.EpcHelper, which takes care of the configuration of the Evolved Packet Core. TheEpcHelperclass is an abstract base class, which only provides the API definition; the implementation is delegated to the child classes in order to allow for different EPC network models.
A third helper object is used to configure the Carrier Aggregation functionality:
CcHelper, which takes care of the configuration of theLteEnbComponentCarrierMap, basically, it creates a user specified number ofLteEnbComponentCarrier.LteUeComponentCarrierMapis currently created starting from theLteEnbComponentCarrierMap.LteHelper:InstallSingleUeDevice, in this implementation, is needed to invoke after theLteHelper:InstallSingleEnbDeviceto ensure that theLteEnbComponentCarrierMapis properly initialized.
It is possible to create a simple LTE-only simulations by using the LteHelper alone, or to create complete LTE-EPC simulations by using both LteHelper and EpcHelper. When both helpers are used, they interact in a master-slave fashion, with the LteHelper being the Master that interacts directly with the user program, and the EpcHelper working โunder the hoodโ to configure the EPC upon explicit methods called by the LteHelper. The exact interactions are displayed in the Figure Sequence diagram of the interaction between LteHelper and EpcHelper..
[image] Sequence diagram of the interaction betweenLteHelperandEpcHelper..
๐ User Documentation ๐
๐ Background ๐
We assume the reader is already familiar with how to use the ns-3 simulator to run generic simulation programs. If this is not the case, we strongly recommend the reader to consult [ns3tutorial]. Bestie, please go read it, I'm begging ๐ญ
โญ Usage Overview โญ
The ns-3 LTE model is a software library that allows the simulation of LTE networks, optionally including the Evolved Packet Core (EPC). The process of performing such simulations typically involves the following steps:
- Define the scenario to be simulated
- Write a simulation program that recreates the desired scenario topology/architecture. This is done accessing the ns-3 LTE model library using the
ns3::LteHelperAPI defined insrc/lte/helper/lte-helper.h. - Specify configuration parameters of the objects that are being used for the simulation. This can be done using input files (via the
ns3::ConfigStore) or directly within the simulation program. - Configure the desired output to be produced by the simulator
- Run the simulation.
All these aspects will be explained in the following sections by means of practical examples. Periodt ๐
๐ Basic simulation program ๐
Here is the minimal simulation program that is needed to do an LTE-only simulation (without EPC).
- Initial boilerplate:
#include <ns3/core-module.h>
#include <ns3/network-module.h>
#include <ns3/mobility-module.h>
#include <ns3/lte-module.h>
using namespace ns3;
int main (int argc, char *argv[])
{
// the rest of the simulation program follows
- Create an
LteHelperobject:
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
This will instantiate some common objects (e.g., the Channel object) and provide the methods to add eNBs and UEs and configure them.
- Create
Nodeobjects for the eNB(s) and the UEs:
NodeContainer enbNodes;
enbNodes.Create (1);
NodeContainer ueNodes;
ueNodes.Create (2);
Note that the above Node instances at this point still donโt have an LTE protocol stack installed; theyโre just empty nodes. Like, absolutely nothing going on upstairs yet ๐
- Configure the Mobility model for all the nodes:
MobilityHelper mobility;
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (enbNodes);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (ueNodes);
The above will place all nodes at the coordinates (0,0,0). Please refer to the documentation of the ns-3 mobility model for how to set your own position or configure node movement.
- Install an LTE protocol stack on the eNB(s):
NetDeviceContainer enbDevs;
enbDevs = lteHelper->InstallEnbDevice (enbNodes);
- Install an LTE protocol stack on the UEs:
NetDeviceContainer ueDevs;
ueDevs = lteHelper->InstallUeDevice (ueNodes);
- Attach the UEs to an eNB. This will configure each UE according to the eNB configuration, and create an RRC connection between them:
lteHelper->Attach (ueDevs, enbDevs.Get (0));
- Activate a data radio bearer between each UE and the eNB it is attached to:
enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
EpsBearer bearer (q);
lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
okay so this method will also activate two saturation traffic generators for that bearer โ one in uplink and one in downlink. bestie it's giving โจdual vibesโจ
- Set the stop time:
Simulator::Stop (Seconds (0.005));
fr fr you NEED this โ otherwise the simulation will last forever ๐ญ because (among others) the start-of-subframe event is scheduled repeatedly, and the ns-3 simulator scheduler will hence never run out of events. it just keeps going. iconic but no ๐
- Run the simulation:
Simulator::Run ();
- Cleanup and exit:
Simulator::Destroy ();
return 0;
}
For how to compile and run simulation programs, please refer to [ns3tutorial] ๐
๐ Configuration of LTE model parameters ๐
All the relevant LTE model parameters are managed through the ns-3 attribute system. Please refer to [ns3tutorial] and [ns3manual] for detailed information on all the possible methods to do it (environmental variables, C++ API, GtkConfigStoreโฆ). so many options, so much slay
In the following, we just briefly summarize how to do it using input files together with the ns-3 ConfigStore. First of all, you need to put the following in your simulation program, right after main () starts:
CommandLine cmd (__FILE__);
cmd.Parse (argc, argv);
ConfigStore inputConfig;
inputConfig.ConfigureDefaults ();
// parse again so you can override default values from the command line
cmd.Parse (argc, argv);
for the above to work, make sure you also #include "ns3/config-store.h". ๐ซถ Now create a text file named (for example) input-defaults.txt specifying the new default values that you want to use for some attributes:
default ns3::LteHelper::Scheduler "ns3::PfFfMacScheduler"
default ns3::LteHelper::PathlossModel "ns3::FriisSpectrumPropagationLossModel"
default ns3::LteEnbNetDevice::UlBandwidth "25"
default ns3::LteEnbNetDevice::DlBandwidth "25"
default ns3::LteEnbNetDevice::DlEarfcn "100"
default ns3::LteEnbNetDevice::UlEarfcn "18100"
default ns3::LteUePhy::TxPower "10"
default ns3::LteUePhy::NoiseFigure "9"
default ns3::LteEnbPhy::TxPower "30"
default ns3::LteEnbPhy::NoiseFigure "5"
Supposing your simulation program is called src/lte/examples/lte-sim-with-input, you can now pass these settings to the simulation program in the following way:
./waf --command-template="%s --ns3::ConfigStore::Filename=input-defaults.txt
--ns3::ConfigStore::Mode=Load --ns3::ConfigStore::FileFormat=RawText"
--run src/lte/examples/lte-sim-with-input
Furthermore, you can generate a template input file with the following command:
./waf --command-template="%s --ns3::ConfigStore::Filename=input-defaults.txt
--ns3::ConfigStore::Mode=Save --ns3::ConfigStore::FileFormat=RawText"
--run src/lte/examples/lte-sim-with-input
note that the above will put in the file input-defaults.txt all the default values that are registered in your particular build of the simulator, including lots of non-LTE attributes. ๐ญ not it dumping everything on you but okay we move
๐ Configure LTE MAC Scheduler ๐
There are several types of LTE MAC scheduler user can choose here. User can use following codes to define scheduler type:
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
lteHelper->SetSchedulerType ("ns3::FdMtFfMacScheduler"); // FD-MT scheduler
lteHelper->SetSchedulerType ("ns3::TdMtFfMacScheduler"); // TD-MT scheduler
lteHelper->SetSchedulerType ("ns3::TtaFfMacScheduler"); // TTA scheduler
lteHelper->SetSchedulerType ("ns3::FdBetFfMacScheduler"); // FD-BET scheduler
lteHelper->SetSchedulerType ("ns3::TdBetFfMacScheduler"); // TD-BET scheduler
lteHelper->SetSchedulerType ("ns3::FdTbfqFfMacScheduler"); // FD-TBFQ scheduler
lteHelper->SetSchedulerType ("ns3::TdTbfqFfMacScheduler"); // TD-TBFQ scheduler
lteHelper->SetSchedulerType ("ns3::PssFfMacScheduler"); //PSS scheduler
eight schedulers, pick your main character โจ
TBFQ and PSS have more parameters than other schedulers. Users can define those parameters in following way:
- TBFQ scheduler::
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
lteHelper->SetSchedulerAttribute("DebtLimit", IntegerValue(yourvalue)); // default value -625000 bytes (-5Mb)
lteHelper->SetSchedulerAttribute("CreditLimit", UintegerValue(yourvalue)); // default value 625000 bytes (5Mb)
lteHelper->SetSchedulerAttribute("TokenPoolSize", UintegerValue(yourvalue)); // default value 1 byte
lteHelper->SetSchedulerAttribute("CreditableThreshold", UintegerValue(yourvalue)); // default value 0
- PSS scheduler::
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
lteHelper->SetSchedulerAttribute("nMux", UIntegerValue(yourvalue)); // the maximum number of UE selected by TD scheduler
lteHelper->SetSchedulerAttribute("PssFdSchedulerType", StringValue("CoItA")); // PF scheduler type in PSS
In TBFQ, default values of debt limit and credit limit are set to -5Mb and 5Mb respectively based on paper [FABokhari2009]. cited, we love a receipts moment ๐ Current implementation does not consider credit threshold (C = 0). In PSS, if user does not define nMux, PSS will set this value to half of total UE. The default FD scheduler is PFsch.
In addition, token generation rate in TBFQ and target bit rate in PSS need to be configured by Guarantee Bit Rate (GBR) or Maximum Bit Rate (MBR) in epc bearer QoS parameters. Users can use following codes to define GBR and MBR in both downlink and uplink:
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
enum EpsBearer::Qci q = EpsBearer::yourvalue; // define Qci type
GbrQosInformation qos;
qos.gbrDl = yourvalue; // Downlink GBR
qos.gbrUl = yourvalue; // Uplink GBR
qos.mbrDl = yourvalue; // Downlink MBR
qos.mbrUl = yourvalue; // Uplink MBR
EpsBearer bearer (q, qos);
lteHelper->ActivateDedicatedEpsBearer (ueDevs, bearer, EpcTft::Default ());
In PSS, TBR is obtained from GBR in bearer level QoS parameters. In TBFQ, token generation rate is obtained from the MBR setting in bearer level QoS parameters, which therefore needs to be configured consistently. the way that consistency MATTERS here For constant bit rate (CBR) traffic, it is suggested to set MBR to GBR. For variance bit rate (VBR) traffic, it is suggested to set MBR k times larger than GBR in order to cover the peak traffic rate. In current implementation, k is set to three based on paper [FABokhari2009]. In addition, current version of TBFQ does not consider RLC header and PDCP header length in MBR and GBR. Another parameter in TBFQ is packet arrival rate. This parameter is calculated within scheduler and equals to the past average throughput which is used in PF scheduler.
Many useful attributes of the LTE-EPC model will be described in the following subsections. Still, there are many attributes which are not explicitly mentioned in the design or user documentation, but which are clearly documented using the ns-3 attribute system. You can easily print a list of the attributes of a given object together with their description and default value passing --PrintAttributes= to a simulation program, like this:
./waf --run lena-simple --command-template="%s --PrintAttributes=ns3::LteHelper"
You can try also with other LTE and EPC objects, like this:
./waf --run lena-simple --command-template="%s --PrintAttributes=ns3::LteEnbNetDevice"
./waf --run lena-simple --command-template="%s --PrintAttributes=ns3::LteEnbMac"
./waf --run lena-simple --command-template="%s --PrintAttributes=ns3::LteEnbPhy"
./waf --run lena-simple --command-template="%s --PrintAttributes=ns3::LteUePhy"
./waf --run lena-simple --command-template="%s --PrintAttributes=ns3::PointToPointEpcHelper"
go poke around, it's giving treasure hunt ๐
๐ Simulation Output ๐
The ns-3 LTE model currently supports the output to file of PHY, MAC, RLC and PDCP level Key Performance Indicators (KPIs). You can enable it in the following way:
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
// configure all the simulation scenario here...
lteHelper->EnablePhyTraces ();
lteHelper->EnableMacTraces ();
lteHelper->EnableRlcTraces ();
lteHelper->EnablePdcpTraces ();
Simulator::Run ();
RLC and PDCP KPIs are calculated over a time interval and stored on ASCII files, two for RLC KPIs and two for PDCP KPIs, in each case one for uplink and one for downlink. The time interval duration can be controlled using the attribute ns3::RadioBearerStatsCalculator::EpochDuration.
The columns of the RLC KPI files is the following (the same for uplink and downlink):
- start time of measurement interval in seconds since the start of simulation
- end time of measurement interval in seconds since the start of simulation
- Cell ID
- unique UE ID (IMSI)
- cell-specific UE ID (RNTI)
- Logical Channel ID
- Number of transmitted RLC PDUs
- Total bytes transmitted.
- Number of received RLC PDUs
- Total bytes received
- Average RLC PDU delay in seconds
- Standard deviation of the RLC PDU delay
- Minimum value of the RLC PDU delay
- Maximum value of the RLC PDU delay
- Average RLC PDU size, in bytes
- Standard deviation of the RLC PDU size
- Minimum RLC PDU size
- Maximum RLC PDU size
eighteen columns bestie, we are NOT skimming ๐
Similarly, the columns of the PDCP KPI files is the following (again, the same for uplink and downlink):
- start time of measurement interval in seconds since the start of simulation
- end time of measurement interval in seconds since the start of simulation
- Cell ID
- unique UE ID (IMSI)
- cell-specific UE ID (RNTI)
- Logical Channel ID
- Number of transmitted PDCP PDUs
- Total bytes transmitted.
- Number of received PDCP PDUs
- Total bytes received
- Average PDCP PDU delay in seconds
- Standard deviation of the PDCP PDU delay
- Minimum value of the PDCP PDU delay
- Maximum value of the PDCP PDU delay
- Average PDCP PDU size, in bytes
- Standard deviation of the PDCP PDU size
- Minimum PDCP PDU size
- Maximum PDCP PDU size
Note: The PDCP traces for data radio bearers are not generated when sec-sm-rlc is used. ๐
MAC KPIs are basically a trace of the resource allocation reported by the scheduler upon the start of every subframe. They are stored in ASCII files. For downlink MAC KPIs the format is the following:
- Simulation time in seconds at which the allocation is indicated by the scheduler
- Cell ID
- unique UE ID (IMSI)
- Frame number
- Subframe number
- cell-specific UE ID (RNTI)
- MCS of TB 1
- size of TB 1
- MCS of TB 2 (0 if not present)
- size of TB 2 (0 if not present)
while for uplink MAC KPIs the format is:
- Simulation time in seconds at which the allocation is indicated by the scheduler
- Cell ID
- unique UE ID (IMSI)
- Frame number
- Subframe number
- cell-specific UE ID (RNTI)
- MCS of TB
- size of TB
The names of the files used for MAC KPI output can be customized via the ns-3 attributes ns3::MacStatsCalculator::DlOutputFilename and ns3::MacStatsCalculator::UlOutputFilename. โจ
PHY KPIs are distributed in seven different files, configurable through the attributes:
ns3::PhyStatsCalculator::DlRsrpSinrFilenamens3::PhyStatsCalculator::UeSinrFilenamens3::PhyStatsCalculator::InterferenceFilenamens3::PhyStatsCalculator::DlTxOutputFilenamens3::PhyStatsCalculator::UlTxOutputFilenamens3::PhyStatsCalculator::DlRxOutputFilenamens3::PhyStatsCalculator::UlRxOutputFilename
In the RSRP/SINR file, the following content is available:
- Simulation time in seconds at which the allocation is indicated by the scheduler
- Cell ID
- unique UE ID (IMSI)
- RSRP
- Linear average over all RBs of the downlink SINR in linear units
The contents in the UE SINR file are:
- Simulation time in seconds at which the allocation is indicated by the scheduler
- Cell ID
- unique UE ID (IMSI)
- uplink SINR in linear units for the UE
In the interference filename the content is:
- Simulation time in seconds at which the allocation is indicated by the scheduler
- Cell ID
- List of interference values per RB
In UL and DL transmission files the parameters included are:
- Simulation time in milliseconds
- Cell ID
- unique UE ID (IMSI)
- RNTI
- Layer of transmission
- MCS
- size of the TB
- Redundancy version
- New Data Indicator flag
And finally, in UL and DL reception files the parameters included are:
- Simulation time in milliseconds
- Cell ID
- unique UE ID (IMSI)
- RNTI
- Transmission Mode
- Layer of transmission
- MCS
- size of the TB
- Redundancy version
- New Data Indicator flag
- Correctness in the reception of the TB
Note: The traces generated by simulating the scenarios involving the RLF will have a discontinuity in time from the moment of the RLF event until the UE connects again to an eNB. ๐
๐ฆ Fading Trace Usage ๐ฆ
In this section we will describe how to use fading traces within LTE simulations. Let's go, bestie. ๐
๐ธ Fading Traces Generation ๐ธ
It is possible to generate fading traces by using a dedicated matlab script provided with the code (/lte/model/fading-traces/fading-trace-generator.m). This script already includes the typical taps configurations for three 3GPP scenarios (i.e., pedestrian, vehicular and urban as defined in Annex B.2 of [TS36104]); however users can also introduce their specific configurations. The list of the configurable parameters is provided in the following:
fc: the frequency in use (it affects the computation of the doppler speed).v_km_h: the speed of the userstraceDuration: the duration in seconds of the total length of the trace.numRBs: the number of the resource block to be evaluated.tag: the tag to be applied to the file generated.
The file generated contains ASCII-formatted real values organized in a matrix fashion: every row corresponds to a different RB, and every column correspond to a different temporal fading trace sample. ๐ง
It has to be noted that the ns-3 LTE module is able to work with any fading trace file that complies with the above described ASCII format. Hence, other external tools can be used to generate custom fading traces, such as for example other simulators or experimental devices. ๐
๐ Fading Traces Usage ๐
When using a fading trace, it is of paramount importance to specify correctly the trace parameters in the simulation, so that the fading model can load and use it correctly. The parameters to be configured are:
TraceFilename: the name of the trace to be loaded (absolute path, or relative path w.r.t. the path from where the simulation program is executed);TraceLength: the trace duration in seconds;SamplesNum: the number of samples;WindowSize: the size of the fading sampling window in seconds;
It is important to highlight that the sampling interval of the fading trace has to be 1 ms or greater, and in the latter case it has to be an integer multiple of 1 ms in order to be correctly processed by the fading module.
The default configuration of the matlab script provides a trace 10 seconds long, made of 10,000 samples (i.e., 1 sample per TTI=1ms) and used with a windows size of 0.5 seconds amplitude. These are also the default values of the parameters above used in the simulator; therefore their settage can be avoided in case the fading trace respects them. โจ
In order to activate the fading module (which is not active by default) the following code should be included in the simulation program:
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
lteHelper->SetFadingModel("ns3::TraceFadingLossModel");
And for setting the parameters:
lteHelper->SetFadingModelAttribute ("TraceFilename", StringValue ("src/lte/model/fading-traces/fading_trace_EPA_3kmph.fad"));
lteHelper->SetFadingModelAttribute ("TraceLength", TimeValue (Seconds (10.0)));
lteHelper->SetFadingModelAttribute ("SamplesNum", UintegerValue (10000));
lteHelper->SetFadingModelAttribute ("WindowSize", TimeValue (Seconds (0.5)));
lteHelper->SetFadingModelAttribute ("RbNum", UintegerValue (100));
It has to be noted that, TraceFilename does not have a default value, therefore is has to be always set explicitly. ๐
The simulator provide natively three fading traces generated according to the configurations defined in in Annex B.2 of [TS36104]. These traces are available in the folder src/lte/model/fading-traces/). An excerpt from these traces is represented in the following figures.
- [image: Fading trace 3 kmph] [image] Excerpt of the fading trace included in the simulator for a pedestrian scenario (speed of 3 kmph).
- [image: Fading trace 60 kmph] [image] Excerpt of the fading trace included in the simulator for a vehicular scenario (speed of 60 kmph).
- [image: Fading trace 3 kmph] [image] Excerpt of the fading trace included in the simulator for an urban scenario (speed of 3 kmph).
๐ข Mobility Model with Buildings ๐ข
We now explain by examples how to use the buildings model (in particular, the MobilityBuildingInfo and the BuildingPropagationModel classes) in an ns-3 simulation program to setup an LTE simulation scenario that includes buildings and indoor nodes. ๐ซถ
- Header files to be included:
#include <ns3/mobility-building-info.h>
#include <ns3/buildings-propagation-loss-model.h>
#include <ns3/building.h>
- Pathloss model selection:
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::BuildingsPropagationLossModel"));
- EUTRA Band Selection
The selection of the working frequency of the propagation model has to be done with the standard ns-3 attribute system as described in the correspond section ("Configuration of LTE model parameters") by means of the DlEarfcn and UlEarfcn parameters, for instance:
lteHelper->SetEnbDeviceAttribute ("DlEarfcn", UintegerValue (100));
lteHelper->SetEnbDeviceAttribute ("UlEarfcn", UintegerValue (18100));
It is to be noted that using other means to configure the frequency used by the propagation model (i.e., configuring the corresponding BuildingsPropagationLossModel attributes directly) might generates conflicts in the frequencies definition in the modules during the simulation, and is therefore not advised. ๐ญ
- Mobility model selection:
MobilityHelper mobility;
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
It is to be noted that any mobility model can be used.
- Building creation:
double x_min = 0.0;
double x_max = 10.0;
double y_min = 0.0;
double y_max = 20.0;
double z_min = 0.0;
double z_max = 10.0;
Ptr<Building> b = CreateObject <Building> ();
b->SetBoundaries (Box (x_min, x_max, y_min, y_max, z_min, z_max));
b->SetBuildingType (Building::Residential);
b->SetExtWallsType (Building::ConcreteWithWindows);
b->SetNFloors (3);
b->SetNRoomsX (3);
b->SetNRoomsY (2);
This will instantiate a residential building with base of 10 x 20 meters and height of 10 meters whose external walls are of concrete with windows; the building has three floors and has an internal 3 x 2 grid of rooms of equal size.
- Node creation and positioning:
ueNodes.Create (2);
mobility.Install (ueNodes);
BuildingsHelper::Install (ueNodes);
NetDeviceContainer ueDevs;
ueDevs = lteHelper->InstallUeDevice (ueNodes);
Ptr<ConstantPositionMobilityModel> mm0 = enbNodes.Get (0)->GetObject<ConstantPositionMobilityModel> ();
Ptr<ConstantPositionMobilityModel> mm1 = enbNodes.Get (1)->GetObject<ConstantPositionMobilityModel> ();
mm0->SetPosition (Vector (5.0, 5.0, 1.5));
mm1->SetPosition (Vector (30.0, 40.0, 1.5));
- Finalize the building and mobility model configuration:
BuildingsHelper::MakeMobilityModelConsistent ();
See the documentation of the buildings module for more detailed information. ๐
๐ฅ PHY Error Model ๐ฅ
The Physical error model consists of the data error model and the downlink control error model, both of them active by default. It is possible to deactivate them with the ns3 attribute system, in detail:
Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
๐ MIMO Model ๐
Is this subsection we illustrate how to configure the MIMO parameters. LTE defines 7 types of transmission modes:
- Transmission Mode 1: SISO.
- Transmission Mode 2: MIMO Tx Diversity.
- Transmission Mode 3: MIMO Spatial Multiplexity Open Loop.
- Transmission Mode 4: MIMO Spatial Multiplexity Closed Loop.
- Transmission Mode 5: MIMO Multi-User.
- Transmission Mode 6: Closer loop single layer precoding.
- Transmission Mode 7: Single antenna port 5.
Ok so the model as implemented ships with the first three transmission mode types, and the default one is Transmission Mode 1 (SISO). Wanna change which one is the default? There's an attribute for that: DefaultTransmissionMode on the LteEnbRrc. Like this:
Config::SetDefault ("ns3::LteEnbRrc::DefaultTransmissionMode", UintegerValue (0)); // SISO
Config::SetDefault ("ns3::LteEnbRrc::DefaultTransmissionMode", UintegerValue (1)); // MIMO Tx diversity (1 layer)
Config::SetDefault ("ns3::LteEnbRrc::DefaultTransmissionMode", UintegerValue (2)); // MIMO Spatial Multiplexity (2 layers)
And if you wanna switch the transmission mode for one specific user while the simulation is running, both of the standard schedulers got a lil interface for that ๐ :
void TransmissionModeConfigurationUpdate (uint16_t rnti, uint8_t txMode);
You can use this method for two things: building a transmission mode decision engine (aka optimizing the transmission mode based on channel condition and/or what the user needs), or just manually flipping it from your simulation script. For that manual vibe, the switch looks like this:
Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
PointerValue ptrval;
enbNetDev->GetAttribute ("FfMacScheduler", ptrval);
Ptr<RrFfMacScheduler> rrsched = ptrval.Get<RrFfMacScheduler> ();
Simulator::Schedule (Seconds (0.2), &RrFfMacScheduler::TransmissionModeConfigurationUpdate, rrsched, rnti, 1);
Last thing bestie: the model can be reconfigured for different MIMO models by updating the gain values. The only constraints are that the gain has to be constant during simulation run-time and common for the layers. You change each Transmission Mode's gain through the standard ns3 attribute system, and the attributes are: TxMode1Gain, TxMode2Gain, TxMode3Gain, TxMode4Gain, TxMode5Gain, TxMode6Gain and TxMode7Gain. By default only TxMode1Gain, TxMode2Gain and TxMode3Gain have a meaningful value โ those are the ones derived by _[CatreuxMIMO] (i.e., respectively 0.0, 4.2 and -2.8 dB).
๐ Use of AntennaModel ๐
So now we're gonna show how to associate a particular AntennaModel with an eNB device to model a sector of a macro eNB โจ. For this, it's convenient to use the CosineAntennaModel provided by the ns-3 antenna module. The eNB config happens via the LteHelper instance right before the creation of the EnbNetDevice, like so:
lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel");
lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (0));
lteHelper->SetEnbAntennaModelAttribute ("Beamwidth", DoubleValue (60));
lteHelper->SetEnbAntennaModelAttribute ("MaxGain", DoubleValue (0.0));
That code above generates an antenna model with a 60 degrees beamwidth pointing along the X axis. Orientation is measured in degrees from the X axis โ so an orientation of 90 points along the Y axis, and an orientation of -90 points in the negative direction along the Y axis. Beamwidth is the -3 dB beamwidth: for a 60 degree beamwidth, the antenna gain at an angle of \pm 30 degrees from the direction of orientation is -3 dB.
To create a multi-sector site, you need to create different ns-3 nodes placed at the same position, and configure separate EnbNetDevice with different antenna orientations to be installed on each node ๐ฆ.
๐บ๏ธ Radio Environment Maps ๐บ๏ธ
Using the class RadioEnvironmentMapHelper you can output to a file a Radio Environment Map (REM) โ a uniform 2D grid of values representing the Signal-to-noise ratio in the downlink with respect to the eNB that has the strongest signal at each point ๐. You can specify whether the REM should be generated for data or control channel. Also you can set the RbId that the REM will be generated for. Default RbId is -1, which means the REM gets generated with the averaged Signal-to-noise ratio from all RBs.
To do it, just add this code to your simulation program towards the end, right before the call to Simulator::Run ():
Ptr<RadioEnvironmentMapHelper> remHelper = CreateObject<RadioEnvironmentMapHelper> ();
remHelper->SetAttribute ("Channel", PointerValue (lteHelper->GetDownlinkSpectrumChannel ()));
remHelper->SetAttribute ("OutputFile", StringValue ("rem.out"));
remHelper->SetAttribute ("XMin", DoubleValue (-400.0));
remHelper->SetAttribute ("XMax", DoubleValue (400.0));
remHelper->SetAttribute ("XRes", UintegerValue (100));
remHelper->SetAttribute ("YMin", DoubleValue (-300.0));
remHelper->SetAttribute ("YMax", DoubleValue (300.0));
remHelper->SetAttribute ("YRes", UintegerValue (75));
remHelper->SetAttribute ("Z", DoubleValue (0.0));
remHelper->SetAttribute ("UseDataChannel", BooleanValue (true));
remHelper->SetAttribute ("RbId", IntegerValue (10));
remHelper->Install ();
By configuring the attributes of the RadioEnvironmentMapHelper object like that, you can tune the parameters of the REM you're generating. Heads up: each RadioEnvironmentMapHelper instance can generate only one REM โ if you want more REMs, you need to create one separate instance for each REM, no cap ๐.
Also note that REM generation is very demanding, in particular:
- the run-time memory consumption is approximately 5KB per pixel. For example, a REM with a resolution of 500x500 would need about 1.25 GB of memory, and a resolution of 1000x1000 would need about 5 GB (too much for a regular PC at the time of this writing). To overcome this issue, the REM is generated at successive steps, with each step evaluating at most a number of pixels determined by the value of the attribute
RadioEnvironmentMapHelper::MaxPointsPerIteration. - if you generate a REM at the beginning of a simulation, it will slow down the execution of the rest of the simulation. If you want to generate a REM for a program and also use the same program to get simulation result, it's recommended to add a command-line switch that allows you to either generate the REM or run the complete simulation. For this purpose, note that there's an attribute
RadioEnvironmentMapHelper::StopWhenDone(default:true) that will force the simulation to stop right after the REM has been generated.
The REM is stored in an ASCII file in this format:
- column 1 is the x coordinate
- column 2 is the y coordinate
- column 3 is the z coordinate
- column 4 is the SINR in linear units
A minimal gnuplot script that lets you plot the REM is given below:
set view map;
set xlabel "X"
set ylabel "Y"
set cblabel "SINR (dB)"
unset key
plot "rem.out" using ($1):($2):(10*log10($4)) with image
As an example, here's the REM you can get with the example program lena-dual-stripe, which shows a three-sector LTE macrocell in a co-channel deployment with some residential femtocells randomly deployed in two blocks of apartments ๐ธ.
๐ผ๏ธ [image] REM obtained from the lena-dual-stripe example.
Not me forgetting the best part: the lena-dual-stripe example program also generates gnuplot-compatible output files containing info about the positions of the UE and eNB nodes as well as of the buildings โ respectively in the files ues.txt, enbs.txt and buildings.txt. These can be easily included when using gnuplot. For example, assuming your gnuplot script (e.g., the minimal gnuplot script described above) is saved in a file named my_plot_script, running the following command would plot the location of UEs, eNBs and buildings on top of the REM:
gnuplot -p enbs.txt ues.txt buildings.txt my_plot_script
๐ถ AMC Model and CQI Calculation ๐ถ
The simulator provides two possible schemes for what concerns the selection of the MCSs and correspondingly the generation of the CQIs โจ. The first one is based on the GSoC module [Piro2011] and works per RB basis. This model can be activated with the ns3 attribute system, as presented in the following:
Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
While the solution based on the physical error model can be controlled with:
Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::MiErrorModel));
Finally, the required efficiency of the PiroEW2010 AMC module can be tuned thanks to the Ber attribute (), for instance:
Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
๐ Evolved Packet Core (EPC) ๐
Now we're explaining how to write a simulation program that lets you simulate the EPC in addition to the LTE radio access network ๐. Using EPC lets you use IPv4 and IPv6 networking with LTE devices. In other words, you'll be able to use the regular ns-3 applications and sockets over IPv4 and IPv6 over LTE, and also to connect an LTE network to any other IPv4 and IPv6 network you might have in your simulation.
First of all โ in addition to LteHelper that we already introduced in Basic simulation program โ you need to use an additional EpcHelper class, which will take care of creating the EPC entities and network topology. Note that you can't use EpcHelper directly, as it is an abstract base class; instead you need to use one of its child classes, which provide different EPC topology implementations ๐ซถ. In this example we'll consider PointToPointEpcHelper, which implements an EPC based on point-to-point links. To use it, you need first to insert this code in your simulation program:
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper> ();
Then you need to tell the LTE helper that the EPC will be used:
lteHelper->SetEpcHelper (epcHelper);
That step above is necessary so that the LTE helper will trigger the appropriate EPC configuration in correspondence with some important configuration, such as when a new eNB or UE is added to the simulation, or an EPS bearer is created. The EPC helper will automatically take care of the necessary setup, such as S1 link creation and S1 bearer setup. All of this gets done without any intervention from the user, iconic behaviour honestly ๐.
Calling lteHelper->SetEpcHelper (epcHelper) enables the use of EPC, and has the side effect that any new LteEnbRrc that is created will have the EpsBearerToRlcMapping attribute set to RLC_UM_ALWAYS instead of RLC_SM_ALWAYS if the latter was the default; otherwise, the attribute won't be changed (e.g., if you changed the default to RLC_AM_ALWAYS, it won't be touched) ๐
.
It's also, like, super important to know that the EpcHelper is gonna auto-magically create the PGW node for you AND configure it so it can actually handle traffic going to/from the LTE radio access network. ๐
But bestie โ you still have to write some explicit code yourself to hook that PGW up to other IPv4/IPv6 networks (think: the internet, or a whole other EPC). No cap.
Here's a very simple example of connecting one single remote host (IPv4 type) to the PGW over a point-to-point link:
Ptr<Node> pgw = epcHelper->GetPgwNode ();
// Create a single RemoteHost
NodeContainer remoteHostContainer;
remoteHostContainer.Create (1);
Ptr<Node> remoteHost = remoteHostContainer.Get (0);
InternetStackHelper internet;
internet.Install (remoteHostContainer);
// Create the internet
PointToPointHelper p2ph;
p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
Ipv4AddressHelper ipv4h;
ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
// interface 0 is localhost, 1 is the p2p device
Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
Ipv4StaticRoutingHelper ipv4RoutingHelper;
Ptr<Ipv4StaticRouting> remoteHostStaticRouting;
remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
remoteHostStaticRouting->AddNetworkRouteTo (epcHelper->GetEpcIpv4NetworkAddress (),
Ipv4Mask ("255.255.0.0"), 1);
Okay so now you go on and create your LTE eNBs and UEs exactly like the previous sections told you to. You can totally also configure other LTE aspects, like pathloss and fading models, slay. ๐ฆ And right after you've created the UEs, you should also set them up for IP networking. It goes like this โ we're assuming you've got a container for UE and eNodeB nodes that looks like:
NodeContainer ueNodes;
NodeContainer enbNodes;
For an LTE-only simulation, you'd normally do something like:
NetDeviceContainer ueLteDevs = lteHelper->InstallUeDevice (ueNodes);
lteHelper->Attach (ueLteDevs, enbLteDevs.Get (0));
But to get those UEs doing IP networking, you just gotta additionally do this:
// we install the IP stack on the UEs
InternetStackHelper internet;
internet.Install (ueNodes);
// assign IP address to UEs
for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
{
Ptr<Node> ue = ueNodes.Get (u);
Ptr<NetDevice> ueLteDevice = ueLteDevs.Get (u);
Ipv4InterfaceContainer ueIpIface;
ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteDevice));
// set the default gateway for the UE
Ptr<Ipv4StaticRouting> ueStaticRouting;
ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ue->GetObject<Ipv4> ());
ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
}
Now โ the way that bearer activation works when EPC is in the picture is slightly different from the LTE-only situation. Three things, okay, write these down bestie:
- First: the method
ActivateDataRadioBeareris not to be used when the EPC is being used. Do not. - Second: when EPC is used, the default EPS bearer gets activated automatically the moment you call
LteHelper::Attach (). Iconic behaviour, honestly. - Third: if you wanna set up a dedicated EPS bearer, you can, using the method
LteHelper::ActivateDedicatedEpsBearer (). This method takes, as a parameter, the Traffic Flow Template (TFT) โ which is a struct that identifies the type of traffic getting mapped onto the dedicated EPS bearer. ๐
Here's an example of setting up a dedicated bearer for an application at the UE that's communicating on port 1234:
Ptr<EpcTft> tft = Create<EpcTft> ();
EpcTft::PacketFilter pf;
pf.localPortStart = 1234;
pf.localPortEnd = 1234;
tft->Add (pf);
lteHelper->ActivateDedicatedEpsBearer (ueLteDevs,
EpsBearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT),
tft);
And yeah, you can of course use custom EpsBearer and EpcTft configurations โ just go check the doxygen documentation for how to do that, iykyk. ๐
Finallyyy, you can install applications on the LTE UE nodes that talk to remote applications over the internet. Standard ns-3 procedures, nothing new. Keeping our simple single-remoteHost example going, here's how to set up downlink communication with a UdpClient application on the remote host and a PacketSink on the LTE UE (using the same variable names as the previous snippets):
uint16_t dlPort = 1234;
PacketSinkHelper packetSinkHelper ("ns3::UdpSocketFactory",
InetSocketAddress (Ipv4Address::GetAny (), dlPort));
ApplicationContainer serverApps = packetSinkHelper.Install (ue);
serverApps.Start (Seconds (0.01));
UdpClientHelper client (ueIpIface.GetAddress (0), dlPort);
ApplicationContainer clientApps = client.Install (remoteHost);
clientApps.Start (Seconds (0.01));
That's all! ๐ You can now start your simulation like you always do:
Simulator::Stop (Seconds (10.0));
Simulator::Run ();
โจ Using the EPC with emulation mode โจ
So in the previous section we used PointToPoint links to connect the eNBs and the SGW (that's the S1-U interface) and also among the eNBs themselves (the X2-U and X2-C interfaces). But bestie โ the LTE module supports using emulated links instead of PointToPoint links. ๐
And the way you turn that on is just by replacing the creation of LteHelper and EpcHelper with this:
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
Ptr<EmuEpcHelper> epcHelper = CreateObject<EmuEpcHelper> ();
lteHelper->SetEpcHelper (epcHelper);
epcHelper->Initialize ();
The attributes ns3::EmuEpcHelper::sgwDeviceName and ns3::EmuEpcHelper::enbDeviceName are what you use to set the name of the devices used for transporting the S1-U, X2-U and X2-C interfaces at the SGW and eNB, respectively. ๐ซถ
Now let's show you how it's done in an example where we run the example program lena-simple-epc-emu using two virtual ethernet interfaces.
First of all, we build ns-3 appropriately:
# configure
./waf configure --enable-sudo --enable-modules=lte,fd-net-device --enable-examples
# build
./waf
Then we set up two virtual ethernet interfaces, and start wireshark so we can stare at the traffic going through:
# note: you need to be root
# create two paired veth devices
ip link add name veth0 type veth peer name veth1
ip link show
# enable promiscuous mode
ip link set veth0 promisc on
ip link set veth1 promisc on
# bring interfaces up
ip link set veth0 up
ip link set veth1 up
# start wireshark and capture on veth0
wireshark &
Heads up bestie: you need to be root for those interface commands. ๐
We can now run the example program with the simulated clock:
./waf --run lena-simple-epc-emu --command="%s --ns3::EmuEpcHelper::sgwDeviceName=veth0
--ns3::EmuEpcHelper::enbDeviceName=veth1"
Using wireshark, you should see ARP resolution happen first, and then some GTP packets getting exchanged in both uplink and downlink. ๐
The default setting of the example program is 1 eNB and 1 UE. You can change that via command line parameters, like:
./waf --run lena-simple-epc-emu --command="%s --ns3::EmuEpcHelper::sgwDeviceName=veth0
--ns3::EmuEpcHelper::enbDeviceName=veth1 --nEnbs=2 --nUesPerEnb=2"
And to get a list of the available parameters:
./waf --run lena-simple-epc-emu --command="%s --PrintHelp"
Now โ running with the realtime clock? Okay so real talk: it turns out the default debug build is just too slow for realtime. ๐ญ And softening the real time constraints with BestEffort mode is not a good idea โ something can go wrong (like, ARP can fail) and if that happens, you won't get any data packets out. So you need decent hardware AND the optimized build with statically linked modules:
./waf configure -d optimized --enable-static --enable-modules=lte --enable-examples
--enable-sudo
Then run the example program like this:
./waf --run lena-simple-epc-emu --command="%s --ns3::EmuEpcHelper::sgwDeviceName=veth0
--ns3::EmuEpcHelper::enbDeviceName=veth1
--SimulatorImplementationType=ns3::RealtimeSimulatorImpl
--ns3::RealtimeSimulatorImpl::SynchronizationMode=HardLimit"
Note the HardLimit setting, bestie โ that's what causes the program to terminate if it can't keep up with real time. ๐
The approach described in this section can be used with any type of net device. For instance, [Baldo2014] describes how it was used to run an emulated LTE-EPC network over a real multi-layer packet-optical transport network. โจ
โจ Custom Backhaul โจ
In the previous sections, Evolved Packet Core (EPC), we explained how to write a simulation program using EPC with a predefined backhaul network between the RAN and the EPC. We used the PointToPointEpcHelper for that โ and this EpcHelper creates point-to-point links between the eNBs and the SGW.
Now we're explaining how to write a simulation program that lets the simulator user create any kind of backhaul network in the simulation program. ๐
First of all, in addition to LteHelper, you need to use the NoBackhaulEpcHelper class โ which implements an EPC but without connecting the eNBs to the core network. It just creates the network elements of the core network:
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
Ptr<NoBackhaulEpcHelper> epcHelper = CreateObject<NoBackhaulEpcHelper> ();
Then, as usual, you need to tell the LTE helper that the EPC is gonna be used:
lteHelper->SetEpcHelper (epcHelper);
Now you should create the backhaul network. Here we're creating point-to-point links the same way PointToPointEpcHelper does it. We assume you've got a container for eNB nodes like this:
NodeContainer enbNodes;
We get the SGW node:
Ptr<Node> sgw = epcHelper->GetSgwNode ();
And then we connect every eNB from the container to the SGW with a point-to-point link. We also assign IPv4 addresses to the interfaces of the eNB and SGW using s1uIpv4AddressHelper.Assign (sgwEnbDevices), and finally we tell the EpcHelper that this enb has a new S1 interface via epcHelper->AddS1Interface (enb, enbS1uAddress, sgwS1uAddress) โ where enbS1uAddress and sgwS1uAddress are the IPv4 addresses of the eNB and the SGW, respectively. ๐
Ipv4AddressHelper s1uIpv4AddressHelper;
// Create networks of the S1 interfaces
s1uIpv4AddressHelper.SetBase ("10.0.0.0", "255.255.255.252");
for (uint16_t i = 0; i < enbNodes.GetN (); ++i)
{
Ptr<Node> enb = enbNodes.Get (i);
// Create a point to point link between the eNB and the SGW with
// the corresponding new NetDevices on each side
PointToPointHelper p2ph;
DataRate s1uLinkDataRate = DataRate ("10Gb/s");
uint16_t s1uLinkMtu = 2000;
Time s1uLinkDelay = Time (0);
p2ph.SetDeviceAttribute ("DataRate", DataRateValue (s1uLinkDataRate));
p2ph.SetDeviceAttribute ("Mtu", UintegerValue (s1uLinkMtu));
p2ph.SetChannelAttribute ("Delay", TimeValue (s1uLinkDelay));
NetDeviceContainer sgwEnbDevices = p2ph.Install (sgw, enb);
Ipv4InterfaceContainer sgwEnbIpIfaces = s1uIpv4AddressHelper.Assign (sgwEnbDevices);
s1uIpv4AddressHelper.NewNetwork ();
Ipv4Address sgwS1uAddress = sgwEnbIpIfaces.GetAddress (0);
Ipv4Address enbS1uAddress = sgwEnbIpIfaces.GetAddress (1);
// Create S1 interface between the SGW and the eNB
epcHelper->AddS1Interface (enb, enbS1uAddress, sgwS1uAddress);
}
okay so that right there is just one lil example of how you'd build a custom backhaul network, bestie. not the only way!! here's another one where literally every eNB and the SGW all get yeeted onto the same CSMA network:
// Create networks of the S1 interfaces
s1uIpv4AddressHelper.SetBase ("10.0.0.0", "255.255.255.0");
NodeContainer sgwEnbNodes;
sgwEnbNodes.Add (sgw);
sgwEnbNodes.Add (enbNodes);
CsmaHelper csmah;
NetDeviceContainer sgwEnbDevices = csmah.Install (sgwEnbNodes);
Ptr<NetDevice> sgwDev = sgwEnbDevices.Get (0);
Ipv4InterfaceContainer sgwEnbIpIfaces = s1uIpv4AddressHelper.Assign (sgwEnbDevices);
Ipv4Address sgwS1uAddress = sgwEnbIpIfaces.GetAddress (0);
for (uint16_t i = 0; i < enbNodes.GetN (); ++i)
{
Ptr<Node> enb = enbNodes.Get (i);
Ipv4Address enbS1uAddress = sgwEnbIpIfaces.GetAddress (i + 1);
// Create S1 interface between the SGW and the eNB
epcHelper->AddS1Interface (enb, enbS1uAddress, sgwS1uAddress);
}
the way that it doesn't matter how you build the backhaul network โ point-to-point links, CSMA network, whatever slays your heart โ the actual โจpointโจ is that you tell the EpcHelper that an eNB has a new S1 interface. that's it. that's the whole vibe check. ๐
Now!! you should keep configuring your simulation program the way it's explained in the Evolved Packet Core (EPC) subsection, bestie. that config includes:
- the internet ๐
- installing the LTE eNBs and possibly configuring other LTE aspects ๐ ๏ธ
- installing the LTE UEs and configuring them as IP nodes ๐ฑ
- activation of the dedicated EPS bearers ๐
- installing applications on the LTE UEs and on the remote hosts ๐
๐ Network Attachment ๐
so as the basic example in section Basic simulation program shows, you attach a UE to an eNodeB by calling the LteHelper::Attach function. iconic behavior.
there are 2 possible ways of network attachment:
- the โmanualโ one ๐โโ๏ธ
- the one with more of an โautomaticโ sense to it ๐ค
both are getting covered in this section, no skips, no crumbs left behind.
๐ซถ Manual attachment ๐ซถ
this method uses the LteHelper::Attach function we just mentioned. it was literally the only network attachment method in earlier versions of the LTE module, so it's got OG status. you typically invoke it before the simulation begins:
lteHelper->Attach (ueDevs, enbDev); // attach one or more UEs to a single eNodeB
โ ๏ธ heads up bestie:LteHelper::InstallEnbDeviceandLteHelper::InstallUeDevicemust have been called before attaching. and in an EPC-enabled simulation, it's also required to have IPv4/IPv6 properly pre-installed in the UE. no shortcuts.
this method is very simple, but it requires you to know exactly which UE belongs to which eNodeB before the simulation begins. which is... lowkey a problem when the UE initial position is randomly determined by the simulation script. ๐ญ
one may choose the distance between the UE and the eNodeB as a criterion for selecting the appropriate cell. it's quite simple (at least from the simulator's point of view) and sometimes practical. BUT โ and this is important โ sometimes distance does not make a single correct criterion. for instance, the eNodeB antenna directivity should be considered as well. besides that, one should also take into account the channel condition, which might be fluctuating if there's fading or shadowing in effect. in these kinds of cases, network attachment should not be based on distance alone. periodt. ๐
in real life, a UE will automatically evaluate certain criteria and select the best cell to attach to, with zero manual intervention from the user. obviously that is not the case in this LteHelper::Attach function. the other network attachment method uses a more โautomaticโ approach, as we're about to spill. ๐
๐ฆ Automatic attachment using Idle mode cell selection procedure ๐ฆ
the strength of the received signal is the standard criterion used for selecting the best cell to attach to. the use of this criterion is implemented in the initial cell selection process, which can be invoked by calling another version of the LteHelper::Attach function, like so:
lteHelper->Attach (ueDevs); // attach one or more UEs to a strongest cell
the difference from the manual method? the destination eNodeB is not specified. the procedure will find the best cell for the UEs, based on several criteria, including the strength of the received signal (RSRP). it's giving matchmaker energy fr fr. ๐
after the method is called, the UE will spend some time measuring the neighbouring cells, and then attempt to attach to the best one. more details can be found in section sec-initial-cell-selection of the Design Documentation.
๐จ IMPORTANT: this method only works in EPC-enabled simulations. LTE-only simulations must resort to the manual attachment method. no cap.
๐ Closed Subscriber Group ๐
an interesting use case of the initial cell selection process is setting up a simulation environment with a Closed Subscriber Group (CSG).
for example, a certain eNodeB โ typically a smaller version such as a femtocell โ might belong to a private owner (e.g. a household or business), allowing access only to some UEs which have been previously registered by the owner. the eNodeB and the registered UEs altogether form a CSG. it's giving VIP club only. ๐
the access restriction can be simulated by โlabelingโ the CSG members with the same CSG ID. this is done through the attributes in both eNodeB and UE, for example using the following LteHelper functions:
// label the following eNodeBs with CSG identity of 1 and CSG indication enabled
lteHelper->SetEnbDeviceAttribute ("CsgId", UintegerValue (1));
lteHelper->SetEnbDeviceAttribute ("CsgIndication", BooleanValue (true));
// label one or more UEs with CSG identity of 1
lteHelper->SetUeDeviceAttribute ("CsgId", UintegerValue (1));
// install the eNodeBs and UEs
NetDeviceContainer csgEnbDevs = lteHelper->InstallEnbDevice (csgEnbNodes);
NetDeviceContainer csgUeDevs = lteHelper->InstallUeDevice (csgUeNodes);
then enable the initial cell selection procedure on the UEs:
lteHelper->Attach (csgUeDevs);
this is necessary because the CSG restriction only works with the automatic method of network attachment, but not in the manual method. soz. ๐
๐ note that setting the CSG indication of an eNodeB as false (the default value) will disable the restriction, i.e., any UEs can connect to this eNodeB. the velvet rope just... comes down.
โจ Configure UE measurements โจ
the active UE measurement configuration in a simulation is dictated by the selected so called โconsumersโ, such as handover algorithm. users may add their own configuration into action, and there are several ways to do so:
- direct configuration in eNodeB RRC entity;
- configuring existing handover algorithm; and
- developing a new handover algorithm.
this section will cover the first method only. the second method is covered in Automatic handover trigger, while the third method is explained in length in Section sec-handover-algorithm of the Design Documentation.
direct configuration in eNodeB RRC works as follows. the user begins by creating a new LteRrcSap::ReportConfigEutra instance and passing it to the LteEnbRrc::AddUeMeasReportConfig function. the function will return the measId (measurement identity) which is a unique reference of the configuration in the eNodeB instance. this function must be called before the simulation begins. the measurement configuration will be active in all UEs attached to the eNodeB throughout the duration of the simulation. during the simulation, the user can capture the measurement reports produced by the UEs by listening to the existing LteEnbRrc::RecvMeasurementReport trace source. it's giving surveillance but make it cute. ๐
the structure ReportConfigEutra is in accord with 3GPP specification. definition of the structure and each member field can be found in Section 6.3.5 of [TS36331].
the code sample below configures Event A1 RSRP measurement to every eNodeB within the container devs:
LteRrcSap::ReportConfigEutra config;
config.eventId = LteRrcSap::ReportConfigEutra::EVENT_A1;
config.threshold1.choice = LteRrcSap::ThresholdEutra::THRESHOLD_RSRP;
config.threshold1.range = 41;
config.triggerQuantity = LteRrcSap::ReportConfigEutra::RSRP;
config.reportInterval = LteRrcSap::ReportConfigEutra::MS480;
std::vector<uint8_t> measIdList;
NetDeviceContainer::Iterator it;
for (it = devs.Begin (); it != devs.End (); it++)
{
Ptr<NetDevice> dev = *it;
Ptr<LteEnbNetDevice> enbDev = dev->GetObject<LteEnbNetDevice> ();
Ptr<LteEnbRrc> enbRrc = enbDev->GetRrc ();
uint8_t measId = enbRrc->AddUeMeasReportConfig (config);
measIdList.push_back (measId); // remember the measId created
enbRrc->TraceConnect ("RecvMeasurementReport",
"context",
MakeCallback (&RecvMeasurementReportCallback));
}
๐ก note that thresholds are expressed as range. in the example above, the range41for RSRP corresponds to -100 dBm. the conversion from and to the range format is due to Section 9.1.4 and 9.1.7 of [TS36133]. theEutranMeasurementMappingclass has several static functions that can be used for this purpose. math girlies stay winning. ๐ง
the corresponding callback function would have a definition similar as below:
void
RecvMeasurementReportCallback (std::string context,
uint64_t imsi,
uint16_t cellId,
uint16_t rnti,
LteRrcSap::MeasurementReport measReport);
Okay so this method? It registers your callback function as a consumer of UE measurements. โจ And bestie, heads up: when there's more than one consumer in the sim (handover algorithm, I'm looking at you ๐), the measurements meant for those other consumers will also get caught by this callback. Not a bug, just how it is. So if you wanna know which measurement configuration actually triggered the report, go look at the measId field inside the LteRrcSap::MeasurementReport argument of your callback function. That's the receipts. ๐งพ
In general, this whole mechanism exists so that one consumer doesn't unknowingly intervene with another consumer's reporting configuration. Teamwork, slay. ๐ซถ
Note: only the reporting configuration part (i.e. LteRrcSap::ReportConfigEutra) of the UE measurements parameter is open for consumers to configure โ everything else stays hidden. The intra-frequency limitation is literally the main motivation behind this API implementation decision, and here's why:
- there is only one, unambiguous and definitive measurement object, so there's no need to configure it;
- measurement identities are kept hidden because there's a one-to-one mapping between reporting configuration and measurement identity โ so a new measurement identity gets set up automatically whenever a new reporting configuration is created;
- quantity configuration is configured elsewhere, see
sec-performing-measurements; and - measurement gaps are not supported, because it's only applicable for inter-frequency settings.
X2-based handover ๐
As defined by 3GPP, handover is a procedure for changing the serving cell of a UE in CONNECTED mode. The two eNodeBs involved in the process are typically called the source eNodeB and the target eNodeB. Two queens, one handover. ๐
So to actually enable the execution of X2-based handover in simulation, there are two requirements that must be met. First up: EPC must be enabled in the simulation (see Evolved Packet Core (EPC)).
Second: an X2 interface must be configured between the two eNodeBs, and you have to do it explicitly within the simulation program:
lteHelper->AddX2Interface (enbNodes);
where enbNodes is a NodeContainer that contains the two eNodeBs between which the X2 interface is to be configured. And if the container has more than two eNodeBs? The function will create an X2 interface between every pair of eNodeBs in the container. It's giving โจnetworkingโจ.
Lastly, the target eNodeB must be configured as "open" to X2 HANDOVER REQUEST. Every eNodeB is open by default, so no extra instruction is needed in most cases. Default behaviour ate, no notes. But users may set the eNodeB to "closed" by setting the boolean attribute LteEnbRrc::AdmitHandoverRequest to false. As an example, you can run the lena-x2-handover program and set the attribute like this:
NS_LOG=EpcX2:LteEnbRrc ./waf --run lena-x2-handover --command="%s --ns3::LteEnbRrc::AdmitHandoverRequest=false"
After those three requirements are fulfilled, the handover procedure can be triggered manually or automatically. Each gets its own subsection below, let's go ๐ฆ
Manual handover trigger ๐
Handover events can be triggered "manually" within the simulation program by scheduling an explicit handover event. The LteHelper object provides a convenient method for the scheduling of a handover event. As an example, let's assume ueLteDevs is a NetDeviceContainer that contains the UE that is to be handed over, and enbLteDevs is another NetDeviceContainer that contains the source and the target eNB. Then a handover at 0.1s can be scheduled like this:
lteHelper->HandoverRequest (Seconds (0.100),
ueLteDevs.Get (0),
enbLteDevs.Get (0),
enbLteDevs.Get (1));
Note: the UE needs to be already connected to the source eNB, otherwise the simulation will terminate with an error message. No connection, no handover, bestie. ๐ญ
For an example with full source code, please refer to the lena-x2-handover example program.
Automatic handover trigger ๐ฅ
The handover procedure can also be triggered "automatically" by the serving eNodeB of the UE. The logic behind the trigger depends on the handover algorithm currently active in the eNodeB RRC entity. Users may select and configure the handover algorithm that will be used in the simulation, which we're about to explain right here in this section. Users may also opt to write their own implementation of handover algorithm, as described in Section sec-handover-algorithm of the Design Documentation. Main character energy: write your own algorithm. ๐
Selecting a handover algorithm is done via the LteHelper object and its SetHandoverAlgorithmType method, as shown below:
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
lteHelper->SetHandoverAlgorithmType ("ns3::A2A4RsrqHandoverAlgorithm");
The selected handover algorithm may also provide several configurable attributes, which can be set as follows:
lteHelper->SetHandoverAlgorithmAttribute ("ServingCellThreshold",
UintegerValue (30));
lteHelper->SetHandoverAlgorithmAttribute ("NeighbourCellOffset",
UintegerValue (1));
Three options of handover algorithm are included in the LTE module. The A2-A4-RSRQ handover algorithm (named ns3::A2A4RsrqHandoverAlgorithm) is the default option, and its usage has already been shown above. ๐
Another option is the strongest cell handover algorithm (named ns3::A3RsrpHandoverAlgorithm), which can be selected and configured by the following code:
lteHelper->SetHandoverAlgorithmType ("ns3::A3RsrpHandoverAlgorithm");
lteHelper->SetHandoverAlgorithmAttribute ("Hysteresis",
DoubleValue (3.0));
lteHelper->SetHandoverAlgorithmAttribute ("TimeToTrigger",
TimeValue (MilliSeconds (256)));
The last option is a special one, called the no-op handover algorithm, which basically disables automatic handover trigger. This is useful, for example, in cases where manual handover trigger needs an exclusive control of all handover decisions. It does not have any configurable attributes. The usage is as follows:
lteHelper->SetHandoverAlgorithmType ("ns3::NoOpHandoverAlgorithm");
For more information on each handover algorithm's decision policy and their attributes, please refer to their respective subsections in Section sec-handover-algorithm of the Design Documentation.
Finally, the InstallEnbDevice function of LteHelper will instantiate one instance of the selected handover algorithm for each eNodeB device. In other words, make sure to select the right handover algorithm before finalizing it in the following line of code:
NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNodes);
An example with full source code of using automatic handover trigger can be found in the lena-x2-handover-measures example program.
Tuning simulation with handover ๐ธ
As mentioned in the Design Documentation, the current implementation of the handover model may produce unpredicted behaviour when handover failure occurs. Not me warning you but like, I'm warning you. ๐ญ This subsection is gonna focus on the steps users should take into account if they plan to use handover in their simulations.
The major cause of handover failure that we'll tackle is the error in transmitting handover-related signaling messages during the execution of a handover procedure. As is apparent from the Figure fig-x2-based-handover-seq-diagram in the Design Documentation, there are many of them, and they use different interfaces and protocols. For the sake of simplicity, we can safely assume that the X2 interface (between the source eNodeB and the target eNodeB) and the S1 interface (between the target eNodeB and the SGW/PGW) are quite stable. Those two are fine, trust. So we're focusing our attention on the RRC protocol (between the UE and the eNodeBs) and the Random Access procedure, which are normally transmitted through the air and susceptible to degradation of channel condition. ๐ฆ
A general tip to reduce transmission error is to ensure a high enough SINR level in every UE. This can be done by a proper planning of the network topology that minimizes network coverage hole. And if the topology has a known coverage hole? Then the UE should be configured not to venture to that area. Stay in your lane, literally. ๐
Another approach to keep in mind is to avoid too-late handovers. In other words, handover should happen before the UE's SINR becomes too low, otherwise the UE may fail to receive the handover command from the source eNodeB. Handover algorithms have the means to control how early or late a handover decision is made. For example, the A2-A4-RSRQ handover algorithm can be configured with a higher threshold to make it decide a handover earlier. Similarly, smaller hysteresis and/or shorter time-to-trigger in the strongest cell handover algorithm typically results in earlier handovers. In order to find the right values for these parameters, one of the factors that should be considered is the UE movement speed. Generally, a faster moving UE requires the handover to be executed earlier. Some research work has suggested recommended values, such as in [Lee2010]. ๐
The above tips should be enough in normal simulation uses, but in case some special needs arise, then an extreme measure can be taken into consideration. For instance, users may consider disabling the channel error models. This will ensure that all handover-related signaling messages will be transmitted successfully, regardless of distance and channel condition. However โ it will also affect all other data or control packets not related to handover, which may be an unwanted side effect. Trade-offs, bestie, always trade-offs. Otherwise, it can be done as follows:
Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
By using the above code, we disable the error model in both control and data channels and in both directions (downlink and uplink). This is necessary because handover-related signaling messages are transmitted using these channels. An exception is when the simulation uses the ideal RRC protocol. In this case, only the Random Access procedure is left to be considered. The procedure consists of control messages, therefore we only need to disable the control channel's error model. โจ
Handover traces ๐
The RRC model โ in particular the LteEnbRrc and LteUeRrc objects โ provides some useful traces which can be hooked up to some custom functions, so that they are called upon start and end of the handover execution phase at both the UE and eNB side. Obsessed with a good trace hookup, fr fr. As an example, in your simulation program you can declare the following methods:
void
NotifyHandoverStartUe (std::string context,
uint64_t imsi,
uint16_t cellId,
uint16_t rnti,
uint16_t targetCellId)
{
std::cout << Simulator::Now ().GetSeconds () << " " << context
<< " UE IMSI " << imsi
<< ": previously connected to CellId " << cellId
<< " with RNTI " << rnti
<< ", doing handover to CellId " << targetCellId
<< std::endl;
}
void
NotifyHandoverEndOkUe (std::string context,
uint64_t imsi,
uint16_t cellId,
uint16_t rnti)
{
std::cout << Simulator::Now ().GetSeconds () << " " << context
<< " UE IMSI " << imsi
<< ": successful handover to CellId " << cellId
<< " with RNTI " << rnti
<< std::endl;
}
void
NotifyHandoverStartEnb (std::string context,
uint64_t imsi,
uint16_t cellId,
uint16_t rnti,
uint16_t targetCellId)
{
std::cout << Simulator::Now ().GetSeconds () << " " << context
<< " eNB CellId " << cellId
<< ": start handover of UE with IMSI " << imsi
<< " RNTI " << rnti
<< " to CellId " << targetCellId
<< std::endl;
}
void
NotifyHandoverEndOkEnb (std::string context,
uint64_t imsi,
uint16_t cellId,
uint16_t rnti)
{
std::cout << Simulator::Now ().GetSeconds () << " " << context
<< " eNB CellId " << cellId
<< ": completed handover of UE with IMSI " << imsi
<< " RNTI " << rnti
<< std::endl;
}
okay bestie those are the four lil callback girlies we just met โ NotifyHandoverStartUe, NotifyHandoverEndOkUe, NotifyHandoverStartEnb, NotifyHandoverEndOkEnb. ๐
And then โจ you hook them up โจ to the matching trace sources like this, no cap:
Config::Connect ("/NodeList/*/DeviceList/*/LteEnbRrc/HandoverStart",
MakeCallback (&NotifyHandoverStartEnb));
Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/HandoverStart",
MakeCallback (&NotifyHandoverStartUe));
Config::Connect ("/NodeList/*/DeviceList/*/LteEnbRrc/HandoverEndOk",
MakeCallback (&NotifyHandoverEndOkEnb));
Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/HandoverEndOk",
MakeCallback (&NotifyHandoverEndOkUe));
The example program src/lte/examples/lena-x2-handover.cc is literally the blueprint for how all of the above gets stitched into an actual simulation program, iykyk. ๐ง
Run it like:
./waf --run lena-x2-handover
and it'll spit out the messages printed by your custom handover trace hooks. ๐ซถ And if you also want to visualize some meaningful logging info on top of that, run it like:
NS_LOG=LteEnbRrc:LteUeRrc:EpcX2 ./waf --run lena-x2-handover
โจ Frequency Reuse Algorithms โจ
okay so this section is all about how to use Frequency Reuse Algorithms in the eNb inside your LTE sims, and there are two ways to configure them:
- The first approach is the "manual" one. It needs more parameters set up, but it lets the user configure the FR algorithm however he/she actually needs. ๐
- The second approach is the more "automatic" one. It's super convenient because it's the same for every FR algorithm, so you can swap FR algorithms so fast by only changing the type of FR algorithm. The catch? The "automatic" approach only uses a limited set of configurations for each algorithm, which makes it less flexible โ but it's still enough for most cases. ๐
Both approaches get described more in the sub-sections that follow.
If the user doesn't configure a Frequency Reuse algorithm at all, the default one (aka LteFrNoOpAlgorithm) gets installed in the eNb. It acts like the FR algorithm was disabled. ๐ซ
One thing that should absolutely be mentioned: most of the implemented FR algorithms work with cell bandwidth greater or equal than 15 RBs. This limitation exists because at least three continuous RBs have to be assigned to a UE for transmission. Periodt.
๐ธ Manual configuration ๐ธ
Frequency reuse algorithm can be configured "manually" inside the simulation program by setting the type of FR algorithm and all of its attributes. Currently, seven FR algorithms are implemented:
ns3::LteFrNoOpAlgorithmns3::LteFrHardAlgorithmns3::LteFrStrictAlgorithmns3::LteFrSoftAlgorithmns3::LteFfrSoftAlgorithmns3::LteFfrEnhancedAlgorithmns3::LteFfrDistributedAlgorithm
Selecting a FR algorithm happens through the LteHelper object and its SetFfrAlgorithmType method, like this:
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
lteHelper->SetFfrAlgorithmType ("ns3::LteFrHardAlgorithm");
Each implemented FR algorithm gives you several configurable attributes. Users do not have to care about UL and DL bandwidth configuration, because that's done automatically during cell configuration. But if you do want to change the bandwidth for the FR algorithm, configure the required values for LteEnbNetDevice:
uint8_t bandwidth = 100;
lteHelper->SetEnbDeviceAttribute ("DlBandwidth", UintegerValue (bandwidth));
lteHelper->SetEnbDeviceAttribute ("UlBandwidth", UintegerValue (bandwidth));
Now, let's get into each FR algorithm's configuration one by one. ๐ฆ
๐ Hard Frequency Reuse Algorithm ๐
As described in Section sec-fr-hard-algorithm of the Design Documentation, ns3::LteFrHardAlgorithm uses one sub-band. To configure this sub-band, the user needs to specify the offset and bandwidth for DL and UL in number of RBs.
Hard Frequency Reuse Algorithm provides these attributes:
DlSubBandOffset: Downlink Offset in number of Resource Block GroupsDlSubBandwidth: Downlink Transmission SubBandwidth Configuration in number of Resource Block GroupsUlSubBandOffset: Uplink Offset in number of Resource Block GroupsUlSubBandwidth: Uplink Transmission SubBandwidth Configuration in number of Resource Block Groups
Example configuration of LteFrHardAlgorithm can be done like this:
lteHelper->SetFfrAlgorithmType ("ns3::LteFrHardAlgorithm");
lteHelper->SetFfrAlgorithmAttribute ("DlSubBandOffset", UintegerValue (8));
lteHelper->SetFfrAlgorithmAttribute ("DlSubBandwidth", UintegerValue (8));
lteHelper->SetFfrAlgorithmAttribute ("UlSubBandOffset", UintegerValue (8));
lteHelper->SetFfrAlgorithmAttribute ("UlSubBandwidth", UintegerValue (8));
NetDeviceContainer enbDevs = lteHelper->InstallEnbDevice (enbNodes.Get(0));
The example above lets the eNB use only RBs from 8 to 16 in DL and UL, while the entire cell bandwidth is 25. slay. ๐
๐ Strict Frequency Reuse Algorithm ๐
Strict Frequency Reuse Algorithm uses two sub-bands: one common to every cell, and one private. There's also an RSRQ threshold, which is needed to decide which sub-band the UE should be served within. And on top of that, the power transmission in these sub-bands can be different. ๐
Strict Frequency Reuse Algorithm provides these attributes:
UlCommonSubBandwidth: Uplink Common SubBandwidth Configuration in number of Resource Block GroupsUlEdgeSubBandOffset: Uplink Edge SubBand Offset in number of Resource Block GroupsUlEdgeSubBandwidth: Uplink Edge SubBandwidth Configuration in number of Resource Block GroupsDlCommonSubBandwidth: Downlink Common SubBandwidth Configuration in number of Resource Block GroupsDlEdgeSubBandOffset: Downlink Edge SubBand Offset in number of Resource Block GroupsDlEdgeSubBandwidth: Downlink Edge SubBandwidth Configuration in number of Resource Block GroupsRsrqThreshold: If the RSRQ of is worse than this threshold, UE should be served in edge sub-bandCenterPowerOffset:PdschConfigDedicated::Pavalue for center sub-band, default valuedB0EdgePowerOffset:PdschConfigDedicated::Pavalue for edge sub-band, default valuedB0CenterAreaTpc: TPC value which will be set in DL-DCI for UEs in center area, Absolute mode is used, default value1is mapped to-1according to TS36.213 Table 5.1.1.1-2EdgeAreaTpc: TPC value which will be set in DL-DCI for UEs in edge area, Absolute mode is used, default value1is mapped to-1according to TS36.213 Table 5.1.1.1-2
The example below lets the eNB use RBs from 0 to 6 as the common sub-band and from 12 to 18 as the private sub-band in DL and UL, with an RSRQ threshold of 20 dB, power in the center area equal to LteEnbPhy::TxPower - 3dB, and power in the edge area equal to LteEnbPhy::TxPower + 3dB:
lteHelper->SetFfrAlgorithmType ("ns3::LteFrStrictAlgorithm");
lteHelper->SetFfrAlgorithmAttribute ("DlCommonSubBandwidth", UintegerValue (6));
lteHelper->SetFfrAlgorithmAttribute ("UlCommonSubBandwidth", UintegerValue (6));
lteHelper->SetFfrAlgorithmAttribute ("DlEdgeSubBandOffset", UintegerValue (6));
lteHelper->SetFfrAlgorithmAttribute ("DlEdgeSubBandwidth", UintegerValue (6));
lteHelper->SetFfrAlgorithmAttribute ("UlEdgeSubBandOffset", UintegerValue (6));
lteHelper->SetFfrAlgorithmAttribute ("UlEdgeSubBandwidth", UintegerValue (6));
lteHelper->SetFfrAlgorithmAttribute ("RsrqThreshold", UintegerValue (20));
lteHelper->SetFfrAlgorithmAttribute ("CenterPowerOffset",
UintegerValue (LteRrcSap::PdschConfigDedicated::dB_3));
lteHelper->SetFfrAlgorithmAttribute ("EdgePowerOffset",
UintegerValue (LteRrcSap::PdschConfigDedicated::dB3));
lteHelper->SetFfrAlgorithmAttribute ("CenterAreaTpc", UintegerValue (1));
lteHelper->SetFfrAlgorithmAttribute ("EdgeAreaTpc", UintegerValue (2));
NetDeviceContainer enbDevs = lteHelper->InstallEnbDevice (enbNodes.Get(0));
๐ Soft Frequency Reuse Algorithm ๐
With Soft Frequency Reuse Algorithm, the eNb uses the entire cell bandwidth, but there are two sub-bands, and UEs get served with a different power level depending on which one they land in. โจ
Soft Frequency Reuse Algorithm provides these attributes:
UlEdgeSubBandOffset: Uplink Edge SubBand Offset in number of Resource Block GroupsUlEdgeSubBandwidth: Uplink Edge SubBandwidth Configuration in number of Resource Block GroupsDlEdgeSubBandOffset: Downlink Edge SubBand Offset in number of Resource Block GroupsDlEdgeSubBandwidth: Downlink Edge SubBandwidth Configuration in number of Resource Block GroupsAllowCenterUeUseEdgeSubBandโ bestie, if this istrue, center UEs are allowed to receive on edge sub-band RBGs. If it'sfalse, that edge sub-band is edge-UEs-only, no gatecrashing ๐ . Default value istrue.RsrqThresholdโ if a UE's RSRQ is worse than this threshold, she gets served in the edge sub-band. It's giving "you're on the edge, babe".CenterPowerOffsetโ thePdschConfigDedicated::Pavalue for the center sub-band. Default value isdB0.EdgePowerOffsetโ thePdschConfigDedicated::Pavalue for the edge sub-band. Default value isdB0.CenterAreaTpcโ the TPC value that gets set in DL-DCI for UEs in the center area. Absolute mode is used, and the default value1is mapped to-1according to TS36.213 Table 5.1.1.1-2.EdgeAreaTpcโ the TPC value that gets set in DL-DCI for UEs in the edge area. Absolute mode is used, and the default value1is mapped to-1according to TS36.213 Table 5.1.1.1-2.
The example below configures RBs from 8 to 16 to be used by cell edge UEs, and this sub-band is not available for cell center users. RSRQ threshold is 20 dB, power in the center area equals LteEnbPhy::TxPower, and power in the edge area equals LteEnbPhy::TxPower + 3dB:
lteHelper->SetFfrAlgorithmType ("ns3::LteFrSoftAlgorithm");
lteHelper->SetFfrAlgorithmAttribute ("DlEdgeSubBandOffset", UintegerValue (8));
lteHelper->SetFfrAlgorithmAttribute ("DlEdgeSubBandwidth", UintegerValue (8));
lteHelper->SetFfrAlgorithmAttribute ("UlEdgeSubBandOffset", UintegerValue (8));
lteHelper->SetFfrAlgorithmAttribute ("UlEdgeSubBandwidth", UintegerValue (8));
lteHelper->SetFfrAlgorithmAttribute ("AllowCenterUeUseEdgeSubBand", BooleanValue (false));
lteHelper->SetFfrAlgorithmAttribute ("RsrqThreshold", UintegerValue (20));
lteHelper->SetFfrAlgorithmAttribute ("CenterPowerOffset",
UintegerValue (LteRrcSap::PdschConfigDedicated::dB0));
lteHelper->SetFfrAlgorithmAttribute ("EdgePowerOffset",
UintegerValue (LteRrcSap::PdschConfigDedicated::dB3));
NetDeviceContainer enbDevs = lteHelper->InstallEnbDevice (enbNodes.Get(0));
Soft Fractional Frequency Reuse Algorithm ๐ฆ
Soft Fractional Frequency Reuse (SFFR) uses three sub-bands: center, medium (common) and edge. And here's the tea ๐ต โ you only have to configure two of them: common and edge. The center sub-band gets composed from whatever bandwidth is left over. Each sub-band can be served with a different transmission power. And because there are three sub-bands, you need to configure two RSRQ thresholds. Two thresholds, three vibes, iconic honestly.
The Soft Fractional Frequency Reuse Algorithm provides the following attributes:
UlCommonSubBandwidthโ Uplink Common SubBandwidth Configuration, in number of Resource Block Groups.UlEdgeSubBandOffsetโ Uplink Edge SubBand Offset, in number of Resource Block Groups.UlEdgeSubBandwidthโ Uplink Edge SubBandwidth Configuration, in number of Resource Block Groups.DlCommonSubBandwidthโ Downlink Common SubBandwidth Configuration, in number of Resource Block Groups.DlEdgeSubBandOffsetโ Downlink Edge SubBand Offset, in number of Resource Block Groups.DlEdgeSubBandwidthโ Downlink Edge SubBandwidth Configuration, in number of Resource Block Groups.CenterRsrqThresholdโ if a UE's RSRQ is worse than this threshold, she should be served in the medium sub-band.EdgeRsrqThresholdโ if a UE's RSRQ is worse than this threshold, she should be served in the edge sub-band.CenterAreaPowerOffsetโ thePdschConfigDedicated::Pavalue for the center sub-band. Default value isdB0.MediumAreaPowerOffsetโ thePdschConfigDedicated::Pavalue for the medium sub-band. Default value isdB0.EdgeAreaPowerOffsetโ thePdschConfigDedicated::Pavalue for the edge sub-band. Default value isdB0.CenterAreaTpcโ the TPC value that gets set in DL-DCI for UEs in the center area. Absolute mode is used, and the default value1is mapped to-1according to TS36.213 Table 5.1.1.1-2.MediumAreaTpcโ the TPC value that gets set in DL-DCI for UEs in the medium area. Absolute mode is used, and the default value1is mapped to-1according to TS36.213 Table 5.1.1.1-2.EdgeAreaTpcโ the TPC value that gets set in DL-DCI for UEs in the edge area. Absolute mode is used, and the default value1is mapped to-1according to TS36.213 Table 5.1.1.1-2.
In the example below, RBs from 0 to 6 will be used as the common (medium) sub-band, RBs from 6 to 12 will be used as the edge sub-band, and RBs from 12 to 24 will be used as the center sub-band (it's composed with the remaining RBs). RSRQ threshold between center and medium area is 28 dB, RSRQ threshold between medium and edge area is 18 dB. Power in the center area equals LteEnbPhy::TxPower - 3dB, power in the medium area equals LteEnbPhy::TxPower + 3dB, and power in the edge area equals LteEnbPhy::TxPower + 3dB:
lteHelper->SetFfrAlgorithmType ("ns3::LteFfrSoftAlgorithm");
lteHelper->SetFfrAlgorithmAttribute ("UlCommonSubBandwidth", UintegerValue (6));
lteHelper->SetFfrAlgorithmAttribute ("DlCommonSubBandwidth", UintegerValue (6));
lteHelper->SetFfrAlgorithmAttribute ("DlEdgeSubBandOffset", UintegerValue (0));
lteHelper->SetFfrAlgorithmAttribute ("DlEdgeSubBandwidth", UintegerValue (6));
lteHelper->SetFfrAlgorithmAttribute ("UlEdgeSubBandOffset", UintegerValue (0));
lteHelper->SetFfrAlgorithmAttribute ("UlEdgeSubBandwidth", UintegerValue (6));
lteHelper->SetFfrAlgorithmAttribute ("CenterRsrqThreshold", UintegerValue (28));
lteHelper->SetFfrAlgorithmAttribute ("EdgeRsrqThreshold", UintegerValue (18));
lteHelper->SetFfrAlgorithmAttribute ("CenterAreaPowerOffset",
UintegerValue (LteRrcSap::PdschConfigDedicated::dB_3));
lteHelper->SetFfrAlgorithmAttribute ("MediumAreaPowerOffset",
UintegerValue (LteRrcSap::PdschConfigDedicated::dB0));
lteHelper->SetFfrAlgorithmAttribute ("EdgeAreaPowerOffset",
UintegerValue (LteRrcSap::PdschConfigDedicated::dB3));
NetDeviceContainer enbDevs = lteHelper->InstallEnbDevice (enbNodes.Get(0));
Enhanced Fractional Frequency Reuse Algorithm โจ
Enhanced Fractional Frequency Reuse (EFFR) reserves part of the system bandwidth for each cell โ typically there are 3 cell types and each one gets 1/3 of the system bandwidth, so like, very fair division bestie. Then part of this subbandwidth is used as the Primary Segment with reuse factor 3, and as the Secondary Segment with reuse factor 1.
You (yes, you ๐ซต) have to configure, for both DL and UL: the offset of the cell subbandwidth in number of RB, the number of RB that will be used as the Primary Segment, and the number of RB that will be used as the Secondary Segment.
The Primary Segment is used by the cell at will โ do whatever, queen ๐ โ but RBs from the Secondary Segment can only be assigned to a UE if the CQI feedback from that UE has a higher value than the configured CQI threshold. And a UE is considered an edge UE when her RSRQ is lower than RsrqThreshold.
Since each eNb needs to know where the Primary and Secondary segments of the other cell types are, it will calculate them assuming the configuration is the same for each cell and only the subbandwidth offsets differ. So it is important to divide the available system bandwidth equally to each cell and apply the same configuration of Primary and Secondary Segments to them. No cap, this part is load-bearing ๐.
The Enhanced Fractional Frequency Reuse Algorithm provides the following attributes:
UlSubBandOffsetโ Uplink SubBand Offset for this cell, in number of Resource Block Groups.UlReuse3SubBandwidthโ Uplink Reuse 3 SubBandwidth Configuration, in number of Resource Block Groups.UlReuse1SubBandwidthโ Uplink Reuse 1 SubBandwidth Configuration, in number of Resource Block Groups.DlSubBandOffsetโ Downlink SubBand Offset for this cell, in number of Resource Block Groups.DlReuse3SubBandwidthโ Downlink Reuse 3 SubBandwidth Configuration, in number of Resource Block Groups.DlReuse1SubBandwidthโ Downlink Reuse 1 SubBandwidth Configuration, in number of Resource Block Groups.RsrqThresholdโ if a UE's RSRQ is worse than this threshold, she should be served in the edge sub-band.CenterAreaPowerOffsetโ thePdschConfigDedicated::Pavalue for the center sub-band. Default value isdB0.EdgeAreaPowerOffsetโ thePdschConfigDedicated::Pavalue for the edge sub-band. Default value isdB0.DlCqiThresholdโ if the DL-CQI for an RBG is higher than this threshold, transmission on that RBG is possible.UlCqiThresholdโ if the UL-CQI for an RBG is higher than this threshold, transmission on that RBG is possible.CenterAreaTpcโ the TPC value that gets set in DL-DCI for UEs in the center area. Absolute mode is used, and the default value1is mapped to-1according to TS36.213 Table 5.1.1.1-2.EdgeAreaTpcโ the TPC value that gets set in DL-DCI for UEs in the edge area. Absolute mode is used, and the default value1is mapped to-1according to TS36.213 Table 5.1.1.1-2.
In the example below, the offset in DL and UL is 0 RB, and 4 RB will be used in the Primary Segment and the Secondary Segment. RSRQ threshold between center and edge area is 25 dB. DL and UL CQI thresholds are set to a value of 10. Power in the center area equals LteEnbPhy::TxPower - 6dB, and power in the edge area equals LteEnbPhy::TxPower + 0dB:
lteHelper->SetFfrAlgorithmType("ns3::LteFfrEnhancedAlgorithm");
lteHelper->SetFfrAlgorithmAttribute("RsrqThreshold", UintegerValue (25));
lteHelper->SetFfrAlgorithmAttribute("DlCqiThreshold", UintegerValue (10));
lteHelper->SetFfrAlgorithmAttribute("UlCqiThreshold", UintegerValue (10));
lteHelper->SetFfrAlgorithmAttribute("CenterAreaPowerOffset",
UintegerValue (LteRrcSap::PdschConfigDedicated::dB_6));
lteHelper->SetFfrAlgorithmAttribute("EdgeAreaPowerOffset",
UintegerValue (LteRrcSap::PdschConfigDedicated::dB0));
lteHelper->SetFfrAlgorithmAttribute("UlSubBandOffset", UintegerValue (0));
lteHelper->SetFfrAlgorithmAttribute("UlReuse3SubBandwidth", UintegerValue (4));
lteHelper->SetFfrAlgorithmAttribute("UlReuse1SubBandwidth", UintegerValue (4));
lteHelper->SetFfrAlgorithmAttribute("DlSubBandOffset", UintegerValue (0));
lteHelper->SetFfrAlgorithmAttribute("DlReuse3SubBandwidth", UintegerValue (4));
lteHelper->SetFfrAlgorithmAttribute("DlReuse1SubBandwidth", UintegerValue (4));
Distributed Fractional Frequency Reuse Algorithm ๐ธ
Distributed Fractional Frequency Reuse requires an X2 interface between all eNBs to be installed. And here's the catch bestie, don't skip this part ๐ญ โ X2 interfaces can be installed only when EPC is configured, so this FFR scheme can be used only with EPC scenarios. No EPC, no DFFR, that's the rule, periodt ๐ .
โ ๏ธ fr fr: if you're not running an EPC setup, this one's simply not for you. Don't fight it, just configure EPC or pick a different FFR algorithm ๐.
With the Distributed Fractional Frequency Reuse Algorithm, the eNb flexes the entire cell bandwidth, and there can be two sub-bands: a center sub-band and an edge sub-band. Inside those sub-bands, UEs can be served at different power levels. The algorithm adaptively picks RBs for the cell-edge sub-band based on coordination info (that's RNTP) coming from the adjacent cells, and it tells the base stations of those adjacent cells which RBs it chose to use in the edge sub-band. And if there are no UEs classified as edge UEs in a cell, the eNB won't use any RBs as edge sub-band. periodt. ๐
The Distributed Fractional Frequency Reuse Algorithm serves up these attributes:
CalculationIntervalโ the time interval between calculations of the Edge sub-band. Default value is 1 second.RsrqThresholdโ if the RSRQ is worse than this threshold, the UE should be served in the edge sub-band.RsrpDifferenceThresholdโ if the difference between the power of the signal the UE receives from the serving cell and the power of the signal it receives from the adjacent cell is less than thisRsrpDifferenceThresholdvalue, the cell weight gets incremented.CenterPowerOffsetโPdschConfigDedicated::Pavalue for edge sub-band, default valuedB0.EdgePowerOffsetโPdschConfigDedicated::Pavalue for edge sub-band, default valuedB0.EdgeRbNumโ number of RB that can be used in the edge sub-band.CenterAreaTpcโ TPC value that will be set in DL-DCI for UEs in the center area. Absolute mode is used, and the default value1is mapped to-1according to TS36.213 Table 5.1.1.1-2.EdgeAreaTpcโ TPC value that will be set in DL-DCI for UEs in the edge area. Absolute mode is used, and the default value1is mapped to-1according to TS36.213 Table 5.1.1.1-2.
In the example below the calculation interval is 500 ms, the RSRQ threshold between center and edge area is 25, and the RSRP Difference Threshold is set to 5. In DL and UL, 6 RB will be used by each cell in the edge sub-band. Power in the center area equals LteEnbPhy::TxPower - 0dB, and power in the edge area equals LteEnbPhy::TxPower + 3dB:
lteHelper->SetFfrAlgorithmType("ns3::LteFfrDistributedAlgorithm");
lteHelper->SetFfrAlgorithmAttribute("CalculationInterval", TimeValue(MilliSeconds(500)));
lteHelper->SetFfrAlgorithmAttribute ("RsrqThreshold", UintegerValue (25));
lteHelper->SetFfrAlgorithmAttribute ("RsrpDifferenceThreshold", UintegerValue (5));
lteHelper->SetFfrAlgorithmAttribute ("EdgeRbNum", UintegerValue (6));
lteHelper->SetFfrAlgorithmAttribute ("CenterPowerOffset",
UintegerValue (LteRrcSap::PdschConfigDedicated::dB0));
lteHelper->SetFfrAlgorithmAttribute ("EdgePowerOffset",
UintegerValue (LteRrcSap::PdschConfigDedicated::dB3));
โจ Automatic configuration โจ
Frequency Reuse algorithms can also be set up in a way more โautomaticโ fashion โ you just set the bandwidth and the FrCellTypeId and that's it. When the FR instance initializes, the configuration for the bandwidth and FrCellTypeId you set gets pulled from the configuration table. Important: only the sub-bands will be configured this way โ thresholds and transmission power get set to their default values. If you want, you can change thresholds and transmission power like we showed in the previous sub-section. ๐ซถ
There are three FrCellTypeId values: 1, 2, 3 โ and they correspond to three different configurations for each bandwidth. Those three configurations are what let you have different configs in neighbouring cells in a hexagonal eNB layout. If you need even more different configurations for neighbouring cells, you'll have to go with manual configuration, bestie.
Example below shows automatic FR algorithm configuration:
lteHelper->SetFfrAlgorithmType("ns3::LteFfrSoftAlgorithm");
lteHelper->SetFfrAlgorithmAttribute("FrCellTypeId", UintegerValue (1));
NetDeviceContainer enbDevs = lteHelper->InstallEnbDevice (enbNodes.Get(0));
โก Uplink Power Control โก
Uplink Power Control functionality is enabled by default. You can disable it by setting the boolean attribute ns3::LteUePhy::EnableUplinkPowerControl to true.
You can switch between Open Loop Power Control and Closed Loop Power Control mechanisms by setting the boolean attribute ns3::LteUePowerControl::ClosedLoop. By default, Closed Loop Power Control with Accumulation Mode is enabled.
Path-loss is a key component of Uplink Power Control. It's computed as the difference between filtered RSRP and the ReferenceSignalPower parameter. ReferenceSignalPower is sent with SIB2.
Attributes available in Uplink Power Control:
ClosedLoopโ iftrue, Closed Loop Uplink Power Control mode is enabled; Open Loop Power Control otherwise. Default value isfalse.AccumulationEnabledโ iftrue, Accumulation Mode is enabled; Absolute mode otherwise. Default value isfalse.Alphaโ the path loss compensation factor. Default value is1.0.Pcminโ minimal UE TxPower. Default value is-40 dBm.Pcmaxโ maximal UE TxPower. Default value is23 dBm.PoNominalPuschโ this parameter should be set by higher layers, but currently it needs to be configured by the attribute system. Possible values are integers in range(-126 โฆ 24). Default value is-80.PoUePuschโ this parameter should be set by higher layers, but currently it needs to be configured by the attribute system. Possible values are integers in range(-8 โฆ 7). Default value is0.PsrsOffsetโ this parameter should be set by higher layers, but currently it needs to be configured by the attribute system. Possible values are integers in range(0 โฆ 15). Default value is7, which givesP_Srs_Offset_Value = 0.
Traced values in Uplink Power Control:
ReportPuschTxPowerโ current UE TxPower for PUSCHReportPucchTxPowerโ current UE TxPower for PUCCHReportSrsTxPowerโ current UE TxPower for SRS
Example configuration is presented below:
Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (true));
Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (30));
Config::SetDefault ("ns3::LteUePowerControl::ClosedLoop", BooleanValue (true));
Config::SetDefault ("ns3::LteUePowerControl::AccumulationEnabled", BooleanValue (true));
As an example, you can take a look at and run the lena-uplink-power-control program. ๐โโ๏ธ
๐ธ Examples Programs ๐ธ
The directory src/lte/examples/ contains some example simulation programs that show you how to simulate different LTE scenarios. iconic, honestly.
๐ Reference scenarios ๐
There is a vast amount of reference LTE simulation scenarios floating around in the literature. Here we list some of them:
- The system simulation scenarios mentioned in section A.2 of
[TR36814]. - The dual stripe model
[R4-092042], which is partially implemented in the example programsrc/lte/examples/lena-dual-stripe.cc. This example program features a lot of configurable parameters which can be customized by changing the corresponding global variables. To get a list of all these global variables, you can run this command:
./waf --run lena-dual-stripe --command-template="%s --PrintGlobals"
The following subsection presents an example of running a simulation campaign using this example program.
๐ฆ Handover simulation campaign ๐ฆ
In this subsection, we will demonstrate an example of running a simulation campaign using the LTE module of ns-3. The objective of the campaign is to compare the effect of each built-in handover algorithm of the LTE module. no cap. ๐ฅ
The campaign will use the lena-dual-stripe example program. First, we have to modify the example program to produce the output that we need. This time around, we want to produce the number of handovers, user average throughput, and average SINR.
The number of handovers can be obtained by counting the number of times the HandoverEndOk Handover traces is fired. Then the user average throughput can be obtained by enabling the RLC Simulation Output. Finally, SINR can be obtained by enabling the PHY simulation output. The following sample code snippet shows one possible way to obtain the above:
void
NotifyHandoverEndOkUe (std::string context, uint64_t imsi,
uint16_t cellId, uint16_t rnti)
{
std::cout << "Handover IMSI " << imsi << std::endl;
}
int
main (int argc, char *argv[])
{
/*** SNIP ***/
Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/HandoverEndOk",
MakeCallback (&NotifyHandoverEndOkUe));
lteHelper->EnablePhyTraces ();
lteHelper->EnableRlcTraces ();
Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (0)));
rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (simTime)));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
Then we have to configure the parameters of the program to suit our simulation needs. We are looking for the following assumptions in our simulation:
- 7 sites of tri-sectored macro eNodeBs (i.e. 21 macrocells) deployed in hexagonal layout with 500 m inter-site distance.
- Although
lena-dual-stripeis originally intended for a two-tier (macrocell and femtocell) simulation, we will simplify our simulation to a one-tier (macrocell) simulation only. - UEs are randomly distributed around the sites and attach to the network automatically using Idle mode cell selection. After that, UE will roam the simulation environment with 60 kmph movement speed.
- 50 seconds simulation duration, so UEs would have traveled far enough to trigger some handovers.
- 46 dBm macrocell Tx power and 10 dBm UE Tx power.
- EPC mode will be used because the X2 handover procedure requires it to be enabled.
- Full-buffer downlink and uplink traffic, both in 5 MHz bandwidth, using TCP protocol and Proportional Fair scheduler.
- Ideal RRC protocol.
Table lena-dual-stripe parameter configuration for handover campaign below shows how we configure the parameters of lena-dual-stripe to achieve the above assumptions. ๐
๐ lena-dual-stripe parameter configuration for handover campaign ๐
okay bestie, here's the whole vibe of how lena-dual-stripe gets configured for the handover campaign โ every single knob, no skips ๐
simTime=50โ 50 seconds simulation duration โฑ๏ธnBlocks=0โ Disabling apartment buildings and femtocells ๐ข๐nMacroEnbSites=7โ Number of macrocell sites (each site has 3 cells) ๐nMacroEnbSitesX=2โ The macrocell sites will be positioned in a 2-3-2 formation โจinterSiteDistance=500โ 500 m distance between adjacent macrocell sites ๐macroEnbTxPowerDbm=46โ 46 dBm Tx power for each macrocell ๐ฅepc=1โ Enable EPC mode ๐epcDl=1โ Enable full-buffer DL traffic โฌ๏ธepcUl=1โ Enable full-buffer UL traffic โฌ๏ธuseUdp=0โ Disable UDP traffic and enable TCP instead ๐ซถmacroUeDensity=0.00002โ Determines number of UEs (translates to 48 UEs in our simulation) ๐งoutdoorUeMinSpeed=16.6667โ Minimum UE movement speed in m/s (60 kmph) ๐ฆoutdoorUeMaxSpeed=16.6667โ Maximum UE movement speed in m/s (60 kmph) ๐ฆmacroEnbBandwidth=25โ 5 MHz DL and UL bandwidth ๐generateRem=1โ (Optional) For plotting the Radio Environment Map ๐บ๏ธ
so like, some of the required assumptions are just not available as parameters of lena-dual-stripe. no biggie. in that case we override the default attributes, as shown in Table Overriding default attributes for handover campaign below ๐
๐ธ Overriding default attributes for handover campaign ๐ธ
ns3::LteHelper::HandoverAlgorithmโ value isns3::NoOpHandoverAlgorithm,ns3::A3RsrpHandoverAlgorithm, orns3::A2A4RsrqHandoverAlgorithmโ Choice of handover algorithm ๐ns3::LteHelper::Schedulerโ value isns3::PfFfMacSchedulerโ Proportional Fair scheduler โ๏ธns3::LteHelper::UseIdealRrcโ value is1โ Ideal RRC protocol โจns3::RadioBearerStatsCalculator::DlRlcOutputFilenameโ value is<run>-DlRlcStats.txtโ File name for DL RLC trace output ๐ns3::RadioBearerStatsCalculator::UlRlcOutputFilenameโ value is<run>-UlRlcStats.txtโ File name for UL RLC trace output ๐ns3::PhyStatsCalculator::DlRsrpSinrFilenameโ value is<run>-DlRsrpSinrStats.txtโ File name for DL PHY RSRP/SINR trace output ๐ns3::PhyStatsCalculator::UlSinrFilenameโ value is<run>-UlSinrStats.txtโ File name for UL PHY SINR trace output ๐
fr fr, peep the <run> in those filenames โ that's a placeholder that gets swapped at runtime, so don't go hardcoding it, bestie ๐ซถ
ns-3 is literally serving so many ways to pass configuration values into a simulation ๐ In this example we're using the command line arguments โ it's basically just appending the parameters and their values to the waf call when you start each individual simulation. So the waf calls for invoking our 3 simulations look like this:
$ ./waf --run="lena-dual-stripe --simTime=50 --nBlocks=0 --nMacroEnbSites=7 --nMacroEnbSitesX=2 --epc=1 --useUdp=0 --outdoorUeMinSpeed=16.6667 --outdoorUeMaxSpeed=16.6667 --ns3::LteHelper::HandoverAlgorithm=ns3::NoOpHandoverAlgorithm --ns3::RadioBearerStatsCalculator::DlRlcOutputFilename=no-op-DlRlcStats.txt --ns3::RadioBearerStatsCalculator::UlRlcOutputFilename=no-op-UlRlcStats.txt --ns3::PhyStatsCalculator::DlRsrpSinrFilename=no-op-DlRsrpSinrStats.txt --ns3::PhyStatsCalculator::UlSinrFilename=no-op-UlSinrStats.txt --RngRun=1" > no-op.txt
$ ./waf --run="lena-dual-stripe --simTime=50 --nBlocks=0 --nMacroEnbSites=7 --nMacroEnbSitesX=2 --epc=1 --useUdp=0 --outdoorUeMinSpeed=16.6667 --outdoorUeMaxSpeed=16.6667 --ns3::LteHelper::HandoverAlgorithm=ns3::A3RsrpHandoverAlgorithm --ns3::RadioBearerStatsCalculator::DlRlcOutputFilename=a3-rsrp-DlRlcStats.txt --ns3::RadioBearerStatsCalculator::UlRlcOutputFilename=a3-rsrp-UlRlcStats.txt --ns3::PhyStatsCalculator::DlRsrpSinrFilename=a3-rsrp-DlRsrpSinrStats.txt --ns3::PhyStatsCalculator::UlSinrFilename=a3-rsrp-UlSinrStats.txt --RngRun=1" > a3-rsrp.txt
$ ./waf --run="lena-dual-stripe --simTime=50 --nBlocks=0 --nMacroEnbSites=7 --nMacroEnbSitesX=2 --epc=1 --useUdp=0 --outdoorUeMinSpeed=16.6667 --outdoorUeMaxSpeed=16.6667 --ns3::LteHelper::HandoverAlgorithm=ns3::A2A4RsrqHandoverAlgorithm --ns3::RadioBearerStatsCalculator::DlRlcOutputFilename=a2-a4-rsrq-DlRlcStats.txt --ns3::RadioBearerStatsCalculator::UlRlcOutputFilename=a2-a4-rsrq-UlRlcStats.txt --ns3::PhyStatsCalculator::DlRsrpSinrFilename=a2-a4-rsrq-DlRsrpSinrStats.txt --ns3::PhyStatsCalculator::UlSinrFilename=a2-a4-rsrq-UlSinrStats.txt --RngRun=1" > a2-a4-rsrq.txt
Some notes on the execution: ๐ซถ
- Notice that some arguments aren't specified because they're already the same as the default values ๐ We also keep the handover algorithms on each own default settings.
- Note the file names of simulation output, e.g. RLC traces and PHY traces, because we have to make sure that they are not overwritten by the next simulation run ๐ญ In this example, we specify the names one by one using the command line arguments.
- The
--RngRun=1argument at the end is used for setting the run number used by the random number generator used in the simulation ๐ฒ We re-run the same simulations with differentRngRunvalues, hence creating several independent replications of the same simulations. Then we average the results obtained from these replications to achieve some statistical confidence โจ - We can add a
--generateRem=1argument to generate the files necessary for generating the Radio Environment Map (REM) of the simulation ๐บ๏ธ The result is Figure REM obtained from a simulation in handover campaign below, which can be produced by following the steps described in Section Radio Environment Maps. This figure also shows the position of eNodeBs and UEs at the beginning of a simulation usingRngRun = 1. Other values ofRngRunmay produce different UE position ๐
[image] REM obtained from a simulation in handover campaign.
After hours of running, the simulation campaign will eventually end ๐ Next we will perform some post-processing on the produced simulation output to obtain meaningful information out of it ๐ธ
In this example, we use GNU Octave to assist the processing of throughput and SINR data, as demonstrated in a sample GNU Octave script below:
% RxBytes is the 10th column
DlRxBytes = load ("no-op-DlRlcStats.txt") (:,10);
DlAverageThroughputKbps = sum (DlRxBytes) * 8 / 1000 / 50
% RxBytes is the 10th column
UlRxBytes = load ("no-op-UlRlcStats.txt") (:,10);
UlAverageThroughputKbps = sum (UlRxBytes) * 8 / 1000 / 50
% Sinr is the 6th column
DlSinr = load ("no-op-DlRsrpSinrStats.txt") (:,6);
% eliminate NaN values
idx = isnan (DlSinr);
DlSinr (idx) = 0;
DlAverageSinrDb = 10 * log10 (mean (DlSinr)) % convert to dB
% Sinr is the 5th column
UlSinr = load ("no-op-UlSinrStats.txt") (:,5);
% eliminate NaN values
idx = isnan (UlSinr);
UlSinr (idx) = 0;
UlAverageSinrDb = 10 * log10 (mean (UlSinr)) % convert to dB
As for the number of handovers, we can use simple shell scripting to count the number of occurrences of string โHandoverโ in the log file:
โ โ โ โ
โ $ grep "Handover" no-op.txt | wc -l โ โ โ
โ โ โ โ
okay so that was us counting handovers, and now we get the receipts ๐
The table of results of the handover campaign below shows the complete statistics after we're done with post-processing on every individual simulation run. The values shown are the average of the results obtained from RngRun of 1, 2, 3, and 4.
Results of handover campaign ๐
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโ
โ Statistics โ No-op โ A2-A4-RSRQ โ Strongest cell โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ Average DL โ 6 615 kbps โ 20 509 kbpsโ 19 709 kbps โ
โ system โ โ โ โ
โ throughput โ โ โ โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ Average UL โ 4 095 kbps โ 5 705 kbps โ 6 627 kbps โ
โ system โ โ โ โ
โ throughput โ โ โ โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ Average DL SINR โ -0.10 dB โ 5.19 dB โ 5.24 dB โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ Average UL SINR โ 9.54 dB โ 81.57 dB โ 79.65 dB โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ Number of โ 0 โ 0.05694 โ 0.04771 โ
โ handovers per UE โ โ โ โ
โ per second โ โ โ โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโ
ngl the tea here is so good ๐ซ the results show that having a handover algorithm in a mobility simulation improves both user throughput and SINR significantly. There's little difference between the two handover algorithms in this campaign scenario. It would be interesting to see their performance in different scenarios, such as scenarios with home eNodeBs deployment ๐
๐ธ Frequency Reuse examples ๐ธ
There are two examples showing Frequency Reuse Algorithms functionality.
lena-frequency-reuse is a simple example with 3 eNBs in a triangle layout. There are 3 cell edge UEs, which are located in the center of this triangle, and 3 cell center UEs (one near each eNB). User can also specify the number of randomly located UEs. The FR algorithm is installed in eNBs and each eNB has a different FrCellTypeId, which means each eNB uses a different FR configuration. User can run lena-frequency-reuse with 6 different FR algorithms: NoOp, Hard FR, Strict FR, Soft FR, Soft FFR and Enhanced FFR. To run the scenario with the Distributed FFR algorithm, user should use lena-distributed-ffr. These two examples are very similar, but they were split because Distributed FFR requires EPC to be used, and the other algorithms do not.
To run lena-frequency-reuse with different Frequency Reuse algorithms, the user needs to specify the FR algorithm by overriding the default attribute ns3::LteHelper::FfrAlgorithm. Example command to run lena-frequency-reuse with the Soft FR algorithm is presented below:
$ ./waf --run "lena-frequency-reuse --ns3::LteHelper::FfrAlgorithm=ns3::LteFrSoftAlgorithm"
In these examples, functionality to generate REM and spectrum analyzer trace was added. User can enable generation of it by setting generateRem and generateSpectrumTrace attributes.
Command to generate REM for RB 1 in the data channel from the lena-frequency-reuse scenario with the Soft FR algorithm is presented below:
$ ./waf --run "lena-frequency-reuse --ns3::LteHelper::FfrAlgorithm=ns3::LteFrSoftAlgorithm
--generateRem=true --remRbId=1"
Radio Environment Map for Soft FR is presented in Figure REM for RB 1 obtained from the lena-frequency-reuse example with Soft FR algorithm enabled.
๐ผ๏ธ [image] REM for RB 1 obtained from lena-frequency-reuse example with Soft FR algorithm enabled.
Command to generate spectrum trace from the lena-frequency-reuse scenario with the Soft FFR algorithm is presented below (Spectrum Analyzer position needs to be configured inside script):
$ ./waf --run "lena-frequency-reuse --ns3::LteHelper::FfrAlgorithm=ns3::LteFfrSoftAlgorithm
--generateSpectrumTrace=true"
Example spectrum analyzer trace is presented in the figure Spectrum Analyzer trace obtained from the lena-frequency-reuse example with Soft FFR algorithm enabled. Spectrum Analyzer was located need eNB with FrCellTypeId 2. As can be seen, different data channel subbands are sent with different power level (according to configuration), while the control channel is transmitted with uniform power along the entire system bandwidth ๐ซ
๐ผ๏ธ [image] Spectrum Analyzer trace obtained fromlena-frequency-reuseexample with Soft FFR algorithm enabled. Spectrum Analyzer was located need eNB withFrCellTypeId2.
lena-dual-stripe can also be run with Frequency Reuse algorithms installed in all macro eNB. User needs to specify the FR algorithm by overriding the default attribute ns3::LteHelper::FfrAlgorithm. Example command to run lena-dual-stripe with the Hard FR algorithm is presented below:
$ ./waf --run="lena-dual-stripe
--simTime=50 --nBlocks=0 --nMacroEnbSites=7 --nMacroEnbSitesX=2
--epc=1 --useUdp=0 --outdoorUeMinSpeed=16.6667 --outdoorUeMaxSpeed=16.6667
--ns3::LteHelper::HandoverAlgorithm=ns3::NoOpHandoverAlgorithm
--ns3::LteHelper::FfrAlgorithm=ns3::LteFrHardAlgorithm
--ns3::RadioBearerStatsCalculator::DlRlcOutputFilename=no-op-DlRlcStats.txt
--ns3::RadioBearerStatsCalculator::UlRlcOutputFilename=no-op-UlRlcStats.txt
--ns3::PhyStatsCalculator::DlRsrpSinrFilename=no-op-DlRsrpSinrStats.txt
--ns3::PhyStatsCalculator::UlSinrFilename=no-op-UlSinrStats.txt
--RngRun=1" > no-op.txt
Example command to generate REM for RB 1 in the data channel from the lena-dual-stripe scenario with the Hard FR algorithm is presented below:
$ ./waf --run="lena-dual-stripe
--simTime=50 --nBlocks=0 --nMacroEnbSites=7 --nMacroEnbSitesX=2
--epc=0 --useUdp=0 --outdoorUeMinSpeed=16.6667 --outdoorUeMaxSpeed=16.6667
--ns3::LteHelper::HandoverAlgorithm=ns3::NoOpHandoverAlgorithm
--ns3::LteHelper::FfrAlgorithm=ns3::LteFrHardAlgorithm
--ns3::RadioBearerStatsCalculator::DlRlcOutputFilename=no-op-DlRlcStats.txt
--ns3::RadioBearerStatsCalculator::UlRlcOutputFilename=no-op-UlRlcStats.txt
--ns3::PhyStatsCalculator::DlRsrpSinrFilename=no-op-DlRsrpSinrStats.txt
--ns3::PhyStatsCalculator::UlSinrFilename=no-op-UlSinrStats.txt
--RngRun=1 --generateRem=true --remRbId=1" > no-op.txt
Radio Environment Maps for RB 1, 10 and 20 generated from the lena-dual-stripe scenario with the Hard Frequency Reuse algorithm are presented in the figures below. These RB were selected because each one is used by a different FR cell type ๐ฆ
๐ผ๏ธ [image] REM for RB 1 obtained from lena-dual-stripe simulation with Hard FR algorithm enabled.
๐ผ๏ธ [image] REM for RB 10 obtained from lena-dual-stripe simulation with Hard FR algorithm enabled.
๐ผ๏ธ [image] REM for RB 20 obtained from lena-dual-stripe simulation with Hard FR algorithm enabled.
๐ Carrier aggregation examples ๐
The carrier aggregation feature is not enabled by default. The user can enable it by setting the boolean attribute ns3::LteHelper::UseCa to true. The number of component carriers to be used in carrier aggregation can be configured by setting the attribute ns3::LteHelper::NumberOfComponentCarriers. Currently the maximum number is 5. Additionally, the component carrier manager needs to be configured. By default the NoOpComponentCarrierManager is selected, which means that only the primary carrier is enabled. The Component carrier manager (CCM) implementation that uses all the available carriers is RrComponentCarrierManager. The CCM can be configured by using the attribute LteHelper::EnbComponentCarrierManager.
An example configuration is presented below:
Config::SetDefault ("ns3::LteHelper::UseCa", BooleanValue (useCa));
Config::SetDefault ("ns3::LteHelper::NumberOfComponentCarriers", UintegerValue (2));
Config::SetDefault ("ns3::LteHelper::EnbComponentCarrierManager", StringValue ("ns3::RrComponentCarrierManager"));
As an example, the user can take a look and run the lena-simple and lena-simple-epc programs and enable LTE traces to check the performance. A new column is added to PHY and MAC traces to indicate the component carrier โจ
๐จ Radio link failure example
Bestie, meet lena-radio-link-failure.cc โ the example that lets you simulate the RLF functionality in all its dramatic glory โจ. Specifically, it simulates only one moving UE using either Ideal or Real RRC protocol with EPC, doing downlink and uplink communication, across two whole scenarios:
- Scenario A: Radio link failure example with one eNB โ [image] Scenario A: Radio link failure example with one eNB.
- Scenario B: Radio link failure example with two eNBs โ [image] Scenario B: Radio link failure example with two eNBs.
Quick heads-up tho ๐ซถ: RLF detection is enabled by default, and you can turn it off by configuring LteUePhy::EnableRlfDetection to false, like this:
Config::SetDefault ("ns3::LteUePhy::EnableRlfDetection", BooleanValue (false));
In this example, to study the impact of an RLF on the user's quality of experience, we compute an instantaneous (i.e., every 200 ms) DL throughput of the UE, and write it into a file for plotting purposes ๐. For example, to simulate the "Scenario A" with Ideal and Real RRC protocol a user can use the following commands:
Ideal RRC:
./waf --run "lena-radio-link-failure
--numberOfEnbs=1 --useIdealRrc=1
--interSiteDistance=1200 --n310=1 --n311=1
--t310=1 --enableCtrlErrorModel=1
--enableDataErrorModel=1 --simTime=25"
Real RRC:
./waf --run "lena-radio-link-failure
--numberOfEnbs=1 --useIdealRrc=0
--interSiteDistance=1200 --n310=1 --n311=1
--t310=1 --enableCtrlErrorModel=1
--enableDataErrorModel=1 --simTime=25"
After running the above two commands, we can use a simple gnuplot script to plot the throughput as shown in the Figure Downlink instantaneous throughput of UE in scenario A , e.g., ๐ธ
set terminal png
set output "lena-radio-link-failure-one-enb-thrput.png"
set multiplot
set xlabel "Time [s]"
set ylabel "Instantaneous throughput UE [Mbps]"
set grid
set title "LTE RLF example 1 eNB DL instantaneous throughput"
plot "rlf_dl_thrput_1_eNB_ideal_rrc" using ($1):($2) with linespoints
title 'Ideal RRC' linestyle 1 lw 2 lc rgb 'blue', "rlf_dl_thrput_1_eNB_real_rrc"
using ($1):($2) with linespoints title 'Real RRC' linestyle 2 lw 2 lc rgb 'red'
unset multiplot
[image] Downlink instantaneous throughput of UE in scenario A.
In the simulator, a UE can synchronize (i.e., start reading system information) with an eNB at a low RSRP level, which defaults to -140 dBm (see QRxLevMin attribute of eNB RRC). It enables the UE to start the random access procedure with the eNB ๐. In this scenario, when using the Ideal RRC the UE after the RLF will connect and disconnect from the eNB several times. This is because in the Ideal RRC mode, once the UE is able to receive Random Access Response (RAR) from the eNB, it can complete the RRC connection establishment procedure (sec-rrc-connection-establishment) without any errors, since all the RRC messages are exchanged ideally between the eNB and the UE. However, soon after the connection establishment, it ends up in RLF due to the poor channel quality ๐ญ. On the other hand, with the Real RRC the UE after the RLF will not be able to complete the RRC connection establishment procedure due to the loss of RRC messages. Thus, it will not be able to establish the connection with the eNB. Therefore, in both the cases the UE throughput drops to zero as shown in the Figure Downlink instantaneous throughput of UE in scenario A. It is also worthwhile to mention that towards the end of the simulation (using Ideal or Real RRC) there are occasions where RAR timer at the UE MAC would timeout due to the increased distance between the eNB and the UE, which causes errors while decoding this message at the UE (Note: the downlink control error model is enabled by default).
Similarly, to simulate the "Scenario B" with Ideal and Real RRC protocol following commands can be used:
Ideal RRC:
./waf --run "lena-radio-link-failure
--numberOfEnbs=2 --useIdealRrc=1
--interSiteDistance=1200 --n310=1 --n311=1
--t310=1 --enableCtrlErrorModel=1
--enableDataErrorModel=1 --simTime=25"
Real RRC:
./waf --run "lena-radio-link-failure
--numberOfEnbs=2 --useIdealRrc=0
--interSiteDistance=1200 --n310=1 --n311=1
--t310=1 --enableCtrlErrorModel=1
--enableDataErrorModel=1 --simTime=25"
Figure Downlink instantaneous throughput of UE in scenario B, shows the throughput in "Scenario B". We note that in this scenario the handover algorithm is not used. As expected, with Ideal RRC protocol the UE after the RLF can complete the random access procedure with the second eNB. Interestingly, the DL SINR after the connection establishment is not low enough to trigger the RLF, but it is low enough to impact the DL control reception for some TBs, which in turn causes loss of data. It can be observed from the slightly unstable throughput of the UE after connecting to the second eNB ๐. On the other hand, with Real RRC the UE faces problems in connection establishment phase due to the loss of RRC messages, in particular, the RRC connection request from the UE. This is the reason why the UE throughput after the RLF remains zero for a more extended period as compared to the ideal RRC protocol.
[image] Downlink instantaneous throughput of UE in scenario B.
๐ง Troubleshooting and debugging tips
Many users post on the ns-3-users mailing list asking, for example, why they do not get any traffic in their simulation, or maybe only uplink but no downlink traffic is generated, etc. ๐ฉ In most of the cases, this is a bug in the user simulation program. Here the reader can find some tips to debug the program and find out the cause of the problem.
The general approach is to selectively and incrementally enable the logging of relevant LTE module components, verifying upon each activation that the output is as expected. In detail:
- first check the control plane, in particular the RRC connection establishment procedure, by enabling the log components
LteUeRrcandLteEnbRrc - then check packet transmissions on the data plane, starting by enabling the log components
LteUeNetDeviceand theEpcSgwApplication,EpcPgwApplicationandEpcEnbApplication, then moving down the LTE radio stack (PDCP, RLC, MAC, and finally PHY). All this until you find where packets stop being processed / forwarded.
๐งช Testing Documentation
Overview
To test and validate the ns-3 LTE module, several test suites are provided which are integrated with the ns-3 test framework. To run them, you need to have configured the build of the simulator in this way:
$ ./waf configure --enable-tests --enable-modules=lte --enable-examples
$ ./test.py
The above will run not only the test suites belonging to the LTE module, but also those belonging to all the other ns-3 modules on which the LTE module depends. See the ns-3 manual for generic information on the testing framework.
You can get a more detailed report in HTML format in this way:
$ ./test.py -w results.html
After the above command has run, you can view the detailed result for each test by opening the file results.html with a web browser ๐.
You can run each test suite separately using this command:
$ ./test.py -s test-suite-name
For more details about test.py and the ns-3 testing framework, please refer to the ns-3 manual.
Description of the test suites
Unit Tests
SINR calculation in the Downlink
The test suite lte-downlink-sinr checks that the SINR calculation in downlink is performed correctly. The SINR in the downlink is calculated for each RB assigned to data transmissions by dividing the power of the intended signal from the considered eNB by the sum of the noise power plus all the transmissions on the same RB coming from other eNBs (the interference signals):
\gamma = \frac{ P_\mathrm{signal} }{ P_\mathrm{noise} + \sum
P_\mathrm{interference} }
In general, different signals can be active during different periods of time. We define a chunk as the time interval between any two events of type either start or end of a waveform. In other words, a chunk identifies a time interval during which the set of active waveforms does not change โจ. Let i be the generic chunk, T_i its duration and \mathrm{SINR_i} its SINR, calculated with the above equation. The calculation of the average SINR \overline{\gamma} to be used for CQI feedback reporting uses the following formula:
\overline{\gamma} = \frac{ \sum_i {\gamma}_i T_i }{ \sum_i T_{i} }
okay bestie so โ this test suite is literally doing a vibe check on the math from above, making sure the simulator performs that calculation correctly. ๐
The test vectors are obtained offline by an Octave script that implements the above equation, and that recreates a number of random transmitted signals and interference signals that mimic a scenario where an UE is trying to decode a signal from an eNB while facing interference from other eNBs. The test passes if the calculated values are equal to the test vector within a tolerance of 10^{-7}. That tolerance is there to account for the approximation errors typical of floating point arithmetic โ floats stay floatin', that's just the way it is. ๐ซถ
SINR calculation in the Uplink ๐ธ
The test suite lte-uplink-sinr checks that the SINR calculation in uplink is performed correctly. It's giving identical-to-lte-downlink-sinr energy (described in the previous section) with one glow-up: both the signal and the interference now refer to transmissions by the UEs, and reception is performed by the eNB. ๐
This test suite recreates a number of random transmitted signals and interference signals to mimic a scenario where an eNB is trying to decode the signal from several UEs simultaneously (the ones in the cell of the eNB) while facing interference from other UEs (the ones belonging to other cells). It's giving chaos, but make it physics. ๐ญ
The test vectors are obtained by a dedicated Octave script. The test passes if the calculated values are equal to the test vector within a tolerance of 10^{-7} which, as for the downlink SINR test, deals with floating point arithmetic approximation issues. same energy, same tolerance, same float drama.
E-UTRA Absolute Radio Frequency Channel Number (EARFCN) ๐ก
The test suite lte-earfcn checks that the carrier frequency used by the LteSpectrumValueHelper class (which implements the LTE spectrum model) is done in compliance with [TS36101], where the E-UTRA Absolute Radio Frequency Channel Number (EARFCN) is defined. โจ
The test vector for this test suite comprises a set of EARFCN values and the corresponding carrier frequency calculated by hand following the specification of [TS36101]. The test passes if the carrier frequency returned by LteSpectrumValueHelper is the same as the known value for each element in the test vector. match made in spec heaven. ๐
System Tests ๐งช
Dedicated Bearer Deactivation Tests ๐
The test suite lte-test-deactivate-bearer creates test case with single EnodeB and Three UE's. Each UE consists of one Default and one Dedicated EPS bearer with same bearer specification but with different ARP. The Test Case Flow is as follows: Attach UE -> Create Default+Dedicated Bearer -> Deactivate one of the Dedicated bearer. a whole storyline fr fr.
Test case further deactivates dedicated bearer having bearer ID 2 (LCID=BearerId+2) of First UE (UE_ID=1). User can schedule bearer deactivation after specific time delay using Simulator::Schedule () method. scheduling queen behavior. โฐ
Once the test case execution ends it will create DlRlcStats.txt and UlRlcStats.txt. Key fields that need to be checked in statistics are:
|Start | end | Cell ID | IMSI | RNTI | LCID | TxBytes | RxBytes |
Test case executes in three epochs:
- In first Epoch (
0.04s-1.04s) All UE's and corresponding bearers gets attached and packet flow over the dedicated bearers activated. - In second Epoch (
1.04s-2.04s), bearer deactivation is instantiated, hence User can see relatively less number of TxBytes onUE_ID=1andLCID=4as compared to other bearers. - In third Epoch (
2.04s-3.04s) since bearer deactivation ofUE_ID=1andLCID=4is completed, user will not see any logging related toLCID=4.
Test case passes if and only if
IMSI=1andLCID=4completely removed in third epoch- No packets seen in TxBytes and RxBytes corresponding to
IMSI=1andLCID=4
If above criteria do not match, the test case is considered to be failed. no partial credit, bestie, it's pass or it's flop. ๐ญ
Adaptive Modulation and Coding Tests ๐ฅ
The test suite lte-link-adaptation provides system tests recreating a scenario with a single eNB and a single UE. Different test cases are created corresponding to different SNR values perceived by the UE. The aim of the test is to check that in each test case the chosen MCS corresponds to some known reference values. ๐
These reference values are obtained by re-implementing in Octave (see src/lte/test/reference/lte_amc.m) the model described in Section sec-lte-amc for the calculation of the spectral efficiency, and determining the corresponding MCS index by manually looking up the tables in [R1-081483]. The resulting test vector is represented in Figure Test vector for Adaptive Modulation and Coding. iconic manual table lookup moment.
The MCS which is used by the simulator is measured by obtaining the tracing output produced by the scheduler after 4ms (this is needed to account for the initial delay in CQI reporting). The SINR which is calculated by the simulator is also obtained using the LteChunkProcessor interface. The test passes if both the following conditions are satisfied:
- the SINR calculated by the simulator correspond to the SNR of the test vector within an absolute tolerance of
10^{-7}; - the MCS index used by the simulator exactly corresponds to the one in the test vector.
[image] Test vector for Adaptive Modulation and Coding.
Inter-cell Interference Tests ๐
The test suite lte-interference provides system tests recreating an inter-cell interference scenario with two eNBs, each having a single UE attached to it and employing Adaptive Modulation and Coding both in the downlink and in the uplink. The topology of the scenario is depicted in Figure Topology for the inter-cell interference test. The d_1 parameter represents the distance of each UE to the eNB it is attached to, whereas the d_2 parameter represent the interferer distance. We note that the scenario topology is such that the interferer distance is the same for uplink and downlink; still, the actual interference power perceived will be different, because of the different propagation loss in the uplink and downlink bands. same distance, different drama. Different test cases are obtained by varying the d_1 and d_2 parameters.
[image] Topology for the inter-cell interference test.
The test vectors are obtained by use of a dedicated octave script (available in src/lte/test/reference/lte_link_budget_interference.m), which does the link budget calculations (including interference) corresponding to the topology of each test case, and outputs the resulting SINR and spectral efficiency. The latter is then used to determine (using the same procedure adopted for Adaptive Modulation and Coding Tests). We note that the test vector contains separate values for uplink and downlink. ๐
UE Measurements Tests ๐
The test suite lte-ue-measurements provides system tests recreating an inter-cell interference scenario identical of the one defined for lte-interference test-suite. However, in this test the quantities to be tested are represented by RSRP and RSRQ measurements performed by the UE in two different points of the stack: the source, which is UE PHY layer, and the destination, that is the eNB RRC. two locations, one truth. โจ
The test vectors are obtained by the use of a dedicated octave script (available in src/lte/test/reference/lte-ue-measurements.m), which does the link budget calculations (including interference) corresponding to the topology of each test case, and outputs the resulting RSRP and RSRQ. The obtained values are then used for checking the correctness of the UE Measurements at PHY layer. After that, they have to be converted according to 3GPP formatting for the purpose of checking their correctness at eNB RRC level. glow-up: PHY edition, then RRC edition.
UE measurement configuration tests ๐ฆ
Besides the previously mentioned test suite, there are 3 other test suites for testing UE measurements: lte-ue-measurements-piecewise-1, lte-ue-measurements-piecewise-2, and lte-ue-measurements-handover. These test suites are more focused on the reporting trigger procedure, i.e. the correctness of the implementation of the event-based triggering criteria is verified here. ๐
In more specific, the tests verify the timing and the content of each measurement reports received by eNodeB. Each test case is an stand-alone LTE simulation and the test case will pass if measurement report(s) only occurs at the prescribed time and shows the correct level of RSRP (RSRQ is not verified at the moment). timing is everything, bestie. โฐ
Piecewise configuration ๐
The piecewise configuration aims to test a particular UE measurements configuration. The simulation script will setup the corresponding measurements configuration to the UE, which will be active throughout the simulation. ๐ธ
Since the reference values are precalculated by hands, several assumptions are made to simplify the simulation. Firstly, the channel is only affected by path loss model (in this case, Friis model is used). Secondly, the ideal RRC protocol is used, and layer 3 filtering is disabled. Finally, the UE moves in a predefined motion pattern between 4 distinct spots, as depicted in Figure UE movement trace throughout the simulation in piecewise configuration below. Therefore the fluctuation of the measured RSRP can be determined more easily. we love a controlled little world.
[image] UE movement trace throughout the simulation in piecewise configuration.
The motivation behind the "teleport" between the predefined spots is to introduce drastic change of RSRP level, which will guarantee the triggering of entering or leaving condition of the tested event. By performing drastic changes, the test can be run within shorter amount of time. teleporting is a valid testing strategy, no cap. ๐ง
Figure Measured RSRP trace of an example Event A1 test case in piecewise configuration below shows the measured RSRP after layer 1 filtering by the PHY layer during the simulation with a piecewise configuration. Because layer 3 filtering is disabled, these are the exact values used by the UE RRC instance to evaluate reporting trigger procedure. Notice that the values are refreshed every 200 ms, which is the default filtering period of PHY layer measurements report. The figure also shows the time when entering and leaving conditions of an example instance of Event A1 (serving cell becomes better than threshold) occur during the simulation. โญ
[image] Measured RSRP trace of an example Event A1 test case in piecewise configuration.
Each reporting criterion is tested several times with different threshold/offset parameters. Some test scenarios also take hysteresis and time-to-trigger into account. Figure Measured RSRP trace of an example Event A1 with hysteresis test case in piecewise configuration depicts the effect of hysteresis in another example of Event A1 test. ๐
[image] Measured RSRP trace of an example Event A1 with hysteresis test case in piecewise configuration.
okay so here's the tea on piecewise configuration, bestie โ it's getting used in two whole test suites for UE measurements, and honestly? iconic behavior. โจ
The first one is lte-ue-measurements-piecewise-1, which we're calling Piecewise test #1 from here on out (iykyk, shorter is better ๐
). It simulates 1 UE and 1 eNodeB. Just the two of them. A little duo. A tiny little network situationship. ๐ซถ
The other one is lte-ue-measurements-piecewise-2, and she's different โ she's got 1 UE and 2 eNodeBs running around in the simulation. Extra eNodeB energy. Main character expansion. ๐
So what's Piecewise test #1 actually for? She's the designated tester for the event-based criteria that don't depend on a neighboring cell existing. Like, no neighbor? No problem. Those criteria are:
- Event A1 ๐
- Event A2 ๐
And then โ not me forgetting the other events โ the rest of the events also get a brief little test run, just to double-check they're still working correctly. Even though they're not reporting anything, because, well, there's no neighboring cell for them to report about. They're literally doing the most for zero reward and we respect them for it. ๐ญ
important vibe check: in Piecewise test #1 there is no neighboring cell at all, so those other events produce no reports. The test is confirming they still behave correctly in that absence โ not that they report stuff. Don't get it twisted. ๐
Table UE measurements test scenarios using piecewise configuration #1 (down below, keep scrolling bestie ๐ธ) lists out every scenario that gets tested in piecewise test #1. Go look at it. It's giving organized. It's giving thorough. It's giving slay. โญ
๐ UE measurements test scenarios using piecewise configuration #1 ๐
okay bestie, this first table is the whole vibe check for Piecewise test #1 โ every single scenario it runs, laid out plain. Reporting Criteria, Threshold/Offset, Hysteresis, Time-to-Trigger, one row per test. no cap, all 17 of them are right here:
Test # Reporting Threshold/Offset Hysteresis Time-to-Trigger
Criteria
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
1 Event A1 Low No No
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
2 Event A1 Normal No No
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
3 Event A1 Normal No Short
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
4 Event A1 Normal No Long
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
5 Event A1 Normal No Super
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
6 Event A1 Normal Yes No
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
7 Event A1 High No No
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
8 Event A2 Low No No
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
9 Event A2 Normal No No
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
10 Event A2 Normal No Short
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
11 Event A2 Normal No Long
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
12 Event A2 Normal No Super
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
13 Event A2 Normal Yes No
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
14 Event A2 High No No
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
15 Event A3 Zero No No
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
16 Event A4 Normal No No
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
17 Event A5 Normal-Normal No No
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Other events such as Event A3, A4, and A5 depend on measurements of neighbouring cell, so they are more thoroughly tested in Piecewise test #2. The simulation places the nodes on a straight line and instruct the UE to "jump" in a similar manner as in Piecewise test #1. Handover is disabled in the simulation, so the role of serving and neighbouring cells do not switch during the simulation. Table UE measurements test scenarios using piecewise configuration #2 below lists the scenarios tested in Piecewise test #2.
๐ fr fr, handover being off is the whole plot twist here โ nobody switches roles mid-sim, so serving and neighbouring cells stay exactly who they are. periodt.
๐ฆ UE measurements test scenarios using piecewise configuration #2 ๐ฆ
and here's the sequel, bestie โ Piecewise test #2, sixteen scenarios, zero skips:
โโโโโโโโโโฌโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ
โ Test # โ Reporting โ Threshold/Offset โ Hysteresis โ Time-to-Trigger โ
โ โ Criteria โ โ โ โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 1 โ Event A1 โ Low โ No โ No โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 2 โ Event A1 โ Normal โ No โ No โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 3 โ Event A1 โ Normal โ Yes โ No โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 4 โ Event A1 โ High โ No โ No โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 5 โ Event A2 โ Low โ No โ No โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 6 โ Event A2 โ Normal โ No โ No โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 7 โ Event A2 โ Normal โ Yes โ No โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 8 โ Event A2 โ High โ No โ No โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 9 โ Event A3 โ Positive โ No โ No โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 10 โ Event A3 โ Zero โ No โ No โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 11 โ Event A3 โ Zero โ No โ Short โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 12 โ Event A3 โ Zero โ No โ Super โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 13 โ Event A3 โ Zero โ Yes โ No โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 14 โ Event A3 โ Negative โ No โ No โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 15 โ Event A4 โ Low โ No โ No โ
โโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ 16 โ Event A4 โ Normal โ No โ No โ
okay bestie the table is STILL going, stay with me ๐
17โ Event A4 ยท Normal ยท No ยท Short18โ Event A4 ยท Normal ยท No ยท Super19โ Event A4 ยท Normal ยท Yes ยท No20โ Event A4 ยท High ยท No ยท No21โ Event A5 ยท Low-Low ยท No ยท No22โ Event A5 ยท Low-Normal ยท No ยท No23โ Event A5 ยท Low-High ยท No ยท No24โ Event A5 ยท Normal-Low ยท No ยท No25โ Event A5 ยท Normal-Normal ยท No ยท No26โ Event A5 ยท Normal-Normal ยท No ยท Short27โ Event A5 ยท Normal-Normal ยท No ยท Super28โ Event A5 ยท Normal-Normal ยท Yes ยท No29โ Event A5 ยท Normal-High ยท No ยท No30โ Event A5 ยท High-Low ยท No ยท No31โ Event A5 ยท High-Normal ยท No ยท No32โ Event A5 ยท High-High ยท No ยท No
one note about the tests with time-to-trigger, bestie: they get tested using 3 different values of time-to-trigger:
- short โ shorter than the report interval
- long โ shorter than the filter measurement period of
200 ms - super โ longer than
200 ms
The first two are there to make sure that time-to-trigger evaluation always uses the freshest measurement reports it received from the PHY layer. The last one has the job of verifying time-to-trigger cancellation โ like when a measurement report from PHY shows that the entering/leaving condition is no longer true before the first trigger has even fired. ๐ซถ
Handover configuration ๐
So the whole point of the handover configuration is to check whether the UE measurement configuration gets updated properly after a successful handover takes place. To do that, the simulation constructs 2 eNodeBs with different UE measurement configuration, and the UE performs a handover from one cell to another. The UE is sitting on a straight line between the 2 eNodeBs, and the handover is invoked manually. Each simulation runs for 2 seconds (except the last test case), and the handover gets triggered exactly at halfway of the simulation. โจ
The lte-ue-measurements-handover test suite covers all sorts of configuration differences. The first one is the difference in report interval โ like, the first eNodeB is configured with 480 ms report interval, while the second eNodeB is configured with 240 ms report interval. So when the UE performed the handover to the second cell, that new report interval must take effect. And same as in piecewise configuration, the timing and the content of each measurement report received by the eNodeB will be verified. ๐
Other types of differences the test suite covers are differences in event and differences in threshold/offset. The table UE measurements test scenarios using handover configuration below lists all the tested scenarios. ๐ธ
UE measurements test scenarios using handover configuration
okay so picking right back up where we left off โ this is the full scenario table, and the whole vibe is: every single test case flips one measurement knob between the Initial config and the Post-Handover config. Report interval? Event? Threshold/offset? Time-to-trigger? All of it, swapped mid-flight, no cap. The way tests 16 and 17 both start at 1024 ms and then justโฆ diverge ๐ญ
UE measurements test scenarios using handover configuration
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Test # Test Subject Initial Post-Handover
Configuration Configuration
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
1 Report interval 480 ms 240 ms
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
2 Report interval 120 ms 640 ms
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
3 Event Event A1 Event A2
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
4 Event Event A2 Event A1
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
5 Event Event A3 Event A4
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
6 Event Event A4 Event A3
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
7 Event Event A2 Event A3
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
8 Event Event A3 Event A2
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
9 Event Event A4 Event A5
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
10 Event Event A5 Event A4
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
11 Threshold/offset RSRP range 52 RSRP range 56
(Event A1) (Event A1)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
12 Threshold/offset RSRP range 52 RSRP range 56
(Event A2) (Event A2)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
13 Threshold/offset A3 offset -30 A3 offset +30
(Event A3) (Event A3)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
14 Threshold/offset RSRP range 52 RSRP range 56
(Event A4) (Event A4)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
15 Threshold/offset RSRP range 52-52 RSRP range 56-56
(Event A5) (Event A5)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
16 Time-to-trigger 1024 ms 100 ms
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
17 Time-to-trigger 1024 ms 640 ms
seventeen scenarios, every one of them documented, periodt โจ
also bestie, fair warning: the table borders in this stretch of the source doc are fully scrambled โ stray โ marks just vibing inside the middle of sentences, iconic honestly ๐ โ so here's the frame it left behind before the next bit:
โโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโ
โ โ โ โ โ
๐ Round Robin scheduler performance
So the test suite lte-rr-ff-mac-scheduler spins up a bunch of test cases, and every single one has one eNB and several UEs, all sharing the exact same Radio Bearer specification. In each test case the UEs are all seeing the same SINR from the eNB โ what changes between cases is the distance between the UEs and the eNB (which is, like, the whole reason the SINR values differ) plus how many UEs are in the mix.
What's the test actually checking? That the throughput everybody gets is equal among users, and that it matches a reference throughput value derived from the SINR, all within a given tolerance. Fairness girlies rise ๐ซถ
The test vector comes from the transport block size values reported in table 7.1.7.2.1-1 of [TS36213], assuming the physical resource blocks get distributed equally among the users via Resource Allocation Type 0, exactly as defined in Section 7.1.6.1 of [TS36213].
Let \tau be the TTI duration, N be the number of UEs, B the transmission bandwidth configuration in number of RBs, G the RBG size, M the modulation and coding scheme in use at the given SINR, and S(M, B) the transport block size in bits as defined by 3GPP TS 36.213. First we calculate the number L of RBGs allocated to each user:
L = \left\lfloor \frac{B}{NG} \right\rfloor
and then the reference throughput T in bit/s achieved by each UE is:
T = \frac{S(M, L G)}{8 \; \tau}
The test passes if the measured throughput matches the reference throughput within a relative tolerance of0.1. That tolerance exists because of the transient behavior at the start of the simulation (like, CQI feedback only shows up after a few subframes) and because of how accurate the estimator of average throughput is over the chosen simulation time (0.4s). That0.4sis what it is because of the ns-3 guidelines โ keep the total execution time of the test suite low even though there's a huge number of test cases. And lowkey, if you're running longer simulations, a lower tolerance value can be used. noted ๐
In Figure fig-lenaThrTestCase1, the curves labeled โRRโ are the test values calculated for the RR scheduler test, plotted against the number of UEs and the MCS index used in each test case.
[image] Test vectors for the RR and PF Scheduler in the downlink in a scenario where all UEs use the same MCS.. (yes the caption really does end with two dots and a stray .UNINDENT in the source. we love an unpolished queen ๐)
๐ Proportional Fair scheduler performance
Now for the other one โ the test suite lte-pf-ff-mac-scheduler makes a bunch of test cases with a single eNB, using the Proportional Fair (PF) scheduler, and several UEs, all with the same Radio Bearer specification. These test cases split into two categories, so we can check performance both in terms of adapting to the channel condition and from a fairness perspective. two birds, one icon ๐
First category: all the UEs are placed at the same distance from the eNB, which means they all have the same SINR. Different test cases = a different SINR value and a different number of UEs. The test checks that the throughput performance matches the known reference throughput up to a given tolerance.
What should the PF scheduler do when every UE has the same SNR? Each UE should get an equal fraction of the throughput that a single UE could get using all the resources. So the reference throughput value = the throughput achievable by a single UE at the given SNR, divided by the total number of UEs.
Let \tau be the TTI duration, B the transmission bandwidth configuration in number of RBs, M the modulation and coding scheme in use at the given SINR, and S(M, B) the transport block size as defined in [TS36213]. Then the reference throughput T in bit/s achieved by each UE is:
T = \frac{S(M,B)}{\tau N}
The curves labeled โPFโ in Figure fig-lenaThrTestCase1 are the test values calculated for the PF scheduler tests of the first category, the one we just described.
The second category of tests aims at verifying the fairness of the PF
scheduler in a more realistic simulation scenario where the UEs have a different SINR (constant for the whole simulation). Under those conditions, the PF scheduler hands each user a slice of the system bandwidth that's proportional to the capacity a single user could get on their own, given their SINR. Let's break it down: let M_i be the modulation and coding scheme each UE is using (which is a deterministic function of that UE's SINR, so in this scenario it's just... known, bestie). Based on the MCS, we figure out the achievable rate R_i for each user i using the procedure from Section~ref{sec:pfs}. Then we define the achievable rate ratio \rho_{R,i} of each user i as
\rho_{R,i} = \frac{R_i}{\sum_{j=1}^N R_j}
Now let T_i be the throughput actually achieved by UE i, which you get as part of the simulation output. We define the obtained throughput ratio \rho_{T,i} of UE i as
\rho_{T,i} = \frac{T_i}{\sum_{j=1}^N T_j}
The test is literally just checking that this condition holds:
\rho_{R,i} = \rho_{T,i}
and if it does, it means the throughput each UE got over the whole simulation matches the steady-state throughput the PF scheduler is supposed to give according to theory. โจ Iconic. This test can be derived from [Holtzman2000] like so: from Section 3 of [Holtzman2000], we know that
\frac{T_i}{R_i} = c, \, \forall i
where c is a constant. Substitute that into the definition of \rho_{T,i} from before and we get
\frac{T_i}{\sum_{j=1}^N T_j} &= \frac{c R_i}{\sum_{j=1}^N c R_j} \\
&= \frac{c R_i}{c \sum_{j=1}^N R_j} \\
&= \frac{R_i}{\sum_{j=1}^N R_j}
which is exactly the expression the test uses. no cap. ๐
๐ผ๏ธ Figure Throughput ratio evaluation for the PF scheduler in a scenario where the UEs have MCS index 28, 24, 16, 12, 6 โ this figure shows the results from a test case with UEs i=1,\dots,5 sitting at a distance from the base station such that they'll use the MCS index 28, 24, 16, 12, 6 respectively. Looking at it, we see that โ as expected โ the obtained throughput is proportional to the achievable rate. In other words, the PF scheduler assigns more resources to the users with a higher MCS index. ๐
๐ธ Maximum Throughput scheduler performance ๐ธ
Test suites lte-fdmt-ff-mac-scheduler and lte-tdmt-ff-mac-scheduler build a bunch of different test cases with a single eNB and several UEs, all sharing the same Radio Bearer specification, using the Frequency Domain Maximum Throughput (FDMT) scheduler and the Time Domain Maximum Throughput (TDMT) scheduler respectively. In other words, all the UEs are placed at the same distance from the eNB, so they all end up with the same SNR. Different test cases come from using different SNR values and a different number of UEs. The test checks that the obtained throughput performance matches the known reference throughput up to a given tolerance.
The expected behavior of both FDMT and TDMT when all UEs have the same SNR is that the scheduler allocates all RBGs to the first UE defined in the script. Why? Because the current FDMT and TDMT implementation always picks the first UE to serve whenever multiple UEs have the same SNR value. So we compute the reference throughput value for the first UE from the throughput achievable by a single UE at the given SNR, while the reference throughput value for the other UEs is zero. Let \tau be the TTI duration, B the transmission bandwidth configuration in number of RBs, M the modulation and coding scheme in use at the given SNR, and S(M, B) the transport block size as defined in [TS36213]. The reference throughput T in bit/s achieved by each UE is calculated as
T = \frac{S(M,B)}{\tau}
๐ฆ Throughput to Average scheduler performance ๐ฆ
Test suites lte-tta-ff-mac-scheduler create different test cases with a single eNB and several UEs, all having the same Radio Bearer specification, using the TTA scheduler. The network topology and configurations in the TTA test case are the same as in the test for the MT scheduler. More complex test cases need to be developed to show off the fairness feature of the TTA scheduler. ๐ซถ
๐ Blind Average Throughput scheduler performance ๐
Test suites lte-tdbet-ff-mac-scheduler and lte-fdbet-ff-mac-scheduler create different test cases with a single eNB and several UEs, all having the same Radio Bearer specification.
In the first test case of lte-tdbet-ff-mac-scheduler and lte-fdbet-ff-mac-scheduler, the UEs are all placed at the same distance from the eNB, and hence all placed in order to have the same SNR. Different test cases are implemented by using a different SNR value and a different number of UEs. The test consists on checking that the obtained throughput performance matches the known reference throughput up to a given tolerance. In the long term, the expected behavior of both TD-BET and FD-BET when all UEs have the same SNR is that each UE should get an equal throughput. However, the exact throughput value of TD-BET and FD-BET in this test case is not the same.
When all UEs have the same SNR, TD-BET can be seen as a specific case of PF where the achievable rate equals 1. Therefore, the throughput obtained by TD-BET is equal to that of PF. On the other hand, FD-BET performs very similarly to the round robin (RR) scheduler when all UEs have the same SNR and the number of UE (or RBG) is an integer multiple of the number of RBG (or UE). In that case, FD-BET always allocates the same number of RBGs to each UE. For example, if the eNB has 12 RBGs and there are 6 UEs, then each UE will get 2 RBGs in each TTI. Or if the eNB has 12 RBGs and there are 24 UEs, then each UE will get 2 RBGs per two TTIs. When the number of UE (RBG) is not an integer multiple of the number of RBG (UE), FD-BET will not follow the RR behavior, because it will assign a different number of RBGs to some UEs, while the throughput of each UE is still the same.
The second category of tests aims at verifying the fairness of both the TD-BET and FD-BET schedulers in a more realistic simulation scenario where the UEs have a different SNR (constant for the whole simulation). In this case, both schedulers should give the same amount of averaged throughput to each user.
Specifically, for TD-BET, let F_i be the fraction of time allocated to user i in total simulation time, R^{fb}_i be the full bandwidth achievable rate for user i and T_i be the achieved throughput of user i. Then we have:
T_i = F_i R^{fb}_i
In TD-BET, the sum of F_i for all users equals one. In the long term, all UEs have the same T_i, so we replace T_i by T. Then we have:
T = \frac{1}{ \sum_{i=1}^{N} \frac{1}{R^{fb}_i} }
๐ Token Band Fair Queue scheduler performance ๐
Test suites lte-fdtbfq-ff-mac-scheduler and lte-tdtbfq-ff-mac-scheduler create different test cases for testing three key features of the TBFQ scheduler: traffic policing, fairness and traffic balance. Constant Bit Rate UDP traffic is used in both downlink and uplink in all test cases. The packet interval is set to 1ms to keep the RLC buffer non-empty. Different traffic rates are achieved by setting different packet sizes. Specifically, two classes of flows are created in the test suites:
- Homogeneous flow: flows with the same token generation rate and packet arrival rate
- Heterogeneous flow: flows with different packet arrival rate, but with the same token generation rate
In test case 1, the traffic policing and fairness features are verified for the scenario where all UEs are placed at the same distance from the eNB. In this case, all UEs have the same SNR value. Different test cases are implemented by using a different SNR value and a different number of UEs. Because each flow has the same traffic rate and token generation rate, the TBFQ scheduler will guarantee the same throughput among UEs without the constraint of the token generation rate. In addition, the exact value of the UE throughput depends on the total traffic rate:
- If total traffic rate <= maximum throughput, UE throughput = traffic rate
- If total traffic rate > maximum throughput, UE throughput = maximum throughput / N
Here, N is the number of UEs connected to the eNodeB. The maximum throughput in this case equals the rate at which all RBGs are assigned to one UE (e.g., when distance equals 0, maximum throughput is 2196000 byte/sec). When the traffic rate is smaller than the max bandwidth, TBFQ can police the traffic by token generation rate so that the UE throughput equals its actual traffic rate (token generation rate is set to traffic generation rate). On the other hand, when the total traffic rate is bigger than the max throughput, the eNodeB cannot forward all traffic to the UEs. Therefore, in each TTI, TBFQ will allocate all RBGs to one UE due to the large packets buffered in the RLC buffer. When a UE is scheduled in the current TTI, its token counter is decreased so that it will not be scheduled in the next TTI. Because each UE has the same traffic generation rate, TBFQ will serve each UE in turn and only serve one UE in each TTI (both in TD TBFQ and FD TBFQ). Therefore, the UE throughput in the second condition equals the even share of the maximum throughput. ๐โจ
Test case 2 is where we verify traffic policing and fairness when every UE sits at a different distance from the eNB. So in this case, each UE has a different SNR value. Like test case 1, UE throughput in test case 2 depends on the total traffic rate too, but with a different maximum throughput. Say all UEs are carrying a high traffic load โ then the traffic saturates the RLC buffer in eNodeB. In each TTI, after picking the one UE with the highest metric, TBFQ will allocate all the RBGs to that UE because the RLC buffer size is so large. But once the RLC buffer is saturated, the total throughput of all UEs can't grow any more. And like we said in test case 1, for homogeneous flows that have the same t_i and r_i, every UE ends up with the same throughput in the long term. So we can use the same method as in TD BET to compute the maximum throughput:
T = \frac{N}{ \sum_{i=1}^{N} \frac{1}{R^{fb}_i} }
Here, T is the maximum throughput. R^{fb}_i is the full bandwidth achievable rate for user i. N is the number of UE.
When the total traffic rate is bigger than T, the UE throughput equals \frac{T}{N}. Otherwise, UE throughput equals its traffic generation rate.
Test case 3 creates three flows with different traffic rates. The token generation rate for each flow is the same, and it equals the average traffic rate of the three flows. Since TBFQ uses a shared token bank, tokens contributed by a UE with lower traffic load can be used by a UE with higher traffic load. That's how TBFQ guarantees the traffic rate for each flow. Even though we're using heterogeneous flows here, the calculation of maximum throughput is the same as in test case 2. When we calculated the max throughput of test case 2, we assumed all UEs suffer a high traffic load, so the scheduler always assigns all RBGs to one UE in each TTI. That assumption still holds in the heterogeneous flow case. In other words โ whether or not those flows have the same traffic rate and token generation rate, if their traffic rate is big enough, TBFQ performs just like it does in test case 2. So the maximum bandwidth in test case 3 is the same as in test case 2. ๐ซ
In test case 3, for some flows the token generation rate does not equal MBR, even though all flows are CBR traffic. That's not in line with our parameter setting rules. Honestly, the traffic balance feature is meant for VBR traffic โ because different UEs' peak rates may happen at different times, TBFQ uses a shared token bank to balance the traffic among those VBR traffics. Test case 3 just uses CBR traffic to verify this feature. But in a real simulation, it's recommended to set the token generation rate to MBR. ๐ซถ
๐ Priority Set scheduler performance ๐
The test suites lte-pss-ff-mac-scheduler create different test cases with a single eNB and several UEs. In all test cases, we select PFsch in the FD scheduler. Same testing results can also be obtained by using the CoItA scheduler. Also, all test cases don't define nMux, so the TD scheduler in PSS will always select half of the total UE.
In the first class of test cases in lte-pss-ff-mac-scheduler, the UEs are all placed at the same distance from the eNB, so they're all set up to have the same SNR. Different test cases are implemented by using a different TBR for each UE. In every test case, all UEs have the same Target Bit Rate, configured by GBR in the EPS bearer setting. The expected behavior of PSS is to guarantee that each UE's throughput at least equals its TBR, as long as the total flow rate is below maximum throughput. Just like TBFQ, the maximum throughput here equals the rate you get when all RBGs are assigned to one UE. When the traffic rate is smaller than max bandwidth, UE throughput equals its actual traffic rate; on the other hand, UE throughput equals an even share of the maximum throughput.
In the first class of test cases, each UE has the same SNR. So the priority metric in the PF scheduler is determined by the past average throughput T_{j}(t), because each UE has the same achievable throughput R_{j}(k,t) in PFsch, or the same CoI[k,n] in CoItA. This means PSS will perform like a TD-BET, allocating all RBGs to one UE in each TTI. Then the maximum value of UE throughput equals the achievable rate when all RBGs are allocated to that UE. ๐
In the second class of test cases in lte-pss-ff-mac-scheduler, the UEs are all placed at the same distance from the eNB, and so again they're all set up to have the same SNR. Different TBR values are assigned to each UE. There's still a maximum throughput in this case. Once the total traffic rate goes above that threshold, there will be some UEs that can't achieve their TBR. Because there's no fading, the subband CQIs for each RBG's frequency are the same. So in the FD scheduler, in each TTI, the priority metrics of a UE for all RBGs are the same. That means the FD scheduler will always allocate all RBGs to one user. Therefore, in the maximum throughput case, PSS performs like a TD-BET. And then we have:
T = \frac{N}{ \sum_{i=1}^N \frac{1}{R^{fb}_i} }
Here, T is the maximum throughput. R^{fb}_i is the full bandwidth achievable rate for user i. N is the number of UE.
๐ฆ Channel and QoS aware scheduler performance ๐ฆ
The performance of the Channel and QoS aware scheduler can be tested similarly to the performance of the Priority Set scheduler โ when the GBR flows are not delay sensitive โ by measuring whether the achieved throughput at the RLC layer is close to the TBR. With that in mind, the performance of the CQA scheduler is tested using the same test cases as lte-pss-ff-mac-scheduler. Also, in [Bbojovic2014] you can find a performance evaluation of the CQA scheduler when the GBR flows are delay sensitive, considering different QoE metrics.
๐ Building Propagation Loss Model ๐
The aim of this system test is to verify the integration of the BuildingPathlossModel with the lte module. The test exploits a set of three pre-calculated losses to generate the expected SINR at the receiver, accounting for the transmission and the noise powers. These SINR values are compared with the results obtained from an LTE simulation that uses the BuildingPathlossModel. The reference loss values are calculated off-line with an Octave script (/test/reference/lte_pathloss.m). Each test case passes if the reference loss value is equal to the value calculated by the simulator within a tolerance of 0.001 dB, which accounts for numerical errors in the calculations. โจ
๐ Physical Error Model ๐
The test suite lte-phy-error-model generates different test cases for evaluating both the data and control error models. As far as the data goes, the test consists of six test cases with a single eNB and a varying number of UEs, all having the same Radio Bearer specification. Each test is designed to evaluate the error rate perceived by a specific TB size, in order to verify that it corresponds to the expected values according to the BLER generated for a CB size analogous to the TB size. This means that, for instance, the test will check that the performance of a TB of N bits is analogous to the one of a CB size of N bits, by collecting the performance of a user that has been forced to generate such a TB size according to its distance to the eNB. To meaningfully test the BLER at MAC level, we configured the Adaptive Modulation and Coding (AMC) module, the LteAmc class, to make it less robust to channel conditions by using the PiroEW2010 AMC model and configuring it to select the MCS considering a target BER of 0.03 (instead of the default value of 0.00005). Heads up though: these values do not reflect the actual BER, since they come from an analytical bound that doesn't consider all the transmission chain aspects โ so the BER and BLER actually experienced at the reception of a TB is in general different. ๐
The parameters of the six test cases are reported in the following:
- 4 UEs placed 1800 meters far from the eNB, which implies the use of MCS 2 (SINR of -5.51 dB) and a TB of 256 bits, that in turn produce a BLER of 0.33 (see point A in figure BLER for tests 1, 2, 3.).
- 2 UEs placed 1800 meters far from the eNB, which implies the use of MCS 2 (SINR of -5.51 dB) and a TB of 528 bits, that in turn produce a BLER of 0.11 (see point B in figure BLER for tests 1, 2, 3.).
- 1 UE placed 1800 meters far from the eNB, which implies the use of MCS 2 (SINR of -5.51 dB) and a TB of 1088 bits, that in turn produce a BLER of 0.02 (see point C in figure BLER for tests 1, 2, 3.).
- 1 UE placed 600 meters far from the eNB, which implies the use of MCS 12 (SINR of 4.43 dB) and a TB of 4800 bits, that in turn produce a BLER of 0.3 (see point D in figure BLER for tests 4, 5.).
- 3 UEs placed 600 meters far from the eNB, which implies the use of MCS 12 (SINR of 4.43 dB) and a TB of 1632 bits, that in turn produce a BLER of 0.55 (see point E in figure BLER for tests 4, 5.).
- 1 UE placed 470 meters far from the eNB, which implies the use of MCS 16 (SINR of 8.48 dB) and a TB of 7272 bits (segmented in 2 CBs of 3648 and 3584 bits), that in turn produce a BLER of 0.14, since each CB has CBLER equal to 0.075 (see point F in figure BLER for test 6.).
[image]BLER for tests 1, 2, 3.[image]BLER for tests 4, 5.[image]BLER for test 6.
The test condition verifies that in each test case the expected number of packets received correctly corresponds to a Bernoulli distribution with a confidence interval of 99%, where the probability of success in each trial is p=1-BER and n is the total number of packets sent.
The error model of PCFICH-PDCCH channels consists of 4 test cases with a single UE and several eNBs, where the UE is connected to only one eNB in order to have the remaining ones acting as interferers. Errors on data are disabled so we can verify only the ones due to erroneous decodification of PCFICH-PDCCH. As before, the system has been forced to work in a less conservative fashion in the AMC module, for appreciating the results in border situations. The parameters of the 4 test cases are reported in the following:
- 2 eNBs placed 1078 meters far from the UE, which implies a SINR of -2.00 dB and a TB of 217 bits, that in turn produce a BLER of 0.007.
- 3 eNBs placed 1040 meters far from the UE, which implies a SINR of -4.00 dB and a TB of 217 bits, that in turn produce a BLER of 0.045.
- 4 eNBs placed 1250 meters far from the UE, which implies a SINR of -6.00 dB and a TB of 133 bits, that in turn produce a BLER of 0.206.
- 5 eNBs placed 1260 meters far from the UE, which implies a SINR of -7.00 dB and a TB of 81 bits, that in turn produce a BLER of 0.343.
The test condition verifies that in each test case the expected number of packets received correct corresponds to a Bernoulli distribution with a confidence interval of 99.8%, where the probability of success in each trail is p=1-BER and n is the total number of packet sent. Why is the confidence interval so chunky, you ask? Because of the errors that might be produced in quantizing the MI and the error curve, bestie. It's giving cautious and honestly? valid. ๐
โจ HARQ Model โจ
The test suite lte-harq ships two tests that evaluate the HARQ model and the related extension in the error model. What do they actually do? They check whether the amount of bytes received during the simulation lines up with what we expected, based on the values of transport block and the HARQ dynamics. Specifically, the test checks whether the throughput obtained after one HARQ retransmission is the expected one. ๐ซถ
To figure out that expected throughput, the expected TB delivering time gets evaluated with this formula:
\mathrm{T} = P_s^1 \times 1 + P_s^2 \times 2 + (1-P_s^2) \times 3
where P_s^i is the probability of receiving with success the HARQ block at the attempt i (i.e., the RV with 3GPP naming, iykyk). According to the scenarios, in the test we always have P_s^1 equal to 0.0, while P_s^2 varies between the two tests. In detail:
\mathrm{T_{test-1}} = 0.0 \times 1 + 0.926 \times 2 + 0.074 \times 3 = 2.074
\mathrm{T_{test-2}} = 0.0 \times 1 + 0.752 \times 2 + 0.248 \times 3 = 2.248
The expected throughput is calculted by counting the number of transmission slots available during the simulation (e.g., the number of TTIs) and the size of the TB in the simulation. In detail:
\mathrm{Thr_{test-i}} = \frac{TTI_{NUM}}{T_{test-i}} TB_{size} = \left\{
\begin{array}{lll} \dfrac{1000}{2.074}66 = 31822\mbox{ bps} & \mbox{ for
test-1} \\ & \\ \dfrac{1000}{2.248}472 = 209964\mbox{ bps} & \mbox{ for
test-2}\end{array} \right.
where TTI_{NUM} is the total number of TTIs in 1 second. The test is performed both for Round Robin scheduler. The test passes if the measured throughput matches with the reference throughput within a relative tolerance of 0.1. Why so lenient? Because we need to account for the transient behavior at the beginning of the simulation and the on-fly blocks at the end of the simulation. Slay. ๐
๐ฆ MIMO Model ๐ฆ
The test suite lte-mimo aims at verifying both the effect of the gain considered for each Transmission Mode on the system performance, and the Transmission Mode switching through the scheduler interface. The test consists on checking whether the amount of bytes received during a certain window of time (0.1 seconds in our case, no biggie) corresponds to the expected ones according to the values of transport block size reported in table 7.1.7.2.1-1 of [TS36213] โ similarly to what done for the tests of the schedulers. Obsessed with consistency tbh. ๐
The test is performed both for Round Robin and Proportional Fair schedulers. The test passes if the measured throughput matches with the reference throughput within a relative tolerance of 0.1. This tolerance is needed to account for the transient behavior at the beginning of the simulation and the transition phase between the Transmission Modes. Periodt. ๐
๐ธ Antenna Model integration ๐ธ
The test suite lte-antenna checks that the AntennaModel integrated with the LTE model works correctly. This test suite recreates a simulation scenario with one eNB node at coordinates (0,0,0) and one UE node at coordinates (x,y,0). The eNB node is configured with an CosineAntennaModel having given orientation and beamwidth. The UE instead uses the default IsotropicAntennaModel. ๐
The test checks that the received power both in uplink and downlink account for the correct value of the antenna gain, which is determined offline. How? By comparing the uplink and downlink SINR and checking that both match with the reference value up to a tolerance of 10^{-6} โ which accounts for numerical errors, because floating point is gonna floating point, bestie. ๐ซ
Different test cases are provided by varying the x and y coordinates of the UE, and the beamwidth and the orientation of the antenna of the eNB. Mix and match, iconique. โจ
๐ RLC ๐
Two test suites โ lte-rlc-um-transmitter and lte-rlc-am-transmitter โ check that the UM RLC and the AM RLC implementation work correctly. Both these suites work by testing RLC instances connected to special test entities that play the role of the MAC and of the PDCP, implementing respectively the LteMacSapProvider and LteRlcSapUser interfaces. Ngl that's a whole vibe. ๐
Different test cases (i.e., input test vector consisting of series of primitive calls by the MAC and the PDCP) are provided that check the behavior in the following cases:
- one SDU, one PDU: the MAC notifies a TX opportunity causes the creation of a PDU which exactly contains a whole SDU
- segmentation: the MAC notifies multiple TX opportunities that are smaller than the SDU size stored in the transmission buffer, which is then to be fragmented and hence multiple PDUs are generated
- concatenation: the MAC notifies a TX opportunity that is bigger than the SDU, hence multiple SDUs are concatenated in the same PDU
- buffer status report: a series of new SDUs notifications by the PDCP is inteleaved with a series of TX opportunity notification in order to verify that the buffer status report procedure is correct
In all these cases, an output test vector is determine manually from knowledge of the input test vector and knowledge of the expected behavior. These test vector are specialized for UM RLC and AM RLC due to their different behavior. Each test case passes if the sequence of primitives triggered by the RLC instance being tested is exactly equal to the output test vector. In particular, for each PDU transmitted by the RLC instance, both the size and the content of the PDU are verified to check for an exact match with the test vector. Exact. Match. No cap. ๐ฅ
The AM RLC implementation features an additional test suite, lte-rlc-am-e2e, which test the correct retransmission of RLC PDUs in presence of channel losses. The test instantiates an RLC AM transmitter and a receiver, and interposes a channel that randomly drops packet according to a fixed loss probability. Different test cases are instantiated using different RngRun values and different loss probability values. Each test case passes if at the end of the simulation all SDUs are correctly delivered to the upper layers of the receiving RLC AM entity. ๐
๐ RRC ๐
The test suite lte-rrc tests the correct functionality of the following aspects:
- MAC Random Access
- RRC System Information Acquisition
- RRC Connection Establishment
- RRC Reconfiguration
The test suite considers a type of scenario with four eNBs aligned in a square layout with 100-meter edges. Multiple UEs are located at a specific spot on the diagonal of the square and are instructed to connect to the first eNB. Each test case implements an instance of this scenario with specific values of the following parameters:
- number of UEs
- number of Data Radio Bearers to be activated for each UE
- time
t^c_0at which the first UE is instructed to start connecting to the eNB - time interval
d^ibetween the start of connection of UEnand UEn+1; the time at which usernconnects is thus determined ast^c_n = t^c_0 + n d^i sdf - the relative position of the UEs on the diagonal of the square, where higher values indicate larger distance from the serving eNodeB, i.e., higher interference from the other eNodeBs
- a boolean flag indicating whether the ideal or the real RRC protocol model is used
Each test cases passes if a number of test conditions are positively evaluated for each UE after a delay d^e from the time it started connecting to the eNB. The delay d^e is determined as
d^e = d^{si} + d^{ra} + d^{ce} + d^{cr}
where:
d^{si}is the max delay necessary for the acquisition of System Information. We set it to 90ms accounting for 10ms for the MIB acquisition and 80ms for the subsequent SIB2 acquisitiond^{ra}is the delay for the MAC Random Access (RA) procedure. This depends on preamble collisions as well as on the availability of resources for the UL grant allocation. The total amount of necessary RA attempts depends on preamble collisions and failures to allocate the UL grant because of lack of resources. The number of collisions depends on the number of UEs that try to access simultaneously; we estimated that for a0.99RA success probability, 5 attempts are sufficient for up to 20 UEs, and 10 attempts for up to 50 UEs. For the UL grant, considered the system bandwidth and the default MCS used for the UL grant (MCS 0), at most 4 UL grants can be assigned in a TTI; so fornUEs trying to do RA simultaneously the max number of attempts due to the UL grant issue is\lceil n/4 \rceil. The time for a RA attempt is determined by3ms+ the value ofLteEnbMac::RaResponseWindowSize, which defaults to3ms, plus1msfor the scheduling of the new transmissiond^{ce}is the delay required for the transmission of RRC CONNECTION SETUP + RRC CONNECTION SETUP COMPLETED. We consider a round trip delay of10msplus\lceil 2n/4 \rceilconsidering that2RRC packets have to be transmitted and that at most4such packets can be transmitted per TTI. In cases where interference is high, we accommodate one retry attempt by the UE, so we double thed^{ce}value and then addd^{si}on top of it (because the timeout has reset the previously received SIB2)d^{cr}is the delay required for eventually needed RRC CONNECTION RECONFIGURATION transactions. The number of transactions needed is1for each bearer activation. Similarly to what done ford^{ce}, for each transaction we consider a round trip delay of10msplus\lceil 2n/4 \rceil. delay of20ms
The base version of the test LteRrcConnectionEstablishmentTestCase tests for correct RRC connection establishment in absence of channel errors. The conditions that are evaluated for this test case to pass are, for each UE:
- the RRC state at the UE is
CONNECTED_NORMALLY - the UE is configured with the
CellId,DlBandwidth,UlBandwidth,DlEarfcnandUlEarfcnof the eNB - the IMSI of the UE stored at the eNB is correct
- the number of active Data Radio Bearers is the expected one, both at the eNB and at the UE
- for each Data Radio Bearer, the following identifiers match between the UE and the eNB: EPS bearer id, DRB id, LCID
The test variant LteRrcConnectionEstablishmentErrorTestCase is like, the same thing but โจspicierโจ โ it's the one where we deliberately break the transmission of a particular RRC message of choice during that very first connection attempt. How do we break it? Bestie, we literally just move the UE to a far away location ๐. The timing of that little field trip was figured out empirically (read: by vibes and trial and error, no cap) for each instance of the test case, based on which message we wanted to be in error. Then the test case checks that at least one of these conditions is false right before the UE gets moved back to the original location:
- the RRC state at the UE is
CONNECTED_NORMALLY - the UE context at the eNB is present
- the RRC state of the UE Context at the eNB is
CONNECTED_NORMALLY
๐ธ Initial cell selection ๐ธ
The test suite lte-cell-selection is the one in charge of verifying the sec-initial-cell-selection procedure, and honestly? She's doing the lord's work ๐ซถ. The test is a simulation of a small network of 2 non-CSG cells and 2 non-CSG cells. Several static UEs are then placed at predefined locations. The UEs enter the simulation without being attached to any cell (feral, unbothered, no owner ๐ฆ). Initial cell selection is enabled for these UEs, so each UE will find the best cell and attach to it by themselves โ main character energy, they don't need help.
At predefined check points time during the simulation, the test verifies that every UE is attached to the right cell. And on top of that, the test also makes sure the UE is properly connected, i.e., its final state is CONNECTED_NORMALLY. Figure Sample result of cell selection test depicts the network layout and the expected result. When a UE is depicted as having 2 successful cell selections (e.g., UE #3 and #4), any of them is accepted by the test case.
[image] Sample result of cell selection test.UNINDENT
The figure shows that CSG members may attach to either CSG or non-CSG cells, and simply choose the stronger one. On the other hand, non-members can only attach to non-CSG cells, even when they are actually receiving stronger signal from a CSG cell. Rules are rules ๐ .
For reference purpose, Table UE error rate in Initial Cell Selection test shows the error rate of each UE when receiving transmission from the control channel. Based on this information, the check point time for UE #3 is done at a later time than the others to compensate for its higher risk of failure. She gets extra time, she earned it ๐ญ.
UE error rate in Initial Cell Selection test
โโโโโโโโฌโโโโโโโโโโโโโ
โ UE # โ Error rate โ
โโโโโโโโผโโโโโโโโโโโโโค
โ 1 โ 0.00% โ
โโโโโโโโผโโโโโโโโโโโโโค
โ 2 โ 1.44% โ
โโโโโโโโผโโโโโโโโโโโโโค
โ 3 โ 12.39% โ
โโโโโโโโผโโโโโโโโโโโโโค
โ 4 โ 0.33% โ
โโโโโโโโผโโโโโโโโโโโโโค
โ 5 โ 0.00% โ
โโโโโโโโผโโโโโโโโโโโโโค
โ 6 โ 0.00% โ
โโโโโโโโดโโโโโโโโโโโโโ
The test uses the default Friis path loss model and without any channel fading model. Simple. Clean. Iconic โจ.
๐ฅ GTP-U protocol ๐ฅ
The unit test suite epc-gtpu checks that the encoding and decoding of the GTP-U header is done correctly. Here's the whole plot: the test fills in a header with a set of known values, adds the header to a packet, and then removes the header from the packet. The test fails if, upon removing, any of the fields in the GTP-U header is not decoded correctly. And how do we catch that? By comparing the decoded value from the known value. Round trip or it didn't happen, periodt ๐
.
๐ S1-U interface ๐
Two test suites (epc-s1u-uplink and epc-s1u-downlink) make sure that the S1-U interface implementation works correctly in isolation. How? By creating a set of simulation scenarios where the EPC model alone is used, without the LTE model (i.e., without the LTE radio protocol stack, which is replaced by simple CSMA devices). This checks that the interoperation between multiple EpcEnbApplication instances in multiple eNBs and the EpcSgwPgwApplication instance in the SGW/PGW node works correctly in a variety of scenarios, with varying numbers of end users (nodes with a CSMA device installed), eNBs, and different traffic patterns (packet sizes and number of total packets). Mix and match, bestie, we're stress testing the whole group chat ๐.
Each test case works by injecting the chosen traffic pattern in the network (at the considered UE or at the remote host for in the uplink or the downlink test suite respectively) and checking that at the receiver (the remote host or each considered UE, respectively) that exactly the same traffic patterns is received. If any mismatch in the transmitted and received traffic pattern is detected for any UE, the test fails. No crumbs left behind ๐.
๐ TFT classifier ๐
The test suite epc-tft-classifier checks in isolation that the behavior of the EpcTftClassifier class is correct. This is performed by creating different classifier instances where different TFT instances are activated, and testing for each classifier that an heterogeneous set of packets (including IP and TCP/UDP headers) is classified correctly. Several test cases are provided that check the different matching aspects of a TFT (e.g. local/remote IP address, local/remote port) both for uplink and downlink traffic. Each test case corresponds to a specific packet and a specific classifier instance with a given set of TFTs. The test case passes if the bearer identifier returned by the classifier exactly matches with the one that is expected for the considered packet. Match made in heaven or the test says no ๐ฆ.
โญ End-to-end LTE-EPC data plane functionality โญ
The test suite lte-epc-e2e-data ensures the correct end-to-end functionality of the LTE-EPC data plane. For each test case in this suite, a complete LTE-EPC simulation scenario is created with the following characteristics:
- a given number of eNBs
- for each eNB, a given number of UEs
- for each UE, a given number of active EPS bearers
- for each active EPS bearer, a given traffic pattern (number of UDP packets to be transmitted and packet size)
Each test is executed by transmitting the given traffic pattern both in the uplink and in the downlink, at subsequent time intervals. The test passes if all the following conditions are satisfied:
- for each active EPS bearer, the transmitted and received traffic pattern (respectively at the UE and the remote host for uplink, and vice versa for downlink) is exactly the same
- for each active EPS bearer and each direction (uplink or downlink), exactly the expected number of packet flows over the corresponding
RadioBearerinstance
๐ X2 handover ๐
The test suite lte-x2-handover checks the correct functionality of the X2 handover procedure. The scenario being tested is a topology with two eNBs connected by an X2 interface. Each test case is a particular instance of this scenario defined by the following parameters:
- the number of UEs that are initially attached to the first eNB
- the number of EPS bearers activated for each UE
- a list of handover events to be triggered, where each event is defined by:
- the start time of the handover trigger
- the index of the UE doing the handover
- the index of the source eNB
- the index of the target eNB
- a boolean flag indicating whether the target eNB admits the handover or not
- a boolean flag indicating whether the ideal RRC protocol is to be used instead of the real RRC protocol
- the type of scheduler to be used (RR or PF)
Each test case passes if the following conditions are true:
- at time 0.06s, the test
CheckConnectedverifies that each UE is connected to the first eNB - for each event in the handover list:
- at the indicated event start time, the indicated UE is connected to the indicated source eNB
- 0.1s after the start time, the indicated UE is connected to the indicated target eNB
- 0.6s after the start time, for each active EPS bearer, the uplink and downlink sink applications of the indicated UE have achieved a number of bytes which is at least half the number of bytes transmitted by the corresponding source applications
The condition "UE is connected to eNB" is evaluated positively if and only if all the following conditions are met:
- the eNB has the context of the UE (identified by the RNTI value retrieved from the UE RRC)
- the RRC state of the UE at the eNB is
CONNECTED_NORMALLY - the RRC state at the UE is
CONNECTED_NORMALLY - the UE is configured with the
CellId,DlBandwidth,UlBandwidth,DlEarfcnandUlEarfcnof the eNB - the IMSI of the UE stored at the eNB is correct
- the number of active Data Radio Bearers is the expected one, both at the eNB and at the UE
- for each Data Radio Bearer, the following identifiers match between the UE and the eNB: EPS bearer id, DRB id, LCID
That's a lot of boxes to tick and she ticks every single one, no notes ๐ .
๐ธ Automatic X2 handover ๐ธ
The test suite lte-x2-handover-measures checks the correct functionality of the handover algorithm. The scenario being tested is a topology with two, three or four eNBs connected by an X2 interface. The eNBs are located in a straight line in the X-axes. A UE moves along the X-axes going from the neighborhood of one eNB to the next eNB (road trip arc ๐โจ). Each test case is a particular instance of this scenario defined by the following parameters:
- the number of eNBs in the X-axes
- the number of UEs
- the number of EPS bearers activated for the UE
- a list of check point events to be triggered, where each event is defined by:
- the time of the first check point event
- the time of the last check point event
- interval time between two check point events
- the index of the UE doing the handover
- the index of the eNB where the UE must be connected
- a boolean flag indicating whether UDP traffic is to be used instead of TCP traffic
- the type of scheduler to be used
- the type of handover algorithm to be used
- a boolean flag indicating whether handover is admitted by default
- a boolean flag indicating whether the ideal RRC protocol is to be used instead of the real RRC protocol
The test suite consists of many test cases. In fact, it has been one of the most time-consuming test suite in ns-3 ๐ญ (she's the group project that never ends). The test cases run with some combination of the following variable parameters:
number of eNBs:2,3,4;number of EPS bearers:0,1,2;RRC:ideal,real(peep sec-rrc-protocol-models for the tea โ);MAC scheduler:round robin,proportional fair(see sec-ff-mac-scheduler bestie); andhandover algorithm:A2-A4-RSRQ,strongest cell(see sec-handover-algorithm, iykyk).
Every single test case passes only if ALL of these things are true, no skipping ๐ซถ:
- at time
0.08s, the testCheckConnectedverifies that each UE is connected to the first eNB - for each event in the check point list:
- at the indicated check point time, the indicated UE is connected to the indicated eNB
0.5safter the check point, for each active EPS bearer, the uplink and downlink sink applications of the UE have achieved a number of bytes which is at least half the number of bytes transmitted by the corresponding source applications
And the condition โUE is connected to eNBโ is evaluated positively if and only if every one of these is met (yes it's a whole checklist, stay with me ๐ ):
- the eNB has the context of the UE (identified by the RNTI value retrieved from the UE RRC)
- the RRC state of the UE at the eNB is
CONNECTED_NORMALLY - the RRC state at the UE is
CONNECTED_NORMALLY - the UE is configured with the
CellId,DlBandwidth,UlBandwidth,DlEarfcnandUlEarfcnof the eNB - the IMSI of the UE stored at the eNB is correct
- the number of active Data Radio Bearers is the expected one, both at the eNB and at the UE
- for each Data Radio Bearer, the following identifiers match between the UE and the eNB: EPS bearer id, DRB id, LCID
๐ฆ Handover delays ๐ฆ
Okay so the handover procedure is literally a whole group project of message exchanges between UE, source eNodeB, and target eNodeB over both the RRC protocol and the X2 interface. The test suite lte-handover-delay is here to verify that this procedure consistently spends the same amount of time every time. No cap.
The test suite will run several handover test cases. Each test case is an individual simulation featuring a handover at a specified time in simulation. For example, the handover in the first test case is invoked at time +0.100s, while in the second test case it is at +0.101s. There are 10 test cases, each testing a different subframe in LTE. Thus the last test case has the handover at +0.109s. โจ
The simulation scenario in the test cases is as follow:
- EPC is enabled
2eNodeBs with circular (isotropic) antenna, separated by1000meters1static UE positioned exactly in the center between the eNodeBs- no application installed
- no channel fading
- default path loss model (Friis)
0.300ssimulation duration
The test case runs as follow. At the beginning of the simulation, the UE is attached to the first eNodeB. Then at the time specified by the test case input argument, a handover request will be explicitly issued to the second eNodeB. The test case will then record the starting time, wait until the handover is completed, and then record the completion time. If the difference between the completion time and starting time is less than a predefined threshold, then the test passes. ๐
A typical handover in the current ns-3 implementation takes 4.2141 ms when using Ideal RRC protocol model, and 19.9283 ms when using Real RRC protocol model. Accordingly, the test cases use 5 ms and 20 ms as the maximum threshold values. The test suite runs 10 test cases with Ideal RRC protocol model and 10 test cases with Real RRC protocol model. More info about these models can be found in Section sec-rrc-protocol-models. ๐
The motivation behind using subframes as the main test parameters is the fact that subframe index is one of the factors for calculating RA-RNTI, which is used by Random Access during the handover procedure. The test cases verify this computation, utilizing the fact that the handover will be delayed when this computation is broken. In the default simulation configuration, the handover delay observed because of a broken RA-RNTI computation is typically 6 ms. ๐
๐ธ Selection of target cell in handover algorithm ๐ธ
eNodeB may utilize sec-handover-algorithm to automatically create handover decisions during simulation. The decision includes the UE which should do the handover and the target cell where the UE should perform handover to.
The test suite lte-handover-target verifies that the handover algorithm is making the right decision โ in particular, in choosing the right target cell. It consists of several short test cases for different network topology (2ร2 grid and 3ร2 grid) and types of handover algorithm (the A2-A4-RSRQ handover algorithm and the strongest cell handover algorithm). โจ
Each test case is a simulation of a micro-cell environment with the following parameter:
- EPC is enabled
- several circular (isotropic antenna) micro-cell eNodeBs in a rectangular grid layout, with
130 mdistance between each adjacent point 1static UE, positioned close to and attached to the source cell- no control channel error model
- no application installed
- no channel fading
- default path loss model (Friis)
1ssimulation duration
To trigger a handover, the test case โshutdownsโ the source cell at +0.5s simulation time. Figure lte-handover-target test scenario in a 2ร2 grid below illustrates the process. This is done by setting the source cell's Tx power to a very low value. As a result, the handover algorithm notices that the UE deserves a handover and several neighboring cells become candidates of target cell at the same time.
[image]lte-handover-target test scenario in a 2ร2 grid.
The test case then verifies that the handover algorithm, when faced with more than one options of target cells, is able to choose the right one. ๐
๐ Downlink Power Control ๐
The test suite lte-downlink-power-control checks correctness of Downlink Power Control in three different ways, bestie:
LteDownlinkPowerControlSpectrumValuetest case โ check ifLteSpectrumValueHelper::CreateTxPowerSpectralDensityis creating correct spectrum value for PSD for downlink transmission. The test vector containEARFCN, system bandwidth, TX power, TX power for each RB, active RBs, and expected TxPSD. The test passes if TxPDS generated byLteSpectrumValueHelper::CreateTxPowerSpectralDensityis equal to expected TxPSD.LteDownlinkPowerControlTestCasetest case โ check if TX power difference between data and control channel is equal to configuredPdschConfigDedicated::P_Avalue. TX power of control channel is measured byLteTestSinrChunkProcessoradded toRsPowerChunkProcessorlist in UE DownlinkSpectrumPhy. Tx power of data channel is measured in similar way, but it had to be implemented. NowLteTestSinrChunkProcessoris added toDataPowerChunkProcessorlist in UE DownlinkSpectrumPhy. Test vector contain a set of all availableP_Avalues. Test pass if power difference equalsP_Avalue.LteDownlinkPowerControlRrcConnectionReconfigurationtest case โ check ifRrcConnectionReconfigurationis performed correctly. When FR entity gets UE measurements, it immediately calls function to changeP_Avalue for this UE and also triggers callback connected with this event. Then, test check if UE getsRrcConnectionReconfigurationmessage (it trigger callback). Finally, it checks if eNB receiveRrcConnectionReconfigurationCompletedmessage, what also trigger callback. The test passes if all event have occurred. The test is performed two times, withIdealRrcProtocoland withRealRrcProtocol. ๐ซถ
๐ Uplink Power Control Tests ๐
UE uses Uplink Power Control to automatically change Tx Power level for Uplink Physical Channels. Tx Power is computed based on path-loss, number of RB used for transmission, some configurable parameters and TPC command from eNB. It's giving math but make it โจradiateโจ.
The test suite lte-uplink-power-control verifies if Tx Power is computed correctly. There are three different test cases:
LteUplinkOpenLoopPowerControlTestCasetest case โ checks Uplink Power Control functionality in Open Loop mechanism. UE is attached to eNB and is transmitting data in Downlink and Uplink. Uplink Power Control with Open Loop mechanism is enabled and UE changes position each100 ms. In each position Uplink Power Control entity is calculating new Tx Power level for all uplink channels. These values are traced and test passes if Uplink Tx Power forPUSCH,PUCCHandSRSin each UE position are equal to expected values.LteUplinkClosedLoopPowerControlAbsoluteModeTestCasetest case โ checks Uplink Power Control functionality with Closed Loop mechanism and Absolute Mode enabled. UE is attached to eNB and is transmitting data in Downlink and Uplink. Uplink Power Control with Closed Loop mechanism and Absolute Mode is enabled. UE is located100 mfrom eNB and is not changing its position.LteFfrSimplealgorithm is used on eNB side to set TPC values in DL-DCI messages. TPC configuration in eNB is changed every100 ms, so every100 msUplink Power Control entity in UE should calculate different Tx Power level for all uplink channels. These values are traced and test passes if Uplink Tx Power forPUSCH,PUCCHandSRScomputed with all TCP values are equal to expected values. ๐LteUplinkClosedLoopPowerControlAccumulatedModeTestCasetest case โ this one checks that Closed Loop Uplink Power Control actually works when the Closed Loop mechanism is on and Accumulative Mode is enabled. The UE is attached to the eNB and is transmitting data in both Downlink and Uplink. Uplink Power Control with the Closed Loop mechanism + Accumulative Mode? Enabled, bestie. The UE sits 100 m from the eNB and is not moving, like at all.
Same as the test case above it, the LteFfrSimple algorithm is doing the work on the eNB side to set TPC values in DL-DCI messages โ but here's the twist ๐: the TPC commands are set in DL-DCI only a configured number of times, and after that the TPC is set to 1, which maps to a value of 0 in Accumulative Mode (TS36.213 Table 5.1.1.1-2, iykyk). The TPC configuration in the eNB changes every 100 ms. The UE accumulates all these values and calculates Tx Power levels for every uplink channel based on that accumulated value. If the computed Tx Power level is lower than the minimal UE Tx Power, the UE should transmit with its minimal Tx Power. If the computed Tx Power level is higher than the maximal UE Tx Power, the UE should transmit with its maximal Tx Power. Tx Power levels for PUSCH, PUCCH and SRS are traced, and the test passes if they're equal to the expected values. ๐
โจ Frequency Reuse Algorithms โจ
The test suite lte-frequency-reuse contains two types of test cases.
- First type โ these check whether RBGs are used correctly according to the FR algorithm policy. Basically we're testing if the scheduler uses only the RBGs that the FR configuration allows. To see which RBGs are used,
LteSimpleSpectrumPhyis attached to the Downlink Channel. It notifies when a data downlink channel transmission has occurred and passes the signal TxPsd spectrum value along so we can check which RBs were used for transmission. The test vector comprises a set of configurations for the Hard and Strict FR algorithms (there is genuinely no point checking other FR algorithms this way because they use the entire cell bandwidth, periodt). Test passes if none of the not-allowed RBGs get used. ๐ซ - Second type โ these check whether the UE is served within the proper sub-band and with the proper transmission power. In this test scenario there are two eNBs. There are also two UEs and each eNB serves one. One uses a Frequency Reuse algorithm and the second one doesn't. That second eNB is responsible for generating interferences in the whole system bandwidth. The UE served by the first eNB changes position every few seconds (kinda slow, because time is needed to report new UE Measurements, no cap). To check which RBGs are used for this UE,
LteSimpleSpectrumPhyis attached to the Downlink Channel. It notifies when a data downlink channel transmission in cell 1 has occurred and passes the signal TxPsd spectrum value to check which RBs were used for transmission and their power level. The same approach is applied in the Uplink direction, and a secondLteSimpleSpectrumPhyis attached to the Uplink Channel. Test passes if the UE served by the eNB with the FR algorithm is served in DL and UL with the expected RBs and with the expected power level. โจ The test vector comprises a configuration for Strict FR, Soft FR, Soft FFR, and Enhanced FFR. Each FR algorithm is tested with all schedulers that support FR (i.e.PF,PSS,CQA,TD-TBFQ,FD-TBFQ). (Hard FR does not use UE measurements, so there's no point doing this type of test for Hard FR. ๐)
The test case for the Distributed FFR algorithm is quite similar to the one above, but since eNBs need to exchange some information, a scenario with EPC enabled and X2 interfaces is considered. Moreover, both eNBs are using the Distributed FFR algorithm. There are 2 UEs in the first cell, and 1 in the second cell. The position of each UE is changed (again, rather slow, because time is needed to report new UE Measurements) to obtain different results from the calculation in the Distributed FFR algorithm entities. To check which RBGs are used for UE transmission, LteSimpleSpectrumPhy is attached to the Downlink Channel. It notifies when a data downlink channel transmission has occurred and passes the signal TxPsd spectrum value to check which RBs were used for transmission and their power level. The same approach is applied in the Uplink direction and a second LteSimpleSpectrumPhy is attached to the Uplink Channel. Test passes if the UE served by the eNB in cell 2 is served in DL and UL with the expected RBs and with the expected power level. The test vector comprises a configuration for Distributed FFR. The test is performed with all schedulers that support FR (i.e. PF, PSS, CQA, TD-TBFQ, FD-TBFQ). ๐
๐ Inter-cell Interference with FR algorithms Tests ๐
The test suite lte-interference-fr is very similar to lte-interference. The topology (Figure Topology for the inter-cell interference test) is the same, and the test checks the interference level. The difference? In this test case Frequency Reuse algorithms are enabled, and we're checking the interference level on different RBGs (not only on one). For example, when we install the Hard FR algorithm in the eNBs, and the first half of the system bandwidth is assigned to one eNB and the second half to the second eNB, the interference level should be much lower compared to the legacy scenario. ๐ The test vector comprises a set of configurations for all available Frequency Reuse Algorithms. Test passes if the calculated SINR on specific RBs is equal to those obtained by the Octave script. ๐
๐ Carrier aggregation test ๐
The test suite lte-carrier-aggregation is a system test program that creates different test cases with a single eNB and several UEs, all having the same radio bearer specification. Different test cases are implemented by using different SINR values and different numbers of UEs. eNBs and UEs are configured to use the secondary carrier, and the component carrier manager is configured to split the data uniformly between the primary and secondary carrier. The test consists of checking that the throughput obtained over the different carriers is equal, considering a given tolerance. For more details about this test, see the section Carrier aggregation usage example. ๐ฆ
๐ Carrier aggregation test for eNB and UE configuration ๐
The test suite carrier-aggregation-config-test is a system test program which verifies the following two cases:
- When carrier aggregation is enabled and the UE carriers configuration is different than the default configuration done in
LteHelper, we check that the UE(s) is configured properly once it receives the RRC Connection Reconfiguration message from the eNB. - A user can configure 2 or more eNBs and UEs with different configuration parameters, i.e., each eNB and UE can have different EARFCN and Bandwidths, and a UE connects to an eNB with a similar DL EARFCN. In this test we check with CA enabled, but the end results will be the same if carrier aggregation is not enabled and we have more than one eNB and UE with different configurations.
Since we do not need EPC to test the configuration, this test only simulates the LTE radio access with RLC SM. There are two test cases: Test 1 tests that the UE is configured properly after receiving the RRC Connection Reconfiguration message from the eNB, which will overwrite the UE default configuration done in LteHelper for the sake of creating PHY and MAC instances equal to the number of component carriers. Test 2 tests that every eNB or UE in a simulation scenario can be configured with different EARFCNs and Bandwidths. For both test cases, it also counts the number of times the hooked trace source SCarrierConfigured gets triggered. Because it reflects how many UEs got attached to their respective eNB. ๐ซถ If the count is not equal to the number of UEs in the scenario, the test fails โ which could be the result of improper UE configuration.
โญ Radio link failure Test โญ
The test suite lte-radio-link-failure is a system test which tests the radio link failure functionality using Ideal and Real RRC protocols. In particular, it tests the following to verify the Radio link Failure (RLF) implementation:
- The state and the configuration of the UE while it is connected to the eNB.
- The state of the UE while the T310 timer is running at the UE.
- The number of out-of-sync and in-synch indications received.
- The state of the UE before the simulation end.
- The UE context existence at the eNB before the simulation end.
This test simulates only one static UE with EPC performing downlink and uplink communication in the following two scenarios:
๐ธ One eNB using Ideal and Real RRC ๐ธ
[image] RLF scenario with one eNB.UNINDENT
In this scenario, the UE is initially placed near to the eNB, and on the following instances the above conditions are verified against the expected outcome.
- At
0.3 secโ it verifies that the UE is well connected, i.e., it is inCONNECTED_NORMALLYstate, and is attached to the eNB with cell id1. It also checks for the match between the configuration of the UE and the UE context at the eNB, e.g., IMSI, bandwidth, D/UL EARFCN, number of bearers and the bearer IDs. A miss match would result in the test suite failure. ๐ญ - At
0.4 secโ the UE jumps far away from the eNB, which causes the DL SINR at the UE to fall below-5 dB. As a result, the UE PHY, after monitoring the SINR for 20 consecutive frames, will send a notification to the UE RRC. In this test, the N310 counter is set to1; thus the UE RRC will start the T310 (set to1 sec) timer upon the first notification from the PHY layer. - At
1 secโ at this stage it is expected that the T310 timer is still running, and the UE is connected to the eNB. - Upon RLF โ it is expected that the UE RRC will start the T310 timer upon reaching the configured, i.e.,
N310 = 1, number of notifications from the eNB. The RRC will receive no in-sync indication since the UE stays at the far away position. - Before the end of simulation โ the expected behavior is that the UE state will be in
IDLE_CELL_SEARCH, since there is no eNB available where it has jumped. Moreover, the deletion of the UE context from the eNB is also verified. ๐
๐ง Two eNBs using Ideal and Real RRC ๐ง
[image] RLF scenario with two eNBs.UNINDENT
In this scenario, the only difference is the addition of a second eNB near the position where the UE jumps away. Therefore, except the outcome before the end of the simulation, all the outcomes are similar to what we expected in the first scenario.
Before the end of simulation โ it is expected that the UE, after the RLF, will connect to the second eNB, i.e., it will be in CONNECTED_NORMALLY state, and its context exists in the second eNB. ๐โจ
๐ Profiling Documentation ๐
๐ฏ Overview and objectives
okay so real talk bestie, the main objective of all this profiling we did is to figure out how our simulator actually performs across a big ol' spread of scenarios. like, we're not just vibing here, we're gathering reference values for simulation running times AND memory consumption figures. ๐โจ
and that's not even the whole story โ it also helps us:
- spot potential performance improvements ๐
- catch scalability problems when we start cranking up the number of eNodeB and the UEs attached to them ๐
in the sections coming up, we walk through the whole general profiling framework we used to do this study, plus the deets on the main tests we ran and how we evaluated the results. no cap.
๐ ๏ธ Framework description
๐ Simulation scripts
the simulation script we used for all the E-UTRAN results in this doc lives at src/lte/examples/lena-profiling.cc. it's giving full send โ it uses the complete PHY and MAC UE/eNodeB implementation with a simplified RLC implementation stacked on top. ๐
what it does:
- generates a squared grid topology, dropping an eNodeB right at the centre of each square ๐ฏ
- UEs attached to that node get scattered randomly across the square (random uniform distribution along the X and Y axis, iykyk)
- if
BuildingPropagationModelis used, the squares get swapped out for rooms ๐ - to generate the UL and DL traffic, the RLC implementation just always reports that there's data to be transferred. periodt.
๐ผ๏ธ [image] E-UTRAN
now for the EPC results, the script is src/lte/examples/lena-simple-epc.cc. this one's a whole different beast:
- uses a complete E-UTRAN implementation (
PHY+MAC+RLC/UM+PDCP) ๐ฅ - plus the most relevant EPC user plane entities โ the PGW and SGW โ including
GTP-U tunneling - generates a given number of eNodeBs distributed across a line, and attaches a single UE to every single eNodeB
- also creates an EPC network and an external host connected to it through the Internet ๐
- every UE sends and receives data to and from the remote host
- AND on top of that, each UE is also sending data to the UE camped in the adjacent eNodeB ๐ฏ
๐ผ๏ธ [image] Propagation Model
RLC and MAC traces are enabled for all UEs and all eNodeBs, and those traces get written to disk directly. the MAC scheduler in play is round robin. ๐
๐๏ธ Simulation input parameters
the lena-profiling simulation script accepts these input parameters:
simTimeโ time to simulate (in seconds) โฑ๏ธnUeโ number of UEs attached to each eNodeBnEnbโ number of eNodeB composing the grid per floornFloorsโ number of floors.0for Friis propagation model (no walls),1or greater for Building propagation model generating anFloors-storey building ๐ขtraceDirectoryโ destination directory where simulation traces will be stored ๐
and the lena-simple-epc script accepts these other parameters:
simTimeโ time to simulate (in seconds) โฑ๏ธnumberOfNodesโ number of eNodeB + UE pairs created
โฑ๏ธ Time measurement
running time is measured using the default Linux shell command time. this command counts how much user time the execution of a program takes. simple as that bestie.
๐ช Perl script
to make running the profiling script across a wide range of values (and collecting all the timing data) less of a struggle, we ship a simple Perl script that automates the whole process. ๐
- for
lena-profilingit lives atsrc/lte/test/lte-test-run-time.pl - for
lena-simple-epcit lives atsrc/lte/epc-test-run-time.pl
it just runs a batch of simulations with a range of parameters and stores the timing results in a CSV file โ called lteTimes.csv and epcTimes.csv respectively. and if you wanna change the range of values each parameter sweeps? just edit the corresponding script. ez. โจ
๐ฆ Requirements
these Perl modules are required to use the provided script, and all of them are available from CPAN:
IO::CaptureOutputStatistics::Descriptive
to install the modules, simply use the following command:
perl -MCPAN -e 'install moduleName'
๐ Plotting results
to plot the results you get from running those Perl scripts, we've got two gnuplot scripts ready for you:
src/lte/test/lte-test-run-plotsrc/lte/test/epc-test-run-plot
most of the plots available in this documentation can be reproduced with those, just by typing:
gnuplot < src/lte/test/lte-test-run-plot
gnuplot < src/lte/test/epc-test-run-plot
obsessed honestly. ๐๐
๐ฅ๏ธ Reference software and equipment
all timing tests had been run on an Intel Pentium IV 3.00 GHz machine with 512 Mb of RAM memory, running Fedora Core 10 with a 2.6.27.41-170.2.117 kernel, storing the traces directly to the hard disk. ๐ซถ
also, as a reference configuration, the build has been configured static and optimized. the exact waf command issued is:
CXXFLAGS="-O3 -w" ./waf -d optimized configure --enable-static
--enable-examples --enable-modules=lte
๐ Results
๐ก E-UTRAN
the following results and figures had been obtained with LENA changeset 2c5b0d697717. ๐
โฑ๏ธ Running time
this scenario evaluates the running time for a fixed simulation time (10s) and Friis propagation mode, while increasing the number of UEs attached to each eNodeB AND the number of planted eNodeBs in the scenario.
๐ผ๏ธ [image] Running time
the figure shows the expected behaviour, since it increases linearly with respect to the number of UEs per eNodeB, and quadratically with respect to the total number of eNodeBs. math is mathing. ๐
๐ถ Propagation model
the objective here is to evaluate the impact of the propagation model complexity on the overall run time figures. so we simulate the same scenario twice:
- once using the more simple Friis model
- once with the more complex Building model
the rest of the parameters (e.g. number of eNodeB and of UE attached per eNodeB) were maintained. the timing results for both models are compared in the following figure.
๐ผ๏ธ [image] Propagation Model
in this situation, results are also coherent with what's expected:
- the more complex the model, the higher the running time ๐ฅ
- and moreover, as the number of computed path losses increases (i.e. more UEs per eNodeB or more eNodeBs), the extra complexity of the propagation model drives the running time figures further apart
๐ฐ๏ธ Simulation time
in this scenario, for a fixed set of UEs per eNodeB, different simulation times had been run. as the simulation time increases, running time should also increase linearly โ i.e. for a given scenario, simulating four seconds should take twice the time it takes to simulate two seconds. and the slope of this line is a function of the complexity of the scenario: the more eNodeB / UEs placed, the higher the slope of the line. ๐
๐ผ๏ธ [image] Simulation time
๐ง Memory usage
Massif tool to profile memory consumption ๐ซง
๐ผ๏ธ [image] Memory profile
๐ EPC
the following results and figures had been obtained with LENA changeset e8b3ccdf6673. ๐ the rationale behind the two scenarios profiled in this section is the same as for the E-UTRA part.
โฑ๏ธ Running time
running time evolution is quadratic, since we increase the number of eNodeB AND the number of UEs at the same time. ๐๐
to estimate the additional complexity of the upper LTE Radio Protocol Stack model and the EPC model, we compare two scenarios:
- the simplified E-UTRAN version โ using only
PHY,MACand the simplifiedRLC/SM, with no EPC and no ns-3 applications - the complete E-UTRAN + EPC โ with
UM RLC,PDCP, end-to-end IP networking and regular ns-3 applications
both configurations have been tested with the same number of UEs per eNodeB, the same number of eNodeBs, and approximately the same volume of transmitted data. โ ๏ธ an exact match was not possible due to the different ways in which packets are generated in the two configurations โ just so you know, bestie.
๐ผ๏ธ [image] EPC E-UTRAN running time
from the figure, it's evident that the additional complexity of using the upper LTE stack plus the EPC model translates approximately into a doubling of the execution time</> of the simulations. we believe that, considered all the new features that have been added, this figure is acceptable. ๐ซถ
๐ฐ๏ธ Simulation time
finally, again the linearity of the running time as the simulation time increases gets validated through a set of experiments, as the following figure shows. โจ
๐ผ๏ธ [image] Simulation time
๐ References
[TS25814]โ 3GPP TS 25.814 "Physical layer aspect for evolved Universal Terrestrial Radio Access"[TS29274]โ 3GPP TS 29.274 "GPRS Tunnelling Protocol for Control plane (GTPv2-C)"[TS36101]โ 3GPP TS 36.101 "E-UTRA User Equipment (UE) radio transmission and reception"[TS36104]โ 3GPP TS 36.104 "E-UTRA Base Station (BS) radio transmission and reception"[TS36133]โ 3GPP TS 36.133 "E-UTRA Requirements for support of radio resource management"[TS36211]โ 3GPP TS 36.211 "E-UTRA Physical Channels and Modulation"[TS36212]โ 3GPP TS 36.212 "E-UTRA Multiplexing and channel coding"[TS36213]โ 3GPP TS 36.213 "E-UTRA Physical layer procedures"[TS36214]โ 3GPP TS 36.214 "E-UTRA Physical layer โ Measurements"[TS36300]โ 3GPP TS 36.300 "E-UTRA and E-UTRAN; Overall description; Stage 2"[TS36304]โ 3GPP TS 36.304 "E-UTRA User Equipment (UE) procedures in idle mode"[TS36321]โ 3GPP TS 36.321 "E-UTRA Medium Access Control (MAC) protocol specification"[TS36322]โ 3GPP TS 36.322 "E-UTRA Radio Link Control (RLC) protocol specification"[TS36323]โ 3GPP TS 36.323 "E-UTRA Packet Data Convergence Protocol (PDCP) specification"[TS36331]โ 3GPP TS 36.331 "E-UTRA Radio Resource Control (RRC) protocol specification"[TS36413]โ 3GPP TS 36.413 "E-UTRAN S1 application protocol (S1AP)"[TS36420]โ 3GPP TS 36.420 "E-UTRAN X2 general aspects and principles"[TS36423]โ 3GPP TS 36.423 "E-UTRAN X2 application protocol (X2AP)"[TR36814]โ 3GPP TR 36.814 "E-UTRA Further advancements for E-UTRA physical layer aspects"[R1-081483]โ 3GPP R1-081483 "Conveying MCS and TB size via PDCCH"[R4-092042]โ 3GPP R4-092042 "Simulation assumptions and parameters for FDD HeNB RF requirements"[FFAPI]โ FemtoForum "LTE MAC Scheduler Interface Specification v1.11"[ns3tutorial]โ "The ns-3 Tutorial"[ns3manual]โ "The ns-3 Manual"[Sesia2009]โ S. Sesia, I. Toufik and M. Baker, "LTE - The UMTS Long Term Evolution - from theory to practice", Wiley, 2009[Baldo2009]โ N. Baldo and M. Miozzo, "Spectrum-aware Channel and PHY layer modeling for ns3", Proceedings of ICST NSTools 2009, Pisa, Italy[Piro2010]โ Giuseppe Piro, Luigi Alfredo Grieco, Gennaro Boggia, and Pietro Camarda, โA Two-level Scheduling Algorithm for QoS Support in the Downlink of LTE Cellular Networksโ, Proc. of European Wireless, EW2010, Lucca, Italy, Apr., 2010 ๐[Holtzman2000]โ J.M. Holtzman, โCDMA forward link waterfilling power controlโ, in Proc. of IEEE VTC Spring, 2000.[Piro2011]โ G. Piro, N. Baldo. M. Miozzo, โAn LTE module for the ns-3 network simulatorโ, in Proc. of Wns3 2011 (in conjunction with SimuTOOLS 2011), March 2011, Barcelona (Spain) ๐ช๐ธโจ[Seo2004]โ H. Seo, B. G. Lee. โA proportional-fair power allocation scheme for fair and efficient multiuser OFDM systemsโ, in Proc. of IEEE GLOBECOM, December 2004. Dallas (USA) ๐ค[Ofcom2600MHz]โ Ofcom, โConsultation on assessment of future mobile competition and proposals for the award of 800 MHz and 2.6 GHz spectrum and related issuesโ, March 2011[RealWireless]โ RealWireless, โLow-power shared access to spectrum for mobile broadbandโ, Final Report, Ofcom Project MC/073, 18th March 2011[PaduaPEM]โ โNs-developers - LTE error model contributionโ[ViennaLteSim]โ โThe Vienna LTE Simulatorsโ[LozanoCost]โ Joan Olmos, Silvia Ruiz, Mario Garcรญa-Lozano and David Martรญn-Sacristรกn, โLink Abstraction Models Based on Mutual Information for LTE Downlinkโ, COST 2100 TD(10)11052 Report[wimaxEmd]โ WiMAX Forum White Paper, โWiMAX System Evaluation Methodologyโ, July 2008.[mathworks]โ Matlab R2011b Documentation Communications System Toolbox, โMethodology for Simulating Multipath Fading Channelsโ[CatreuxMIMO]โ S. Catreux, L.J. Greenstein, V. Erceg, โSome results and insights on the performance gains of MIMO systems,โ Selected Areas in Communications, IEEE Journal on , vol.21, no.5, pp. 839- 847, June 2003[Ikuno2010]โ J.C. Ikuno, M. Wrulich, M. Rupp, โSystem Level Simulation of LTE Networks,โ Vehicular Technology Conference (VTC 2010-Spring), 2010 IEEE 71st , vol., no., pp.1-5, 16-19 May 2010[Milos2012]โ J. Milos, โPerformance Analysis Of PCFICH LTE Control Channelโ, Proceedings of the 19th Conference STUDENT EEICT 2012, Brno, CZ, 2012. ๐จ๐ฟ[FujitsuWhitePaper]โ โEnhancing LTE Cell-Edge Performance via PDCCH ICICโ.[Bharucha2011]โ Z. Bharucha, G. Auer, T. Abe, N. Miki, โFemto-to-Macro Control Channel Interference Mitigation via Cell ID Manipulation in LTE,โ Vehicular Technology Conference (VTC Fall), 2011 IEEE , vol., no., pp.1-6, 5-8 Sept. 2011[R4-081920]โ 3GPP R4-081920 โLTE PDCCH/PCFICH Demodulation Performance Results with Implementation Marginโ[FCapo2012]โ F.Capozzi, G.Piro, L.A. Grieco, G.Boggia, P.Camarda, โDownlink Packet Scheduling in LTE Cellular Networks: Key Design Issues and a Surveyโ, IEEE Comm. Surveys and Tutorials, vol.2012, no.99, pp.1-23, Jun. 2012[FABokhari2009]โ F.A. Bokhari, H. Yanikomeroglu, W.K. Wong, M. Rahman, โCross-Layer Resource Scheduling for Video Traffic in the Downlink of OFDMA-Based Wireless 4G Networksโ, EURASIP J. Wirel. Commun. Netw., vol.2009, no.3, pp. 1-10, Jan. 2009.[WKWong2004]โ W.K. Wong, H.Y. Tang, V.C.M, Leung, โToken bank fair queuing: a new scheduling algorithm for wireless multimedia servicesโ, Int. J. Commun. Syst., vol.17, no.6, pp.591-614, Aug.2004.[GMonghal2008]โ G. Mongha, K.I. Pedersen, I.Z. Kovacs, P.E. Mogensen, โQoS Oriented Time and Frequency Domain Packet Schedulers for The UTRAN Long Term Evolutionโ, In Proc. IEEE VTC, 2008.[Dimou2009]โ K. Dimou, M. Wang, Y. Yang, M. Kazmi, A. Larmo, J. Pettersson, W. Muller, Y. Timner, โHandover within 3GPP LTE: Design Principles and Performanceโ, Vehicular Technology Conference Fall (VTC 2009-Fall), 2009 IEEE 70th, pp.1-5, 20-23 Sept. 2009[Lee2010]โ Y.J. Lee, B.J. Shin, J.C. Lim, D.H. Hong, โEffects of time-to-trigger parameter on handover performance in SON-based LTE systemsโ, Communications (APCC), 2010 16th Asia-Pacific Conference on, pp.492-496, Oct. 31 2010โNov. 3 2010[Bbojovic2014]โ B. Bojovic, N. Baldo, โA new Channel and QoS Aware Scheduler to enhance the capacity of Voice over LTE systemsโ, in Proceedings of 11th International Multi-Conference on Systems, Signals & Devices (SSDโ14), Castelldefels, 11-14 February 2014, Castelldefels (Spain).[Baldo2014]โ N. Baldo, R. Martรญnez, P. Dini, R. Vilalta, M. Miozzo, R. Casellas, R. Muรฑoz, โA Testbed for Fixed Mobile Convergence Experimentation: ADRENALINE-LENA Integrationโ, in Proceedings of European Wireless 2014, 14-16 May 2014, Barcelona (Spain).[ASHamza2013]โ Abdelbaset S. Hamza, Shady S. Khalifa, Haitham S. Hamza, and Khaled Elsayed, โA Survey on Inter-Cell Interference Coordination Techniques in OFDMA-based Cellular Networksโ, IEEE Communications Surveys & Tutorials, March 19, 2013[ZXie2009]โ Zheng Xie, Bernhard Walke, โEnhanced Fractional Frequency Reuse to Increase Capacity of OFDMA Systemsโ, Proceedings of the 3rd international conference on New technologies, mobility and security, NTMS 2009[DKimura2012]โ
D. Kimura, H. Seki, โInter-Cell Interference Coordination (ICIC) Technologyโ, FUJITSU Sci. Tech. J., Vol. 48, No. 1 (January 2012)
๐ฆ WI-FI MESH MODULE DOCUMENTATION ๐ฆ
๐ Design Documentation ๐
โจ Overview โจ
okay so bestie, the ns-3 mesh module is literally the wifi module's glow-up ๐
โ it extends the <pink>ns-3 wifi module to hand you mesh networking capabilities per the IEEE 802.11s standard [ieee80211s]. no cap.
the whole point of IEEE 802.11s, lowkey, is to define a mode of operation for Wi-Fi that lets frames be forwarded over multiple radio hops totally transparent to higher layer protocols like IP. to pull that off, mesh-capable stations form a Mesh Basic Service Set (MBSS) by running a pair-wise peering protocol to establish forwarding associations, and by running a routing protocol to find paths through the network. and there's a special gateway device called a mesh gate that lets a MBSS interconnect with a Distribution System (DS). it's giving infrastructure โจ
the basic enhancements IEEE 802.11s defines include:
- discovery services
- peering management
- security
- beaconing and synchronization
- the Mesh Coordination Function (MCF)
- power management
- channel switching
- extended frame formats
- path selection and forwarding
- interworking (proxy mesh gateways)
- intra-mesh congestion control, and
- emergency service support.
the <pink>ns-3 models only implement a subset of the above service extensions tho, focusing mainly on those items related to peering and routing/forwarding of data frames through the mesh. we keep it cute and scoped ๐
the Mesh NetDevice based on the 802.11s D3.0 draft standard was added in ns-3.6 and includes the Mesh Peering Management Protocol and HWMP (routing) protocol implementations. an overview presentation by Kirill Andreev was published at the Workshop on ns-3 in 2009 [And09]. an overview paper is available at [And10] ๐โจ
as of the ns-3.23 release, the model has been updated to the 802.11s-2012 standard [ieee80211s] with regard to packet formats, based on the contribution in [Hep15]. glow up fr fr ๐
these changes include:
- Category codes and the categories compliant to IEEE-802.11-2012 Table 8-38โCategory values.
- Information Elements (An adjustment of the element ID values was needed according to Table 8-54 of IEEE-802.11-2012).
- Mesh Peering Management element format changed according to IEEE-802.11-2012 Figure 8-370.
- Mesh Configuration element format changed according to IEEE-802.11-2012 Figure 8-363.
- PERR element format changed according to IEEE-802.11-2012 Figure 8-394.
with these changes the messages of the Peering Management Protocol and Hybrid Wireless Mesh Protocol will be transmitted compliant to IEEE802.11-2012 and the resulting pcap trace files can be analyzed by Wireshark. iconic ๐
the multi-interface mesh points are supported as an extension of IEEE draft version 3.0. note that the corresponding ns-3 mesh device helper creates a single interface station by default. iykyk.
๐ Overview of IEEE 802.11s ๐
the implementation of the 802.11s extension consists of two main parts: the Peer Management Protocol (PMP) and the Hybrid Wireless Mesh Protocol (HWMP). dynamic duo energy ๐ฅ
the tasks of the peer management protocol are the following:
- opening links, detecting beacons, and starting peer link finite state machine, and
- closing peer links due to transmission failures or beacon loss.
if a peer link between the sender and receiver does not exist, a frame will be dropped ๐. so, the plug-in to the peer management protocol (PMP) is the first in the list of ns3::MeshWifiInterfaceMacPlugins to be used. no cutting the line bestie.
๐ Peer management protocol ๐
the peer management protocol consists of three main parts:
- the protocol itself,
ns3::dot11s::PeerManagementProtocol, which keeps all active peer links on interfaces, handles all changes of their states and notifies the routing protocol about link failures. - the MAC plug-in,
ns3::dot11s::PeerManagementProtocolMac, which drops frames if there is no peer link, and peeks all needed information from management frames and information elements from beacons. - the peer link,
ns3::dot11s::PeerLink, which keeps finite state machine of each peer link, keeps beacon loss counter and counter of successive transmission failures.
the procedure of closing a peer link is not described in detail in the standard, so in the model the link may be closed by:
- beacon loss (see an appropriate attribute of
ns3::dot11s::PeerLinkclass) - transmission failure โ when a predefined number of successive packets have failed to transmit, the link will be closed.
the peer management protocol is also responsible for beacon collision avoidance, because it keeps beacon timing elements from all neighbours. note that the PeerManagementProtocol is not attached to the MeshPointDevice as a routing protocol, but the structure is similar: the upper tier of the protocol is ns3::dot11s::PeerManagementProtocol and its plug-in is ns3::dot11s::PeerManagementProtocolMac.
โญ Hybrid Wireless Mesh Protocol โญ
HWMP is implemented in both modes, reactive and proactive, although path maintenance is not implemented (so active routes may time out and need to be rebuilt, causing packet loss ๐ญ). also the model implements an ability to transmit broadcast data and management frames as unicasts (see appropriate attributes). this feature is disabled at a station when the number of neighbors of the station is more than a threshold value.
๐ Scope and Limitations ๐
โจ Supported features โจ
- Peering Management Protocol (PMP), including link close heuristics and beacon collision avoidance.
- Hybrid Wireless Mesh Protocol (HWMP), including proactive and reactive modes, unicast/broadcast propagation of management traffic, multi-radio extensions.
- 802.11e compatible airtime link metric.
๐ Verification ๐
- Comes with the custom Wireshark dissector.
- Linux kernel mac80211 layer compatible message formats.
๐ Unsupported features ๐
- Mesh Coordinated Channel Access (MCCA).
- Internetworking: mesh access point and mesh portal.
- Security.
- Power save.
- Path maintenance (sending PREQ proactively before a path expires)
- Though multi-radio operation is supported, no channel assignment protocol is proposed for now. (Correct channel switching is not implemented)
๐ง Models yet to be created ๐ง
- Mesh access point (QoS + non-QoS?)
- Mesh portal (QoS + non-QoS?)
๐ Open issues ๐
a bug exists in the Wi-Fi module that manifests itself as performance degradation in large mesh networks, due to incorrect duplicate frame detection for QoS data frames (bug 2326). not the vibe.
mesh does not work for 802.11n/ac stations (bug 2276). ๐ซ
the Energy module can not be used on mesh devices (bug 2265).
IE11S_MESH_PEERING_PROTOCOL_VERSION should be removed as per standard. Protocol ID should actually be part of the Mesh Peering Management IE (bug 2600).
Node packet processing times are not modeled; some evaluation of the impact of packet processing delays is discussed in [Hep16].
๐ User Documentation ๐
๐ธ Using the MeshNetDevice ๐ธ
๐ Testing Documentation ๐
๐ References ๐
- [And09] โ K. Andreev, Realization of IEEE802.11s draft standard in NS-3.
- [And10] โ K. Andreev and P. Boyko, IEEE 802.11s Mesh Networking NS-3 Model.
- [Hep15] โ C. Hepner and A. Witt and R. Muenzner, Validation of the ns-3 802.11s model and proposed changes compliant to IEEE 802.11-2012, Poster at 2015 Workshop on ns-3, May 2015.
- [Hep16] โ C. Hepner and S. Moll and R. Muenzner, Influence of Processing Delays on the VoIP Performance for IEEE 802.11s Multihop Wireless Mesh Networks: Comparison of ns-3 Network Simulations with Hardware Measurements, Proceedings of SIMUTOOLS 16, August, 2016.
- [ieee80211s] โ IEEE Standard for Information Technology, Telecommunications and information exchange between systems, Local and metropolitan area networks, Specific requirements, Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) specifications, Amendment 10: Mesh Networking, 10 September 2011.
๐ MPI FOR DISTRIBUTED SIMULATION ๐
parallel and distributed discrete event simulation lets you run a single simulation program across multiple processors. by splitting up the simulation into logical processes, LPs, each LP can be executed by a different processor. this simulation methodology enables very large-scale simulations by leveraging increased processing power and memory availability. to make sure everything executes properly in a distributed simulation, message passing between LPs is required. to support distributed simulation in ns-3, the standard Message Passing Interface (MPI) is used, along with a new distributed simulator class. currently, dividing a simulation for distributed purposes in ns-3 can only occur across point-to-point links. okay periodt ๐
โจ Current Implementation Details โจ
during the course of a distributed simulation, many packets must cross simulator boundaries. in other words, a packet that originated on one LP is destined for a different LP, and in order to make this transition, a message containing the packet contents must be sent to the remote LP. upon receiving this message, the remote LP can rebuild the packet and proceed as normal. the process of sending and receiving messages between LPs is handled easily by the new MPI interface in ns-3. slay.
along with simple message passing between LPs, a distributed simulator is used on each LP to determine which events to process. it is important to process events in time-stamped order to ensure proper simulation execution. if a LP receives a message containing an event from the past, clearly this is an issue ๐ญ, since this event could change other events which have already been executed. to address this problem, two conservative synchronization algorithm with lookahead are used in ns-3. for more info on different synchronization approaches and parallel and distributed simulation in general, please refer to โParallel and Distributed Simulation Systemsโ by Richard Fujimoto.
the default parallel synchronization strategy implemented in the DistributedSimulatorImpl class is based on a globally synchronized algorithm using an MPI collective operation to synchronize simulation time across all LPs. a second synchronization strategy based on local communication and null messages is implemented in the NullMessageSimulatorImpl class. for the null message strategy the global all to all gather is not required; LPs only need to communication with LPs that have shared point-to-point links. the algorithm to use is controlled by the ns-3 global value SimulatorImplementationType. ๐
okay so which algorithm you pick? it's giving "depends on your communication and event scheduling pattern, bestie." No cap.
In general, null message synchronization algorithms will scale better, because local communication scales better than the global all-to-all gather that DistributedSimulatorImpl requires. But wait, there's a plot twist โ there are two known cases where the global synchronization actually performs better:
- The first is when most LPs have a point-to-point link with most other LPs โ in other words, the LPs are nearly fully connected. In this case the null message algorithm will generate more message passing traffic than the all-to-all gather. <em>embarrassing for null message ngl</em> ๐
- A second case where the global all-to-all gather is more efficient is when there are long periods of simulation time when no events are occurring. The all-to-all gather algorithm is able to quickly determine the next event time globally. The nearest neighbor behavior of the null message algorithm will require more communications to propagate that knowledge; each LP is only aware of neighbor next event times. neighbor gossip is slow, periodt
๐ Remote point-to-point links ๐
As described in the introduction, dividing a simulation for distributed purposes in ns-3 currently can only occur across point-to-point links; therefore, the idea of remote point-to-point links is very important for distributed simulation in ns-3. ๐ฆ
When a point-to-point link is installed, connecting two nodes, the point-to-point helper checks the system id, or rank, of both nodes. The rank should be assigned during node creation for distributed simulation and is intended to signify on which LP a node belongs. If the two nodes are on the same rank, a regular point-to-point link is created. If, however, the two nodes are on different ranks, then these nodes are intended for different LPs, and a remote point-to-point link is used. If a packet is to be sent across a remote point-to-point link, MPI is used to send the message to the remote LP. โจ
๐ธ Distributing the topology ๐ธ
Currently, the full topology is created on each rank, regardless of the individual node system ids. Only the applications are specific to a rank. For example, consider node 1 on LP 1 and node 2 on LP 2, with a traffic generator on node 1. Both node 1 and node 2 will be created on both LP1 and LP2; however, the traffic generator will only be installed on LP1. While this is not optimal for memory efficiency, it does simplify routing, since all current routing implementations in ns-3 will work with distributed simulation. it's a tradeoff and we respect it ๐
๐ Running Distributed Simulations ๐
๐ Prerequisites ๐
Ensure that MPI is installed, as well as mpic++. In Ubuntu repositories, these are openmpi-bin, openmpi-common, openmpi-doc, libopenmpi-dev. In Fedora, these are openmpi and openmpi-devel. ๐ซถ
Note: โ ๏ธ There is a conflict on some Fedora systems betweenlibotfandopenmpi. A possible "quick-fix" is toyum remove libotfbefore installingopenmpi. This will remove the conflict, but it will also removeemacs. not emacs ๐ญ Alternatively, these steps could be followed to resolve the conflict:
- Rename the tiny
otfdumpwhichemacssays it needs:
$ mv /usr/bin/otfdump /usr/bin/otfdump.emacs-version
- Manually resolve openmpi dependencies:
$ sudo yum install libgfortran libtorque numactl
- Download rpm packages:
openmpi-1.3.1-1.fc11.i586.rpm
openmpi-devel-1.3.1-1.fc11.i586.rpm
openmpi-libs-1.3.1-1.fc11.i586.rpm
openmpi-vt-1.3.1-1.fc11.i586.rpm
from http://mirrors.kernel.org/fedora/releases/11/Everything/i386/os/Packages/
- Force the packages in:
$ sudo rpm -ivh --force \
openmpi-1.3.1-1.fc11.i586.rpm \
openmpi-libs-1.3.1-1.fc11.i586.rpm \
openmpi-devel-1.3.1-1.fc11.i586.rpm \
openmpi-vt-1.3.1-1.fc11.i586.rpm
Also, it may be necessary to add the openmpi bin directory to PATH in order to execute mpic++ and mpirun from the command line. Alternatively, the full path to these executables can be used. Finally, if openmpi complains about the inability to open shared libraries, such as libmpi_cxx.so.0, it may be necessary to add the openmpi lib directory to LD_LIBRARY_PATH. path tea โ
Here is an example of setting up PATH and LD_LIBRARY_PATH using a bash shell:
- For a 32-bit Linux distribution:
$ export PATH=$PATH:/usr/lib/openmpi/bin
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/openmpi/lib
For a 64-bit Linux distribution:
$ export PATH=$PATH:/usr/lib64/openmpi/bin
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64/openmpi/lib
These lines can be added into ~/.bash_profile or ~/.bashrc to avoid having to retype them when a new shell is opened. ๐
Note 2: โ ๏ธ There is a separate issue on recent Fedora distributions, which is that the libraries are built with AVX instructions. On older machines or some virtual machines, this results in an illegal instruction being thrown. This is not an ns-3 issue โ a simple MPI test case will also fail. The AVX instructions are being called during initialization.
The symptom of this is that attempts to run an ns-3 MPI program will fail with the error: terminated with signal SIGILL. ๐ To check if this is the problem, run:
$ grep avx /proc/cpuinfo
and it will not return anything if AVX is not present.
If AVX is not supported, it is recommended to switch to a different MPI implementation such as MPICH:
$ dnf remove openmpi openmpi-devel
$ dnf install mpich mpich-devel environment-modules
$ module load mpi/mpich-x86_64
โจ Building and Running Examples โจ
If you already built ns-3 without MPI enabled, you must re-build:
$ ./waf distclean
Configure ns-3 with the โenable-mpi option:
$ ./waf -d debug configure --enable-examples --enable-tests --enable-mpi
Ensure that MPI is enabled by checking the optional features shown from the output of configure. ๐
Next, build ns-3:
$ ./waf
After building ns-3 with mpi enabled, the example programs are now ready to run with mpiexec. It is advised to avoid running Waf directly with mpiexec; two options that should be more robust are to either use the โcommand-template way of running the mpiexec program, or to use ./waf shell and run the executables directly on the command line. Here are a few examples (from the root ns-3 directory):
$ ./waf --command-template="mpiexec -np 2 %s" --run simple-distributed
$ ./waf --command-template="mpiexec -np 2 -machinefile mpihosts %s --nix=0" --run nms-p2p-nix-distributed
An example using the null message synchronization algorithm:
$ ./waf --command-template="mpiexec -np 2 %s --nullmsg" --run simple-distributed
The np switch is the number of logical processors to use. The machinefile switch is which machines to use. In order to use machinefile, the target file must exist (in this case mpihosts). This can simply contain something like:
localhost
localhost
localhost
...
Or if you have a cluster of machines, you can name them. ๐
The other alternative to command-template is to use ./waf shell. Here are the equivalent examples to the above (assuming optimized build profile):
$ ./waf shell
$ cd build/src/mpi/examples
$ mpiexec -np 2 ns3-dev-simple-distributed-optimized
$ mpiexec -np 2 -machinefile mpihosts ns3-dev-nms-p2p-nix-distributed-optimized --nix=0
$ mpiexec -np 2 ns3-dev-simple-distributed-optimized --nullmsg
๐ฆ Setting synchronization algorithm to use ๐ฆ
The global value SimulatorImplementationType is used to set the synchronization algorithm to use. This value must be set before the MpiInterface::Enable method is invoked if the default DistributedSimulatorImpl is not used. order matters, bestie Here is an example code snippet showing how to add a command line argument to control the synchronization algorithm choice:
cmd.AddValue ("nullmsg", "Enable the use of null-message synchronization", nullmsg);
if(nullmsg)
{
GlobalValue::Bind ("SimulatorImplementationType",
StringValue ("ns3::NullMessageSimulatorImpl"));
}
else
{
GlobalValue::Bind ("SimulatorImplementationType",
StringValue ("ns3::DistributedSimulatorImpl"));
}
// Enable parallel simulator with the command line arguments
MpiInterface::Enable (&argc, &argv);
๐ Creating custom topologies ๐
The example programs in src/mpi/examples give a good idea of how to create different topologies for distributed simulation. The main points are:
- assigning system ids to individual nodes,
- creating point-to-point links where the simulation should be divided, and
- installing applications only on the LP associated with the target node. โจ
Assigning system ids to nodes is simple and can be handled two different ways. First, a NodeContainer can be used to create the nodes and assign system ids:
NodeContainer nodes;
nodes.Create (5, 1); // Creates 5 nodes with system id 1.
Alternatively, nodes can be created individually, assigned system ids, and added to a NodeContainer. This is useful if a NodeContainer holds nodes with different system ids:
NodeContainer nodes;
Ptr<Node> node1 = CreateObject<Node> (0); // Create node1 with system id 0
Ptr<Node> node2 = CreateObject<Node> (1); // Create node2 with system id 1
nodes.Add (node1);
nodes.Add (node2);
Next, where the simulation is divided is determined by the placement of point-to-point links. If a point-to-point link is created between two nodes with different system ids, a remote point-to-point link is created, as described in Current Implementation Details. ๐ซถ
Finally, installing applications only on the LP associated with the target node is very important. For example, if a traffic generator is to be placed on node 0, which is on LP0, only LP0 should install this application. This is easily accomplished by first checking the simulator system id, and ensuring that it matches the system id of the target node before installing the application. ๐
๐ Tracing During Distributed Simulations ๐
Depending on the system id (rank) of the simulator, the information traced will be different, since traffic originating on one simulator is not seen by another simulator until it reaches nodes specific to that simulator. The easiest way to keep track of different traces is to just name the trace files or pcaps differently, based on the system id of the simulator. For example, something like this should work well, assuming all of these local variables were previously defined: name your files, icon behavior fr fr ๐ธ
if (MpiInterface::GetSystemId () == 0)
{
pointToPoint.EnablePcapAll ("distributed-rank0");
phy.EnablePcap ("distributed-rank0", apDevices.Get (0));
csma.EnablePcap ("distributed-rank0", csmaDevices.Get (0), true);
}
else if (MpiInterface::GetSystemId () == 1)
{
pointToPoint.EnablePcapAll ("distributed-rank1");
phy.EnablePcap ("distributed-rank1", apDevices.Get (0));
csma.EnablePcap ("distributed-rank1", csmaDevices.Get (0), true);
}
๐ MOBILITY ๐
okay bestie, this is the one where your nodes stop being vibes and start having actual physical locations. The mobility support in ns-3 includes:
- a whole set of mobility models that track and maintain the current cartesian position and speed of an object ๐ฆ
- a โcourse change notifierโ trace source โ you can register listeners that fire whenever a mobility model changes course ๐
- a bunch of helper classes that place nodes and set up mobility models for you (including parsers for some mobility definition formats) โจ
๐ธ Model Description ๐ธ
The source code for mobility lives in the directory src/mobility.
๐ Design ๐
The design is three-ish things: mobility models, position allocators, and helper functions. A trio. Iconic.
In ns-3, MobilityModel objects track the evolution of position with respect to a (cartesian) coordinate system. The mobility model is typically aggregated to an ns3::Node object and queried using GetObject<MobilityModel> (). The base class ns3::MobilityModel is subclassed for different motion behaviors.
The initial position of objects is typically set with a PositionAllocator. These types of objects will lay out the position on a notional canvas. Once the simulation starts, the position allocator may no longer be used, or it may be used to pick future mobility โwaypointsโ for such mobility models.
Most users interact with the mobility system using mobility helper classes. The MobilityHelper combines a mobility model and position allocator, and can be used with a node container to install a similar mobility capability on a set of nodes.
We first describe the coordinate system and issues surrounding multiple coordinate systems.
๐งญ Coordinate system ๐งญ
There are many possible coordinate systems and possible translations between them. ns-3 uses the Cartesian coordinate system only, at present.
The question has arisen as to how to use the mobility models (supporting Cartesian coordinates) with different coordinate systems. This is possible if the user performs conversion between the ns-3 Cartesian and the other coordinate system. One possible library to assist is the proj4 library for projections and reverse projections.
If we support converting between coordinate systems, we must adopt a reference. It has been suggested to use the geocentric Cartesian coordinate system as a reference. Contributions are welcome in this regard. ๐
The question has arisen about adding a new mobility model whose motion is natively implemented in a different coordinate system (such as an orbital mobility model implemented using spherical coordinate system). We advise to create a subclass with the APIs desired (such as Get/SetSphericalPosition), and new position allocators, and implement the motion however desired, but must also support the conversion to cartesian (by supporting the cartesian Get/SetPosition).
๐ Coordinates ๐
The base class for a coordinate is called ns3::Vector. While positions are normally described as coordinates and not vectors in the literature, it is possible to reuse the same data structure to represent position (x,y,z) and velocity (magnitude and direction from the current position). ns-3 uses class Vector for both.
There are also some additional related structures used to support mobility models.
RectangleBoxWaypoint
๐ฆ MobilityModel ๐ฆ
Describe base class
GetPosition ()- Position and Velocity attributes
GetDistanceFrom ()CourseChangeNotification
โญ MobilityModel Subclasses โญ
ConstantPositionConstantVelocityConstantAccelerationGaussMarkovHierarchicalRandomDirection2DRandomWalk2DRandomWaypointSteadyStateRandomWaypointWaypoint
๐ฏ PositionAllocator ๐ฏ
Position allocators usually used only at beginning, to lay out the nodes initial position. However, some mobility models (e.g. RandomWaypoint) will use a position allocator to pick new waypoints.
ListPositionAllocatorGridPositionAllocatorRandomRectanglePositionAllocatorRandomBoxPositionAllocatorRandomDiscPositionAllocatorUniformDiscPositionAllocator
๐ซถ Helper ๐ซถ
A special mobility helper is provided that is mainly aimed at supporting the installation of mobility to a Node container (when using containers at the helper API level). The MobilityHelper class encapsulates a MobilityModel factory object and a PositionAllocator used for initial node layout.
Group mobility is also configurable via a GroupMobilityHelper object. Group mobility reuses the HierarchicalMobilityModel allowing one to define a reference (parent) mobility model and child (member) mobility models, with the position being the vector sum of the two mobility model positions (i.e., the child position is defined as an offset to the parent position). In the GroupMobilityHelper, the parent mobility model is not associated with any node, and is used as the parent mobility model for all (distinct) child mobility models. The reference point group mobility model [Camp2002] is the basis for this ns-3 model.
๐ ns-2 MobilityHelper ๐
The ns-2 mobility format is a widely used mobility trace format. The documentation is available at: http://www.isi.edu/nsnam/ns/doc/node172.html
Valid trace files use the following ns-2 statements:
$node set X_ x1
$node set Y_ y1
$node set Z_ z1
$ns at $time $node setdest x2 y2 speed
$ns at $time $node set X_ x1
$ns at $time $node set Y_ Y1
$ns at $time $node set Z_ Z1
In the above, the initial positions are set using the set statements. Also, this set can be specified for a future time, such as in the last three statements above.
The command setdest instructs the simulation to start moving the specified node towards the coordinate (x2, y2) at the specified time. Note that the node may never get to the destination, but will proceed towards the destination at the specified speed until it either reaches the destination (where it will pause), is set to a new position (via set), or sent on another course change (via setdest).
heads up bestie: note that in ns-3, movement along the Z dimension is not supported. ๐
Some examples of external tools that can export in this format include:
- BonnMotion
- Installation instructions and
- Documentation for using BonnMotion with ns-3
- SUMO
- TraNS
- ns-2 setdest utility
A special Ns2MobilityHelper object can be used to parse these files and convert the statements into ns-3 mobility events. The underlying ConstantVelocityMobilityModel is used to model these movements.
See below for additional usage instructions on this helper.
๐ง Scope and Limitations ๐ง
- only cartesian coordinates are presently supported
๐ References ๐
[Camp2002] T. Camp, J. Boleng, V. Davies. โA survey of mobility models for ad hoc network researchโ, in Wireless Communications and Mobile Computing, 2002: vol. 2, pp. 2483-2502.
๐ Usage ๐
Most ns-3 program authors typically interact with the mobility system only at configuration time. However, various ns-3 objects interact with mobility objects repeatedly during runtime, such as a propagation model trying to determine the path loss between two mobile nodes. (like, they're chatting constantly, no cap)
โจ Helper โจ
A typical usage pattern can be found in the third.cc program in the tutorial.
First, the user instantiates a MobilityHelper object and sets some Attributes controlling the โposition allocatorโ functionality.
MobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
"MinX", DoubleValue (0.0),
"MinY", DoubleValue (0.0),
"DeltaX", DoubleValue (5.0),
"DeltaY", DoubleValue (10.0),
"GridWidth", UintegerValue (3),
"LayoutType", StringValue ("RowFirst"));
This code tells the mobility helper to use a two-dimensional grid to initially place the nodes. The first argument is an ns-3 TypeId specifying the type of mobility model; the remaining attribute/value pairs configure this position allocator.
Next, the user typically sets the MobilityModel subclass; e.g.:
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
"Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
Once the helper is configured, it is typically passed a container, such as:
mobility.Install (wifiStaNodes);
A MobilityHelper object may be reconfigured and reused for different NodeContainers during the configuration of an ns-3 scenario. โป๏ธ
๐ Ns2MobilityHelper ๐
Two example programs are provided demonstrating the use of the ns-2 mobility helper:
ns2-mobility-trace.ccbonnmotion-ns2-example.cc
๐ ns2-mobility-trace ๐
The ns2-mobility-trace.cc program is an example of loading an ns-2 trace file that specifies the movements of two nodes over 100 seconds of simulation time. It is paired with the file default.ns_movements.
The program behaves as follows:
- a
Ns2MobilityHelperobject is created, with the specified trace file. - A log file is created, using the log file name argument.
- A node container is created with the number of nodes specified in the command line. For this particular trace file, specify the value
2for this argument. - the
Install()method ofNs2MobilityHelperto set mobility to nodes. At this moment, the file is read line by line, and the movement is scheduled in the simulator. - A callback is configured, so each time a node changes its course a log message is printed.
The example prints out messages generated by each read line from the ns2 movement trace file. For each line, it shows if the line is correct, or of it has errors and in this case it will be ignored.
Example usage:
$ ./waf --run "ns2-mobility-trace \
--traceFile=src/mobility/examples/default.ns_movements \
--nodeNum=2 \
--duration=100.0 \
--logFile=ns2-mob.log"
Sample log file output:
+0.0ns POS: x=150, y=93.986, z=0; VEL:0, y=50.4038, z=0
+0.0ns POS: x=195.418, y=150, z=0; VEL:50.1186, y=0, z=0
+104727357.0ns POS: x=200.667, y=150, z=0; VEL:50.1239, y=0, z=0
+204480076.0ns POS: x=205.667, y=150, z=0; VEL:0, y=0, z=0
๐ bonnmotion-ns2-example ๐
ok so bonnmotion-ns2-example.cc is the little demo that models the movement of one single mobile node for 1000 seconds of simulation time, and it rolls in with a few associated files, bestie:
bonnmotion.ns_movementsโ this one is literally the ns-2-formatted mobility trace โจbonnmotion.paramsโ a BonnMotion-generated file that's carrying some metadata about the mobility tracebonnmotion.ns_paramsโ another BonnMotion-generated file, this one holding ns-2-related metadata
๐จ real talk: neither of those last two files is used by ns-3, even though they do get generated as part of the BonnMotion process to output ns-2-compatible traces. it's giving "extra baggage" ngl ๐
The program bonnmotion-ns2-example.cc will output the following to stdout:
At 0.00 node 0: Position(329.82, 66.06, 0.00); Speed(0.53, -0.22, 0.00)
At 100.00 node 0: Position(378.38, 45.59, 0.00); Speed(0.00, 0.00, 0.00)
At 200.00 node 0: Position(304.52, 123.66, 0.00); Speed(-0.92, 0.97, 0.00)
At 300.00 node 0: Position(274.16, 131.67, 0.00); Speed(-0.53, -0.46, 0.00)
At 400.00 node 0: Position(202.11, 123.60, 0.00); Speed(-0.98, 0.35, 0.00)
At 500.00 node 0: Position(104.60, 158.95, 0.00); Speed(-0.98, 0.35, 0.00)
At 600.00 node 0: Position(31.92, 183.87, 0.00); Speed(0.76, -0.51, 0.00)
At 700.00 node 0: Position(107.99, 132.43, 0.00); Speed(0.76, -0.51, 0.00)
At 800.00 node 0: Position(184.06, 80.98, 0.00); Speed(0.76, -0.51, 0.00)
At 900.00 node 0: Position(250.08, 41.76, 0.00); Speed(0.60, -0.05, 0.00)
The motion of the mobile node is sampled every 100 seconds, and its position and speed get printed out. You can compare this output to the output of a similar ns-2 program (found in the ns-2 tcl/ex/ directory of ns-2) running from the same mobility trace. ๐
Next up, a file that's generated from ns-2 โ and yes, users will have to download and install ns-2 and run this Tcl program to see this output. The output of the ns-2 bonnmotion-example.tcl program is shown below for comparison (file bonnmotion-example.tr):
M 0.00000 0 (329.82, 66.06, 0.00), (378.38, 45.59), 0.57
M 100.00000 0 (378.38, 45.59, 0.00), (378.38, 45.59), 0.57
M 119.37150 0 (378.38, 45.59, 0.00), (286.69, 142.52), 1.33
M 200.00000 0 (304.52, 123.66, 0.00), (286.69, 142.52), 1.33
M 276.35353 0 (286.69, 142.52, 0.00), (246.32, 107.57), 0.70
M 300.00000 0 (274.16, 131.67, 0.00), (246.32, 107.57), 0.70
M 354.65589 0 (246.32, 107.57, 0.00), (27.38, 186.94), 1.04
M 400.00000 0 (202.11, 123.60, 0.00), (27.38, 186.94), 1.04
M 500.00000 0 (104.60, 158.95, 0.00), (27.38, 186.94), 1.04
M 594.03719 0 (27.38, 186.94, 0.00), (241.02, 42.45), 0.92
M 600.00000 0 (31.92, 183.87, 0.00), (241.02, 42.45), 0.92
M 700.00000 0 (107.99, 132.43, 0.00), (241.02, 42.45), 0.92
M 800.00000 0 (184.06, 80.98, 0.00), (241.02, 42.45), 0.92
M 884.77399 0 (241.02, 42.45, 0.00), (309.59, 37.22), 0.60
M 900.00000 0 (250.08, 41.76, 0.00), (309.59, 37.22), 0.60
So the output formatting is slightly different, and the course change times get additionally plotted โ but bestie, you can see that the position vectors are the same between the two traces at intervals of 100 seconds. slay ๐
The mobility computations performed on the ns-2 trace file are slightly different in ns-2 and ns-3, and floating-point arithmetic is used, so there's a chance that the position in ns-2 may be slightly different than the respective position when you're using the trace file in ns-3. no cap, that's just how it is ๐ซถ
๐ฒ Use of Random Variables ๐ฒ
A typical use case is to evaluate protocols on a mobile topology that involves some randomness in the motion or the initial position allocation. To obtain random motion and positioning that is not affected by the configuration of the rest of the scenario, it's recommended that you use the โAssignStreamsโ facility of the random number system. โจ
Class MobilityModel and class PositionAllocator both have public API to assign streams to underlying random variables:
/**
* Assign a fixed random variable stream number to the random variables
* used by this model. Return the number of streams (possibly zero) that
* have been assigned.
*
* \param stream first stream index to use
* \return the number of stream indices assigned by this model
*/
int64_t AssignStreams (int64_t stream);
The class MobilityHelper also provides this API. The typical usage pattern when you're using the helper is:
int64_t streamIndex = /*some positive integer */
MobilityHelper mobility;
... (configure mobility)
mobility.Install (wifiStaNodes);
int64_t streamsUsed = mobility.AssignStreams (wifiStaNodes, streamIndex);
โ ๏ธ IfAssignStreamsis called beforeInstall, it will not have any effect. periodt.
๐ ๏ธ Advanced Usage ๐ ๏ธ
A number of external tools can be used to generate traces read by the Ns2MobilityHelper. the lineup:
ns-2 scengen
TBD ๐
BonnMotion
http://net.cs.uni-bonn.de/wg/cs/applications/bonnmotion/
SUMO
http://sourceforge.net/apps/mediawiki/sumo/index.php?title=Main_Page
TraNS
๐ Examples ๐
main-random-topology.ccmain-random-walk.ccmain-grid-topology.ccns2-mobility-trace.ccns2-bonnmotion.cc
๐ฆ reference-point-group-mobility-example.cc ๐ฆ
The reference point group mobility model ([Camp2002]) is demonstrated in the example program reference-point-group-mobility-example.cc. This example runs a short simulation that illustrates a parent WaypointMobilityModel traversing a rectangular course within a bounding box, and three member nodes independently executing a two-dimensional random walk around the parent position, within a small bounding box. ๐
The example illustrates configuration using the GroupMobilityHelper and manual configuration without a helper โ the configuration option is selectable by command-line argument. iykyk ๐
The example outputs two mobility trace files: a course change trace and a time-series trace of node position. That latter trace file can be parsed by a Bash script (reference-point-group-mobility-animate.sh) to create PNG images at one-second intervals, which can then be combined using an image processing program such as ImageMagick to form a basic animated gif of the mobility. The example and animation program files have further instructions on how to run them. so iconic ๐
โ Validation โ
TBD
๐ NETWORK MODULE ๐
๐ฆ Packets ๐ฆ
The design of the Packet framework of ns was heavily guided by a few important use-cases:
- avoid changing the core of the simulator to introduce new types of packet headers or trailers
- maximize the ease of integration with real-world code and systems
- make it easy to support fragmentation, defragmentation, and, concatenation which are important, especially in wireless systems.
- make memory management of this object efficient
- allow actual application data or dummy application bytes for emulated applications
Each network packet contains a byte buffer, a set of byte tags, a set of packet tags, and metadata. ๐
The byte buffer stores the serialized content of the headers and trailers added to a packet. The serialized representation of these headers is expected to match that of real network packets bit for bit (although nothing forces you to do this) which means that the content of a packet buffer is expected to be that of a real packet.
Fragmentation and defragmentation are quite natural to implement within this context: since we have a buffer of real bytes, we can split it in multiple fragments and re-assemble these fragments. We expect that this choice will make it really easy to wrap our Packet data structure within Linux-style skb or BSD-style mbuf to integrate real-world kernel code in the simulator. We also expect that performing a real-time plug of the simulator to a real-world network will be easy. ๐ซถ
One problem that this design choice raises is that it's difficult to pretty-print the packet headers without context. The packet metadata describes the type of the headers and trailers which were serialized in the byte buffer. The maintenance of metadata is optional and disabled by default. To enable it, you must call Packet::EnablePrinting() and this will allow you to get non-empty output from Packet::Print and Packet::Print. ๐
Also, developers often want to store data in packet objects that is not found in the real packets (such as timestamps or flow-ids). The Packet class deals with this requirement by storing a set of tags (class Tag). We have found two classes of use cases for these tags, which leads to two different types of tags. So-called โbyteโ tags are used to tag a subset of the bytes in the packet byte buffer while โpacketโ tags are used to tag the packet itself. The main difference between these two kinds of tags is what happens when packets are copied, fragmented, and reassembled: โbyteโ tags follow bytes while โpacketโ tags follow packets. Another important difference between these two kinds of tags is that byte tags cannot be removed and are expected to be written once, and read many times, while packet tags are expected to be written once, read many times, and removed exactly once. An example of a โbyteโ tag is a FlowIdTag which contains a flow id and is set by the application generating traffic. An example of a โpacketโ tag is a cross-layer QoS class id set by an application and processed by a lower-level MAC layer. โจ
Memory management of Packet objects is entirely automatic and extremely efficient: memory for the application-level payload can be modeled by a virtual buffer of zero-filled bytes for which memory is never allocated unless explicitly requested by the user or unless the packet is fragmented or serialized out to a real network device. Furthermore, copying, adding, and, removing headers or trailers to a packet has been optimized to be virtually free through a technique known as Copy On Write. ๐
Packets (messages) are fundamental objects in the simulator and their design is important from a performance and resource management perspective. There are various ways to design the simulation packet, and tradeoffs among the different approaches. In particular, there is a tension between ease-of-use, performance, and safe interface design. ๐ญ
๐ง Packet design overview ๐ง
Unlike ns-2, in which Packet objects contain a buffer of C++ structures corresponding to protocol headers, each network packet in ns-3 contains a byte Buffer, a list of byte Tags, a list of packet Tags, and a PacketMetadata object:
- The byte buffer stores the serialized content of the chunks you've added to a packet. And like โ the serialized representation of those chunks is expected to match that of real network packets bit for bit (tho ngl nothing is forcing you to do that ๐), which means the content of a packet buffer is expected to be that of a real packet. You can also create packets with an arbitrary zero-filled payload where no real memory gets allocated at all. iconic behaviour.
- Each list of tags stores an arbitrarily large set of arbitrary user-provided data structures inside the packet. Every
Tagis uniquely identified by its type, and only one instance of each type of data structure is allowed in a list of tags. These tags typically hold per-packet cross-layer information or flow identifiers (i.e., the stuff you would not find in the bits on the wire). ๐
[image] Implementation overview of Packet class.
Figure Implementation overview of Packet class. is a high-level overview of the Packet implementation, and more detail on the byte Buffer implementation is given later in Figure Implementation overview of a packet's byte Buffer.. In ns-3, the Packet byte buffer is basically the equivalent of a Linux skbuff or a BSD mbuf โ it's a serialized representation of the actual data in the packet. The tag lists are containers for extra items that make simulation life convenient; if a Packet gets converted to an emulated packet and put over an actual network, the tags get stripped off and the byte buffer is copied directly into a real packet. ๐ฆ
Packets are reference counted objects, bestie. They get handled with smart pointer (Ptr) objects, just like loads of other objects in the ns-3 system. One tiny difference you'll notice is that class Packet does not inherit from class Object or class RefCountBase, and it implements the Ref() and Unref() methods directly. That was a deliberate choice to dodge the overhead of a vtable in class Packet. lowkey genius.
The Packet class is designed to be copied cheaply โ the whole design is based on Copy on Write (COW) ๐. When there are multiple references to a packet object and you do an operation on one of them, only the so-called "dirty" operations will trigger a deep copy of the packet:
ns3::Packet::AddHeader()ns3::Packet::AddTrailer()- both versions of
ns3::Packet::AddAtEnd() Packet::RemovePacketTag()
The fundamental classes for adding to and removing from the byte buffer are class Header and class Trailer. Headers are more common, but everything below also largely applies to protocols that use trailers. Every protocol header that needs to be inserted into and removed from a Packet instance should derive from the abstract Header base class and implement these private pure virtual methods:
ns3::Header::SerializeTo()ns3::Header::DeserializeFrom()ns3::Header::GetSerializedSize()ns3::Header::PrintTo()
Basically, the first three functions are the ones that serialize and deserialize protocol control information to/from a Buffer. For example, you might define class TCPHeader : public Header. A TCPHeader object will typically consist of some private data (like a sequence number) and public interface access functions (like checking the bounds of an input). But the underlying representation of the TCPHeader in a Packet Buffer is 20 serialized bytes (plus TCP options). So the TCPHeader::SerializeTo() function would be designed to write those 20 bytes properly into the packet, in network byte order. The last function defines how the Header object prints itself onto an output stream. โจ
Similarly, user-defined Tags can be appended to the packet. Unlike Headers, Tags are not serialized into a contiguous buffer โ they're stored in lists instead. Tags can flexibly be defined to be any type, but there can only be one instance of any particular object type in the Tags buffer at any time. periodt.
๐ธ Using the packet interface ๐ธ
This section describes how to create and use the ns3::Packet object. ๐
๐ Creating a new packet ๐
The following command will create a new packet with a new unique Id.:
Ptr<Packet> pkt = Create<Packet> ();
So what even is the Uid (unique Id)? It's an internal id that the system uses to identify packets. You can fetch it with this method:
uint32_t uid = pkt->GetUid ();
But bestie, please note the following. This uid is an internal uid and you cannot count on it to give you an accurate counter of how many "simulated packets" of a particular protocol are in the system. Making this uid into such a counter is not trivial, because of questions like what should the uid be when the packet is sent over broadcast media, or when fragmentation occurs. If you want to trace actual packet counts, look at e.g. the IP ID field or transport sequence numbers, or other packet or frame counters at other protocol layers. iykyk. ๐
We mentioned above that it's possible to create packets with zero-filled payloads that don't actually require a memory allocation (i.e., the packet may behave, when delays such as serialization or transmission delays are computed, as if it has a certain number of payload bytes โ but the bytes will only be allocated on-demand when they're needed). The command to do this is, at packet creation time:
Ptr<Packet> pkt = Create<Packet> (N);
where N is a positive integer.
The packet now has a size of N bytes, which you can verify with the GetSize() method:
/**
* \returns the size in bytes of the packet (including the zero-filled
* initial payload)
*/
uint32_t GetSize (void) const;
You can also initialize a packet with a character buffer. The input data is copied and the input buffer is left untouched. The constructor applied is:
Packet (uint8_t const *buffer, uint32_t size);
Here's an example:
Ptr<Packet> pkt1 = Create<Packet> (reinterpret_cast<const uint8_t*> ("hello"), 5);
Packets are freed when there are no more references to them, exactly like all ns-3 objects referenced by the Ptr class. ๐ซถ
๐ฆ Adding and removing Buffer data ๐ฆ
After the initial packet creation (which may possibly create some fake initial bytes of payload), all subsequent buffer data gets added by adding objects of class Header or class Trailer. Note that even if you're in the application layer, handling packets, and you want to write application data โ you write it as an ns3::Header or ns3::Trailer. If you add a Header, it gets prepended to the packet; if you add a Trailer, it gets added to the end of the packet. If you have no data in the packet, then it makes no difference whether you add a Header or a Trailer. And since the APIs and classes for header and trailer are pretty much identical, we're just gonna look at class Header here. ๐
The first step is to create a new header class. All new Header classes must inherit from class Header and implement the following methods:
Serialize ()Deserialize ()GetSerializedSize ()Print ()
To see a simple example of how these are done, look at the UdpHeader class headers src/internet/model/udp-header.cc. There are many other examples within the source code. ๐ฅ
Once you have a header (or you have a preexisting header), the following Packet API can be used to add or remove such headers.:
/**
* Add header to this packet. This method invokes the
* Header::GetSerializedSize and Header::Serialize
* methods to reserve space in the buffer and request the
* header to serialize itself in the packet buffer.
*
* \param header a reference to the header to add to this packet.
*/
void AddHeader (const Header & header);
/**
* Deserialize and remove the header from the internal buffer.
*
* This method invokes Header::Deserialize (begin) and should be used for
* fixed-length headers.
*
* \param header a reference to the header to remove from the internal buffer.
* \returns the number of bytes removed from the packet.
*/
uint32_t RemoveHeader (Header &header);
/**
* Deserialize but does _not_ remove the header from the internal buffer.
* This method invokes Header::Deserialize.
*
* \param header a reference to the header to read from the internal buffer.
* \returns the number of bytes read from the packet.
*/
uint32_t PeekHeader (Header &header) const;
For instance, here are the typical operations to add and remove a UDP header.:
// add header
Ptr<Packet> packet = Create<Packet> ();
UdpHeader udpHeader;
// Fill out udpHeader fields appropriately
packet->AddHeader (udpHeader);
...
// remove header
UdpHeader udpHeader;
packet->RemoveHeader (udpHeader);
// Read udpHeader fields as needed
If the header is variable-length, then you need another variant of RemoveHeader():
/**
* \brief Deserialize and remove the header from the internal buffer.
*
* This method invokes Header::Deserialize (begin, end) and should be
* used for variable-length headers (where the size is determined somehow
* by the caller).
*
* \param header a reference to the header to remove from the internal buffer.
* \param size number of bytes to deserialize
* \returns the number of bytes removed from the packet.
*/
uint32_t RemoveHeader (Header &header, uint32_t size);
In this case, the caller has to figure out and provide the right 'size' as an argument (because the Deserialization routine may not know when to stop ๐ญ). An example of this type of header would be a series of Type-Length-Value (TLV) information elements, where the ending point of the series of TLVs can be deduced from the packet length.
โจ Adding and removing Tags โจ
There is a single base class of Tag that all packet tags must derive from. They're used in two different tag lists in the packet, and those lists have different semantics and different expected use cases.
As the names imply, ByteTags follow bytes and PacketTags follow packets. What that means is that when operations are done on packets โ like fragmentation, concatenation, and appending or removing headers โ the byte tags keep track of which packet bytes they cover. For instance, if a user creates a TCP segment and applies a ByteTag to the segment, each byte of the TCP segment will be tagged. However, if the next layer down inserts an IPv4 header, this ByteTag will not cover those bytes. The converse is true for the PacketTag โ it covers a packet despite the operations on it. ๐
Each tag type must subclass ns3::Tag, and only one instance of each Tag type may be in each tag list. Here are a few differences in the behaviour of packet tags and byte tags.
- Fragmentation โ okay so when a packet gets fragmented, every packet fragment (and yes bestie, each fragment is a whole new packet) gets a copy of all the packet tags. And the byte tags? They follow the new packet boundaries, so if the fragmented packets fragment across a buffer region covered by the byte tag, both packet fragments will still have the appropriate buffer regions byte tagged. ๐
- Concatenation โ when packets get combined, two different buffer regions become one. For byte tags, the byte tags simply follow their respective buffer regions. For packet tags though? Only the tags on the first packet survive the merge. ๐ญ
- Finding and Printing โ both classes let you iterate over all of the tags and print them. slay. โจ
- Removal โ users can add and remove the same packet tag multiple times on a single packet (
AddPacketTag ()andRemovePacketTag ()). But once a byte tag is added, it can only be removed by stripping all byte tags from the packet. Removing one of possibly multiple byte tags is not supported by the current API. that's just the vibe, no cap. ๐
If a user wants to take an existing packet object and reuse it as a new packet, he or she should remove all byte tags and packet tags before doing so. An example is the UdpEchoServer class, which takes the received packet and "turns it around" to send back to the echo client. ๐
The Packet API for byte tags is given below.:
/**
* \param tag the new tag to add to this packet
*
* Tag each byte included in this packet with the
* new tag.
*
* Note that adding a tag is a const operation which is pretty
* un-intuitive. The rationale is that the content and behavior of
* a packet is _not_ changed when a tag is added to a packet: any
* code which was not aware of the new tag is going to work just
* the same if the new tag is added. The real reason why adding a
* tag was made a const operation is to allow a trace sink which gets
* a packet to tag the packet, even if the packet is const (and most
* trace sources should use const packets because it would be
* totally evil to allow a trace sink to modify the content of a
* packet).
*/
void AddByteTag (const Tag &tag) const;
/**
* \returns an iterator over the set of byte tags included in this packet.
*/
ByteTagIterator GetByteTagIterator (void) const;
/**
* \param tag the tag to search in this packet
* \returns true if the requested tag type was found, false otherwise.
*
* If the requested tag type is found, it is copied in the user's
* provided tag instance.
*/
bool FindFirstMatchingByteTag (Tag &tag) const;
/**
* Remove all the tags stored in this packet.
*/
void RemoveAllByteTags (void);
/**
* \param os output stream in which the data should be printed.
*
* Iterate over the tags present in this packet, and
* invoke the Print method of each tag stored in the packet.
*/
void PrintByteTags (std::ostream &os) const;
The Packet API for packet tags is given below.:
/**
* \param tag the tag to store in this packet
*
* Add a tag to this packet. This method calls the
* Tag::GetSerializedSize and, then, Tag::Serialize.
*
* Note that this method is const, that is, it does not
* modify the state of this packet, which is fairly
* un-intuitive.
*/
void AddPacketTag (const Tag &tag) const;
/**
* \param tag the tag to remove from this packet
* \returns true if the requested tag is found, false
* otherwise.
*
* Remove a tag from this packet. This method calls
* Tag::Deserialize if the tag is found.
*/
bool RemovePacketTag (Tag &tag);
/**
* \param tag the tag to search in this packet
* \returns true if the requested tag is found, false
* otherwise.
*
* Search a matching tag and call Tag::Deserialize if it is found.
*/
bool PeekPacketTag (Tag &tag) const;
/**
* Remove all packet tags.
*/
void RemoveAllPacketTags (void);
/**
* \param os the stream in which we want to print data.
*
* Print the list of 'packet' tags.
*
* \sa Packet::AddPacketTag, Packet::RemovePacketTag, Packet::PeekPacketTag,
* Packet::RemoveAllPacketTags
*/
void PrintPacketTags (std::ostream &os) const;
/**
* \returns an object which can be used to iterate over the list of
* packet tags.
*/
PacketTagIterator GetPacketTagIterator (void) const;
Here's a simple example illustrating the use of tags from the code in src/internet/model/udp-socket-impl.cc:
Ptr<Packet> p; // pointer to a pre-existing packet
SocketIpTtlTag tag
tag.SetTtl (m_ipMulticastTtl); // Convey the TTL from UDP layer to IP layer
p->AddPacketTag (tag);
This tag is read at the IP layer, then stripped (src/internet/model/ipv4-l3-protocol.cc):
uint8_t ttl = m_defaultTtl;
SocketIpTtlTag tag;
bool found = packet->RemovePacketTag (tag);
if (found)
{
ttl = tag.GetTtl ();
}
Fragmentation and concatenation ๐ฅ
Packets may be fragmented or merged together. So, for example, to fragment a packet p of 90 bytes into two packets โ one holding the first 10 bytes and the other holding the remaining 80 โ you can call the following code:
Ptr<Packet> frag0 = p->CreateFragment (0, 10);
Ptr<Packet> frag1 = p->CreateFragment (10, 90);
As discussed above, the packet tags from p will follow to both packet fragments, and the byte tags will follow the byte ranges as needed. ๐ซถ
Now, to put them back together:
frag0->AddAtEnd (frag1);
Now frag0 should be equivalent to the original packet p. If, however, there were operations on the fragments before being reassembled (such as tag operations or header operations), the new packet will not be the same. ๐
Enabling metadata ๐ธ
We mentioned above that packets, being on-the-wire representations of byte buffers, present a problem to print out in a structured way unless the printing function has access to the context of the header. For instance, consider a tcpdump-like printer that wants to pretty-print the contents of a packet.
To enable this usage, packets may have metadata enabled (disabled by default for performance reasons โ yeah, it's a whole thing ๐
). This class is used by the Packet class to record every operation performed on the packet's buffer, and provides an implementation of Packet::Print () method that uses the metadata to analyze the content of the packet's buffer.
The metadata is also used to perform extensive sanity checks at runtime when performing operations on a Packet. For example, this metadata is used to verify that when you remove a header from a packet, this same header was actually present at the front of the packet. These errors will be detected and will abort the program. ๐ฑ
To enable this operation, users will typically insert one or both of these statements at the beginning of their programs:
Packet::EnablePrinting ();
Packet::EnableChecking ();
Sample programs ๐
See src/network/examples/main-packet-header.cc and src/network/examples/main-packet-tag.cc.
Implementation details ๐
Private member variables ๐
A Packet object's interface provides access to some private data:
Buffer m_buffer;
ByteTagList m_byteTagList;
PacketTagList m_packetTagList;
PacketMetadata m_metadata;
mutable uint32_t m_refCount;
static uint32_t m_globalUid;
Each Packet has a Buffer and two Tags lists, a PacketMetadata object, and a ref count. A static member variable keeps track of the UIDs allocated. The actual uid of the packet is stored in the PacketMetadata.
Note: that real network packets do not have a UID; the UID is therefore an instance of data that normally would be stored as a Tag in the packet. However, it was felt that a UID is a special case that is so often used in simulations that it would be more convenient to store it in a member variable. ๐
Buffer implementation ๐ง
Class Buffer represents a buffer of bytes. Its size is automatically adjusted to hold any data prepended or appended by the user. Its implementation is optimized to ensure that the number of buffer resizes is minimized, by creating new Buffers of the maximum size ever used. The correct maximum size is learned at runtime during use by recording the maximum size of each packet.
Authors of new Header or Trailer classes need to know the public API of the Buffer class. (add summary here)
The byte buffer is implemented as follows:
struct BufferData {
uint32_t m_count;
uint32_t m_size;
uint32_t m_initialStart;
uint32_t m_dirtyStart;
uint32_t m_dirtySize;
uint8_t m_data[1];
};
struct BufferData *m_data;
uint32_t m_zeroAreaSize;
uint32_t m_start;
uint32_t m_size;
BufferData::m_count: reference count forBufferDatastructureBufferData::m_size: size of data buffer stored inBufferDatastructureBufferData::m_initialStart: offset from start of data buffer where data was first insertedBufferData::m_dirtyStart: offset from start of buffer where everyBufferwhich holds a reference to thisBufferDatainstance have written data so farBufferData::m_dirtySize: size of area where data has been written so farBufferData::m_data: pointer to data bufferBuffer::m_zeroAreaSize: size of zero area which extends beforem_initialStartBuffer::m_start: offset from start of buffer to area used by this bufferBuffer::m_size: size of area used by thisBufferin itsBufferDatastructure
[image] Implementation overview of a packet's byte Buffer.
This data structure is summarized in Figure Implementation overview of a packet's byte Buffer.. Each Buffer holds a pointer to an instance of a BufferData. Most Buffers should be able to share the same underlying BufferData and thus simply increase the BufferData's reference count. If they have to change the content of a BufferData inside the Dirty Area, and if the reference count is not one, they first create a copy of the BufferData and then complete their state-changing operation. โจ
Tags implementation ๐ท๏ธ
(XXX revise me)
๐ธ Memory management ๐ธ
okay bestie this one is literally just a note-to-self in the source docs, so here's the vibe: Describe dataless vs. data-full packets.
โจ Copy-on-write semantics โจ
So the byte buffers and the tag list right now are built on COW โ Copy On Write, bestie. If you want the full lore, it's in Scott Meyer's โMore Effective C++โ, items 17 and 29. This design choice (and a bunch of the public interface) borrows from the packet design of the Georgia Tech Network Simulator. And the COW itself is powered by a customized reference counting smart pointer class. ๐
What COW actually means is this: copying packets without modifying them is very cheap (CPU-wise and memory-wise), and modifying them can also be very cheap. The whole game with a proper COW implementation is being able to tell when a modification of a packet's state is about to trigger a full copy of the data before the modification happens. COW systems gotta detect when an operation is โdirtyโ and therefore must invoke a true copy. no cap.
Dirty operations:
ns3::Packet::AddHeaderns3::Packet::AddTrailer- both versions of
ns3::Packet::AddAtEnd ns3::Packet::RemovePacketTag
Non-dirty operations:
ns3::Packet::AddPacketTagns3::Packet::PeekPacketTagns3::Packet::RemoveAllPacketTagsns3::Packet::AddByteTagns3::Packet::FindFirstMatchingByteTagns3::Packet::RemoveAllByteTagsns3::Packet::RemoveHeaderns3::Packet::RemoveTrailerns3::Packet::CreateFragmentns3::Packet::RemoveAtStartns3::Packet::RemoveAtEndns3::Packet::CopyData
Dirty operations will always be slower than non-dirty ones โ sometimes by several orders of magnitude ๐ญ. But hear me out: even the dirty ops have been optimized for the common use-cases, which means most of the time they won't actually trigger data copies and will still be very fast. iconic behavior honestly.
๐ Error Model ๐
This bit documents a few error model objects โ usually hanging out with NetDevice models โ that are maintained as part of the network module:
RateErrorModelListErrorModelReceiveListErrorModelBurstErrorModel
Error models are how you say "this packet should be considered errored", according to whatever underlying error model you're running (could be stochastic, could be empirical).
๐ฆ Model Description ๐ฆ
The source code for error models lives in the directory src/packet/utils. bestie. that's the address. ๐
There are generally two types of error models provided:
- Stochastic models โ packets get errored according to underlying random variable distributions.
RateErrorModelis the poster child here. - Deterministic / empirical models โ packets get errored according to a particular prescribed pattern.
ListErrorModelis the example, and it lets users specify the list of packets to error by listing the specific packet UIDs.
The ns3::RateErrorModel errors packets according to an underlying random variable distribution, which by default is a UniformRandomVariable distributed between 0.0 and 1.0. The error rate and the error units (bit, byte, or packet) are set by the user. So like, if you set ErrorRate to 0.1 and ErrorUnit to โPacketโ, then in the long run around 10% of the packets will be lost. slay.
๐ Design ๐
Error models are ns-3 objects and can be created using the typical pattern of CreateObject<>(). They have configuration attributes. ๐
An ErrorModel can be applied anywhere, but they're commonly deployed on NetDevice models so you can induce artificial losses (mimicking channel losses). it's giving "we're faking the vibes on purpose."
๐ Scope and Limitations ๐
No known limitations. And there are no existing models that try to modify the packet contents (e.g. apply bit or byte errors to the byte buffers). That type of operation will likely be performance-expensive, and existing Packet APIs may not easily support it.
The ns-3 spectrum model and devices that derive from it (e.g. LTE) have their own error model base class, found in
โญ References โญ
The initial ns-3 error models were ported from ns-2 (queue/errmodel.{cc,h})
๐ธ Usage ๐ธ
The base class API goes like this:
bool ErrorModel::IsCorrupt (Ptr<Packet> pkt)โ Evaluate the packet and returntrueorfalsefor whether the packet should be considered errored or not. Some models could potentially alter the contents of the packet bit buffer.void ErrorModel::Reset (void)โ Reset any state.void ErrorModel::Enable (void)โ Enable the modelvoid ErrorModel::Disble (void)โ Disable the model;IsCorrupt()will always returnfalse.bool ErrorModel::IsEnabled (void) constโ Return the enabled state
Many ns-3 NetDevices contain attributes holding pointers to error models. The error model gets applied in the notional physical layer processing chain of the device, and drops should show up on the PhyRxDrop trace source of the device. The following are known to include an attribute with a pointer available to hold this type of error model:
SimpleNetDevicePointToPointNetDeviceCsmaNetDeviceVirtualNetDevice
But lowkey? The ErrorModel could be used anywhere where packets are used. go off.
๐ง Helpers ๐ง
This model is typically not used with helpers. that's it. that's the tea. ๐
๐ Attributes ๐
The RateErrorModel contains the following attributes:
๐ Output ๐
What kind of data does the model generate? What are the key trace sources? What kind of logging output can be enabled?
โจ Examples โจ
Error models are used in the tutorial fifth and sixth programs.
The directory examples/error-model/ contains an example simple-error-model.cc that exercises the Rate and List error models.
The TCP example examples/tcp/tcp-nsc-lfn.cc uses the Rate error model.
๐ฅ Troubleshooting ๐ฅ
No known issues. we love a clean bill of health. ๐ซถ
๐ Validation ๐
The error-model unit test suite provides a single test case of of a particular combination of ErrorRate and ErrorUnit for the RateErrorModel applied to a SimpleNetDevice.
๐ Acknowledgements ๐
The basic ErrorModel, RateErrorModel, and ListErrorModel classes were ported from ns-2 to ns-3 in 2007. The ReceiveListErrorModel was added at that time.
The burst error model is due to Truc Anh N. Nguyen at the University of Kansas (James P.G. Sterbenz <jpgs@ittc.ku.edu>, director, ResiliNets Research Group (http://wiki.ittc.ku.edu/resilinets), Information and Telecommunication Technology Center (ITTC) and Department of Electrical Engineering and Computer Science, The University of Kansas Lawrence, KS USA). Work supported in part by NSF FIND (Future Internet Design) Program under grant CNS-0626918 (Postmodern Internet Architecture), NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI), US Department of Defense (DoD), and ITTC at The University of Kansas.
๐ Node and NetDevices Overview ๐
This chapter is all about how ns-3 nodes are put together, plus a lil walk-through of how packets traverse an internet-based Node.
[image] High-level node architecture.
In ns-3, nodes are instances of ns3::Node. You could subclass this class, but bestie, the whole conceptual model is that we aggregate or insert objects into it instead of defining subclasses. no inheritance drama. ๐
Picture a bare ns-3 node as a shell of a computer โ you can add NetDevices (cards) and other innards, including the protocols and the applications. The high-level node architecture shows that ns3::Node objects contain:
- a list of
ns3::Applicationinstances (initially, the list is empty) - a list of
ns3::NetDeviceinstances (initially, the list is empty) - a list of
ns3::Node::ProtocolHandlerinstances - a unique integer ID
- a system ID (for distributed simulation)
The design tries to avoid putting too many dependencies on the class ns3::Node, ns3::Application, or ns3::NetDevice for the following:
- IP version, or whether IP is at all even used in the
ns3::Node. - implementation details of the IP stack.
From a software perspective, the lower interface of applications corresponds to the C-based sockets API. The upper interface of ns3::NetDevice objects corresponds to the device independent sublayer of the Linux stack. Everything in between can be aggregated and plumbed together as needed. it's giving modular. it's giving flexible. ๐ฆ
Let's look more closely at the protocol demultiplexer, shall we. We want incoming frames at layer-2 to be delivered to the right layer-3 protocol, such as IPv4. The function of this demultiplexer is to register callbacks for receiving packets. Those callbacks are indexed based on the EtherType in the layer-2 frame.
Many different types of higher-layer protocols may be connected to the NetDevice, such as IPv4, IPv6, ARP, MPLS, IEEE 802.1x, and packet sockets. So the use of a callback-based demultiplexer avoids the need to use a common base class for all of these protocols โ which is problematic anyway because of the different types of objects (including packet sockets) expected to be registered there. literally dodged a whole architecture crisis. ๐ญ
๐ธ Sockets APIs ๐ธ
The sockets API is a long-standing API used by user-space applications to access network services in the kernel. A socket is an abstraction, like a Unix file handle, that allows applications to connect to other Internet hosts and exchange reliable byte streams and unreliable datagrams, among other services. ๐
Okay so bestie, plot twist: ns-3 gives you two whole sockets APIs and you gotta understand the difference or you will be confused forever. ๐ The first one is a native ns-3 API, and the second one uses the services of the native API to give you a POSIX-like API as part of an overall application process. Both of them are trying so hard to be close to the typical sockets API that app writers on Unix systems are used to, but the POSIX variant is much closer to a real system's sockets API. Like, practically twins. ๐ซถ
โจ ns-3 sockets API โจ
The native sockets API for ns-3 gives you an interface to various types of transport protocols (TCP, UDP), plus packet sockets, and โ in the future, bestie, we're manifesting โจ โ Netlink-like sockets. BUT. Users are cautioned to understand that the semantics are not the exact same as what you find in a real system. (If you want an API that's very much aligned to real systems, peep the next section, iykyk.)
ns3::Socket is defined in src/network/model/socket.h. Readers will note that many public member functions are aligned with real sockets function calls, and all other things being equal, we've tried to align with a Posix sockets API. However, note that:
- ns-3 applications handle a smart pointer to a
Socketobject, not a file descriptor ๐ - there is no notion of synchronous API or a blocking API; in fact, the model for interaction between application and socket is one of asynchronous I/O, which is not typically found in real systems (more on this below)
- the C-style socket address structures are not used ๐
- the API is not a complete sockets API, like it doesn't support all socket options or all function variants
- many calls use the
ns3::Packetclass to transfer data between application and socket. Passing Packets across a stream socket API may seem peculiar, but think of these packets as just fancy byte buffers at this level (more on this also below)
๐ธ Basic operation and calls ๐ธ
๐ผ๏ธ [image] Implementation overview of native sockets API.UNINDENT
๐ Creating sockets ๐
An application that wants to use sockets must first create one. On real systems using a C-based API, this is accomplished by calling socket()
int socket(int domain, int type, int protocol);
which creates a socket in the system and returns an integer descriptor.
In ns-3, we have no equivalent of a system call at the lower layers, so we adopt the following model instead. There are certain factory objects that can create sockets. Each factory is capable of creating one type of socket, and if sockets of a particular type are able to be created on a given node, then a factory that can create such sockets must be aggregated to the Node:
static Ptr<Socket> CreateSocket (Ptr<Node> node, TypeId tid);
Examples of TypeIds to pass to this method are ns3::TcpSocketFactory, ns3::PacketSocketFactory, and ns3::UdpSocketFactory.
This method returns a smart pointer to a Socket object. Here's an example, bestie:
Ptr<Node> n0;
// Do some stuff to build up the Node's internet stack
Ptr<Socket> localSocket =
Socket::CreateSocket (n0, TcpSocketFactory::GetTypeId ());
In some ns-3 code, sockets will not be explicitly created by user's main programs, if an ns-3 application does it. For instance, for ns3::OnOffApplication, the function ns3::OnOffApplication::StartApplication() performs the socket creation, and the application holds the socket pointer. Slay, the app handles it for you. ๐
๐ฆ Using sockets ๐ฆ
Below is a typical sequence of socket calls for a TCP client in a real implementation:
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
bind(sock, ...);
connect(sock, ...);
send(sock, ...);
recv(sock, ...);
close(sock);
There are analogs to all of these calls in ns-3, but we will focus on two aspects here. First, most usage of sockets in real systems requires a way to manage I/O between the application and kernel. These models include blocking sockets, signal-based I/O, and non-blocking sockets with polling. In ns-3, we make use of the callback mechanisms to support a fourth mode, which is analogous to POSIX asynchronous I/O. โจ
In this model, on the sending side, if the send() call were to fail because of insufficient buffers, the application suspends the sending of more data until a function registered at the ns3::Socket::SetSendCallback() callback is invoked. An application can also ask the socket how much space is available by calling ns3::Socket::GetTxAvailable(). A typical sequence of events for sending data (ignoring connection setup) might be:
SetSendCallback (MakeCallback(&HandleSendCallback));
Send ();
Send ();
...
// Send fails because buffer is full
// Wait until HandleSendCallback is called
// HandleSendCallback is called by socket, since space now available
Send (); // Start sending again
Similarly, on the receive side, the socket user does not block on a call to recv(). Instead, the application sets a callback with ns3::Socket::SetRecvCallback() in which the socket will notify the application when (and how much) there is data to be read, and the application then calls ns3::Socket::Recv() to read the data until no more can be read. Obsessed with the efficiency honestly. ๐ซถ
๐ Packet vs. buffer variants ๐
There are two basic variants of Send() and Recv() supported:
virtual int Send (Ptr<Packet> p) = 0;
int Send (const uint8_t* buf, uint32_t size);
Ptr<Packet> Recv (void);
int Recv (uint8_t* buf, uint32_t size);
The non-Packet variants are provided for legacy API reasons. When calling the raw buffer variant of ns3::Socket::Send(), the buffer is immediately written into a Packet and the packet variant is invoked.
Users may find it semantically odd to pass a Packet to a stream socket such as TCP. However, do not let the name bother you; think of ns3::Packet to be a fancy byte buffer. There are a few reasons why the Packet variants are more likely to be preferred in ns-3:
- Users can use the Tags facility of packets to, for example, encode a flow ID or other helper data at the application layer โจ
- Users can exploit the copy-on-write implementation to avoid memory copies (on the receive side, the conversion back to a
uint8_t* bufmay sometimes incur an additional copy) - Use of Packet is more aligned with the rest of the ns-3 API ๐
๐ Sending dummy data ๐
Sometimes, users want the simulator to just pretend that there is an actual data payload in the packet (e.g. to calculate transmission delay) but do not want to actually produce or consume the data. This is straightforward to support in ns-3; have applications call Create<Packet> (size); instead of Create<Packet> (buffer, size);. Similarly, passing in a zero to the pointer argument in the raw buffer variants has the same effect.
โ ๏ธ Note that, if some subsequent code tries to read the Packet data buffer, the fake buffer will be converted to a real (zeroed) buffer on the spot, and the efficiency will be lost there. RIP to your optimization, bestie. ๐ญ
๐ Use of Send() vs. SendTo() ๐
There are two variants of methods used to send data to the socket:
virtual int Send (Ptr<Packet> p, uint32_t flags) = 0;
virtual int SendTo (Ptr<Packet> p, uint32_t flags,
const Address &toAddress) = 0;
The first method is used if the socket has already been connected (Socket::Connect()) to a peer address. In the case of stream-based sockets like TCP, the connect call is required to bind the socket to a peer address, and thereafter, Send() is typically used. In the case of datagram-based sockets like UDP, the socket is not required to be connected to a peer address before sending, and the socket may be used to send data to different destination addresses; in this case, the SendTo() method is used to specify the destination address for the datagram. ๐
โญ Socket options โญ
๐ ToS (Type of Service)
The native sockets API for ns-3 provides two public methods (of the Socket base class):
void SetIpTos (uint8_t ipTos);
uint8_t GetIpTos (void) const;
to set and get, respectively, the type of service associated with the socket. These methods are equivalent to using the IP_TOS option of BSD sockets. Clearly, setting the type of service only applies to sockets using the IPv4 protocol. However, users typically do not set the type of service associated with a socket through ns3::Socket::SetIpTos() because sockets are normally created by application helpers and users cannot get a pointer to the sockets. Instead, users can create an address of type ns3::InetSocketAddress with the desired type of service value and pass it to the application helpers:
InetSocketAddress destAddress (ipv4Address, udpPort);
destAddress.SetTos (tos);
OnOffHelper onoff ("ns3::UdpSocketFactory", destAddress);
For this to work, the application must eventually call the ns3::Socket::Connect() method to connect to the provided destAddress and the Connect method of the particular socket type must support setting the type of service associated with a socket (by using the ns3::Socket::SetIpTos() method). Currently, the socket types that support setting the type of service in such a way are ns3::UdpSocketImpl and ns3::TcpSocketBase. Iconic duo fr fr. ๐
The type of service associated with a socket is then used to determine the value of the Type of Service field (renamed as Differentiated Services field by RFC 2474) of the IPv4 header of the packets sent through that socket, as detailed in the next sections.
๐ Setting the ToS with UDP sockets
For IPv4 packets, the ToS field is set according to the following rules:
- If the socket is connected, the ToS field is set to the ToS value associated with the socket.
- If the socket is not connected, the ToS field is set to the value specified in the destination address (of type
ns3::InetSocketAddress) passed tons3::Socket::SendTo(), and the ToS value associated with the socket is ignored. ๐
๐ Setting the ToS with TCP sockets ๐
For IPv4 packets, the ToS field is set to the ToS value associated with the socket. Periodt. ๐
๐ธ Priority ๐ธ
The native sockets API for ns-3 provides two public methods (of the Socket base class):
void SetPriority (uint8_t priority);
uint8_t GetPriority (void) const;
to set and get, respectively, the priority associated with the socket. These methods are equivalent to using the SO_PRIORITY option of BSD sockets.
โ ๏ธ Only values in the range 0..6 can be set through the above method. Don't try anything outside that range, bestie, it's not the vibe. ๐
Okay so bestie, listen up, this one's a lil detail that bites people: when you set the type of service on a socket (like by calling ns3::Socket::SetIpTos()), you are also setting that socket's priority to whatever the ns3::Socket::IpTos2Priority() function hands back when you pass it that ToS value. It's a two-for-one, no extra charge. ๐
That function is implemented after the Linux rt_tos2priority function, which takes an 8-bit value as input and returns a value that's a function of bits 3-6 (and yes, bit 0 is the most significant bit here) of the input value:
- bits 3-6 =
0to3โ priority0(Best Effort) - bits 3-6 =
4to7โ priority2(Bulk) - bits 3-6 =
8to11โ priority6(Interactive) - bits 3-6 =
12to15โ priority4(Interactive Bulk)
The rationale here is that bits 3-6 of the Type of Service field were interpreted as the TOS subfield by (the obsolete, rip ๐ชฆ) RFC 1349. If you want more, readers can refer to the doxygen documentation of ns3::Socket::IpTos2Priority() โ it's got the whole story, including how DSCP values map onto priority values.
The priority that got set for a socket (as described above) is then used to determine the priority of the packets sent through that socket, as detailed in the next sections. Right now, the socket types that support setting the packet priority are ns3::UdpSocketImpl, ns3::TcpSocketBase and ns3::PacketSocket. And where does that packet priority actually get used? By queuing disciplines โ for example the default PfifoFastQueueDisc uses it to classify packets into distinct queues. Iconic behaviour honestly. โจ
๐ Setting the priority with UDP sockets
If the packet is an IPv4 packet and the value to be inserted in the ToS field is not null, then the packet is assigned a priority based on that ToS value (according to the ns3::Socket::IpTos2Priority() function). Otherwise? The priority associated with the socket gets assigned to the packet. Simple as that. ๐
๐ซถ Setting the priority with TCP sockets
Every packet is assigned a priority equal to the priority associated with the socket.
๐ Setting the priority with packet sockets
Every packet is assigned a priority equal to the priority associated with the socket. (Yes bestie, same as TCP โ they're matching. ๐ฏ)
๐ Socket errno
to be completed
โจ Example programs
to be completed
๐ POSIX-like sockets API
๐ฆ Simple NetDevice
Placeholder chapter
๐ Queues
This section documents the queue object, which is typically used by NetDevices and QueueDiscs to store packets. ๐ฆ
Packets stored in a queue can be managed according to different policies. Currently, only the DropTail policy is available.
๐ Model Description
The source code for the new module lives in the directory src/network/utils.
ns3::Queue has been redesigned as a template class object to allow us to instantiate queues storing different types of items. The unique template type parameter specifies the type of items stored in the queue. The only requirement on the item type is that it must provide a GetSize () method which returns the size of the packet included in the item. Currently, queue items can be objects of the following classes:
PacketQueueItemand subclasses (e.g.,QueueDiscItem)WifiMacQueueItem
The internal queues of the queue discs are of type Queue<QueueDiscItem> (an alias of which being InternalQueue). A number of network devices (SimpleNetDevice, PointToPointNetDevice, CsmaNetDevice) use a Queue<Packet> to store packets to be transmitted. WifiNetDevices use instead queues of type WifiMacQueue, which is a subclass of Queue storing objects of type WifiMacQueueItem. Other devices, such as WiMax and LTE, use specialized queues.
๐ Design
The Queue class derives from the QueueBase class, which is a non-template class providing all the methods that are independent of the type of the items stored in the queue. The Queue class provides instead all the operations that depend on the item type, such as enqueue, dequeue, peek and remove. The Queue class also provides the ability to trace certain queue operations such as enqueuing, dequeuing, and dropping. ๐
Queue is an abstract base class and is subclassed for specific scheduling and drop policies. Subclasses need to define the following public methods:
bool Enqueue (Ptr<Item> item): Enqueue a packetPtr<Item> Dequeue (void): Dequeue a packetPtr<Item> Remove (void): Remove a packetPtr<const Item> Peek (void): Peek a packet
The Enqueue method does not allow to store a packet if the queue capacity is exceeded. Subclasses may also define specialized public methods. For instance, the WifiMacQueue class provides a method to dequeue a packet based on its tid and MAC address.
There are five trace sources that may be hooked:
EnqueueDequeueDropDropBeforeEnqueueDropAfterDequeue
Also, the QueueBase class defines two additional trace sources:
PacketsInQueueBytesInQueue
๐ธ DropTail
This is a basic first-in-first-out (FIFO) queue that performs a tail drop when the queue is full. ๐ข
The DropTailQueue class defines one attribute:
MaxSize: the maximum queue size
โญ Usage
๐ง Helpers
A typical usage pattern is to create a device helper and to configure the queue type and attributes from the helper, such as this example:
PointToPointHelper p2p;
p2p.SetQueue ("ns3::DropTailQueue");
p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer devn0n2 = p2p.Install (n0n2);
p2p.SetQueue ("ns3::DropTailQueue");
p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
p2p.SetChannelAttribute ("Delay", StringValue ("3ms"));
NetDeviceContainer devn1n2 = p2p.Install (n1n2);
p2p.SetQueue ("ns3::DropTailQueue",
"MaxSize", StringValue ("50p"));
p2p.SetDeviceAttribute ("DataRate", StringValue (linkDataRate));
p2p.SetChannelAttribute ("Delay", StringValue (linkDelay));
NetDeviceContainer devn2n3 = p2p.Install (n2n3);
Please note that the SetQueue method of the PointToPointHelper class allows to specify "ns3::DropTailQueue" instead of "ns3::DropTailQueue<Packet>". The same holds for CsmaHelper, SimpleNetDeviceHelper and TrafficControlHelper. Convenient! ๐
๐ฅ Output
The ns-3 ascii trace helpers used by many of the NetDevices will hook the Enqueue, Dequeue, and Drop traces of these queues and print out trace statements, such as the following from examples/udp/udp-echo.cc:
+ 2 /NodeList/0/DeviceList/1/$ns3::CsmaNetDevice/TxQueue/Enqueue ns3::EthernetHeader
( length/type=0x806, source=00:00:00:00:00:01, destination=ff:ff:ff:ff:ff:ff)
ns3::ArpHeader (request source mac: 00-06-00:00:00:00:00:01 source ipv4: 10.1.1.1
dest ipv4: 10.1.1.2) Payload (size=18) ns3::EthernetTrailer (fcs=0)
- 2 /NodeList/0/DeviceList/1/$ns3::CsmaNetDevice/TxQueue/Dequeue ns3::EthernetHeader
( length/type=0x806, source=00:00:00:00:00:01, destination=ff:ff:ff:ff:ff:ff)
ns3::ArpHeader (request source mac: 00-06-00:00:00:00:00:01 source ipv4: 10.1.1.1
dest ipv4: 10.1.1.2) Payload (size=18) ns3::EthernetTrailer (fcs=0)
which shows an enqueue + and dequeue - event at time 2 seconds. โฐ
Users are, of course, free to define and hook their own trace sinks to these trace sources. Do your thing bestie. ๐
โจ Examples
The drop-tail queue is used in several examples, such as examples/udp/udp-echo.cc.
๐ Queue limits
This section documents the queue limits model, which is used by the traffic control to limit the NetDevices queueing delay. It operates on the transmission path of the network node.
The reduction of the NetDevices queueing delay is essential to improve the effectiveness of Active Queue Management (AQM) algorithms. Careful assessment of the queueing delay includes a byte-based measure of the NetDevices queue length. In this design, traffic control can use different byte-based schemes to limit the queueing delay. Currently the only available scheme is DynamicQueueLimits, which is modelled after the dynamic queue limit library of Linux. ๐ง
๐ Model Description
The source code for the model lives in the directory src/network/utils.
The model allows a byte-based measure of the netdevice queue. The byte-based measure more accurately approximates the time required to empty the queue than a packet-based measure.
To inform the upper layers about the transmission of packets, NetDevices can call a couple of functions:
void NotifyQueuedBytes (uint32_t bytes): Report the number of bytes queued to the device queuevoid NotifyTransmittedBytes (uint32_t bytes): Report the number of bytes transmitted by device
Based on this information, the QueueLimits object can stop the transmission queue.
In case of multiqueue NetDevices this mechanism is available for each queue.
The QueueLimits model can be used on any NetDevice modelled in ns-3. No cap. ๐
๐ Design
An abstract base class, class QueueLimits, is subclassed for specific byte-based limiting strategies.
Common operations provided by the base class QueueLimits include:
void Reset (): Reset queue limits statevoid Completed (uint32_t count): Record the number of completed bytes and recalculate the limitint32_t Available () const: Return how many bytes can be queuedvoid Queued (uint32_t count): Record number of bytes queued
๐ DynamicQueueLimits
Dynamic queue limits (DQL) is a basic library implemented in the Linux kernel to limit the Ethernet queueing delay. DQL is a general purpose queue length controller. The goal of DQL is to calculate the limit as the minimum number of bytes needed to prevent starvation. ๐
Three attributes are defined in the DynamicQueueLimits class:
HoldTime: The DQL algorithm hold timeMaxLimit: Maximum limitMinLimit: Minimum limit
The DQL algorithm hold time is 1 s โฑ๏ธ. Like, keep that in your head bestie. Shrink the HoldTime and DQL gets more responsive, but you pay for it with a bigger number of limit variation events. Flip it around โ increase the HoldTime and DQL gets less responsive, with only a minor number of limit variation events. That's the tradeoff, periodt.
The limit that DQL calculates lives in the range from MinLimit to MaxLimit ๐ซ. The default values are 0 and DQL_MAX_LIMIT respectively. Bumping up the MinLimit is the move when your NetDevice transmission rate is higher (think 1 Gbps), while trimming down the MaxLimit is the move when your NetDevice transmission rate is lower (think 500 Kbps). Different vibes, different tuning ๐.
There is one trace source in DynamicQueueLimits class that may be hooked:
Limitโ the limit value calculated by DQL ๐
โจ Usage โจ
๐งฐ Helpers ๐งฐ
A typical usage pattern is to create a traffic control helper and configure the queue limits type and attributes from the helper, such as this example:
TrafficControlHelper tch;
uint32_t handle = tch.SetRootQueueDisc ("ns3::PfifoFastQueueDisc", "Limit", UintegerValue (1000));
tch.SetQueueLimits ("ns3::DynamicQueueLimits", "HoldTime", StringValue ("4ms"));
then install the configuration on a NetDevices container ๐ซถ
tch.Install (devices);
๐ NIX-VECTOR ROUTING DOCUMENTATION ๐
Nix-vector routing is a simulation specific routing protocol and it's intended for large network topologies ๐. The on-demand nature of this protocol plus the low-memory footprint of the nix-vector gives you improved performance in terms of memory usage and simulation run time when you're dealing with a large number of nodes. It's giving efficiency, fr fr.
๐ง Model Description ๐ง
The source code for the NixVectorRouting module lives in the directory src/nix-vector-routing ๐.
ns-3 nix-vector-routing performs on-demand route computation using a breadth-first search and an efficient route-storage data structure known as a nix-vector โจ.
When a packet is generated at a node for transmission, the route is calculated, and the nix-vector is built ๐ธ.
How is the Nix-Vector calculated? The nix-vector stores an index for each hop along the path, which corresponds to the neighbor-index. This index is used to determine which net-device and gateway should be used ๐.
How does the routing take place? To route a packet, the nix-vector must be transmitted with the packet. At each hop, the current node extracts the appropriate neighbor-index from the nix-vector and transmits the packet through the corresponding net-device. This continues until the packet reaches the destination ๐ฆ.
NOTE: Nix-Vector routing does not use any routing metrics (interface metrics) during the calculation of nix-vector. It is only based on the shortest path calculated according to BFS ๐.
How does Nix decide between two equally short path from source to destination? It depends on how the topology is constructed i.e., the order in which the net-devices are added on a node and net-devices added on the channels associated with current node's net-devices ๐. Please check the nix-simple.cc example below to understand how nix-vectors are calculated.
ns-3 supports IPv4 as well as IPv6 Nix-Vector routing ๐.
๐ง Scope and Limitations ๐ง
Currently, the ns-3 model of nix-vector routing supports IPv4 and IPv6 p2p links, CSMA links and multiple WiFi networks with the same channel object ๐. It does not (yet) provide support for efficient adaptation to link failures. It simply flushes all nix-vector routing caches ๐ญ.
NixVectorRouting performs a subnet matching check, but it does not check entirely if the addresses have been appropriately assigned ๐. In other terms, using Nix-Vector routing, it is possible to have a working network that violates some good practices in IP address assignments. Lowkey chaotic but that's the tea.
In case of IPv6, Nix assumes the link-local addresses assigned are unique โญ. When using the IPv6 stack, the link-local address allocation is unique by default over the entire topology. However, if the link-local addresses are assigned manually, the user must ensure uniqueness of link-local addresses. No pressure bestie, just do it ๐ .
๐ ๏ธ Usage ๐ ๏ธ
The usage pattern is the one of all the Internet routing protocols ๐. Since NixVectorRouting is not installed by default in the Internet stack, it is necessary to set it in the Internet Stack helper by using InternetStackHelper::SetRoutingHelper ๐.
Remember to include the header file ns3/nix-vector-helper.h to use IPv4 or IPv6 Nix-Vector routing ๐.
NOTE: The previous header file ns3/ipv4-nix-vector-helper.h is maintained for backward compatibility reasons. Therefore, the existing IPv4 Nix-Vector routing simulations should work fine ๐.
- Using IPv4 Nix-Vector Routing:
Ipv4NixVectorHelper nixRouting;
InternetStackHelper stack;
stack.SetRoutingHelper (nixRouting); // has effect on the next Install ()
stack.Install (allNodes); // allNodes is the NodeContainer
- Using IPv6 Nix-Vector Routing:
Ipv6NixVectorHelper nixRouting;
InternetStackHelper stack;
stack.SetRoutingHelper (nixRouting); // has effect on the next Install ()
stack.Install (allNodes); // allNodes is the NodeContainer
NOTE: TheNixVectorHelperhelper class helps to use NixVectorRouting functionality. The NixVectorRouting model can also be used directly to use Nix-Vector routing. To use it directly, the header filens3/nix-vector-routing.hshould be included. The previous header filens3/ipv4-nix-vector-routing.his maintained for backwards compatibility with any existing IPv4 Nix-Vector routing simulations ๐.
๐ Examples ๐
The examples for the NixVectorRouting module lives in the directory src/nix-vector-routing/examples ๐.
There are examples which use both IPv4 and IPv6 networking ๐ฆ.
nix-simple.cc
/*
* ________
* / \
* n0 -- n1 -- n2 -- n3
*
* n0 IP: 10.1.1.1, 10.1.4.1
* n1 IP: 10.1.1.2, 10.1.2.1
* n2 IP: 10.1.2.2, 10.1.3.1, 10.1.4.2
* n3 IP: 10.1.3.2
*/
In this topology, we install Nix-Vector routing between source n0 and destination n3. The shortest possible route will be n0 -> n2 -> n3 ๐ฅ.
Let's see how the nix-vector will be generated for this path:
n0 has 2 neighbors i.e. n1 and n3. n0 is connected to both using separate net-devices. But the net-device for n0 โ n1 p2p link was created before the netdevice for n0 โ n2 p2p link. Thus, n2 has neighbor-index of 1 (n1 has 0) with respect to n0 โจ.
n2 has 3 neighbors i.e. n1, n3 and n0. The n2 net-device for n1 โ n2 p2p link was created before the n2 net-device for n2 โ n3 p2p link which was before the n2 netdevice for n0 โ n2 p2p link. This, n3 has neighbor-index of 01 (n1 has 00 and n0 has 10) with repect to n2 ๐.
Thus, the nix-vector for the path from n0 to n3 is 101 ๐
.
NOTE: This neighbor-index or nix-index has total number of bits equal to minimum number of bits required to represent all the neighbors in their binary form ๐ธ.
NOTE: If there are multiple netdevices connected to the current netdevice on the channel then it depends on which order netdevices were added to the channel ๐ซ.
- Using IPv4:
# By default IPv4 network is selected
./waf โrun src/nix-vector-routing/examples/nix-simple
- Using IPv6:
# Use the โuseIPv6 flag
./waf โrun "src/nix-vector-routing/examples/nix-simple โuseIPv6"
nms-p2p-nix.cc
This example demonstrates the advantage of Nix-Vector routing as Nix performs source-based routing (BFS) to have faster routing โก.
nix-simple-multi-address.cc
This is an IPv4 example demonstrating multiple interface addresses ๐. This example also shows how address assignment in between the simulation causes the all the route caches and Nix caches to flush ๐ง.
# By default IPv4 network is selected
./waf --run src/nix-vector-routing/examples/nix-simple-multi-address
nix-double-wifi.cc
This example demonstrates the working of Nix with two Wifi networks operating on the same Wifi channel object ๐. The example uses ns3::YansWifiChannel for both the wifi networks.
- Using IPv4:
# By default IPv4 network is selected
./waf โrun src/nix-vector-routing/examples/nix-double-wifi
# Use the โenableNixLog to enable NixVectorRouting logging.
./waf โrun "src/nix-vector-routing/examples/nix-double-wifi โenableNixLog"
- Using IPv6:
# Use the โuseIPv6 flag
./waf โrun "src/nix-vector-routing/examples/nix-double-wifi โuseIPv6"
# Use the โenableNixLog to enable NixVectorRouting logging.
./waf โrun "src/nix-vector-routing/examples/nix-double-wifi โuseIPv6 โenableNixLog"
๐ OPTIMIZED LINK STATE ROUTING (OLSR) ๐
okay bestie, meet OLSR ๐ this model implements the base spec of the Optimized Link State Routing (OLSR) protocol, and likeโฆ it's a dynamic mobile ad hoc unicast routing protocol. yes it does all that. it was developed at the University of Murcia (Spain) by Francisco J. Ros for NS-2, and then ported to NS-3 by Gustavo Carneiro at INESC Porto (Portugal) โ iconic collab fr fr ๐โจ
the implementation is based on OLSR Version 1 (RFC 3626 [rfc3626]) and it is not compliant with OLSR Version 2 (RFC 7181 [rfc7181]) or any of the Version 2 extensions. so don't come for her with v2 energy, she said what she said ๐
๐ธ Model Description ๐ธ
the source code for the OLSR model lives in the directory src/olsr. and like, as stated before, the model is based on RFC 3626 ([rfc3626]). plus, many design choices are based on the previous ns2 model. legacy roots, we love to see it ๐ซถ
๐ฆ Scope and Limitations ๐ฆ
the model is for IPv4 only, periodt.
- Mostly compliant with OLSR as documented in
RFC 3626([rfc3626]), - The use of multiple interfaces was not supported by the NS-2 version, but is supported in NS-3;
- OLSR does not respond to the routing event notifications corresponding to dynamic interface up and down (
ns3::RoutingProtocol::NotifyInterfaceUpandns3::RoutingProtocol::NotifyInterfaceDown) or address insertion/removalns3::RoutingProtocol::NotifyAddAddressandns3::RoutingProtocol::NotifyRemoveAddress). - Unlike the NS-2 version, does not yet support MAC layer feedback as described in
RFC 3626([rfc3626]);
Host Network Association (HNA) is supported in this implementation of OLSR. refer to examples/olsr-hna.cc to see how the API is used ๐
๐ References ๐
[rfc3626]RFC 3626 Optimized Link State Routing[rfc7181]RFC 7181 The Optimized Link State Routing Protocol Version 2
โจ Usage โจ
the usage pattern is the one of all the Internet routing protocols. since OLSR is not installed by default in the Internet stack, it is necessary to set it in the Internet Stack helper by using InternetStackHelper::SetRoutingHelper ๐ง
typically, OLSR is enabled in a main program by use of an OlsrHelper class that installs OLSR into an Ipv4ListRoutingProtocol object. the following sample commands will enable OLSR in a simulation using this helper class along with some other routing helper objects. the setting of priority value 10, ahead of the staticRouting priority of 0, means that OLSR will be consulted for a route before the node's static routing table.:
NodeContainer c:
...
// Enable OLSR
NS_LOG_INFO ("Enabling OLSR Routing.");
OlsrHelper olsr;
Ipv4StaticRoutingHelper staticRouting;
Ipv4ListRoutingHelper list;
list.Add (staticRouting, 0);
list.Add (olsr, 10);
InternetStackHelper internet;
internet.SetRoutingHelper (list);
internet.Install (c);
once installed, the OLSR "main interface" can be set with the SetMainInterface() command. if the user does not specify a main address, the protocol will select the first primary IP address that it finds, starting first the loopback interface and then the next non-loopback interface found, in order of Ipv4 interface index. the loopback address of 127.0.0.1 is not selected. in addition, a number of protocol constants are defined in olsr-routing-protocol.cc ๐
Olsr is started at time zero of the simulation, based on a call to Object::Start() that eventually calls OlsrRoutingProtocol::DoStart(). Note: a patch to allow the user to start and stop the protocol at other times would be welcome ๐ (yes she's asking nicely, someone please deliver)
๐ Examples ๐
the examples are in the src/olsr/examples/ directory. however, many other examples esists in the general examples directory, e.g., examples/routing/manet-routing-compare.cc ๐ฅ
for specific examples of the HNA feature, see the examples in src/olsr/examples/.
๐ Helpers ๐
a helper class for OLSR has been written. after an IPv4 topology has been created and unique IP addresses assigned to each node, the simulation script writer can call one of three overloaded functions with different scope to enable OLSR: ns3::OlsrHelper::Install (NodeContainer container); ns3::OlsrHelper::Install (Ptr<Node> node); or ns3::OlsrHelper::InstallAll (void) ๐ซถ
โญ Attributes โญ
in addition, the behavior of OLSR can be modified by changing certain attributes. the method ns3::OlsrHelper::Set () can be used to set OLSR attributes. these include HelloInterval, TcInterval, MidInterval, Willingness. other parameters are defined as macros in olsr-routing-protocol.cc.
the list of configurabel attributes is:
HelloInterval(time, default2s), HELLO messages emission interval.TcInterval(time, default5s), TC messages emission interval.MidInterval(time, default5s), MID messages emission interval.HnaInterval(time, default5s), HNA messages emission interval.Willingness(enum, defaultOLSR_WILL_DEFAULT), Willingness of a node to carry and forward traffic for other nodes.
๐ Tracing ๐
the available traces are:
- Rx: Receive OLSR packet.
- Tx: Send OLSR packet.
- RoutingTableChanged: The OLSR routing table has changed.
๐ Caveats ๐
presently, OLSR is limited to use with an Ipv4ListRouting object, and does not respond to dynamic changes to a device's IP address or link up/down notifications; i.e. the topology changes are due to loss/gain of connectivity over a wireless channel. so yeah, no cap, that's the vibe ๐
the code does not present any known issue. (we love a clean bill of health, slay ๐ )
๐ Validation ๐
the code validation has been done through Wireshark message compliance and unit testings. certified, verified, iconic โจ
๐ OPENFLOW SWITCH SUPPORT ๐
okay bestie, so ns-3 sims can literally use OpenFlow switches (McKeown et al. [1]) and these things are widely used in research, no cap. OpenFlow switches are configurable through the OpenFlow API, and they also have an MPLS extension for quality-of-service and service-level-agreement support. ๐ฆ By extending all that to ns-3 โ a simulated OpenFlow switch that's both configurable and can use the MPLS extension โ ns-3 sims can accurately simulate a whole bunch of different switches. iconic.
The OpenFlow software implementation distribution is hereby referred to as the OFSID. It's a demonstration of running OpenFlow in software that the OpenFlow research group has made available. There's also an OFSID that Ericsson researchers created to add MPLS capabilities โ that's the OFSID currently used with ns-3. The design lets users, with minimal effort, switch in a different OFSID that may include more efficient code than a previous OFSID. ๐
โจ Model Description โจ
The model relies on building an external OpenFlow switch library (OFSID), and then building some ns-3 wrappers that call out to the library. The source code for the ns-3 wrappers lives in the directory src/openflow/model. ๐
๐ Design ๐
The OpenFlow module presents a OpenFlowSwitchNetDevice and a OpenFlowSwitchHelper for installing it on nodes. Like the Bridge module, it takes a collection of NetDevices to set up as ports, and it acts as the intermediary between them โ receiving a packet on one port and forwarding it on another, or all but the received port when flooding. ๐ธ Like an OpenFlow switch, it maintains a configurable flow table that can match packets by their headers and do different actions with the packet based on how it matches. The module's understanding of OpenFlow configuration messages is kept in the same format as a real OpenFlow-compatible switch, so users testing Controllers via ns-3 won't have to rewrite their Controller to work on real OpenFlow-compatible switches. periodt.
The ns-3 OpenFlow switch device models an OpenFlow-enabled switch. It's designed to express basic use of the OpenFlow protocol, with the maintaining of a virtual Flow Table and TCAM to provide OpenFlow-like results. ๐ซถ
The functionality comes down to the Controllers, which send messages to the switch that configure its flows, producing different effects. Controllers can be added by the user, under the ofi namespace extending ofi::Controller. To demonstrate this, a DropController, which creates flows for ignoring every single packet, and LearningController, which effectively makes the switch a more complicated BridgeNetDevice. A user versed in a standard OFSID, and/or OF protocol, can write virtual controllers to create switches of all kinds of types. โจ
๐ OpenFlow switch Model ๐
The OpenFlow switch device behaves somewhat according to the diagram setup as a classical OFSID switch, with a few modifications made for a proper simulation environment.
Normal OF-enabled Switch:
| Secure Channel | <--OF Protocol--> | Controller is external |
| Hardware or Software Flow Table |
ns-3 OF-enabled Switch (module):
| m_controller->ReceiveFromSwitch() | <--OF Protocol--> | Controller is internal |
| Software Flow Table, virtual TCAM |
In essence, there are two differences:
- No SSL, Embedded Controller: Instead of a secure channel and connecting to an outside location for the Controller program/machine, we currently only allow a Controller extended from
ofi::Controller, an extension of anns3::Object. This means ns-3 programmers cannot model the SSL part of the interface or possibility of network failure. The connection to theOpenFlowSwitchis local and there aren't any reasons for the channel/connection to break down. <<This difference may be an option in the future. UsingEmuNetDevices, it should be possible to engage an external Controller program/machine, and thus work with controllers designed outside of the ns-3 environment, that simply use the proper OF protocol when communicating messages to the switch through a tap device.>> - Virtual Flow Table, TCAM: Typical OF-enabled switches are implemented on a hardware TCAM. The OFSID we turn into a library includes a modelled software TCAM, that produces the same results as a hardware TCAM. We include an attribute
FlowTableLookupDelay, which allows a simple delay of using the TCAM to be modelled. We don't endeavor to make this delay more complicated, based on the tasks we are running on the TCAM, that is a possible future improvement. ๐
The OpenFlowSwitch network device is aimed to model an OpenFlow switch, with a TCAM and a connection to a controller program. With some tweaking, it can model every switch type, per OpenFlow's extensibility. It outsources the complexity of the switch ports to NetDevices of the user's choosing. It should be noted that these NetDevices must behave like practical switch ports, i.e. a Mac Address is assigned, and nothing more. It also must support a SendFrom function so that the OpenFlowSwitch can forward across that port. ๐
๐ฅ Scope and Limitations ๐ฅ
All MPLS capabilities are implemented on the OFSID side in the OpenFlowSwitchNetDevice, but ns-3-mpls hasn't been integrated, so ns-3 has no way to pass in proper MPLS packets to the OpenFlowSwitch. If it did, one would only need to make BufferFromPacket pick up the MplsLabelStack or whatever the MPLS header is called on the Packet, and build the MPLS header into the ofpbuf. ๐
โญ Future Work โญ
๐ References ๐
- [1] McKeown, N.; Anderson, T.; Balakrishan, H.; Parulkar, G.; Peterson, L.; Rexford, J.; Shenker, S.; Turner, J.; OpenFlow: enabling innovation in campus networks, ACM SIGCOMM Computer Communication Review, Vol. 38, Issue 2, April 2008.
๐ Usage ๐
The OFSID requires libxml2 (for MPLS FIB xml file parsing), and libdl (for address fault checking).
๐ ๏ธ Building OFSID ๐ ๏ธ
In order to use the OpenFlowSwitch module, you must create and link the OFSID (OpenFlow Software Implementation Distribution) to ns-3. To do this:
- Obtain the OFSID code. An ns-3 specific OFSID branch is provided to ensure operation with ns-3. Use mercurial to download this branch and
wafto build the library:
$ hg clone http://code.nsnam.org/openflow
$ cd openflow
From the "openflow" directory, run:
$ ./waf configure
$ ./waf build
- Your OFSID is now built into a
libopenflow.alibrary! To link to an ns-3 build with this OpenFlow switch module, run from thens-3-dev(or whatever you have named your distribution):
$ ./waf configure --enable-examples --enable-tests --with-openflow=path/to/openflow
- Under
---- Summary of optional NS-3 features:you should see:
"NS-3 OpenFlow Integration : enabled"
indicating the library has been linked to ns-3. Run:
$ ./waf build
to build ns-3 and activate the OpenFlowSwitch module in ns-3. โจ
๐ง Examples ๐ง
For an example demonstrating its use in a simple learning controller/switch, run:
$ ./waf --run openflow-switch
To see it in detailed logging, run:
$ ./waf --run "openflow-switch -v"
๐ Helpers ๐
๐ Attributes ๐
The SwitchNetDevice provides following Attributes:
FlowTableLookUpDelay: This time gets run off the clock when making a lookup in our Flow Table.Flags: OpenFlow specific configuration flags. They are defined in theofp_config_flagsenum. Choices include:OFPC_SEND_FLOW_EXP(Switch notifies controller when a flow has expired),OFPC_FRAG_NORMAL(Match fragment against Flow table),OFPC_FRAG_DROP(Drop fragments),OFPC_FRAG_REASM(Reassemble only ifOFPC_IP_REASMset, which is currently impossible, because switch implementation does not support IP reassembly)OFPC_FRAG_MASK(Mask Fragments)
FlowTableMissSendLength: When the packet doesn't match in our Flow Table, and we forward to the controller, this sets # of bytes forwarded (packet is not forwarded in its entirety, unless specified).
NOTE: TODO
๐ Tracing ๐
NOTE: TODO
๐ Logging ๐
NOTE: TODO
โ ๏ธ Caveats โ ๏ธ
NOTE: TODO
โ Validation โ
This model has one test suite which can be run as follows:
$ ./test.py --suite=openflow
๐ซถ POINTTOPOINT NETDEVICE ๐ซถ
okay bestie, this is your lil intro to the PointToPoint NetDevice chapter, here to be the cute lil sidekick to the PointToPoint model doxygen ๐
โจ Overview of the PointToPoint model โจ
The ns-3 point-to-point model is so simple and I love that for it โ it's a point to point data link connecting exactly two PointToPointNetDevice devices over an PointToPointChannel. Think of it as the equivalent of a full duplex RS-232 or RS-422 link with null modem and no handshaking. Iconic, minimal, no drama ๐
Data is encapsulated in the Point-to-Point Protocol (PPP โ RFC 1661), BUT the Link Control Protocol (LCP) and its associated state machine are not implemented. The PPP link is just assumed to be established and authenticated at all times. Periodt. No handshake arc, we're already together ๐ฅฐ
Data is not framed, so Address and Control fields will not be found. And since the data isn't framed, there's no need to provide Flag Sequence and Control Escape octets, nor is a Frame Check Sequence appended. All you need to implement non-framed PPP is to prepend the PPP protocol number for IP Version 4, which is the sixteen-bit number 0x21 (see http://www.iana.org/assignments/ppp-numbers). That's it, that's the whole vibe โจ
The PointToPointNetDevice provides following Attributes:
Addressโ Thens3::Mac48Addressof the device (if desired);DataRateโ The data rate (ns3::DataRate) of the device;TxQueueโ The transmit queue (ns3::Queue) used by the device;InterframeGapโ The optionalns3::Timeto wait between "frames";Rxโ A trace source for received packets;Dropโ A trace source for dropped packets.
The PointToPointNetDevice models a transmitter section that puts bits on a corresponding channel "wire." The DataRate attribute specifies the number of bits per second that the device will simulate sending over the channel. In reality no bits are sent, but an event is scheduled for an elapsed time consistent with the number of bits in each packet and the specified DataRate. The implication here is that the receiving device models a receiver section that can receive any any data rate. Therefore there is no need, nor way to set a receive data rate in this model. By setting the DataRate on the transmitter of both devices connected to a given PointToPointChannel you can model a symmetric channel; or by setting different DataRates you can model an asymmetric channel (e.g., ADSL). Bestie, that's so versatile of it ๐ฆ
The PointToPointNetDevice supports the assignment of a "receive error model." This is an ErrorModel object that is used to simulate data corruption on the link. Spicy ๐
๐ธ Point-to-Point Channel Model ๐ธ
The point to point net devices are connected via an PointToPointChannel. This channel models two wires transmitting bits at the data rate specified by the source net device. There is no overhead beyond the eight bits per byte of the packet sent. That is, we do not model Flag Sequences, Frame Check Sequences nor do we "escape" any data. Clean, no extra baggage, we love a low-maintenance channel ๐
The PointToPointChannel provides following Attributes:
Delayโ Anns3::Timespecifying the propagation delay for the channel.
๐ Using the PointToPointNetDevice ๐
The PointToPoint net devices and channels are typically created and configured using the associated PointToPointHelper object. The various ns3 device helpers generally work in a similar way, and their use is seen in many of our example programs and is also covered in the ns-3 tutorial.
The conceptual model of interest is that of a bare computer "husk" into which you plug net devices. The bare computers are created using a NodeContainer helper. You just ask this helper to create as many computers (we call them Nodes) as you need on your network:
NodeContainer nodes;
nodes.Create (2);
Once you have your nodes, you need to instantiate a PointToPointHelper and set any attributes you may want to change. Note that since this is a point-to-point (as compared to a point-to-multipoint) there may only be two nodes with associated net devices connected by a PointToPointChannel.:
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
Once the attributes are set, all that remains is to create the devices and install them on the required nodes, and to connect the devices together using a PointToPoint channel. When we create the net devices, we add them to a container to allow you to use them in the future. This all takes just one line of code.:
NetDeviceContainer devices = pointToPoint.Install (nodes);
Literally one line, she's efficient ๐
โจ PointToPoint Tracing โจ
Like all ns-3 devices, the Point-to-Point Model provides a number of trace sources. These trace sources can be hooked using your own custom trace code, or you can use our helper functions to arrange for tracing to be enabled on devices you specify. Choose your own adventure bestie ๐
๐ฆ Upper-Level (MAC) Hooks ๐ฆ
From the point of view of tracing in the net device, there are several interesting points to insert trace hooks. A convention inherited from other simulators is that packets destined for transmission onto attached networks pass through a single "transmit queue" in the net device. We provide trace hooks at this point in packet flow, which corresponds (abstractly) only to a transition from the network to data link layer, and call them collectively the device MAC hooks.
When a packet is sent to the Point-to-Point net device for transmission it always passes through the transmit queue. The transmit queue in the PointToPointNetDevice inherits from Queue, and therefore inherits three trace sources:
- An Enqueue operation source (see
ns3::Queue::m_traceEnqueue); - A Dequeue operation source (see
ns3::Queue::m_traceDequeue); - A Drop operation source (see
ns3::Queue::m_traceDrop).
The upper-level (MAC) trace hooks for the PointToPointNetDevice are, in fact, exactly these three trace sources on the single transmit queue of the device. No cap, that's the whole list ๐ฅ
The m_traceEnqueue event is triggered when a packet is placed on the transmit queue. This happens at the time that ns3::PointtoPointNetDevice::Send or ns3::PointtoPointNetDevice::SendFrom is called by a higher layer to queue a packet for transmission. An Enqueue trace event firing should be interpreted as only indicating that a higher level protocol has sent a packet to the device.
The m_traceDequeue event is triggered when a packet is removed from the transmit queue. Dequeues from the transmit queue can happen in two situations:
- If the underlying channel is idle when
PointToPointNetDevice::Sendis called, a packet is dequeued from the transmit queue and immediately transmitted; - a packet may be dequeued and immediately transmitted in an internal
TransmitCompleteEventthat functions much like a transmit complete interrupt service routine.
A Dequeue trace event firing may be viewed as indicating that the PointToPointNetDevice has begun transmitting a packet. She's moving, she's transmitting, we stan ๐
๐ Lower-Level (PHY) Hooks ๐
Similar to the upper level trace hooks, there are trace hooks available at the lower levels of the net device. We call these the PHY hooks. These events fire from the device methods that talk directly to the PointToPointChannel.
The trace source m_dropTrace is called to indicate a packet that is dropped by the device. This happens when a packet is discarded as corrupt due to a receive error model indication (see ns3::ErrorModel and the associated attribute "ReceiveErrorModel"). ๐ญ
The other low-level trace source fires on reception of a packet (see ns3::PointToPointNetDevice::m_rxTrace) from the PointToPointChannel. ๐
๐ PROPAGATION ๐
The ns-3 propagation module defines two generic interfaces, namely PropagationLossModel and PropagationDelayModel, to model respectively the propagation loss and the propagation delay. Two lil interfaces, big responsibilities ๐ซถ
โญ PropagationLossModel โญ
Propagation loss models calculate the Rx signal power considering the Tx signal power and the mutual Rx and Tx antennas positions.
A propagation loss model can be "chained" to another one, making a list. The final Rx power takes into account all the chained models. In this way one can use a slow fading and a fast fading model (for example), or model separately different fading effects. Chain them like friendship bracelets bestie ๐
The following propagation loss models are implemented:
Cost231PropagationLossModelFixedRssLossModelFriisPropagationLossModelItuR1411LosPropagationLossModelItuR1411NlosOverRooftopPropagationLossModelJakesPropagationLossModelKun2600MhzPropagationLossModelLogDistancePropagationLossModelMatrixPropagationLossModelNakagamiPropagationLossModelOkumuraHataPropagationLossModelRandomPropagationLossModelRangePropagationLossModelThreeLogDistancePropagationLossModelTwoRayGroundPropagationLossModelThreeGppPropagationLossModelThreeGppRMaPropagationLossModelThreeGppUMaPropagationLossModelThreeGppUmiStreetCanyonPropagationLossModelThreeGppIndoorOfficePropagationLossModel
Other models could be available thanks to other modules, e.g., the building module. Surprise guests, love that for us ๐
Each of the available propagation loss models of ns-3 is explained in one of the following subsections.
๐ง FriisPropagationLossModel ๐ง
This model implements the Friis propagation loss model. This model was first described in [friis]. The original equation was described as:
\frac{P_r}{P_t} = \frac{A_r A_t}{d^2\lambda^2}
with the following equation for the case of an isotropic antenna with no heat loss:
A_{isotr.} = \frac{\lambda^2}{4\pi}
The final equation becomes:
\frac{P_r}{P_t} = \frac{\lambda^2}{(4 \pi d)^2}
Modern extensions to this original equation are:
P_r = \frac{P_t G_t G_r \lambda^2}{(4 \pi d)^2 L}
With:
P_t: transmission power (W)P_r: reception power (W)G_t: transmission gain (unit-less)G_r: reception gain (unit-less)\lambda: wavelength (m)d: distance (m)L: system loss (unit-less)
In the implementation, \lambda is calculated as \frac{C}{f}, where C = 299792458 m/s is the speed of light in vacuum, and f is the frequency in Hz which can be configured by the user via the Frequency attribute. โญ
The Friis model is valid only for propagation in free space within the so-called far field region, which can be considered approximately as the region for d > 3 \lambda. The model will still return a value for d < 3 \lambda, as doing so (rather than triggering a fatal error) is practical for many simulation scenarios.
โ ๏ธ However, we stress that the values obtained in such conditions shall not be considered realistic. Do not trust them bestie, I'm serious ๐ญ
Related with this issue, we note that the Friis formula is undefined for d = 0, and results in P_r > P_t for d < \lambda / 2 \sqrt{\pi}. ๐
okay so bestie, both of these conditions are happening outside the far field region, so in principle the Friis model shall not be used in these conditions. In practice tho? Friis gets used all the time in scenarios where nobody cares about accurate propagation modeling, and values of d = 0 absolutely do occur. ๐
To let the model actually be usable in those scenarios, we gotta do two things: 1) return some value for d = 0, and 2) avoid huge discontinuities in propagation loss values โ because those can cause artifacts like bogus capture effects, which are way worse than just inaccurate propagation loss values. The tea is that these two goals are conflicting, because according to the Friis formula, \lim_{d \to 0} P_r = +\infty; so if we just use a fixed loss value for d = 0, we end up with an infinitely large discontinuity, which โ as we just discussed โ can cause those undesirable simulation artifacts. ๐ญ
To dodge the artifact, this implementation of the Friis model gives you an attribute called MinLoss that lets you specify the minimum total loss (in dB) returned by the model. It works like this: P_r continuously increases as d \to 0, until it hits MinLoss, and then it stays constant. That way you get a value for d = 0 and no discontinuities. The model won't be super realistic, but at least the simulation artifacts we talked about are avoided. The default value of MinLoss is 0 dB, which means that by default the model will return P_r = P_t for d <= \lambda / 2 \sqrt{\pi}. And lowkey important: that value of d is outside the far field region, so the validity of the model in the far field region is not affected. ๐
โจ TwoRayGroundPropagationLossModel โจ
This model implements a Two-Ray Ground propagation loss model, ported from NS2. ๐ฆ
The Two-ray ground reflection model uses the formula
P_r = \frac{P_t * G_t * G_r * (H_t^2 * H_r^2)}{d^4 * L}
The original equation in Rappaport's book assumes L = 1. To stay consistent with the free space equation, L is added here. ๐
H_t and H_r are set at the respective nodes' z coordinate plus a model parameter set via SetHeightAboveZ.
The two-ray model does not give a good result for short distances, because of the oscillation caused by constructive and destructive combination of the two rays. So instead, the Friis free-space model is used for small distances. โจ
The crossover distance, below which Friis is used, is calculated like this:
dCross = \frac{(4 * \pi * H_t * H_r)}{\lambda}
In the implementation, \lambda is calculated as \frac{C}{f}, where C = 299792458 m/s is the speed of light in vacuum, and f is the frequency in Hz which can be configured by the user via the Frequency attribute. โญ
๐ธ LogDistancePropagationLossModel ๐ธ
This model implements a log distance propagation model.
The reception power is calculated with a so-called log-distance propagation model:
L = L_0 + 10 n \log(\frac{d}{d_0})
where:
n: the path loss distance exponentd_0: reference distance (m)L_0: path loss at reference distance (dB)d: - distance (m)L: path loss (dB)
When the path loss is requested at a distance smaller than the reference distance, the tx power is returned. ๐ซถ
๐ง ThreeLogDistancePropagationLossModel ๐ง
This model implements a log distance path loss propagation model with three distance fields. It's the same as ns3::LogDistancePropagationLossModel except that it has three distance fields โ near, middle and far โ with different exponents. ๐
Within each field the reception power is calculated using the log-distance propagation equation:
L = L_0 + 10 \cdot n_0 \log_{10}(\frac{d}{d_0})
Each field begins where the previous one ends, and all together they form a continuous function. ๐
There are three valid distance fields: near, middle, far. Actually four: the first one, from 0 to the reference distance, is invalid and returns txPowerDbm.
\underbrace{0 \cdots\cdots}_{=0} \underbrace{d_0 \cdots\cdots}_{n_0}
\underbrace{d_1 \cdots\cdots}_{n_1} \underbrace{d_2 \cdots\cdots}_{n_2} \infty
Complete formula for the path loss in dB:
\displaystyle L =
\begin{cases} 0 & d < d_0 \\ L_0 + 10 \cdot n_0 \log_{10}(\frac{d}{d_0})
& d_0 \leq d < d_1 \\ L_0 + 10 \cdot n_0 \log_{10}(\frac{d_1}{d_0}) + 10
\cdot n_1 \log_{10}(\frac{d}{d_1}) & d_1 \leq d < d_2 \\ L_0 + 10 \cdot
n_0 \log_{10}(\frac{d_1}{d_0}) + 10 \cdot n_1 \log_{10}(\frac{d_2}{d_1})
+ 10 \cdot n_2 \log_{10}(\frac{d}{d_2})& d_2 \leq d \end{cases}
where:
d_0,d_1,d_2: three distance fields (m)n_0,n_1,n_2: path loss distance exponent for each field (unitless)L_0: path loss at reference distance (dB)d: - distance (m)L: path loss (dB)
When the path loss is requested at a distance smaller than the reference distance d_0, the tx power (with no path loss) is returned. The reference distance defaults to 1m, and reference loss defaults to FriisPropagationLossModel with 5.15 GHz, and is thus L_0 = 46.67 dB. ๐
๐ JakesPropagationLossModel ๐
ToDo ๐ญ (bestie it is what it is)
๐ RandomPropagationLossModel ๐
The propagation loss is totally random, and it changes every single time the model is called. As a consequence, all the packets โ even those between two fixed nodes โ experience a random propagation loss. fr fr. ๐ฒ
๐ NakagamiPropagationLossModel ๐
This propagation loss model implements the Nakagami-m fast fading model, which accounts for the variations in signal strength due to multipath fading. It does not account for the path loss due to the distance traveled by the signal, so for typical simulation usage it's recommended to consider using it in combination with other models that take that aspect into account. ๐ฆ
The Nakagami-m distribution is applied to the power level. The probability density function is defined as
p(x; m, \omega) = \frac{2 m^m}{\Gamma(m) \omega^m} x^{2m - 1}
e^{-\frac{m}{\omega} x^2} )
with m the fading depth parameter and \omega the average received power.
It's implemented by either a GammaRandomVariable or a ErlangRandomVariable random variable. โจ
The implementation of the model lets you specify different values of the m parameter (and hence different fast fading profiles) for three different distance ranges:
\underbrace{0 \cdots\cdots}_{m_0} \underbrace{d_1 \cdots\cdots}_{m_1}
\underbrace{d_2 \cdots\cdots}_{m_2} \infty
For m = 1 the Nakagami-m distribution equals the Rayleigh distribution. So this model also implements Rayleigh distribution based fast fading. ๐
๐ FixedRssLossModel ๐
This model sets a constant received power level, independent of the transmit power.
The received power is constant independent of the transmit power; the user must set the received power level. Heads up tho: if this loss model is chained to other loss models, it should be the first loss model in the chain. Otherwise it will disregard the losses computed by the loss models that precede it in the chain. โ ๏ธ
โญ MatrixPropagationLossModel โญ
The propagation loss is fixed for each pair of nodes and doesn't depend on their actual positions. This model should be useful for synthetic tests. Note that by default the propagation loss is assumed to be symmetric. ๐ซถ
๐ RangePropagationLossModel ๐
This propagation loss depends only on the distance (range) between transmitter and receiver.
The single MaxRange attribute (units of meters) determines path loss. Receivers at or within MaxRange meters receive the transmission at the transmit power level. Receivers beyond MaxRange receive at power -1000 dBm (effectively zero). ๐
๐ OkumuraHataPropagationLossModel ๐
This model is used to model open area pathloss for long distance (i.e., > 1 Km). In order to include all the possible frequencies usable by LTE we need to consider several variants of the well known Okumura Hata model. In fact, the original Okumura Hata model [hata] is designed for frequencies ranging from 150 MHz to 1500 MHz, and the COST231 [cost231] extends it for the frequency range from 1500 MHz to 2000 MHz. Another important aspect is the scenarios considered by the models โ in fact, all the models are originally designed for urban scenarios, and then only the standard one and the COST231 are extended to suburban, while only the standard one has been extended to open areas. Therefore, the model cannot cover all scenarios at all frequencies. In the following we detail the models adopted. ๐
The pathloss expression of the COST231 OH is:
L = 46.3 + 33.9\log{f} - 13.82 \log{h_\mathrm{b}} + (44.9 -
6.55\log{h_\mathrm{b}})\log{d} - F(h_\mathrm{M}) + C
where
F(h_\mathrm{M}) = \left\{\begin{array}{ll} (1.1\log(f))-0.7 \times
h_\mathrm{M} - (1.56\times \log(f)-0.8) & \mbox{for medium and small
size cities} \\ 3.2\times (\log{(11.75\times h_\mathrm{M}}))^2 &
\mbox{for large cities}\end{array} \right.
C = \left\{\begin{array}{ll} 0dB & \mbox{for medium-size cities and
suburban areas} \\ 3dB & \mbox{for large cities}\end{array} \right.
and
f: frequency [MHz]h_\mathrm{b}: eNB height above the ground [m]h_\mathrm{M}: UE height above the ground [m]d: distance [km]log: is a logarithm in base 10 (this for the whole document)
This model is only for urban scenarios. ๐๏ธ
The pathloss expression of the standard OH in urban area is:
L = 69.55 + 26.16\log{f} - 13.82 \log{h_\mathrm{b}} + (44.9 -
6.55\log{h_\mathrm{b}})\log{d} - C_\mathrm{H}
where for small or medium sized city
C_\mathrm{H} = 0.8 + (1.1\log{f} - 0.7)h_\mathrm{M} -1.56\log{f}
and for large cities
C_\mathrm{H} = \left\{\begin{array}{ll} 8.29 (\log{(1.54h_M)})^2 -1.1 &
\mbox{if } 150\leq f\leq 200 \\ 3.2(\log{(11.75h_M)})^2 -4.97 & \mbox{if
} 200<f\leq 1500\end{array} \right.
The extension for the standard OH in suburban is
L_\mathrm{SU} = L_\mathrm{U} - 2 \left(\log{\frac{f}{28}}\right)^2 - 5.4
where
L_\mathrm{U}: pathloss in urban areas
The extension for the standard OH in open area is
L_\mathrm{O} = L_\mathrm{U} - 4.70 (\log{f})^2 + 18.33\log{f} - 40.94
The literature lacks extensions of the COST231 to open area (for suburban it seems that we can just impose C = 0); therefore we consider it a special case of the suburban one. ๐ซ
๐ Cost231PropagationLossModel ๐
ToDo ๐ (yeah bestie, still just a placeholder, we move)
๐ฅ ItuR1411LosPropagationLossModel ๐ฅ
This model is designed for Line-of-Sight (LoS) short range outdoor communication in the frequency range 300 MHz to 100 GHz. It provides an upper and lower bound respectively according to the following formulas
L_\mathrm{LoS,l} = L_\mathrm{bp} + \left\{\begin{array}{ll}
20\log{\frac{d}{R_\mathrm{bp}}} & \mbox{for $d \le R_\mathrm{bp}$} \\
40\log{\frac{d}{R_\mathrm{bp}}} & \mbox{for $d >
R_\mathrm{bp}$}\end{array} \right.
okay so the upper-bound LoS pathloss formula is literally this iconic piece of math right here, bestie:
L_\mathrm{LoS,u} = L_\mathrm{bp} + 20 + \left\{\begin{array}{ll}
25\log{\frac{d}{R_\mathrm{bp}}} & \mbox{for $d \le R_\mathrm{bp}$} \\
40\log{\frac{d}{R_\mathrm{bp}}} & \mbox{for $d >
R_\mathrm{bp}$}\end{array} \right.
and the breakpoint distance is giving
R_\mathrm{bp} \approx \frac{4h_\mathrm{b}h_\mathrm{m}}{\lambda}
and the parameters in question are:
\lambda: wavelength [m]h_\mathrm{b}: eNB height above the ground [m]h_\mathrm{m}: UE height above the ground [m]d: distance [m]
and L_{bp} is the value for the basic transmission loss at the break point, defined as:
L_{bp} = \left|20\log \left(\frac{\lambda^2}{8\pi h_\mathrm{b}h\mathrm{m}}\right)\right|
The value the simulator actually uses is the average one for modeling the median pathloss. ๐ซ
ItuR1411NlosOverRooftopPropagationLossModel
This model is designed for Non-Line-of-Sight (LoS) short range outdoor communication over rooftops in the frequency range 300 MHz to 100 GHz. It's got several scenario-dependent parameters โ average street width, orientation, all that โ and the move is that you set those values manually yourself, using the ns-3 attribute system, according to whatever scenario you're on. ๐๏ธ
In detail, the model is based on [walfisch] and [ikegami], where the loss is expressed as the sum of free-space loss (L_{bf}), the diffraction loss from rooftop to street (L_{rts}) and the reduction due to multiple screen diffraction past rows of building (L_{msd}). The formula is:
L_{NLOS1} = \left\{ \begin{array}{ll} L_{bf} + L_{rts} + L_{msd} &
\mbox{for } L_{rts} + L_{msd} > 0 \\ L_{bf} & \mbox{for } L_{rts} +
L_{msd} \le 0\end{array}\right.
The free-space loss is given by:
L_{bf} = 32.4 + 20 \log {(d/1000)} + 20\log{(f)}
where:
f: frequency [MHz]d: distance (whered > 1) [m]
The term L_{rts} takes into account the width of the street and its orientation, according to the formulas
L_{rts} = -8.2 - 10\log {(w)} + 10\log{(f)} + 20\log{(\Delta h_m)} + L_{ori}
L_{ori} = \left\{ \begin{array}{lll} -10 + 0.354\varphi & \mbox{for }
0^{\circ} \le \varphi < 35^{\circ} \\ 2.5 + 0.075(\varphi-35) &
\mbox{for } 35^{\circ} \le \varphi < 55^{\circ} \\ 4.0
-0.114(\varphi-55) & \mbox{for } 55^{\circ} \varphi \le
90^{\circ}\end{array}\right.
\Delta h_m = h_r - h_m
where:
h_r: is the height of the rooftop [m]h_m: is the height of the mobile [m]\varphi: is the street orientation with respect to the direct path (degrees)
The multiple screen diffraction loss depends on the BS antenna height relative to the building height and on the incidence angle. The former is selected as the higher antenna in the communication link. Regarding the latter, the โsettled field distanceโ is used to select the proper model; its value is given by
d_{s} = \frac{\lambda d^2}{\Delta h_{b}^2}
with
\Delta h_b = h_b - h_m
Therefore, in case of l > d_s (where l is the distance over which the building extend), it can be evaluated according to
L_{msd} = L_{bsh} + k_{a} + k_{d}\log{(d/1000)} + k_{f}\log{(f)} - 9\log{(b)}
L_{bsh} = \left\{ \begin{array}{ll} -18\log{(1+\Delta h_{b})} &
\mbox{for } h_{b} > h_{r} \\ 0 & \mbox{for } h_{b} \le h_{hr}
\end{array}\right.
k_a = \left\{ \begin{array}{lll}
71.4 & \mbox{for } h_{b} > h_{r} \mbox{ and } f>2000 \mbox{ MHz} \\
54 & \mbox{for } h_{b} > h_{r} \mbox{ and } f\le2000 \mbox{ MHz} \\
54-0.8\Delta h_b & \mbox{for } h_{b} \le h_{r} \mbox{ and } d \ge
500 \mbox{ m} \\
54-1.6\Delta h_b & \mbox{for } h_{b} \le h_{r} \mbox{ and } d < 500
\mbox{ m} \\
\end{array} \right.
k_d = \left\{ \begin{array}{ll}
18 & \mbox{for } h_{b} > h_{r} \\
18 -15\frac{\Delta h_b}{h_r} & \mbox{for } h_{b} \le h_{r}
\end{array} \right.
k_f = \left\{ \begin{array}{ll}
-8 & \mbox{for } f>2000 \mbox{ MHz} \\
-4 + 0.7(f/925 -1) & \mbox{for medium city and suburban centres
and} f\le2000 \mbox{ MHz} \\
-4 + 1.5(f/925 -1) & \mbox{for metropolitan centres and } f\le2000
\mbox{ MHz}
\end{array}\right.
Alternatively, in case of l < d_s, the formula is:
L_{msd} = -10\log{\left(Q_M^2\right)}
where
Q_M = \left\{ \begin{array}{lll}
2.35\left(\frac{\Delta
h_b}{d}\sqrt{\frac{b}{\lambda}}\right)^{0.9} & \mbox{for } h_{b} > h_{r}
\\
\frac{b}{d} & \mbox{for } h_{b} \approx h_{r} \\
\frac{b}{2\pi
d}\sqrt{\frac{\lambda}{\rho}}\left(\frac{1}{\theta}-\frac{1}{2\pi +
\theta}\right) & \mbox{for } h_{b} < h_{r}
\end{array}\right.
where:
\theta = arc tan \left(\frac{\Delta h_b}{b}\right)
\rho = \sqrt{\Delta h_b^2 + b^2}
Kun2600MhzPropagationLossModel
This is the empirical model for the pathloss at 2600 MHz for urban areas which is described in [kun2600mhz]. The model is as follows. Let d be the distance between the transmitter and the receiver in meters; the pathloss L in dB is calculated as:
L = 36 + 26\log{d}
ThreeGppPropagationLossModel
The base class ThreeGppPropagationLossModel and its derived classes implement the path loss and shadow fading models described in 3GPP TR 38.901 [38901]. 3GPP TR 38.901 includes multiple scenarios modeling different propagation environments โ indoor, outdoor urban and rural โ for frequencies between 0.5 and 100 GHz. ๐
Implemented features:
- Path loss and shadowing models (3GPP TR 38.901, Sec. 7.4.1)
- Autocorrelation of shadow fading (3GPP TR 38.901, Sec. 7.4.4)
- Channel condition models (3GPP TR 38.901, Sec. 7.4.2)
To be implemented:
- O2I penetration loss (3GPP TR 38.901, Sec. 7.4.3)
- Spatial consistent update of the channel states (3GPP TR 38.901 Sec. 7.6.3.3)
Configuration
The ThreeGppPropagationLossModel instance is paired with a ChannelConditionModel instance used to retrieve the LOS/NLOS channel condition. By default, a 3GPP channel condition model related to the same scenario is set (e.g., by default, ThreeGppRmaPropagationLossModel is paired with ThreeGppRmaChannelConditionModel), but it can be configured using the method SetChannelConditionModel. The channel condition models are stored inside the propagation module, for a limitation of the current spectrum API and to avoid a circular dependency between the spectrum and the propagation modules. Please note that it is necessary to install at least one ChannelConditionModel when using any ThreeGppPropagationLossModel subclass. Please look below for more information about the Channel Condition models. ๐ซถ
The operating frequency has to be set using the attribute โFrequencyโ, otherwise an assert is raised. The addition of the shadow fading component can be enabled/disabled through the attribute โShadowingEnabledโ. Other scenario-related parameters can be configured through attributes of the derived classes.
Implementation details
The method DoCalcRxPower computes the propagation loss considering the path loss and the shadow fading (if enabled). The path loss is computed by the method GetLossLos or GetLossNlos depending on the LOS/NLOS channel condition, and their implementation is left to the derived classes. The shadow fading is computed by the method GetShadowing, which generates an additional random loss component characterized by Gaussian distribution with zero mean and scenario-specific standard deviation. Subsequent shadowing components of each BS-UT link are correlated as described in 3GPP TR 38.901, Sec. 7.4.4 [38901].
Note 1: The TR defines height ranges for UTs and BSs, depending on the chosen propagation model (for the exact values, please see below in the specific model documentation). If the user does not set correct values, the model will emit a warning but perform the calculation anyway. ๐ญ
Note 2: The 3GPP model is originally intended to be used to represent BS-UT links. However, in ns-3, we may need to compute the pathloss between two BSs or UTs to evaluate the interference. We have decided to support this case by considering the tallest node as a BS and the smallest as a UT. As a consequence, the height values may be outside the validity range of the chosen class: therefore, an inaccuracy warning may be printed, but it can be ignored. ๐
There are four derived classes, each one implementing the propagation model for a different scenario:
ThreeGppRMaPropagationLossModel
This class implements the LOS/NLOS path loss and shadow fading models described in 3GPP TR 38.901 [38901], Table 7.4.1-1 for the RMa scenario. It supports frequencies between 0.5 and 30 GHz. It is possible to configure some scenario-related parameters through the attributes AvgBuildingHeight and AvgStreetWidth.
As specified in the TR, the 2D distance between the transmitter and the receiver should be between 10 m and 10 km for the LOS case, or between 10 m and 5 km for the NLOS case, otherwise the model may not be accurate (a warning message is printed if the user has enabled logging on the model). Also, the height of the base station (hBS) should be between 10 m and 150 m, while the height of the user terminal (hUT) should be between 1 m and 10 m. ๐พ
ThreeGppUMaPropagationLossModel
This implements the LOS/NLOS path loss and shadow fading models described in 3GPP TR 38.901 [38901], Table 7.4.1-1 for the UMa scenario. It supports frequencies between 0.5 and 100 GHz.
As specified in the TR, the 2D distance between the transmitter and the receiver should be between 10 m and 5 km both for the LOS and NLOS cases, otherwise the model may not be accurate (a warning message is printed if the user has enabled logging on the model). Also, the height of the base station (hBS) should be 25 m and the height of the user terminal (hUT) should be between 1.5 m and 22.5 m. ๐๏ธ
ThreeGppUmiStreetCanyonPropagationLossModel
This implements the LOS/NLOS path loss and shadow fading models described in 3GPP TR 38.901 [38901], Table 7.4.1-1 for the UMi-Street Canyon scenario. It supports frequencies between 0.5 and 100 GHz.
As specified in the TR, the 2D distance between the transmitter and the receiver should be between 10 m and 5 km both for the LOS and NLOS cases, otherwise the model may not be accurate (a warning message is printed if the user has enabled logging on the model). Also, the height of the base station (hBS) should be 10 m and the height of the user terminal (hUT) should be between 1.5 m and 10 m (the validity range is reduced because we assume that the height of the UT nodes is always lower than the height of the BS nodes). ๐ฃ๏ธ
๐ธ ThreeGppIndoorOfficePropagationLossModel
okay so this one is giving indoor-office realness ๐
It implements the LOS/NLOS path loss and shadow fading models described in 3GPP TR 38.901 [38901], Table 7.4.1-1 for the Indoor-Office scenario. And bestie, it supports frequencies between 0.5 and 100 GHz. no cap.
As specified in the TR, the 3D distance between the transmitter and the receiver should be between 1 m and 150 m both for the LOS and NLOS cases, otherwise the model may not be accurate (a warning log message is printed if the user has enabled logging on the model).
โ ๏ธ literally keep your 3D distance in that1m to150m window, LOS and NLOS, or the model starts acting up โ and if you turned logging on for the model, it will print a warning log message at you. ๐
๐งช Testing
The test suite ThreeGppPropagationLossModelsTestSuite provides test cases for the classes implementing the 3GPP propagation loss models. The test cases ThreeGppRmaPropagationLossModelTestCase, ThreeGppUmaPropagationLossModelTestCase, ThreeGppUmiPropagationLossModelTestCase and ThreeGppIndoorOfficePropagationLossModelTestCase compute the path loss between two nodes and compares it with the value obtained using the formulas in 3GPP TR 38.901 [38901], Table 7.4.1-1.
The test case ThreeGppShadowingTestCase checks if the shadowing is correctly computed by testing the deviation of the overall propagation loss from the path loss. The test is carried out for all the scenarios, both in LOS and NLOS condition. โจ
๐ ChannelConditionModel
The loss models require to know if two nodes are in Line-of-Sight (LoS) or if they are not. The interface for that is represented by this class. The main method is GetChannelCondition (a, b), which returns a ChannelCondition object containing the information about the channel state.
We modeled the LoS condition in two ways: (i) by using a probabilistic model specified by the 3GPP (), and (ii) by using an ns-3 specific building-aware model, which checks the space position of the BSs and the UTs.
For what regards the first option, the probability is independent of the node location: in other words, following the 3GPP model, two UT spatially separated by an epsilon may have different LoS conditions. To take into account mobility, we have inserted a parameter called UpdatePeriod, which indicates how often a 3GPP-based channel condition has to be updated. By default, this attribute is set to 0, meaning that after the channel condition is generated, it is never updated. With this default value, we encourage the users to run multiple simulations with different seeds to get statistical significance from the data. For the users interested in using mobile nodes, we suggest changing this parameter to a value that takes into account the node speed and the desired accuracy. For example, lower-speed node conditions may be updated in terms of seconds, while high-speed UT or BS may be updated more often.
The two approach are coded, respectively, in the classes:
ThreeGppChannelConditionModelBuildingsChannelConditionModel(see the building module documentation for further details)
๐ ThreeGppChannelConditionModel
This is the base class for the 3GPP channel condition models. It provides the possibility to updated the condition of each channel periodically, after a given time period which can be configured through the attribute UpdatePeriod. If UpdatePeriod is set to 0, the channel condition is never updated. It has five derived classes implementing the channel condition models described in 3GPP TR 38.901 [38901] for different propagation scenarios. iconic behavior honestly.
๐ฆ ThreeGppRmaChannelConditionModel
This implements the statistical channel condition model described in 3GPP TR 38.901 [38901], Table 7.4.2-1, for the RMa scenario.
๐ฆ ThreeGppUmaChannelConditionModel
This implements the statistical channel condition model described in 3GPP TR 38.901 [38901], Table 7.4.2-1, for the UMa scenario.
๐ฆ ThreeGppUmiStreetCanyonChannelConditionModel
This implements the statistical channel condition model described in 3GPP TR 38.901 [38901], Table 7.4.2-1, for the UMi-Street Canyon scenario.
๐ฆ ThreeGppIndoorMixedOfficeChannelConditionModel
This implements the statistical channel condition model described in 3GPP TR 38.901 [38901], Table 7.4.2-1, for the Indoor-Mixed office scenario.
๐ฆ ThreeGppIndoorOpenOfficeChannelConditionModel
This implements the statistical channel condition model described in 3GPP TR 38.901 [38901], Table 7.4.2-1, for the Indoor-Open office scenario.
๐งช Testing
The test suite ChannelConditionModelsTestSuite contains a single test case:
ThreeGppChannelConditionModelTestCase, which tests all the 3GPP channel condition models. It determines the channel condition between two nodes multiple times, estimates the LOS probability, and compares it with the value given by the formulas in 3GPP TR 38.901 [38901], Table 7.4.2-1
๐ PropagationDelayModel
The following propagation delay models are implemented:
ConstantSpeedPropagationDelayModelRandomPropagationDelayModel
๐ ConstantSpeedPropagationDelayModel
In this model, the signal travels with constant speed. The delay is calculated according with the transmitter and receiver positions. The Euclidean distance between the Tx and Rx antennas is used. Beware that, according to this model, the Earth is flat. ๐
๐ฒ RandomPropagationDelayModel
The propagation delay is totally random, and it changes each time the model is called. All the packets (even those between two fixed nodes) experience a random delay. As a consequence, the packets order is not preserved. chaos behavior, truly.
๐ Models for vehicular environments
The 3GPP TR 37.885 [37885] specifications extends the channel modeling framework described in TR 38.901 [38901] to simulate wireless channels in vehicular environments. The extended framework supports frequencies between 0.5 to 100 GHz and provides the possibility to simulate urban and highway propagation environments. To do so, new propagation loss and channel condition models, as well as new parameters for the fast fading model, are provided.
๐ฃ๏ธ Vehicular channel condition models
To properly capture channel dynamics in vehicular environments, three different channel conditions have been identified:
- LOS (Line Of Sight): represents the case in which the direct path between the transmitter and the receiver is not blocked
- NLOSv (Non Line Of Sight vehicle): when the direct path between the transmitter and the receiver is blocked by a vehicle
- NLOS (Non Line Of Sight): when the direct path is blocked by a building
TR 37.885 includes two models that can be used to determine the condition of the wireless channel between a pair of nodes, the first for urban and the second for highway environments. Each model includes both a deterministic and a stochastic part, and works as follows:
- The model determines the presence of buildings obstructing the direct path between the communicating nodes. This is done in a deterministic way, looking at the possible interceptions between the direct path and the buildings. If the path is obstructed, the channel condition is set to NLOS.
- If not, the model determines the presence of vehicles obstructing the direct path. This is done using a probabilistic model, which is specific for the scenario of interest. If the path is obstructed, the channel condition is set to NLOSv, otherwise is set to LOS.
These models have been implemented by extending the interface ChannelConditionModel with the following classes. They have been included in the building module, because they make use of Buildings objects to determine the presence of obstructions caused by buildings.
ThreeGppV2vUrbanChannelConditionModel: implements the model described in Table 6.2-1 of TR 37.885 for the urban scenario.ThreeGppV2vHighwayChannelConditionModel: implements the model described in Table 6.2-1 of TR 37.885 for the highway scenario.
These models rely on Buildings objects to determine the presence of obstructing buildings. When considering large scenarios with a large number of buildings, this process may become computationally demanding and dramatically increase the simulation time. To solve this problem, we implemented two fully-probabilistic models that can be used as an alternative to the ones included in TR 37.885. These models are based on the work carried out by M. Boban et al. [Boban2016Modeling], which derived a statistical representation of the three channel conditions, With the fully-probabilistic models there is no need to determine the presence of blocking buildings in a deterministic way, and therefore the computational effort is reduced. To determine the channel condition, these models account for the propagation environment, i.e., urban or highway, as well as for the density of vehicles in the scenario, which can be high, medium, or low. ๐ฅ
The classes implementing the fully-probabilistic models are:
ProbabilisticV2vUrbanChannelConditionModel: implements the model described in [Boban2016Modeling] for the urban scenario.ProbabilisticV2vHighwayChannelConditionModel: implements the model described in [Boban2016Modeling] for the highway scenario.
Both the classes own the attribute Density, which can be used to select the proper value depending on the scenario that have to be simulated. Differently from the hybrid models described above, these classes have been included in the propagation module, since they do not have any dependency on the building module.
๐ NOTE: Both the hybrid and the fully-probabilistic models supports the modeling of outdoor scenarios, no support is provided for the modeling of indoor scenarios.
๐ก Vehicular propagation loss models
The propagation models described in TR 37.885 determines the attenuation caused by path loss and shadowing by considering the propagation environment and the channel condition.
These models have been implemented by extending the interface ThreeGppPropagationLossModel with the following classes, which are part of the propagation module:
ThreeGppV2vUrbanPropagationLossModel: implements the models defined in Table 6.2.1-1 of TR 37.885 for the urban scenario.ThreeGppV2vHighwayPropagationLossModel: implements the models defined in Table 6.2.1-1 of TR 37.885 for the highway scenario.
As for all the classes extending the interface ThreeGppPropagationLossModel, they have to be paired with an instance of the class ChannelConditionModel which is used to determine the channel condition. This is done by setting the attribute ChannelConditionModel. To build the channel modeling framework described in TR 37.885, ThreeGppV2vUrbanChannelConditionModel or ThreeGppV2vHighwayChannelConditionModel should be used, but users are allowed to test any other combination. ๐ซถ
Vehicular fast fading model ๐๐จ
okay so this fast fading model is the one described in Sec. 6.2.3 of TR 37.885, and bestie, it's built on top of the one in TR 38.901 โ the implementation of that one lives in the spectrum module (go peek at the spectrum module docs, iykyk). It's a general model, meaning it has a bunch of different parameters you can tune to simulate soooo many propagation environments. ๐
But to really nail the channel dynamics in vehicular environments, TR 37.885 hands you brand-new sets of values for those parameters, specific to vehicle-to-vehicle transmissions in urban and highway scenarios. To pick the vehicular parameter set, you set the attribute Scenario of the class ThreeGppChannelModel to either V2V-Urban or V2V-Highway. That's it, that's the vibe check. โจ
On top of that, TR 37.885 specifies a whole new equation for the Doppler component, and it accounts for the mobility of both nodes, plus scattering from the environment. The scattering effect specifically gets handled by deviating the Doppler frequency by a random value, and the distribution of that random value depends on the parameter v_{scatt}. TR 37.885 says v_{scatt} should be set to the maximum speed of the vehicles in the layout, and if v_{scatt} = 0, the scattering effect just isn't considered. The Doppler equation is implemented in the class ThreeGppSpectrumPropagationLossModel. And through the attribute vScatt, you can adjust the value of v_{scatt} โ by default, it's set to 0.
Example ๐
We implemented the example three-gpp-v2v-channel-example.cc, which shows you how to configure all the different classes to simulate wireless propagation in vehicular scenarios โ you'll find it in the folder examples/channel-models. ๐ซถ
We considered two communicating vehicles moving within the scenario, and computed the SNR experienced during the entire simulation, with a time resolution of 10 ms. The vehicles are equipped with 2x2 antenna arrays modeled with the 3GPP antenna model. The bearing and the downtilt angles are properly configured, and the optimal beamforming vectors are computed at the beginning of the simulation. literally main character setup fr.
The simulation script accepts these command line parameters:
frequency: the operating frequency in HztxPow: the transmission power in dBmnoiseFigure: the noise figure in dBscenario: the simulation scenario,V2V-UrbanorV2V-Highway
The V2V-Urban scenario simulates an urban environment with a rectangular grid of buildings. The vehicles move with a waypoint mobility model. They start from the same position and travel in the same direction, along the main street. The first vehicle moves at 60 km/h and the second at 30 km/h. At a certain point, the first vehicle turns left while the second continues on the main street. ๐๐
The V2V-Highway scenario simulates a highway environment where the two vehicles travel on the same lane, in the same direction, and keep a safety distance of 20 m. They maintain a constant speed of 140 km/h.
The example generates the output file example-output.txt. Each row of that file is organized like this:
Time[s] TxPosX[m] TxPosY[m] RxPosX[m] RxPosY[m] ChannelState SNR[dB] Pathloss[dB]
We also provide the bash script three-gpp-v2v-channel-example.sh, which reads the output file and generates two figures:
map.gif, a GIF representing the simulation scenario and vehicle mobility;snr.png, which represents the behavior of the SNR. ๐
References ๐
[friis]โ Friis, H.T., "A Note on a Simple Transmission Formula," Proceedings of the IRE , vol.34, no.5, pp.254,256, May 1946[hata]โ M.Hata, "Empirical formula for propagation loss in land mobile radio services", IEEE Trans. on Vehicular Technology, vol. 29, pp. 317-325, 1980[cost231]โ "Digital Mobile Radio: COST 231 View on the Evolution Towards 3rd Generation Systems", Commission of the European Communities, L-2920, Luxembourg, 1989[walfisch]โ J.Walfisch and H.L. Bertoni, "A Theoretical model of UHF propagation in urban environments," in IEEE Trans. Antennas Propagat., vol.36, 1988, pp.1788- 1796[ikegami]โ F.Ikegami, T.Takeuchi, and S.Yoshida, "Theoretical prediction of mean field strength for Urban Mobile Radio", in IEEE Trans. Antennas Propagat., Vol.39, No.3, 1991[kun2600mhz]โ Sun Kun, Wang Ping, Li Yingze, "Path loss models for suburban scenario at 2.3GHz, 2.6GHz and 3.5GHz", in Proc. of the 8th International Symposium on Antennas, Propagation and EM Theory (ISAPE), Kunming, China, Nov 2008.[38901]โ 3GPP. 2018. TR 38.901, Study on channel model for frequencies from 0.5 to 100 GHz, V15.0.0. (2018-06).[37885]โ 3GPP. 2019. TR 37.885, Study on evaluation methodology of new Vehicle-to-Everything (V2X) use cases for LTE and NR, V15.3.0. (2019-06).[Boban2016Modeling]โ M. Boban, X. Gong, and W. Xu, "Modeling the evolution of line-of-sight blockage for V2V channels," in IEEE 84th Vehicular Technology Conference (VTC-Fall), 2016.
SPECTRUM MODULE ๐โจ
The Spectrum module is here to provide support for modeling the frequency-dependent aspects of communications in ns-3. The model was first introduced in [Baldo2009Spectrum], and it's been enhanced and refined over the years, glow-up after glow-up. ๐
[image] Spectrogram produced by a spectrum analyzer in a scenario involving wifi signals interfered by a microwave oven, as simulated by the example adhoc-aloha-ideal-phy-with-microwave-oven.
Model Description ๐ฆ
The module provides:
- a set of classes for modeling signals and
- a Channel/PHY interface based on a power spectral density signal representation that is technology-independent
- two technology-independent Channel implementations based on the Channel/PHY interface
- a set of basic PHY model implementations based on the Channel/PHY interface
The source code for the spectrum module is located at src/spectrum. ๐ซถ
Design ๐
Signal model ๐
The signal model is implemented by the SpectrumSignalParameters class. This class hands you the following info for a signal being transmitted/received by PHY devices:
- a reference to the transmitting PHY device
- a reference to the antenna model used by the transmitting PHY device to transmit this signal
- the duration of the signal
- its Power Spectral Density (PSD) of the signal, which is assumed to be constant for the duration of the signal.
The PSD is represented as a set of discrete scalar values, each one corresponding to a certain subband in frequency. The set of frequency subbands that the PSD refers to is defined by an instance of the SpectrumModel class. The PSD itself is implemented as an instance of the SpectrumValue class, which contains a reference to the associated SpectrumModel class instance. The SpectrumValue class provides several arithmetic operators so you can do calculations with PSD instances. And bonus: the SpectrumConverter class provides the means for converting SpectrumValue instances from one SpectrumModel to another. ๐ฅ
If you want a more formal mathematical description of the signal model I just described, bestie, go read [Baldo2009Spectrum].
The SpectrumSignalParameters class is meant to include only information that's valid for all signals; so like, it is not meant to be modified to add technology-specific info (stuff like the type of modulation and coding schemes used, info on preambles and reference signals, etc). Instead, that kind of info shall be put in a new class that inherits from SpectrumSignalParameters and extends it with whatever technology-specific info is needed. This design is intended to model the fact that irl we have signals of different technologies being simultaneously transmitted and received over the air. iconic design choice honestly.
Channel/PHY interface ๐ซ
The spectrum Channel/PHY interface is defined by the base classes SpectrumChannel and SpectrumPhy. Their interaction simulates the transmission and reception of signals over the medium. The way this interaction works is depicted in Sequence diagram showing the interaction between SpectrumPhy and SpectrumChannel:
[image] Sequence diagram showing the interaction between SpectrumPhy and SpectrumChannel.
Spectrum Channel implementations ๐
The module provides two SpectrumChannel implementations: SingleModelSpectrumChannel and MultiModelSpectrumChannel. They both provide this functionality:
- Propagation loss modeling, in two forms:
- you can plug models based on
PropagationLossModelon these channels. Only linear models (where the loss value does not depend on the transmission power) can be used. These models are single-frequency in the sense that the loss value is applied equally to all components of the power spectral density. - you can plug models based on
SpectrumPropagationLossModelon these channels. These models can have frequency-dependent loss, i.e., a separate loss value is calculated and applied to each component of the power spectral density.
- you can plug models based on
- Propagation delay modeling, by plugging a model based on
PropagationDelayModel. The delay is independent of frequency and applied to the signal as a whole. Delay modeling is implemented by scheduling the StartRx event with a delay respect to the StartTx event.
SingleModelSpectrumChannel and MultiModelSpectrumChannel are pretty similar ngl, but the main difference is that MultiModelSpectrumChannel lets you use different SpectrumModel instances with the same channel instance, by automatically taking care of the conversion of PSDs among the different models. slay. โจ
Example model implementations ๐ง
The spectrum module provides some basic implementations of several components that are mainly intended as a proof-of-concept and as an example for building custom models with the spectrum module. Here's a brief list of the available implementations:
SpectrumModel300Khz300GhzLogandSpectrumModelIsm2400MhzRes1Mhzare two exampleSpectrumModelimplementationsHalfDuplexIdealPhy: a basic PHY model using a gaussian interference model (implemented inSpectrumInterference) together with an error model based on Shannon capacity (described in[Baldo2009Spectrum]and implemented inSpectrumErrorModel. This PHY uses theGenericPhyinterface. Its addditional custom signal parameters are defined inHalfDuplexIdealPhySignalParameters.WifiSpectrumValueHelperis an helper object that makes it easy to create SpectrumValues representing PSDs and RF filters for the wifi technology. ๐AlohaNoackNetDeviceโ the bare-minimum NetDevice that just lets you yeet packets overHalfDuplexIdealPhy(or honestly any other PHY model built on theGenericPhyinterface). No frills, no drama, just vibes ๐SpectrumAnalyzer,WaveformGeneratorandMicrowaveOvenโ these are PHY models that are not communication devices, they're just... guys doing their thing. The names lowkey explain themselves, bestie โจ
๐ References ๐
[Baldo2009Spectrum]
N. Baldo and M. Miozzo, "Spectrum-aware Channel and PHY layer modeling for ns3", Proceedings of ICST NSTools 2009, Pisa, Italy ๐
๐ ๏ธ Usage ๐ ๏ธ
The main character use case of the spectrum model is for devs who wanna cook up a brand-new PHY layer model for some wireless tech to use inside ns-3. Here's the tea on how the spectrum module is expected to be used:
SpectrumPhyandSpectrumChannelare abstract base classes. Real code is gonna use classes that inherit from them, periodt.- If you're implementing a new model for some wireless tech you care about and you wanna use the spectrum module, you'll typically spin up your own module and make it depend on the spectrum module. Then you typically gotta implement:
- a child class of
SpectrumModelthat defines the (sets of) frequency subbands used by the wireless technology in question. ๐ Note: instances ofSpectrumModelare typically statically allocated, so that severalSpectrumValueinstances can all reference the sameSpectrumModelinstance. - a child class of
SpectrumPhythat handles transmission and reception of signals (including interference and error modeling, if that's appropriate for your situation). - a child class of
SpectrumSignalParametersthat holds all the info needed to model the signals for the wireless tech you're considering that isn't already handed to you by the baseSpectrumSignalParametersclass. Examples of that kind of info: the type of modulation and coding schemes used, the PHY preamble format, info on the pilot/reference signals, etc. ๐ฆ
- a child class of
- The available
SpectrumChannelimplementations (SingleModelSpectrumChannelandMultiModelSpectrumChannel) are pretty generic. Chances are you can use them as-is, no cap. Which one you prefer is literally just a question of whether you're gonna have a singleSpectrumModelor multiple ones in your simulations. - Typically there's one
SpectrumChannelinstance with severalSpectrumPhyinstances plugged into it. Rule of thumb: all PHYs that are interfering with each other should be plugged on the same channel. MultipleSpectrumChannelinstances are mainly expected when you're simulating completely orthogonal channels โ for example, when simulating the uplink and downlink of a Frequency Division Duplex system, it's a great choice to use twoSpectrumChannelinstances to reduce computational complexity. ๐ - Different types of
SpectrumPhy(i.e., instances of different child classes) can be plugged on the sameSpectrumChannelinstance. This is one of the main features of the spectrum module: supporting inter-technology interference. For example, if you implement aWifiSpectrumPhyand aBluetoohSpectrumPhyand plug both onto aSpectrumChannel, then you'll be able to simulate interference between wifi and bluetooth and vice versa. Iconic. - Different child classes of
SpectrumSignalParameterscan coexist in the same simulation and be transmitted over the same channel object. Again โ this is part of the support for inter-technology interference. A PHY device model is expected to use theDynamicCast<>operator to figure out if a signal is of a certain type it can attempt to receive. If not, the signal is normally expected to be considered as interference. ๐
๐ง Helpers ๐ง
The helpers provided in src/spectrum/helpers are mainly intended for the example implementations described in Example model implementations. If you're developing your own custom model based on the spectrum framework, you'll probably wanna define your own helpers instead. Do you, bestie ๐
๐ Attributes ๐
- Both
SingleModelSpectrumChannelandMultiModelSpectrumChannelhave an attributeMaxLossDbwhich you can use to avoid propagating signals that are affected by very high propagation loss. You can use this to reduce the complexity of interference calculations. Just be careful to choose a value that doesn't make the interference calculations inaccurate. โ ๏ธ - The example implementations described in Example model implementations also have several attributes.
โจ Output โจ
- Both
SingleModelSpectrumChannelandMultiModelSpectrumChannelprovide a trace source calledPathLosswhich is fired whenever a new path loss value is calclulated. ๐ Note: only single-frequency path loss is accounted for, see the attribute description. - The example implementations described in Example model implementations also provide some trace sources.
- The helper class
SpectrumAnalyzerHelpercan be conveniently used to generate an output text file containing the spectrogram produced by aSpectrumAnalyzerinstance. The format is designed to be easily plotted withgnuplot. For example, if your run the exampleadhoc-aloha-ideal-phy-with-microwave-ovenyou will get an output file calledspectrum-analyzer-output-3-0.tr. From this output file, you can generate a figure similar to Spectrogram produced by a spectrum analyzer in a scenario involving wifi signals interfered by a microwave oven, as simulated by the exampleadhoc-aloha-ideal-phy-with-microwave-oven. by executing the following gnuplot commands:
unset surface
set pm3d at s
set palette
set key off
set view 50,50
set xlabel "time (ms)"
set ylabel "freq (MHz)"
set zlabel "PSD (dBW/Hz)" offset 15,0,0
splot "./spectrum-analyzer-output-3-0.tr" using ($1*1000.0):($2/1e6):(10*log10($3))
๐ Examples ๐
The example programs in src/spectrum/examples/ allow you to see the example implementations described in Example model implementations in action. Go look, it's giving demo day ๐ซถ
๐ญ Troubleshooting ๐ญ
- Disclaimer on inter-technology interference: the spectrum model makes it very easy to implement an inter-technology interference model, but this does not guarantee that the resulting model is accurate. For example, the gaussian interference model implemented in the
SpectrumInterferenceclass can be used to calculate inter-technology interference, however the results might not be valid in some scenarios, depending on the actual waveforms involved, the number of interferers, etc. Moreover, it is very important to use error models that are consistent with the interference model. The responsibility of ensuring that the models being used are correct is left to the user. ๐
๐งช Testing ๐งช
In this section we describe the test suites that are provided within the spectrum module.
๐ฅ SpectrumValue test ๐ฅ
The test suite spectrum-value verifies the correct functionality of the arithmetic operators implemented by the SpectrumValue class. Each test case corresponds to a different operator. The test passes if the result provided by the operator implementation is equal to the reference values which were calculated offline by hand. Equality is verified within a tolerance of 10^{-6} which is to account for numerical errors. ๐
๐ฅ SpectrumConverter test ๐ฅ
The test suite spectrum-converter verifies the correct functionality of the SpectrumConverter class. Different test cases correspond to the conversion of different SpectrumValue instances to different SpectrumModel instances. Each test passes if the SpectrumValue instance resulting from the conversion is equal to the reference values which were calculated offline by hand. Equality is verified within a tolerance of 10^{-6} which is to account for numerical errors.
Describe how the model has been tested/validated. What tests run in the test suite? How much API and code is covered by the tests? Again, references to outside published work may help here.
๐ฅ Interference test ๐ฅ
The test suite spectrum-interference verifies the correct functionality of the SpectrumInterference and ShannonSpectrumErrorModel in a scenario involving four signals (an intended signal plus three interferers). Different test cases are created corresponding to different PSDs of the intended signal and different amount of transmitted bytes. The test passes if the output of the error model (successful or failed) coincides with the expected one which was determine offline by manually calculating the achievable rate using Shannon's formula. โจ
๐ฅ IdealPhy test ๐ฅ
The test verifies that AlohaNoackNetDevice and HalfDuplexIdealPhy work properly when installed in a node. The test recreates a scenario with two nodes (a TX and a RX) affected by a path loss such that a certain SNR is obtained. The TX node transmits with a pre-determined PHY rate and with an application layer rate which is larger than the PHY rate, so as to saturate the channel. PacketSocket is used in order to avoid protocol overhead. Different test cases correspond to different PHY rate and SNR values. For each test case, we calculated offline (using Shannon's formula) whether the PHY rate is achievable or not. Each test case passes if the following conditions are satisfied:
- if the PHY rate is achievable, the application throughput shall be within
1\%of the PHY rate; - if the PHY rate is not achievable, the application throughput shall be zero.
๐ Additional Models ๐
๐บ TV Transmitter Model ๐บ
A TV Transmitter model is implemented by the TvSpectrumTransmitter class. This model enables transmission of realistic TV signals to be simulated and can be used for interference modeling. It provides a customizable power spectral density (PSD) model, with configurable attributes including the type of modulation (with models for analog, 8-VSB, and COFDM), signal bandwidth, power spectral density level, frequency, and transmission duration. A helper class, TvSpectrumTransmitterHelper, is also provided to assist users in setting up simulations. ๐ซถ
๐บ Main Model Class ๐บ
The main TV Transmitter model class, TvSpectrumTransmitter, provides a user-configurable PSD model that can be transmitted on the SpectrumChannel. It inherits from SpectrumPhy and is comprised of attributes and methods to create and transmit the signal on the channel.
[image] 8K COFDM signal spectrum generated from TvSpectrumTransmitter
(Left) and theoretical COFDM signal spectrum [KoppCOFDM]
(Right).
One of the user-configurable attributes is the type of modulation for the TV transmitter to use. The options are:
- 8-VSB (Eight-Level Vestigial Sideband Modulation) โ the iconic one, notably used in the North America ATSC digital television standard ๐
- COFDM (Coded Orthogonal Frequency Division Multiplexing) โ notably used in the DVB-T and ISDB-T digital television standards adopted by various countries around the world ๐
- analog modulation โ a legacy technology, but still being used by some countries today ๐ซถ
To accomplish realistic PSD models for these modulation types, the signals' PSDs were approximated from real standards and developed into models that are scalable by frequency and power. The COFDM PSD is approximated from Figure 12 (8k mode) of [KoppCOFDM], the 8-VSB PSD is approximated from Figure 3 of [Baron8VSB], and the analog PSD is approximated from Figure 4 of [QualcommAnalog]. Note that the analog model is approximated from the NTSC standard, but other analog modulation standards such as PAL have similar signals. The approximated COFDM PSD model is in 8K mode. The other configurable attributes are the start frequency, signal/channel bandwidth, base PSD, antenna type, starting time, and transmit duration.
TvSpectrumTransmitter uses IsotropicAntennaModel as its antenna model by default, but any model that inherits from AntennaModel is selectable, so directional antenna models can also be used. The propagation loss models used in simulation are configured in the SpectrumChannel that the user chooses to use. Terrain and spherical Earth/horizon effects may be supported in future ns-3 propagation loss models.
After the attributes are set, along with the SpectrumChannel, MobilityModel, and node locations, the PSD of the TV transmitter signal can be created and transmitted on the channel. โจ
๐ Helper Class ๐
The helper class, TvSpectrumTransmitterHelper, consists of features to assist users in setting up TV transmitters for their simulations. Functionality is also provided to easily simulate real-world scenarios. ๐ฆ
[image] North America ATSC channel 19 & 20 signals generated usingTvSpectrumTransmitterHelper(Left) and theoretical 8-VSB signal[Baron8VSB](Right). Note that the theoretical signal is not shown in dB while the ns-3 generated signals are..
Using this helper class, users can easily set up TV transmitters right after configuring attributes. Multiple transmitters can be created at a time. Also included are real characteristics of specific geographic regions that can be used to run realistic simulations. The regions currently included are North America, Europe, and Japan. The frequencies and bandwidth of each TV channel for each these regions are provided.
[image] Plot from MATLAB implementation ofCreateRegionalTvTransmittersmethod inTvSpectrumTransmitterHelper. Shows 100 random points on Earth's surface (with altitude 0) corresponding to TV transmitter locations within a 2000 km radius of 35ยฐ latitude and -100ยฐ longitude..
A method (CreateRegionalTvTransmitters) is provided that enables users to randomly generate multiple TV transmitters from a specified region with a given density within a chosen radius around a point on Earth's surface. The region, which determines the channel frequencies of the generated TV transmitters, can be specified to be one of the three provided, while the density determines the amount of transmitters generated. The TV transmitters' antenna heights (altitude) above Earth's surface can also be randomly generated to be within a given maximum altitude. This method models Earth as a perfect sphere ๐, and generated location points are referenced accordingly in Earth-Centered Earth-Fixed Cartesian coordinates. Note that bodies of water on Earth are not considered in location point generationโTV transmitters can be generated anywhere on Earth around the origin point within the chosen maximum radius.
๐ธ Examples ๐ธ
Two example simulations are provided that demonstrate the functionality of the TV transmitter model. tv-trans-example simulates two 8-VSB TV transmitters with adjacent channel frequencies. tv-trans-regional-example simulates randomly generated COFDM TV transmitters (modeling the DVB-T standard) located around the Paris, France area with channel frequencies and bandwidths corresponding to the European television channel allocations. ๐ฅ
๐ Testing ๐
The tv-spectrum-transmitter test suite verifies the accuracy of the spectrum/PSD model in TvSpectrumTransmitter by testing if the maximum power spectral density, start frequency, and end frequency comply with expected values for various test cases.
The tv-helper-distribution test suite verifies the functionality of the method in TvSpectrumTransmitterHelper that generates a random number of TV transmitters based on the given density (low, medium, or high) and maximum number of TV channels. It verifies that the number of TV transmitters generated does not exceed the expected bounds.
The CreateRegionalTvTransmitters method in TvSpectrumTransmitterHelper described in Helper Class uses two methods from the GeographicPositions class in the Mobility module to generate the random Cartesian points on or above earth's surface around an origin point which correspond to TV transmitter positions. The first method converts Earth geographic coordinates to Earth-Centered Earth-Fixed (ECEF) Cartesian coordinates, and is tested in the geo-to-cartesian test suite by comparing (with 10 meter tolerance) its output with the output of the geographic to ECEF conversion function [MatlabGeo] of the MATLAB Mapping Toolbox for numerous test cases. The other used method generates random ECEF Cartesian points around the given geographic origin point, and is tested in the rand-cart-around-geo test suite by verifying that the generated points do not exceed the given maximum distance radius from the origin point.
โญ 3GPP TR 38.901 fast fading model โญ
The framework described by TR 38.901 [TR38901] is a 3D statistical Spatial Channel Model supporting different propagation environments (e.g., urban, rural, indoor), multi-antenna operations and the modeling of wireless channels between 0.5 and 100 GHz. The overall channel is represented by the matrix H(t,\tau), in which each entry H u,s (t,\tau) corresponds to the impulse response of the channel between the s-th element of the transmitting antenna and the u-th element of the receiving antenna. H u,s (t,\tau) is generated by the superposition of N different multi-path components, called clusters, each of which composed of M different rays. The channel matrix generation procedure accounts for large and small scale propagation phenomena. The classes ThreeGppSpectrumPropagationLossModel and ThreeGppChannelModel included in the spectrum module takes care of the generation of the channel coefficients and the computation of the frequency-dependent propagation loss. ๐ฅ
๐ Implementation ๐
Our implementation is described in [Zugno]. It is based on the model described in [Zhang], but the code has been refactored, extended, and aligned to TR 38.901 [TR38901]. The fundamental assumption behind this model is the channel reciprocity, i.e., the impulse response of the channel between node a and node b is the same as between node b and node a. To deal with the equivalence of the channel between a and b, no matter who is the transmitter and who is the receiver, the model considers the pair of nodes to be composed by one "s" and one "u" node. The channel matrix, as well as other parameters, are saved and used under the assumption that, within a pair, the definition of the "s" and "u" node will always be the same. For more details, please have a look at the documentation of the classes ThreeGppChannelModel and ThreeGppSpectrumPropagationLossModel.
Note:
- Currently, no error model is provided; a link-to-system campaign may be needed to incorporate it in existing modules.
- The model does not include any spatial consistency update procedure (see
[TR38901], Sec. 7.6.1). The implementation of this feature is left as future work. - Issue regarding the blockage model: according to 3GPP TR 38.901 v15.0.0 (2018-06) section 7.6.4.1, the blocking region for self-blocking is provided in LCS.
However, here, clusterAOA and clusterZOA are in GCS and blocking check is performed for self-blocking similar to non-self blocking, that is in GCS. One would expect the angles to be transposed to LCS before checking self-blockage.
๐ฆ ThreeGppSpectrumPropagationLossModel ๐ฆ
The class ThreeGppSpectrumPropagationLossModel extends the SpectrumPropagationLossModel interface and enables the modeling of frequency dependent propagation phenomena. The main method is DoCalcRxPowerSpectralDensity, which takes as input the power spectral density (PSD) of the transmitted signal, the mobility models of the transmitting node and receiving node, and returns the PSD of the received signal.
Procedure used to compute the PSD of the received signal:
- Retrieve the beamforming vectors โ To account for the beamforming,
ThreeGppSpectrumPropagationLossModelhas to retrieve the beamforming vectors of the transmitting and receiving antennas. The methodDoCalcRxPowerSpectralDensityusesm_deviceAntennaMapto obtain the antenna objects associated to the transmitting and receiving devices, and calls the methodGetCurrentBeamformingVectorto retrieve the beamforming vectors. For each device using the channel, them_deviceAntennaMapcontains the associated antenna object of typePhasedArrayModel. Since the mapping is one-to-one, the model supports a single antenna object for each device. Them_deviceAntennaMaphas to be initialized by inserting the device-antenna pairs using the methodAddDevice. - Retrieve the channel matrix โ The
ThreeGppSpectrumPropagationLossModelrelies on theThreeGppChannelModelclass to obtain the channel matrix. In particular, it makes use of the methodGetChannel, which returns aChannelMatrixobject containing the channel matrix and other channel parameters. TheThreeGppChannelModelinstance is automatically created in the theThreeGppSpectrumPropagationLossModelconstructor and it can be configured using the methodSetChannelModelAttribute (). - Compute the long term component โ the method
GetLongTermhands back the long term component, which you get by multiplying the channel matrix by the beamforming vectors. To keep the compute load from being extra ๐ฎโ๐จ, the long term components for the different channels get stashed in them_longTermMap, and they're only recomputed if the associated channel matrix gets updated, or if the transmitting and/or receiving beamforming vectors have changed. And because of the channel reciprocity assumption, for each node pair there's just one single long term component saved in the map. efficient queen behavior ๐ - Apply the small scale fading and compute the channel gain โ the method
CalcBeamformingGaincomputes the channel gain in each sub-band and applies it to the PSD of the transmitted signal, which gives you the received PSD. To work out the sub-band gain, it takes the Doppler phenomenon and the time dispersion effect on each cluster into account. To reduce the computational load, the Doppler component of each cluster is computed considering only the central ray. Also, as specified here, it's possible to account for the effect of environmental scattering following the model described in Sec. 6.2.3 of 3GPP TR 37.885. That's done by deviating the Doppler frequency by a random value, and the distribution of that value depends on the parameter v_{scatt}. You configure v_{scatt} with the attribute"vScatt"(by default it's set to0, so the scattering effect is just not considered at all ๐ซฅ).
โจ ThreeGppChannelModel โจ
The class ThreeGppChannelModel implements the channel matrix generation procedure described in Sec. of [TR38901]. Its main method is GetChannel, which takes as input the mobility models of the transmitter and receiver nodes plus the associated antenna objects, and returns a ChannelMatrix object containing:
- the channel matrix of size
UxSxN, whereUis the number of receiving antenna elements,Sis the number of transmitting antenna elements andNis the number of clusters ๐ - the clusters delays, as an array of size
N - the clusters arrival and departure angles, as a 2D array in which each row corresponds to a direction (
AOA,ZOA,AOD,ZOD) and each column corresponds to a different cluster - a time stamp indicating the time at which the channel matrix was generated
- the node IDs
- other channel parameters
The ChannelMatrix objects are saved in the map m_channelMap and updated when the coherence time expires, or in case the LOS/NLOS channel condition changes. You can configure the coherence time through the attribute "UpdatePeriod", and bestie you should choose it by taking into account all the factors that affect the channel variability, like mobility, frequency, propagation scenario, etc. By default it's set to 0, which means the channel is recomputed only when the LOS/NLOS condition changes. You can also configure the propagation scenario and the operating frequency you care about through the attributes "Scenario" and "Frequency", respectively. slay โจ
Blockage model: 3GPP TR 38.901 also provides an optional feature that can be used to model the blockage effect caused by obstacles like trees, cars or humans, at the level of a single cluster. This is different from a complete blockage, which would give you an LOS to NLOS transition. So when this feature is enabled, an additional attenuation is added to certain clusters, depending on their angle of arrival. There are two possible methods for computing that additional attenuation: stochastic (Model A) and geometric (Model B). In this work, the implementation provided by [Zhang] is used, which uses the stochastic method. Specifically, the model is implemented by the method CalcAttenuationOfBlockage, which computes the additional attenuation. The blockage feature can be disabled through the attribute "Blockage". Also, the attributes "NumNonselfBlocking", "PortraitMode" and "BlockerSpeed" can be used to configure the model. ๐ง
๐งช Testing ๐งช
The test suite ThreeGppChannelTestSuite includes three test cases:
ThreeGppChannelMatrixComputationTestโ checks if the channel matrix has the correct dimensions and if it's correctly normalizedThreeGppChannelMatrixUpdateTestโ checks if the channel matrix is correctly updated when the coherence time exceedsThreeGppSpectrumPropagationLossModelTestโ tests the functionalities of the classThreeGppSpectrumPropagationLossModel. It builds a simple network composed of two nodes, computes the power spectral density received by the receiving node, and- Checks if the long term components for the direct and the reverse link are the same,
- Checks if the long term component is updated when changing the beamforming vectors,
- Checks if the long term is updated when changing the channel matrix
Note: TR 38.901 includes a calibration procedure that can be used to validate the model, but it requires some additional features which are not currently implemented, thus is left as future work. ๐ญ
๐ References ๐
[Baron8VSB]โ Baron, Stanley. "First-Hand:Digital Television: The Digital Terrestrial Television Broadcasting (DTTB) Standard." IEEE Global History Network.<http://www.ieeeghn.org/wiki/index.php/First-Hand:Digital_Television:_The_Digital_Terrestrial_Television_Broadcasting_(DTTB)_Standard>.[KoppCOFDM]โ Kopp, Carlo. "High Definition Television." High Definition Television. Air Power Australia.<โ http://www.ausairpower.net/AC-1100.html>.[MatlabGeo]โ "Geodetic2ecef." Convert Geodetic to Geocentric (ECEF) Coordinates. The MathWorks, Inc.<โ http://www.mathworks.com/help/map/ref/geodetic2ecef.html>.[QualcommAnalog]โ Stephen Shellhammer, Ahmed Sadek, and Wenyi Zhang. "Technical Challenges for Cognitive Radio in the TV White Space Spectrum." Qualcomm Incorporated.[TR38901]โ 3GPP. 2018. TR 38.901. Study on channel for frequencies from 0.5 to 100 GHz. V.15.0.0. (2018-06).[Zhang]โ Menglei Zhang, Michele Polese, Marco Mezzavilla, Sundeep Rangan, Michele Zorzi. "ns-3 Implementation of the 3GPP MIMO Channel Model for Frequency Spectrum above 6 GHz". In Proceedings of the Workshop on ns-3 (WNS3 '17). 2017.[Zugno]โ Tommaso Zugno, Michele Polese, Natale Patriciello, Biljana Bojovic, Sandra Lagen, Michele Zorzi. "Implementation of a Spatial Channel Model for ns-3". Submitted to the Workshop on ns-3 (WNS3 '20). 2020. Available:https://arxiv.org/abs/2002.09341
๐ and that's the whole 3GPP channel model tea, bestie ๐
๐ 6LOWPAN: TRANSMISSION OF IPV6 PACKETS OVER IEEE 802.15.4 NETWORKS ๐
okay bestie, this chapter is literally about the ns-3 implementation of compressing IPv6 packets over IEEE 802.15.4-Based Networks, exactly as spelled out by RFC 4944 (โTransmission of IPv6 Packets over IEEE 802.15.4 Networksโ) and RFC 6282 (โCompression Format for IPv6 Datagrams over IEEE 802.15.4-Based Networksโ). two RFCs, one module, we love to see it. ๐
โจ Model Description โจ
the source code for the sixlowpan module lives in the directory src/sixlowpan. that's it, that's the address. go knock. ๐
๐ฆ Design ๐ฆ
ngl, the model design does not strictly follow the standard from an architectural standpoint โ it does extend it beyond the original scope by supporting also other kinds of networks. main character energy, honestly. ๐
other than that? the module strictly follows RFC 4944 and RFC 6282, with one exception: HC2 encoding is not supported, because it's been superseded by IPHC and NHC compression type (RFC 6282). rip HC2, you were lowkey iconic. ๐
IPHC sateful (context-based) compression is supported but, since RFC 6775 (โNeighbor Discovery Optimization for IPv6 over Low-Power Wireless Personal Area Networks (6LoWPANs)โ) is not yet implemented, it is necessary to add the context to the nodes manually. yes bestie, by hand. ๐ซถ
this is possible though the SixLowPanHelper::AddContext function. mind that installing different contexts in different nodes will lead to decompression failures. so likeโฆ don't. ๐
๐ธ NetDevice ๐ธ
the whole module is developed as a transparent NetDevice, which can act as a proxy between IPv6 and any NetDevice (the module has been successfully tested with PointToPointNedevice, CsmaNetDevice and LrWpanNetDevice). trio slayed. โจ
for this reason, the module implements a virtual NetDevice, and all the calls are passed without modifications to the underlying NetDevice. the only important difference is in GetMtu behaviour. it will always return at least 1280 bytes, as is the minimum IPv6 MTU. no cap. ๐
the module does provide some attributes and some tracesources. the attributes are:
Rfc6282โ (boolean, defaulttrue), used to activateHC1(RFC 4944) orIPHC(RFC 6282) compression.OmitUdpChecksumโ (boolean, defaulttrue), used to activate UDP checksum compression in IPHC.FragmentReassemblyListSizeโ (integer, default0), indicating the number of packets that can be reassembled at the same time. if the limit is reached, the oldest packet is discarded. zero means infinite.FragmentExpirationTimeoutโ (Time, default60seconds), being the timeout to wait for further fragments before discarding a partial packet.CompressionThresholdโ (unsigned 32 bits integer, default0), minimum compressed payload size.ForceEtherTypeโ (boolean, defaultfalse).EtherTypeโ (unsigned 16 bits integer, default0xFFFF), to force a particular L2 EtherType.UseMeshUnderโ (boolean, defaultfalse), it enables mesh-under flood routing.MeshUnderRadiusโ (unsigned 8 bits integer, default10), the maximum number of hops that a packet will be forwarded.MeshCacheLengthโ (unsigned 16 bits integer, default10), the length of the cache for each source.MeshUnderJitterโ (ns3::UniformRandomVariable[Min=0.0|Max=10.0]), the jitter in ms a node uses to forward mesh-under packets - used to prevent collisions.
the CompressionThreshold attribute is similar to Contiki's SICSLOWPAN_CONF_MIN_MAC_PAYLOAD option. if a compressed packet size is less than the threshold, the uncompressed version is used (plus one byte for the correct dispatch header). this option is useful when a MAC requires a minimum frame size (e.g., ContikiMAC) and the compression would violate the requirement. so it's giving "sometimes bigger is safer". ๐
the last two attributes are needed to use the module with a NetDevice other than 802.15.4, as neither IANA or IEEE did reserve an EtherType for 6LoWPAN. as a consequence there might be a conflict with the L2 multiplexer/demultiplexer which is based on EtherType. the default value is 0xFFFF, which is reserved by IEEE (see [IANA802] and [Ethertype]). the default module behaviour is to not change the EtherType, however this would not work with any NetDevice actually understanding and using the EtherType. ๐
note that the ForceEtherType parameter have also a direct effect on the MAC address kind the module is expecting to handle:
ForceEtherTypetrue:Mac48Address(Ethernet, WiFi, etc.).ForceEtherTypefalse:Mac16AddressorMac64Address(IEEE 802.15.4).
note that using 6LoWPAN over any NetDevice other than 802.15.4 will produce valid .pcap files, but they will not be correctly dissected by Wireshark. the reason lies on the fact that 6LoWPAN was really meant to be used only over 802.15.4, so Wireshark dissectors will not even try to decode 6LoWPAN headers on top of protocols other than 802.15.4. Wireshark said "not my problem bestie". ๐ญ
the Trace sources are:
Txโ exposing packet (including 6LoWPAN header),SixLoWPanNetDevicePtr, interface index.Rxโ exposing packet (including 6LoWPAN header),SixLoWPanNetDevicePtr, interface index.Dropโ exposingDropReason, packet (including 6LoWPAN header),SixLoWPanNetDevicePtr, interface index.
the Tx and Rx traces are called as soon as a packet is received or sent. the Drop trace is invoked when a packet (or a fragment) is discarded. bye bye packet, we hardly knew ye ๐
๐ง Mesh-Under routing ๐ง
the module provides a very simple mesh-under routing [Shelby], implemented as a flooding (a mesh-under routing protocol is a routing system implemented below IP). yes, below IP. sneak level: expert. ๐
this functionality can be activated through the UseMeshUnder attribute and fine-tuned using the MeshUnderRadius and MeshUnderJitter attributes.
note that flooding in a PAN generates a lot of overhead, which is often not wanted. moreover, when using the mesh-under facility, ALL the packets are sent without acknowledgment because, at lower level, they are sent to a broadcast address. not me screaming into the void ๐ฃ๏ธ๐
at node level, each packet is re-broadcasted if its BC0 Sequence Number is not in the cache of the recently seen packets. the cache length (by default 10) can be changed through the MeshCacheLength attribute.
โญ Scope and Limitations โญ
๐ Contex-based compression ๐
IPHC sateful (context-based) compression is supported but, since RFC 6775 (โNeighbor Discovery Optimization for IPv6 over Low-Power Wireless Personal Area Networks (6LoWPANs)โ) is not yet implemented, it is necessary to add the context to the nodes manually. (yes, same tea as before. we're consistent. ๐
)
๐ฆ 6LoWPAM-ND ๐ฆ
future versions of this module will support RFC 6775, however no timeframe is guaranteed. so likeโฆ manifesting it, but no promises bestie ๐ฏ๏ธโจ
๐ Mesh-under routing ๐
it would be a good idea to improve the mesh-under flooding by providing the following:
- Adaptive hop-limit calculation,
- Adaptive forwarding jitter,
- Use of direct (non mesh) transmission for packets directed to 1-hop neighbors.
๐ธ Mixing compression types in a PAN ๐ธ
the IPv6/MAC addressing scheme defined in RFC 6282 and RFC 4944 is different. one adds the PanId in the pseudo-MAC address (4944) and the other doesn't (6282). sibling drama fr fr ๐ญ
the expected use cases (confirmed by the RFC editor) is to never have a mixed environment where part of the nodes are using HC1 and part IPHC because this would lead to confusion on what the IPv6 address of a node is.
due to this, the nodes configured to use IPHC will drop the packets compressed with HC1 and viceversa. the drop is logged in the drop trace as DROP_DISALLOWED_COMPRESSION. the receipts are in the trace, always ๐
๐ Using 6LoWPAN with IPv4 (or other L3 protocols) ๐
as the name implies, 6LoWPAN can handle only IPv6 packets. any other protocol will be discarded. moreover, 6LoWPAN assumes that the network is uniform, as is all the devices connected by the same channel are using 6LoWPAN. mixed environments are not supported by the standard. the reason is simple: 802.15.4 frame doesn't have a โprotocolโ field. as a consequence, there is no demultiplexing at MAC layer and the protocol carried by L2 frames must be known in advance. it's giving "no ID, no entry". ๐
in the ns-3 implementation it is possible, but not advisable, to violate this requirement if the underlying NetDevice is capable of discriminating different protocols. as an example, CsmaNetDevice can carry IPv4 and 6LoWPAN at the same time. however, this configuration has not been tested. proceed at your own risk bestie, i said what i said ๐
๐ฅ References ๐ฅ
[IANA802]โ IANA, assigned IEEE 802 numbers:http://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xml[Ethertype]โ IEEE Ethertype numbers:http://standards.ieee.org/develop/regauth/ethertype/eth.txt[Shelby]โ Z. Shelby and C. Bormann, 6LoWPAN: The Wireless Embedded Internet. Wiley, 2011. [Online]. Available:https://books.google.it/books?id=3Nm7ZCxscMQC
๐ Usage ๐
โจ Enabling sixlowpan โจ
add sixlowpan to the list of modules built with ns-3. one line, instant slay ๐
๐ Helper ๐
the helper is patterned after other device helpers. familiar vibes, new module ๐ซถ
๐ Examples ๐
the following example can be found in src/sixlowpan/examples/:
example-sixlowpan.cc: A simple example showing end-to-end data transfer.
in particular, the example enables a very simplified end-to-end data transfer scenario, with a CSMA network forced to carry 6LoWPAN compressed packets. forced. against its will. and it ATE ๐ฅ
โญ Tests โญ
the test provided checks the connection between two UDP clients and the correctness of the received packets.
๐ง Validation ๐ง
the model has been validated against WireShark, checking whatever the packets are correctly interpreted and validated. Wireshark said yes, so it's canon. ๐
๐ฆ TOPOLOGY INPUT READERS ๐ฆ
the topology modules aim at reading a topology file generated by an automatic topology generator. no hand-drawing bestie, we're automating this ๐
the process is divided in two steps:
- running a topology generator to build a topology file
- reading the topology file and build a ns-3 simulation
hence, model is focused on being able to read correctly the various topology formats.
currently there are three models:
ns3::OrbisTopologyReaderfor Orbis0.7tracesns3::InetTopologyReaderfor Inet3.0tracesns3::RocketfuelTopologyReaderfor Rocketfuel traces
an helper ns3::TopologyReaderHelper is provided to assist on trivial tasks.
a good source for topology data is also Archipelago.
the current Archipelago Measurements, monthly updated, are stored in the CAIDA website using a complete notation and triple data source, one for each working group. monthly updates?? the dedication ๐ญ๐
a different and more compact notation reporting only the AS-relationships (a sort of more Orbis-like format) is here: as-relationships.
the compact notation can be easily stripped down to a pure Orbis format, just removing the double relationships (the compact format use one-way links, while Orbis use two-way links) and pruning the 3rd parameter. note that with the compact data Orbis can then be used create a rescaled version of the topology, thus being the most effective way (to my best knowledge) to make an internet-like topology. "to my best knowledge" โ the author being humble, we love a self-aware icon ๐ซถ
examples can be found in the directory src/topology-read/examples/
โจ TRAFFIC CONTROL LAYER โจ
๐ Traffic Control Layer ๐
okay so bestie, the Traffic Control layer is literally trying to bring the Linux Traffic Control infrastructure vibes into ns-3. It sits right in between the NetDevices (L2) and any network protocol (like IP). It's the main character in charge of processing packets and doing stuff to them: scheduling, dropping, marking, policing, etc. ๐
๐ Introducing the Traffic Control Layer ๐
The Traffic Control layer intercepts both outgoing packets flowing downwards from the network layer to the network device AND incoming packets flowing in the opposite direction. But rn? Only outgoing packets are processed by the Traffic Control layer. No cap. Specifically, outgoing packets get enqueued in a queuing discipline, which can perform multiple actions on them. โจ
In the following, more details are given about how the Traffic Control layer intercepts outgoing and incoming packets and, more in general, about how the packets traverse the network stack.
๐ค Transmitting packets ๐ค
The IPv{4,6} interfaces uses the aggregated object TrafficControlLayer to send down packets, instead of calling NetDevice::Send() directly. After the analysis and the process of the packet, when the backpressure mechanism allows it, TrafficControlLayer will call the Send() method on the right NetDevice. ๐
๐ฅ Receiving packets ๐ฅ
The callback chain that (in the past) involved IPv{4,6}L3Protocol and NetDevices, through ReceiveCallback, is extended to involve TrafficControlLayer. When an IPv{4,6}Interface is added in the IPv{4,6}L3Protocol, the callback chain is configured to have the following packet exchange:
NetDevice โ> Node โ> TrafficControlLayer โ> IPv{4,6}L3Protocol
๐ Brief description of old node/device/protocol interactions ๐
The main question that we would like to answer in the following paragraphs is: how a ns-3 node can send/receive packets? ๐ค
If we analyze any example out there, the ability of the node to receive/transmit packets derives from the interaction of two helper:
- L2 Helper (something derived from NetDevice)
- L3 Helper (usually from Internet module)
๐ ๏ธ L2 Helper main operations ๐ ๏ธ
Any good L2 Helper will do the following operations:
- Create
nnetdevices (n>1) - Attach a channel between these devices
- Call
Node::AddDevice ()
Obviously the last point is the most important. ๐
Node::AddDevice (network/model/node.cc:128) assigns an interface index to the device, calls NetDevice::SetNode, sets the receive callback of the device to Node::NonPromiscReceiveFromDevice. Then, it schedules NetDevice::Initialize() method at Seconds(0.0), then notify the registered DeviceAdditionListener handlers (not used BY ANYONE). ๐
Node::NonPromiscReceiveFromDevice calls Node::ReceiveFromDevice.
Node::ReceiveFromDevice iterates through ProtocolHandlers, which are callbacks which accept as signature:
ProtocolHandler (Ptr<NetDevice>, Ptr<const Packet>, protocol, from_addr,
to_addr, packetType).
If device, protocol number and promiscuous flag corresponds, the handler is invoked.
Who is responsible to set ProtocolHandler? We will analyze that in the next section. ๐
๐ L3 Helper ๐
We have only internet which provides network protocol (IP). That module splits the operations between two helpers: InternetStackHelper and Ipv{4,6}AddressHelper.
InternetStackHelper::Install (internet/helper/internet-stack-helper.cc:423) creates and aggregates protocols {ArpL3,Ipv4L3,Icmpv4}Protocol. It creates the routing protocol, and if Ipv6 is enabled it adds {Ipv6L3,Icmpv6L4}Protocol. In any case, it instantiates and aggregates an UdpL4Protocol object, along with a PacketSocketFactory. Ultimately, it creates the required objects and aggregates them to the node.
Letโs assume an Ipv4 environment (things are the same for Ipv6).
Ipv4AddressHelper::Assign (src/internet/helper/ipv4-address-helper.cc:131) registers the handlers. The process is a bit long. The method is called with a list of NetDevice. For each of them, the node and Ipv4L3Protocol pointers are retrieved; if an Ipv4Interface is already registered for the device, on that the address is set. Otherwise, the method Ipv4L3Protocol::AddInterface is called, before adding the address.
๐ก IP interfaces ๐ก
In Ipv4L3Protocol::AddInterface (src/internet/model/ipv4-l3-protocol.cc:300) two protocol handlers are installed: one that react to ipv4 protocol number, and one that react to arp protocol number (Ipv4L3Protocol::Receive and ArpL3Protocol::Receive, respectively). The interface is then created, initialized, and returned.
Ipv4L3Protocol::Receive (src/internet/model/ipv4-l3-protocol.cc:472) iterates through the interface. Once it finds the Ipv4Interface which has the same device as the one passed as argument, invokes the rxTrace callback. If the interface is down, the packet is dropped. Then, it removes the header and trim any residual frame padding. If checksum is not OK, it drops the packet. Otherwise, forward the packet to the raw sockets (not used). Then, it ask the routing protocol what is the destiny of that packet. The choices are: Ipv4L3Protocol::{IpForward, IpMulticastForward,LocalDeliver,RouteInputError}.
๐ Queue disciplines ๐
๐ธ Model Description ๐ธ
Packets received by the Traffic Control layer for transmission to a netdevice can be passed to a queueing discipline (queue disc) to perform scheduling and policing. The ns-3 term โqueue discโ corresponds to what Linux calls a โqdiscโ. A netdevice can have a single (root) queue disc installed on it. Installing a queue disc on a netdevice is not mandatory. If a netdevice does not have a queue disc installed on it, the traffic control layer sends the packets directly to the netdevice. This is the case, for instance, of the loopback netdevice. ๐ซถ
As in Linux, queue discs may be simple queues or may be complicated hierarchical structures. A queue disc may contain distinct elements:
- queues, which actually store the packets waiting for transmission
- classes, which permit the definition of different treatments for different subdivisions of traffic
- filters, which determine the queue or class which a packet is destined to
Linux uses the terminology โclassful qdiscsโ or โclassless qdiscsโ to describe how packets are handled. This use of the term โclassโ should be distinguished from the C++ language โclassโ. In general, the below discussion uses โclassโ in the Linux, not C++, sense, but there are some uses of the C++ term, so please keep in mind the dual use of this term in the below text. ๐
Notice that a child queue disc must be attached to every class and a packet filter is only able to classify packets of a single protocol. Also, while in Linux some queue discs (e.g., fq-codel) use an internal classifier and do not make use of packet filters, in ns-3 every queue disc including multiple queues or multiple classes needs an external filter to classify packets (this is to avoid having the traffic-control module depend on other modules such as internet). ๐ฅ
Queue disc configuration vary from queue disc to queue disc. A typical taxonomy divides queue discs in classful (i.e., support classes) and classless (i.e., do not support classes). More recently, after the appearance of multi-queue devices (such as Wi-Fi), some multi-queue aware queue discs have been introduced. Multi-queue aware queue discs handle as many queues (or queue discs โ without using classes) as the number of transmission queues used by the device on which the queue disc is installed. An attempt is made, also, to classify each packet similarly in the queue disc and within the device (i.e., to keep the packet classification consistent across layers). โจ
The traffic control layer interacts with a queue disc in a simple manner: after requesting to enqueue a packet, the traffic control layer requests the qdisc to โrunโ, i.e., to dequeue a set of packets, until a predefined number (โquotaโ) of packets is dequeued or the netdevice stops the queue disc. A netdevice shall stop the queue disc when its transmission queue does not have room for another packet. Also, a netdevice shall wake the queue disc when it detects that there is room for another packet in its transmission queue, but the transmission queue is stopped. Waking a queue disc is equivalent to make it run. ๐ค
Every queue disc collects statistics about the total number of packets/bytes received from the upper layers (in case of root queue disc) or from the parent queue disc (in case of child queue disc), enqueued, dequeued, requeued, dropped, dropped before enqueue, dropped after dequeue, marked, and stored in the queue disc and sent to the netdevice or to the parent queue disc. Note that packets that are dequeued may be requeued, i.e., retained by the traffic control infrastructure, if the netdevice is not ready to receive them. Requeued packets are not part of the queue disc. The following identities hold:
dropped = dropped before enqueue + dropped after dequeuereceived = dropped before enqueue + enqueuedqueued = enqueued - dequeuedsent = dequeued - dropped after dequeue (- 1 if there is a requeued packet)
Separate counters are also kept for each possible reason to drop a packet. When a packet is dropped by an internal queue, e.g., because the queue is full, the reason is โDropped by internal queueโ. When a packet is dropped by a child queue disc, the reason is โ(Dropped by child queue disc) โ followed by the reason why the child queue disc dropped the packet. ๐ญ
The QueueDisc base class provides the SojournTime trace source, which provides the sojourn time of every packet dequeued from a queue disc, including packets that are dropped or requeued after being dequeued. The sojourn time is taken when the packet is dequeued from the queue disc, hence it does not account for the additional time the packet is retained within the queue disc in case it is requeued. โณ
๐ Design ๐
A C++ abstract base class, class QueueDisc, is subclassed to implement a specific queue disc. A subclass is required to implement the following methods:
bool DoEnqueue (Ptr<QueueDiscItem> item):Enqueue a packetPtr<QueueDiscItem> DoDequeue (void):Dequeue a packetbool CheckConfig (void) const:Check if the configuration is correctvoid InitializeParams (void):Initialize queue disc parameters
and may optionally override the default implementation of the following method:
Ptr<const QueueDiscItem> DoPeek (void) const:Peek the next packet to extract
okay so the default implementation of the DoPeek method is basically doing the same thing as the qdisc_peek_dequeued function over in the Linux kernel โ it dequeues a packet and then keeps it sitting in the queue disc as a requeued packet. Bestie, this approach is highly recommended, especially for queue discs where it's genuinely not obvious which packet is gonna be dequeued next (iykyk โ we're talking queue discs with multiple internal queues, or child queue discs, or queue discs that drop packets after dequeue). So unless the subclass goes and redefines the DoPeek method, calling Peek causes the next packet to be dequeued from the queue disc ๐
โ even though the packet is still considered to be part of the queue disc, and the dequeue trace is fired when Dequeue is called and the packet is actually extracted from the queue disc. periodt.
The C++ base class QueueDisc implements:
- methods to add/get a single queue, class or filter, plus methods to get the number of installed queues, classes or filters
- a
Classifymethod which classifies a packet by processing the list of filters until a filter able to classify the packet is found - methods to extract multiple packets from the queue disc, while handling transmission (to the device) failures by requeuing packets
The base class QueueDisc provides many trace sources, and no, we're not skipping any of them:
EnqueueDequeueRequeueDropMarkPacketsInQueueBytesInQueue
The C++ base class QueueDisc holds the list of attached queues, classes and filter by means of three vectors accessible through attributes (InternalQueueList, QueueDiscClassList and PacketFilterList).
Internal queues are implemented as (subclasses of) Queue objects. A Queue stores QueueItem objects, which consist of just a Ptr<Packet>. Since a queue disc has to store at least the destination address and the protocol number for each enqueued packet, a new C++ class, QueueDiscItem, is derived from QueueItem to store such additional information for each packet. So internal queues are implemented as Queue objects storing QueueDiscItem objects. Also, there could be the need to store further information depending on the network layer protocol of the packet. For instance, for IPv4 and IPv6 packets it is needed to separately store the header and the payload, so that header fields can be manipulated, e.g., to support Explicit Congestion Notification as defined in RFC 3168. To this end, subclasses Ipv4QueueDiscItem and Ipv6QueueDiscItem are derived from QueueDiscItem to additionally store the IP header and provide protocol specific operations such as ECN marking. slay โจ
Classes (in the Linux sense of the term) are implemented via the QueueDiscClass class, which consists of a pointer to the attached queue disc. Such a pointer is accessible through the QueueDisc attribute. Classful queue discs needing to set parameters for their classes can subclass QueueDiscClass and add the required parameters as attributes.
An abstract base class, PacketFilter, is subclassed to implement specific filters. Subclasses are required to implement two virtual private pure methods:
bool CheckProtocol (Ptr<QueueDiscItem> item) const: check whether the filter is able to classify packets of the same protocol as the given packetint32_t DoClassify (Ptr<QueueDiscItem> item) const: actually classify the packet
PacketFilter provides a public method, Classify, which first calls CheckProtocol to check that the protocol of the packet matches the protocol of the filter and then calls DoClassify. Specific filters subclassed from PacketFilter should not be placed in the traffic-control module but in the module corresponding to the protocol of the classified packets. ๐
๐ธ Usage ๐ธ
The traffic control layer is automatically created and inserted on an ns3::Node object when typical device and internet module helpers are used. By default, the InternetStackHelper::Install() method aggregates a TrafficControlLayer object to every node. When invoked to assign an IPv{4,6} address to a device, the Ipv{4,6}AddressHelper, besides creating an Ipv{4,6}Interface, also installs the default qdisc on the device โ unless a queue disc has been already installed. For single-queue NetDevices (such as PointToPoint, Csma and Simple), the default root qdisc is FqCoDel. For multi-queue NetDevices (such as Wifi), the default root qdisc is Mq with as many FqCoDel child qdiscs as the number of device queues. ๐
To install a queue disc other than the default one, it is necessary to install such queue disc before an IP address is assigned to the device. Alternatively, the default queue disc can be removed from the device after assigning an IP address, by using the Uninstall method of the TrafficControlHelper C++ class, and then installing a different queue disc on the device. By uninstalling without adding a new queue disc, it is also possible to have no queue disc installed on a device.
๐ Helpers ๐
A typical usage pattern is to create a traffic control helper and to configure type and attributes of queue discs, queues, classes and filters from the helper. For example, the pfifo_fast can be configured as follows:
TrafficControlHelper tch;
uint16_t handle = tch.SetRootQueueDisc ("ns3::PfifoFastQueueDisc");
tch.AddInternalQueues (handle, 3, "ns3::DropTailQueue", "MaxSize", StringValue ("1000p"));
QueueDiscContainer qdiscs = tch.Install (devices);
The above code adds three internal queues to the root queue disc of type PfifoFast. With the above configuration, the config path of the root queue disc installed on the j-th device of the i-th node (the index of a device is the same as in DeviceList) is:
/NodeList/[i]/$ns3::TrafficControlLayer/RootQueueDiscList/[j]
and the config path of the second internal queue is:
/NodeList/[i]/$ns3::TrafficControlLayer/RootQueueDiscList/[j]/InternalQueueList/1
For this helper's configuration to take effect, it should be added to the ns-3 program after InternetStackHelper::Install() is called, but before IP addresses are configured using Ipv{4,6}AddressHelper. don't mess up the order bestie, it's giving sequence matters ๐ฆ
โจ Implementation details โจ
In Linux, the struct netdev_queue is used to store information about a single transmission queue of a device: status (i.e., whether it has been stopped or not), data used by techniques such as Byte Queue Limits and a qdisc pointer field that is mainly used to solve the following problems:
- if a device transmission queue is (almost) empty, identify the queue disc to wake
- if a packet will be enqueued in a given device transmission queue, identify the queue disc which the packet must be enqueued into
The latter problem arises because Linux attempts to determine the device transmission queue which a packet will be enqueued into before passing the packet to a queue disc. This is done by calling a specific function of the device driver, if implemented, or by employing fallback mechanisms (such as hashing of the addresses) otherwise. The identifier of the selected device transmission queue is stored in the queue_mapping field of the struct sk_buff, so that both the queue disc and the device driver can get the same information. In ns-3, such identifier is stored in a member of the QueueDiscItem class. ๐
The NetDeviceQueue class in ns-3 is the equivalent of the Linux struct netdev_queue. The qdisc field of the Linux struct netdev_queue, however, cannot be similarly stored in a NetDeviceQueue object, because it would make the network module depend on the traffic-control module. Instead, this information is stored in the TrafficControlLayer object aggregated to each node. In particular, a TrafficControlLayer object holds a struct NetDeviceInfo which stores, for each NetDevice, a pointer to the root queue disc installed on the device, a pointer to the netdevice queue interface (see below) aggregated to the device, and a vector of pointers (one for each device transmission queue) to the queue discs to activate when the above problems occur. The traffic control layer takes care of configuring such a vector at initialization time, based on the "wake mode" of the root queue disc. If the wake mode of the root queue disc is WAKE_ROOT, then all the elements of the vector are pointers to the root queue disc. If the wake mode of the root queue disc is WAKE_CHILD, then each element of the vector is a pointer to a distinct child queue disc. This requires that the number of child queue discs matches the number of netdevice queues. It follows that the wake mode of a classless queue disc must necessarily be WAKE_ROOT. These two configurations are illustrated by the figures below. ๐
Setup of a queue disc (wake mode: WAKE_ROOT) below shows how the TrafficControlLayer map looks like in case of a classful root queue disc whose wake mode is WAKE_ROOT.
[image] Setup of a queue disc (wake mode: WAKE_ROOT).
Setup of a multi-queue aware queue disc below shows instead how the TrafficControlLayer map looks like in case of a classful root queue disc whose wake mode is WAKE_CHILD.
[image] Setup of a multi-queue aware queue disc.
A NetDeviceQueueInterface object is used by the traffic control layer to access the information stored in the NetDeviceQueue objects, retrieve the number of transmission queues of the device and get the transmission queue selected for the transmission of a given packet. A NetDeviceQueueInterface object must be therefore aggregated to all the devices having an interface supporting the traffic control layer (i.e., an IPv4 or IPv6 interface). In particular:
- a
NetDeviceQueueInterfaceobject is aggregated to all the devices by the NetDevice helper classes, atInstalltime. See, for example, the implementation in the methodCsmaHelper::InstallPriv(). - when notified that a netdevice queue interface has been aggregated, traffic control aware devices can cache the pointer to the netdevice queue interface created by the traffic control layer into a member variable. Also, multi-queue devices can set the number of device transmission queues and set the select queue callback through the netdevice queue interface
- at initialization time, the traffic control (after calling
device->Initialize ()to ensure that the netdevice has set the number of device transmission queues, if it has to do so) completes the installation of the queue discs by setting the wake callbacks on the device transmission queues (through the netdevice queue interface). Also, the traffic control calls theInitializemethod of the root queue discs. This initialization of queue discs triggers calls to theCheckConfigandInitializeParamsmethods of the queue disc. ๐ซถ
๐ Requeue
okay so, bestie, real talk: in Linux a packet that's already been dequeued from a queue disc can get requeued โ meaning it's stashed somewhere and sent to the device later on. It happens in a few specific circumstances and the lore goes like this ๐
First up: the function that dequeues a packet, dequeue_skb, only actually dequeues a packet if the device is multi-queue or the (unique) device queue is not stopped. If a packet has been dequeued from the queue disc, it gets handed to the sch_direct_xmit function to be transmitted to the device. That function checks whether the device queue the packet is destined to is stopped โ and if it is, the packet gets requeued. Otherwise it goes to the device. And if the device returns NETDEV_TX_BUSY, the packet is requeued too.
โ ๏ธ heads up: it's advised that the function called to send a packet to the device (ndo_start_xmit) should always returnNETDEV_TX_OKโ that means the packet is consumed by the device driver and doesn't need requeuing. Thendo_start_xmitfunction of the device driver is allowed to returnNETDEV_TX_BUSY(and therefore get the packet requeued) when there's no room for the received packet in the device queue even though the queue isn't stopped. That case is considered a corner case or a hard error, and you should avoid it. fr fr. ๐
ns-3 implements the requeue mechanism in a similar way, and the only difference is that packets are not requeued when those corner cases happen. Basically: the method used to dequeue a packet (QueueDisc::DequeuePacket) actually dequeues a packet only if the device is multi-queue or the (unique) device queue is not stopped. If a packet has been dequeued from the queue disc, it's passed to the QueueDisc::Transmit method for transmission to the device. That method checks whether the device queue the packet is destined to is stopped, and if it is, the packet is requeued. Otherwise it's sent to the device.
We request netdevices to stop a device queue when it's not able to store another packet, so we avoid the situation where a packet arrives that can't be enqueued while the device queue isn't stopped. Should that corner case still occur, the netdevice drops the packet โ but unlike Linux, the value returned by NetDevice::Send is ignored and the packet is not requeued. ๐
The way the requeue mechanism is implemented in ns-3 has the following implications:
- if the underlying device has a single queue, no packet will ever be requeued. Indeed, if the device queue is not stopped when
QueueDisc::DequeuePacketis called, it will not be stopped also whenQueueDisc::Transmitis called, hence the packet is not requeued (recall that a packet is not requeued after being sent to the device, as the value returned byNetDevice::Sendis ignored). - if the underlying device does not implement flow control, i.e., it does not stop its queue(s), no packet will ever be requeued (recall that a packet is only requeued by
QueueDisc::Transmitwhen the device queue the packet is destined to is stopped)
It turns out that packets may only be requeued when the underlying device is multi-queue and supports flow control. that's the vibe check โ
๐ Fifo queue disc
Model Description
FifoQueueDisc implements the FIFO (First-In First-Out) policy, periodt. Packets are enqueued in the unique internal queue, which is implemented as a DropTail queue. The queue disc capacity can be specified in terms of either packets or bytes, depending on the value of the Mode attribute. โจ
The user is allowed to provide an internal queue before the queue disc is initialized. If no internal queue is provided, one DropTail queue having the same capacity of the queue disc is created by default. And no packet filter can be added to a FifoQueueDisc. ๐ซ
Attributes
The FifoQueueDisc class holds the following attribute:
MaxSizeโ The maximum number of packets/bytes the queue disc can hold. The default value is1000packets.
Validation
The fifo model is tested using the FifoQueueDiscTestSuite class defined in src/traffic-control/test/fifo-queue-disc-test-suite.cc. The test aims to check that the capacity of the queue disc is not exceeded and that packets are dequeued in the correct order. slay ๐ฅ
๐ pfifo_fast queue disc
Model Description
PfifoFastQueueDisc behaves like pfifo_fast, which is the default queue disc enabled on Linux systems (init systems such as systemd may override such default setting ๐). Packets are enqueued in three priority bands (implemented as FIFO droptail queues) based on their priority โ users can read Socket-options for details on how to set packet priority. The four least significant bits of the priority are used to determine the selected band according to the following table:
โโโโโโโโโโโโโโโโโโฌโโโโโโโ
โ Priority & 0xf โ Band โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 0 โ 1 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 1 โ 2 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 2 โ 2 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 3 โ 2 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 4 โ 1 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 5 โ 2 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 6 โ 0 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 7 โ 0 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 8 โ 1 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 9 โ 1 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 10 โ 1 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 11 โ 1 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 12 โ 1 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 13 โ 1 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 14 โ 1 โ
โโโโโโโโโโโโโโโโโโผโโโโโโโค
โ 15 โ 1 โ
โโโโโโโโโโโโโโโโโโดโโโโโโโ
The system behaves similar to three ns3::DropTail queues operating together, in which packets from higher priority bands are always dequeued before a packet from a lower priority band is dequeued. it's giving very "line up by importance" energy ๐
The queue disc capacity โ i.e., the maximum number of packets that can be enqueued in the queue disc โ is set through the MaxSize attribute, which plays the same role as txqueuelen in Linux. If no internal queue is provided, three DropTail queues having each a capacity equal to MaxSize are created by default. The user is allowed to provide queues, but they must be three, must operate in packet mode, and each must have a capacity not less than MaxSize. No packet filter can be added to a PfifoFastQueueDisc. ๐
Attributes
The PfifoFastQueueDisc class holds a single attribute:
MaxSizeโ The maximum number of packets accepted by the queue disc. The default value is1000.
Examples
Various examples located in src/traffic-control/examples (e.g., codel-vs-pfifo-asymmetric.cc) show how to configure and install a PfifoFastQueueDisc on internet nodes. go look, it's iconic ๐
Validation
The pfifo_fast model is tested using the PfifoFastQueueDiscTestSuite class defined in src/test/ns3tc/pfifo-fast-queue-disc-test-suite.cc. The suite includes 4 test cases:
- Test 1 โ The first test checks whether IPv4 packets are enqueued in the correct band based on the TOS byte
- Test 2 โ The second test checks whether IPv4 packets are enqueued in the correct band based on the TOS byte
- Test 3 โ The third test checks that the queue disc cannot enqueue more packets than its limit
- Test 4 โ The fourth test checks that packets that the filters have not been able to classify are enqueued into the default band of
1
๐ Prio queue disc
Model Description
PrioQueueDisc implements a strict priority policy, where packets are dequeued from a band only if higher priority bands are all empty. PrioQueueDisc is a classful queue disc and can have an arbitrary number of bands, each of which is handled by a queue disc of any kind. Its capacity is not limited; packets can only be dropped by child queue discs (which may have a limited capacity). ๐
If no packet filter is installed or able to classify a packet, then the packet is enqueued into a priority band based on its priority (modulo 16), which is used as an index into an array called priomap. Users can read Socket-options for details on how to set the packet priority. If a packet is classified by an installed packet filter and the returned value i is non-negative and less than the number of priority bands, then the packet is enqueued into the i-th priority band. Otherwise, the packet is enqueued into the priority band specified by the first element of the priomap array. ๐ฆ
If no queue disc class is added by the user before the queue disc is initialized, three child queue discs of type FifoQueueDisc are automatically added. It has to be noted that PrioQueueDisc needs at least two child queue discs. no cap ๐ฏ
Attributes
The PrioQueueDisc class holds the following attribute:
Priomapโ The priority to band mapping. The default value is the same mapping as the (fixed) one used byPfifoFastQueueDisc.
Examples
An example of how to configure PrioQueueDisc with custom child queue discs and priomap is provided by queue-discs-benchmark.cc located in examples/traffic-control:
TrafficControlHelper tch;
uint16_t handle = tch.SetRootQueueDisc ("ns3::PrioQueueDisc", "Priomap", StringValue ("0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1"));
TrafficControlHelper::ClassIdList cid = tch.AddQueueDiscClasses (handle, 2, "ns3::QueueDiscClass");
tch.AddChildQueueDisc (handle, cid[0], "ns3::FifoQueueDisc");
tch.AddChildQueueDisc (handle, cid[1], "ns3::RedQueueDisc");
okay so bestie, look at what that snippet just did ๐
it adds two classes (bands) to a PrioQueueDisc. The highest priority one is a FifoQueueDisc, the other one is a RedQueueDisc. The attribute Priomap is set to an array containing only 0 and 1 (because PrioQueueDisc only has two bands, that's the whole reason, periodt).
โ Validation โ
PrioQueueDisc is tested using PrioQueueDiscTestSuite class defined in src/traffic-control/test/prio-queue-disc-test-suite.cc. The test is out here checking that: i) packets are enqueued in the correct band based on their priority and the priomap or according to the value returned by the installed packet filter; ii) packets are dequeued in the correct order. iconic behavior honestly ๐
You can run the test suite with these commands:
$ ./waf configure --enable-examples --enable-tests
$ ./waf build
$ ./test.py -s prio-queue-disc
or
$ NS_LOG="PrioQueueDisc" ./waf --run "test-runner --suite=prio-queue-disc"
๐ TBF queue disc ๐
This chapter describes the TBF ([Ref1]) queue disc implementation in ns-3. The TBF model in ns-3 is ported based on Linux kernel code implemented by A. Kuznetsov and D. Torokhov. no cap, that's the lineage
TBF is a qdisc that allows controlling the bandwidth of the output according to a set rate, with the possibility of managing burst conditions also. The TBF implementation consists of a bucket (buffer) having a limited capacity into which tokens (normally representing a unit of bytes or a single packet of predetermined size) are added at a fixed rate โrโ called the token rate. Whenever a packet arrives into the tx queue (fifo by default), the bucket is checked to see if there are appropriate number of tokens that is equivalent to the length of the packet in bytes. If yes, then the tokens are removed and the packet is passed for transmission. If no, then packets will have to wait until there are sufficient tokens in the bucket. This data conformance can be thus put into three possible scenarios [Ref3]:
- Data rate = Token rate : Packets pass without delay. easy, breezy ๐ฆ
- Data rate < Token rate : The tokens might accumulate and the bucket might become full. Then, the next packets to enter TBF will be transmitted right away without having any limit applied to them, until the bucket is empty. This is called a burst condition and in TBF the burst parameter defines the size of the bucket. In order to overcome this problem and provide better control over the bursts, TBF implements a second bucket which is smaller and generally the same size as the MTU. This second bucket cannot store large amount of tokens, but its replenishing rate will be a lot faster than the one of the big bucket. This second rate is called โpeakRateโ and it will determine the maximum rate of a burst.
- Data rate > Token rate : This causes the TBF algorithm to throttle itself for a while as soon as the bucket gets empty. This is called an โoverlimit situationโ [Ref2]. In this situation, some of the packets will be blocked until enough tokens are available at which time a schedule for the waking of the queue will be done. If packets keep coming in, at a larger rate, then the packets will start to get dropped when the total number of bytes exceeds the
QueueLimit. bestie they're getting DROPPED ๐ญ
๐ Model Description ๐
The TBF queue disc does not require packet filters, does not admit internal queues and uses a single child queue disc. If the user does not provide a child queue disc, a Fifo queue disc operating in the same mode (packet or byte) as the TBF queue disc and having a size equal to the TBF QueueLimit attribute is created. Otherwise, the capacity of the TBF queue disc is determined by the capacity of the child queue disc.
There are two token buckets: first bucket and second bucket. The size of the first bucket called โBurstโ should always be greater than the size of the second bucket called the Mtu (which is usually the size of a single packet). But the โPeakRateโ which is the second bucket's token rate should be always greater than the โRateโ which is the first bucket's token rate.
If the PeakRate is zero, then the second bucket does not exist. In order to activate the second bucket, both the Mtu and PeakRate values have to be greater than zero. If the Mtu value is zero at initialization time, then if a NetDevice exits, the Mtu's value will be equal to the Mtu of the NetDevice. But if no NetDevice exists, then the QueueDisc will complain thus prompting the user to set the Mtu value. so likeโฆ set your Mtu, bestie, or she WILL be complaining ๐
The source code for the TBF model is located in the directory src/traffic-control/model and consists of 2 files tbf-queue-disc.h and tbf-queue-disc.cc defining a TbfQueueDisc class.
- class
TbfQueueDisc: This class implements the main TBF algorithm:TbfQueueDisc::DoEnqueue (): This routine enqueue's the incoming packet if the queue is not full and drops the packet otherwise.TbfQueueDisc::DoPeek (): This routine peeks for the top item in the queue and if the queue is not empty, it returns the topmost item.TbfQueueDisc::DoDequeue (): This routine performs the dequeuing of packets according to the following logic:- It calls
TbfQueueDisc::Peek ()and calculates the size of the packet to be dequeued in bytes. - Then it calculates the time difference โdeltaโ, which is the time elapsed since the last update of tokens in the buckets.
- If the second bucket exists, the number of tokens are updated according to the โPeakRateโ and โdeltaโ.
- From this second bucket a number of tokens equal to the size of the packet to be dequeued is subtracted.
- Now the number of tokens in the first bucket are updated according to โRateโ and โdeltaโ.
- From this first bucket a number of tokens equal to the size of the packet to be dequeued is subtracted.
- If after this, both the first and second buckets have tokens greater than zero, then the packet is dequeued. โจ
- Else, an event to
QueueDisc::Run ()is scheduled after a time period when enough tokens will be present for the dequeue operation.
- It calls
๐ References ๐
[Ref1]
A. Kuznetsov and D. Torokhov; Linux Cross Reference Source Code; Available online at http://lxr.free-electrons.com/source/net/sched/sch_tbf.c.
[Ref2]
J. Vehent; Journey to the Center of the Linux Kernel: Traffic Control, Shaping and QoS; Available online at http://wiki.linuxwall.info/doku.php/en:resources:dossiers:networking:traffic_control#tbf_-_token_bucket_filter.
[Ref3]
Practical IP Network QoS: TBF queuing discipline; Available online at http://web.opalsoft.net/qos/default.php?p=ds-24.
โ๏ธ Attributes โ๏ธ
The key attributes that the TbfQueueDisc class holds include the following:
MaxSize: The maximum number of packets/bytes the queue disc can hold. The default value is1000packets.Burst: Size of the first bucket, in bytes. The default value is125000bytes.Mtu: Size of second bucket defaults to the MTU of the attachedNetDevice, if any, or0otherwise.Rate: Rate at which tokens enter the first bucket. The default value is125KB/s.PeakRate: Rate at which tokens enter the second bucket. The default value is0KB/s, which means that there is no second bucket.
๐ TraceSources ๐
The TbfQueueDisc class provides the following trace sources:
TokensInFirstBucket: Number of First Bucket Tokens in bytesTokensInSecondBucket: Number of Second Bucket Tokens in bytes
๐ Examples ๐
The example for TBF is tbf-example.cc located in examples/traffic-control/. The command to run the file (the invocation below shows the available command-line options) is:
.. sourcecode:: bash
$ ./waf โrun โtbf-example โPrintHelpโ $ ./waf โrun โtbf-example
โburst=125000 โrate=1Mbps โpeakRate=1.5Mbpsโ
The expected output from the previous commands are traced value changes in the number of tokens in the first and second buckets. watch those tokens wiggle, it's giving satisfying ๐
โ Validation โ
The TBF model is tested using TbfQueueDiscTestSuite class defined in src/traffic-control/test/tbf-queue-disc-test-suite.cc. The suite includes 4 test cases:
- Test 1: Simple Enqueue/Dequeue with verification of attribute setting and subtraction of tokens from the buckets.
- Test 2: When
DataRate == FirstBucketTokenRate; packets should pass smoothly. ๐ธ - Test 3: When
DataRate >>> FirstBucketTokenRate; some packets should get blocked and waking of queue should get scheduled. - Test 4: When
DataRate < FirstBucketTokenRate; burst condition,peakRateis set so that bursts are controlled.
The test suite can be run using the following commands:
.. sourcecode:: bash
$ ./waf configure โenable-examples โenable-tests $ ./waf build $
./test.py -s tbf-queue-disc
or
.. sourcecode:: bash
$ NS_LOG=โTbfQueueDiscโ ./waf โrun โtest-runner
โsuite=tbf-queue-discโ
๐ RED queue disc ๐
๐ Model Description ๐
Random Early Detection (RED) is a queue discipline that aims to provide early signals to transport protocol congestion control (e.g. TCP) that congestion is imminent, so that they back off their rate gracefully rather than with a bunch of tail-drop losses (possibly incurring TCP timeout). The model in ns-3 is a port of Sally Floyd's ns-2 RED model. queen behavior, she invented the vibe ๐
โ ๏ธ heads up bestie โ ๏ธ Note that, starting from ns-3.25, RED is no longer a queue variant and cannot be installed as a NetDevice queue. Instead, RED is a queue disc and must be installed in the context of the traffic control (see the examples mentioned below).
The RED queue disc does not require packet filters, does not admit child queue discs and uses a single internal queue. If not provided by the user, a DropTail queue operating in the same mode (packet or byte) as the queue disc and having a size equal to the RED MaxSize attribute is created. Otherwise, the capacity of the queue disc is determined by the capacity of the internal queue provided by the user.
๐ฆ Adaptive Random Early Detection (ARED) ๐ฆ
ARED is a variant of RED with two main features: (i) automatically sets Queue weight, MinTh and MaxTh and (ii) adapts maximum drop probability. The model in ns-3 contains implementation of both the features, and is a port of Sally Floyd's ns-2 ARED model. Note that the user is allowed to choose and explicitly configure the simulation by selecting feature (i) or feature (ii), or both. mix and match, it's your simulation, main character energy ๐
๐ธ Fengโs Adaptive RED ๐ธ
Fengโs Adaptive RED is a lil glow-up of RED that adapts the maximum drop probability ๐. The model in ns-3 has this feature implemented, and itโs a port of the ns-2 Fengโs Adaptive RED model. Periodt.
๐ Nonlinear Random Early Detection (NLRED) ๐
NLRED is a RED variant where the linear packet dropping function of RED gets swapped out for a nonlinear quadratic function โจ. The vibe? Packet dropping is gentler when the traffic load is light and way more aggressive when itโs heavy. Itโs giving very โจresponsiveโจ energy.
๐ Explicit Congestion Notification (ECN) ๐
This RED model supports an ECN mode of operation to notify endpoints that congestion might be developing in a bottleneck queue, all without resorting to packet drops ๐ซถ. You turn this mode on by setting the UseEcn attribute to true (itโs false by default, bestie), and it only affects incoming packets with the ECT bit set in their header.
When the average queue length is between the minimum and maximum thresholds, an incoming packet is marked instead of being dropped โจ. When the average queue length is above the maximum threshold, an incoming packet is marked (instead of dropped) only if the UseHardDrop attribute is set to false โ and heads up, itโs true by default ๐ญ.
The implementation of support for ECN marking is done in a way that does not impose an internet module dependency on the traffic control module. The RED model doesnโt directly set ECN bits on the header โ it delegates that job to the QueueDiscItem class ๐. As a result, itโs possible to use RED queues for other non-IP QueueDiscItems that may or may not support the Mark () method.
๐ References ๐
The RED queue disc aims to be close to the results cited in: S.Floyd, K.Fall http://icir.org/floyd/papers/redsims.ps
ARED queue implementation is based on the algorithm provided in: S. Floyd et al, http://www.icir.org/floyd/papers/adaptiveRed.pdf
Fengโs Adaptive RED queue implementation is based on the algorithm provided in: W. C. Feng et al, http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=752150
NLRED queue implementation is based on the algorithm provided in: Kaiyu Zhou et al, http://www.sciencedirect.com/science/article/pii/S1389128606000879
The addition of explicit congestion notification (ECN) to IP: K. K. Ramakrishnan et al, https://tools.ietf.org/html/rfc3168
โญ Attributes โญ
The RED queue contains a number of attributes that control the RED policies:
MaxSizeMeanPktSizeIdlePktSizeWait(time)GentlemodeMinTh,MaxTh- Queue weight
LIntermLinkBandwidthLinkDelayUseEcnUseHardDrop
In addition to RED attributes, the ARED queue requires the following attributes:
ARED(Boolean attribute. Default:false)AdaptMaxP(Boolean attribute to adaptm_curMaxP. Default:false)- Target Delay (time)
- Interval (time)
LastSet(time)Top(upper limit ofm_curMaxP)Bottom(lower limit ofm_curMaxP)Alpha(increment parameter form_curMaxP)Beta(decrement parameter form_curMaxP)RTT
In addition to RED attributes, Fengโs Adaptive RED queue requires the following attributes:
FengAdaptive(Boolean attribute, Default:false)Status(status of current queue length, Default:Above)FengAlpha(increment parameter form_curMaxP, Default:3)FengBeta(decrement parameter form_curMaxP, Default:2)
The following attribute should be turned on to simulate the NLRED queue disc:
NLRED(Boolean attribute. Default:false)
Consult the ns-3 documentation for explanation of these attributes ๐ซถ.
๐ฆ Simulating ARED ๐ฆ
To switch on the ARED algorithm, the ARED attribute must be set to true, as done in src/traffic-control/examples/adaptive-red-tests.cc:
Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true));
Setting ARED to true implicitly configures both: (i) automatic setting of Queue weight, MinTh and MaxTh and (ii) adapting m_curMaxP.
NOTE: To explicitly configure (i) or (ii), set theAREDattribute tofalseand follow the procedure described next:
To configure (i); Queue weight, MinTh and MaxTh, all must be set to 0, as done in src/traffic-control/examples/adaptive-red-tests.cc:
Config::SetDefault ("ns3::RedQueueDisc::QW", DoubleValue (0.0));
Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (0));
Config::SetDefault ("ns3::RedQueueDisc::MaxTh", DoubleValue (0));
To configure (ii); AdaptMaxP must be set to true, as done in src/traffic-control/examples/adaptive-red-tests.cc:
Config::SetDefault ("ns3::RedQueueDisc::AdaptMaxP", BooleanValue (true));
๐ Simulating Fengโs Adaptive RED ๐
To switch on Fengโs Adaptive RED algorithm, the FengAdaptive attribute must be set to true, as done in examples/traffic-control/red-vs-fengadaptive.cc:
Config::SetDefault ("ns3::RedQueueDisc::FengAdaptive", BooleanValue (true));
โจ Simulating NLRED โจ
To switch on the NLRED algorithm, the NLRED attribute must be set to true, as shown below:
Config::SetDefault ("ns3::RedQueueDisc::NLRED", BooleanValue (true));
๐ Examples ๐
The RED queue example is found at src/traffic-control/examples/red-tests.cc.
ARED queue examples can be found at: src/traffic-control/examples/adaptive-red-tests.cc and src/traffic-control/examples/red-vs-ared.cc
Fengโs Adaptive RED example can be found at: examples/traffic-control/red-vs-fengadaptive.cc
NLRED queue example can be found at: examples/traffic-control/red-vs-nlred.cc
๐ฅ Validation ๐ฅ
The RED model has been validated and the report is currently stored at: https://github.com/downloads/talau/ns-3-tcp-red/report-red-ns3.pdf
๐ CoDel queue disc ๐
This chapter describes the CoDel ([Nic12], [Nic14]) queue disc implementation in ns-3.
Developed by Kathleen Nichols and Van Jacobson as a solution to the bufferbloat [Buf14] problem, CoDel (Controlled Delay Management) is a queuing discipline that uses a packetโs sojourn time (time in queue, iykyk) to make decisions on packet drops ๐
.
Note that, starting from ns-3.25, CoDel is no longer a queue variant and cannot be installed as a NetDevice queue. Instead, CoDel is a queue disc and must be installed in the context of the traffic control (see the examples mentioned below).
๐ธ Model Description ๐ธ
The source code for the CoDel model is located in the directory src/traffic-control/model and consists of 2 files codel-queue-disc.h and codel-queue-disc.cc defining a CoDelQueueDisc class and a helper CoDelTimestampTag class. The code was ported to ns-3 by Andrew McGregor based on Linux kernel code implemented by Dave Tรคht and Eric Dumazet ๐ซถ.
- class
CoDelQueueDisc: This class implements the main CoDel algorithm:CoDelQueueDisc::DoEnqueue (): This routine tags a packet with the current time before pushing it into the queue. The timestamp tag is used byCoDelQueue::DoDequeue()to compute the packetโs sojourn time. If the queue is full upon the packet arrival, this routine will drop the packet and record the number of drops due to queue overflow, which is stored inm_dropOverLimit.CoDelQueueDisc::ShouldDrop (): This routine isCoDelQueueDisc::DoDequeue()โs helper routine that determines whether a packet should be dropped or not based on its sojourn time. If the sojourn time goes abovem_targetand remains above continuously for at leastm_interval, the routine returnstrueindicating that it is OK to drop the packet. Otherwise, it returnsfalse.CoDelQueueDisc::DoDequeue (): This routine performs the actual packet drop based onCoDelQueueDisc::ShouldDrop ()โs return value and schedules the next drop/mark.
- class
CoDelTimestampTag: This class implements the timestamp tagging for a packet. This tag is used to compute the packetโs sojourn time (the difference between the time the packet is dequeued and the time it is pushed into the queue).
There are 2 branches to CoDelQueueDisc::DoDequeue ():
- If the queue is currently in the dropping state, which means the sojourn time has remained above
m_targetfor more thanm_interval, the routine determines if itโs OK to leave the dropping state or itโs time for the next drop/mark. WhenCoDelQueueDisc::ShouldDrop ()returnsfalse, the queue can move out of the dropping state (setm_droppingtofalse). Otherwise, the queue continuously drops/marks packets and updates the time for next drop (m_dropNext) until one of the following conditions is met:- The queue is empty, upon which the queue leaves the dropping state and exits
CoDelQueueDisc::ShouldDrop ()routine; CoDelQueueDisc::ShouldDrop ()returnsfalse(meaning the sojourn time goes belowm_target) upon which the queue leaves the dropping state;- It is not yet time for next drop/mark (
m_dropNextis less than current time) upon which the queue waits for the next packet dequeue to check the condition again.
- The queue is empty, upon which the queue leaves the dropping state and exits
- If the queue is not in the dropping state, the routine enters the dropping state and drop/mark the first packet if
CoDelQueueDisc::ShouldDrop ()returnstrue(meaning the sojourn time has gone abovem_targetfor at leastm_intervalfor the first time or it has gone above again after the queue leaves the dropping state).
The CoDel queue disc does not require packet filters, does not admit child queue discs and uses a single internal queue ๐. If not provided by the user, a DropTail queue operating in the same mode (packet or byte) as the queue disc and having a size equal to the CoDel MaxSize attribute is created. Otherwise, the capacity of the queue disc is determined by the capacity of the internal queue provided by the user.
๐ References ๐
[Nic12]
K. Nichols and V. Jacobson, Controlling Queue Delay, ACM Queue, Vol. 10 No. 5, May 2012. Available online at http://queue.acm.org/detail.cfm?id=2209336.
[Nic14]
K. Nichols and V. Jacobson, Internet-Draft: Controlled Delay Active Queue Management, March 2014. Available online at http://tools.ietf.org/html/draft-nichols-tsvwg-codel-02.
[Buf14]
Bufferbloat.net. Available online at http://www.bufferbloat.net/.
๐ Attributes ๐
The key attributes that the CoDelQueue class holds include the following:
MaxSize: The maximum number of packets/bytes the queue can hold. The default value is1500 * DEFAULT_CODEL_LIMIT, which is1500 * 1000bytes.MinBytes: The CoDel algorithm minbytes parameter. The default value is1500bytes.Interval: The sliding-minimum window. The default value is100ms.Target: The CoDel algorithm target queue delay. The default value is5ms.UseEcnโ set this to True and ECN is on, meaning packets get marked instead of straight-up dropped. Default is false. ๐CeThresholdโ the CoDel CE threshold for marking packets. It's disabled by default, bestie, so don't come crying when nothing gets marked.
โจ Examples โจ
First up, the icon that is codel-vs-pfifo-basic-test.cc, chilling in src/traffic-control/examples. Wanna run it? (the first invocation below is literally just showing you the available command-line options, she's helpful like that):
$ ./waf --run "codel-vs-pfifo-basic-test --PrintHelp"
$ ./waf --run "codel-vs-pfifo-basic-test --queueType=CoDel --pcapFileName=codel.pcap --cwndTrFileName=cwndCodel.tr"
What you're supposed to get out of those commands is two files: a codel.pcap file and a cwndCoDel.tr (ASCII trace) file. And the .pcap file? You can analyze that with wireshark or tcptrace, no cap:
$ tcptrace -l -r -n -W codel.pcap
Second example, second serve: codel-vs-pfifo-asymmetric.cc, also in src/traffic-control/examples. This one is intended to model a typical cable modem deployment scenario ๐ฐ๏ธ. To run it:
$ ./waf --run "codel-vs-pfifo-asymmetric --PrintHelp"
$ ./waf --run codel-vs-pfifo-asymmetric
Expected output from those commands is six pcap files, and I need you to know them all by name:
codel-vs-pfifo-asymmetric-CoDel-server-lan.pcapcodel-vs-pfifo-asymmetric-CoDel-router-wan.pcapcodel-vs-pfifo-asymmetric-CoDel-router-lan.pcapcodel-vs-pfifo-asymmetric-CoDel-cmts-wan.pcapcodel-vs-pfifo-asymmetric-CoDel-cmts-lan.pcapcodel-vs-pfifo-asymmetric-CoDel-host-lan.pcap
One attribute file:
codel-vs-pfifo-asymmetric-CoDel.attr
Five ASCII trace files:
codel-vs-pfifo-asymmetric-CoDel-drop.trcodel-vs-pfifo-asymmetric-CoDel-drop-state.trcodel-vs-pfifo-asymmetric-CoDel-sojourn.trcodel-vs-pfifo-asymmetric-CoDel-length.trcodel-vs-pfifo-asymmetric-CoDel-cwnd.tr
๐ธ Validation ๐ธ
The CoDel model gets tested using the CoDelQueueDiscTestSuite class defined in src/traffic-control/test/codel-queue-test-suite.cc. The suite includes 5 test cases (yes she says 5 and then lists 6, the queen contains multitudes, we simply do not question her ๐
):
- Test 1: checks the enqueue/dequeue with no drops and makes sure that CoDel attributes can be set correctly. โจ
- Test 2: checks the enqueue with drops due to queue overflow. ๐
- Test 3: checks the
NewtonStep()arithmetic against explicit port of Linux implementation. - Test 4: checks the
ControlLaw()against explicit port of Linux implementation. - Test 5: checks the enqueue/dequeue with drops according to CoDel algorithm.
- Test 6: checks the enqueue/dequeue with marks according to CoDel algorithm. ๐
Run the whole suite like this:
$ ./waf configure --enable-examples --enable-tests
$ ./waf build
$ ./test.py -s codel-queue-disc
or, the alt route:
$ NS_LOG="CoDelQueueDisc" ./waf --run "test-runner --suite=codel-queue-disc"
๐ FqCoDel queue disc ๐
This chapter describes the FqCoDel ([Hoe16]) queue disc implementation in ns-3.
The FlowQueue-CoDel (FQ-CoDel) algorithm is a combined packet scheduler and Active Queue Management (AQM) algorithm, developed as part of the bufferbloat-fighting community effort ([Buf16]). FqCoDel classifies incoming packets into different queues (by default, 1024 queues are created, iconic honestly), and those queues are served according to a modified Deficit Round Robin (DRR) queue scheduler. Each queue is managed by the CoDel AQM algorithm. FqCoDel distinguishes between "new" queues (which don't build up a standing queue) and "old" queues, that have queued enough data to be around for more than one iteration of the round-robin scheduler. It's giving very organized. ๐ฆ
FqCoDel is installed by default on single-queue NetDevices (such as PointToPoint, Csma and Simple). Also, on multi-queue devices (such as Wifi), the default root qdisc is Mq with as many FqCoDel child queue discs as the number of device queues. Slay.
๐ Model Description ๐
The source code for the FqCoDel queue disc lives in the directory src/traffic-control/model and consists of 2 files, fq-codel-queue-disc.h and fq-codel-queue-disc.cc, defining a FqCoDelQueueDisc class and a helper FqCoDelFlow class. The code was ported to ns-3 based on Linux kernel code implemented by Eric Dumazet. Set associative hashing is also based on the Linux kernel CAKE queue management code. Set associative hashing is used to reduce the number of hash collisions in comparison to choosing queues normally with a simple hash. For a given number of queues, set associative hashing has fewer collisions than a traditional hash, as long as the number of flows is lesser than the number of queues. Essentially, it makes the queue management system more efficient. Set associative hashing is a vital component of CAKE, which is another popular flow management algorithm that is implemented in Linux and is being tested for FqCoDel. Furthermore, this module can be directly used with CAKE when its other components are implemented in ns-3. The only changes needed to incorporate this new hashing scheme are in the SetAssociativeHash and DoEnqueue methods, as described below. ๐
- class
FqCoDelQueueDisc: This class implements the main FqCoDel algorithm:FqCoDelQueueDisc::DoEnqueue (): If no packet filter has been configured, this routine calls theQueueDiscItem::Hash()method to classify the given packet into an appropriate queue. Otherwise, the configured filters are used to classify the packet. If the filters are unable to classify the packet, the packet is dropped ๐ญ. Otherwise, an option is provided if set associative hashing is to be used. The packet is now handed over to the CoDel algorithm for timestamping. Then, if the queue is not currently active (i.e., if it is not in either the list of new or the list of old queues), it is added to the end of the list of new queues, and its deficit is initiated to the configured quantum. Otherwise, the queue is left in its current queue list. Finally, the total number of enqueued packets is compared with the configured limit, and if it is above this value (which can happen since a packet was just enqueued), packets are dropped from the head of the queue with the largest current byte count until the number of dropped packets reaches the configured drop batch size or the backlog of the queue has been halved. Note that this in most cases means that the packet that was just enqueued is not among the packets that get dropped, which may even be from a different queue. Sneaky. ๐FqCoDelQueueDisc::SetAssociativeHash(): An outer hash is identified for the given packet. This corresponds to the set into which the packet is to be enqueued. A set consists of a group of queues. The set determined by outer hash is enumerated; if a queue corresponding to this packet's flow is found (we use per-queue tags to achieve this), or in case of an inactive queue, or if a new queue can be created for this set without exceeding the maximum limit, the index of this queue is returned. Otherwise, all queues of this full set are active and correspond to flows different from the current packet's flow. In such cases, the index of first queue of this set is returned. We don't consider creating new queues for the packet in these cases, since this approach may waste resources in the long run. The situation highlighted is a guaranteed collision and cannot be avoided without increasing the overall number of queues. It's giving tragedy but make it efficient. ๐FqCoDelQueueDisc::DoDequeue (): The first task performed by this routine is selecting a queue from which to dequeue a packet. To this end, the scheduler first looks at the list of new queues; for the queue at the head of that list, if that queue has a negative deficit (i.e., it has already dequeued at least a quantum of bytes), it is given an additional amount of deficit, the queue is put onto the end of the list of old queues, and the routine selects the next queue and starts again. Otherwise, that queue is selected for dequeue. If the list of new queues is empty, the scheduler proceeds down the list of old queues in the same fashion (checking the deficit, and either selecting the queue for dequeuing, or increasing deficit and putting the queue back at the end of the list). After having selected a queue from which to dequeue a packet, the CoDel algorithm is invoked on that queue. As a result of this, one or more packets may be discarded from the head of the selected queue, before the packet that should be dequeued is returned (or nothing is returned if the queue is or becomes empty while being handled by the CoDel algorithm). Finally, if the CoDel algorithm does not return a packet, then the queue must be empty, and the scheduler does one of two things: if the queue selected for dequeue came from the list of new queues, it is moved to the end of the list of old queues. If instead it came from the list of old queues, that queue is removed from the list, to be added back (as a new queue) the next time a packet for that queue arrives. Then (since no packet was available for dequeue), the whole dequeue process is restarted from the beginning. If, instead, the scheduler did get a packet back from the CoDel algorithm, it subtracts the size of the packet from the byte deficit for the selected queue and returns the packet as the result of the dequeue operation. Round and round we go, main character energy forever. ๐ฅFqCoDelQueueDisc::FqCoDelDrop (): This routine is invoked byFqCoDelQueueDisc::DoEnqueue()to drop packets from the head of the queue with the largest current byte count. This routine keeps dropping packets until the number of dropped packets reaches the configured drop batch size or the backlog of the queue has been halved.
- class
FqCoDelFlow: This class implements a flow queue, by keeping its current status (whether it is in the list of new queues, in the list of old queues or inactive) and its current deficit. Just vibes and a number, honestly. ๐ซถ
In Linux, by default, packet classification is done by hashing (using a Jenkins hash function) the 5-tuple of IP protocol, source and destination IP addresses and port numbers (if they exist). This value modulo the number of queues is salted by a random value selected at initialization time, to prevent possible DoS attacks if the hash is predictable ahead of time. Alternatively, any other packet filter can be configured. In ns-3, packet classification is performed in the same way as in Linux. Neither internal queues nor classes can be configured for an FqCoDel queue disc. Periodt. ๐
โจ Possible next steps โจ
- what to do if ECT(1) and either/both ECT(0) and NotECT are in the same flow queue (hash collisions or tunnels)โ our L4S traffic flows will avoid this situation by supporting AccECN and ECN++ (and if it happens in practice, the CoDel logic will just apply two separate thresholds)
- adding a ramp marking response instead of step threshold
- adding a floor value (to suppress marks if the queue length is below a certain number of bytes or packets)
- adding a heuristic such as in PIE to avoid marking a packet if it arrived to an empty flow queue (check on ingress, remember at egress time)
๐ References ๐
[Hoe16]
T. Hoeiland-Joergensen, P. McKenney, D. Taht, J. Gettys and E. Dumazet, The FlowQueue-CoDel Packet Scheduler and Active Queue Management Algorithm, IETF draft. Available online at https://tools.ietf.org/html/draft-ietf-aqm-fq-codel
[Buf16]
Bufferbloat.net. Available online at http://www.bufferbloat.net/.
๐ Attributes ๐
The key attributes that the FqCoDelQueue class holds include the following:
UseEcnโ True to use ECN (packets are marked instead of being dropped)Intervalโ The interval parameter to be used on the CoDel queues. The default value is100 ms.Targetโ The target parameter to be used on the CoDel queues. The default value is5 ms.MaxSizeโ The limit on the maximum number of packets stored by FqCoDel.Flowsโ The number of flow queues managed by FqCoDel.DropBatchSizeโ The maximum number of packets dropped from the fat flow.Perturbationโ The salt used as an additional input to the hash function used to classify packets.CeThresholdโ The FqCoDel CE threshold for marking packetsUseL4sโ True to use L4S (only ECT1 packets are marked at CE threshold)EnableSetAssociativeHashโ The parameter used to enable set associative hash.
Perturbation is an optional configuration attribute and can be used to generate different hash outcomes for different inputs. For instance, the tuples used as input to the hash may cause hash collisions (mapping to the same bucket) for a given set of inputs, but by changing the perturbation value, the same hash inputs now map to distinct buckets.
Note that the quantum, i.e., the number of bytes each queue gets to dequeue on each round of the scheduling algorithm, is set by default to the MTU size of the device (at initialisation time). The FqCoDelQueueDisc::SetQuantum () method can be used (at any time) to configure a different value.
๐ Examples ๐
A typical usage pattern is to create a traffic control helper and to configure type and attributes of queue disc and filters from the helper. For example, FqCodel can be configured as follows:
TrafficControlHelper tch;
tch.SetRootQueueDisc ("ns3::FqCoDelQueueDisc", "DropBatchSize", UintegerValue (1)
"Perturbation", UintegerValue (256));
QueueDiscContainer qdiscs = tch.Install (devices);
The example for FqCoDel's L4S mode is FqCoDel-L4S-example.cc located in src/traffic-control/examples. To run the file (the first invocation below shows the available command-line options):
$ ./waf --run "FqCoDel-L4S-example --PrintHelp"
$ ./waf --run "FqCoDel-L4S-example --scenarioNum=5"
The expected output from the previous command are .dat files. slay.
๐ธ Validation ๐ธ
The FqCoDel model is tested using FqCoDelQueueDiscTestSuite class defined in src/test/ns3tc/codel-queue-test-suite.cc. The suite includes 5 test cases:
- Test 1: The first test checks that packets that cannot be classified by any available filter are dropped.
- Test 2: The second test checks that IPv4 packets having distinct destination addresses are enqueued into different flow queues. Also, it checks that packets are dropped from the fat flow in case the queue disc capacity is exceeded.
- Test 3: The third test checks the dequeue operation and the deficit round robin-based scheduler.
- Test 4: The fourth test checks that TCP packets with distinct port numbers are enqueued into different flow queues.
- Test 5: The fifth test checks that UDP packets with distinct port numbers are enqueued into different flow queues.
- Test 6: The sixth test checks that the packets are marked correctly.
- Test 7: The seventh test checks the working of set associative hashing and its linear probing capabilities by using TCP packets with different hashes enqueued into different sets and queues.
- Test 8: The eighth test checks the L4S mode of FqCoDel where ECT1 packets are marked at CE threshold (target delay does not matter) while ECT0 packets continue to be marked at target delay (CE threshold does not matter).
okay so it says 5 test cases and then hands us 8 โ we're not going to argue with the doc, we're just going to run them all bestie ๐
The test suite can be run using the following commands:
$ ./waf configure --enable-examples --enable-tests
$ ./waf build
$ ./test.py -s fq-codel-queue-disc
or:
$ NS_LOG="FqCoDelQueueDisc" ./waf --run "test-runner --suite=fq-codel-queue-disc"
Set associative hashing is tested by generating a probability collision graph. This graph is then overlapped with the theoretical graph provided in the original CAKE paper (refer to Figure 1 from CAKE). The generated graph is linked below: [image: Generated Collision Probability Graph] [image]
The overlapped graph is also linked below: [image: Overlapped Image with the graph from CAKE paper] [image]
The steps to replicate this graph are available on this link.
๐ Cobalt queue disc ๐
This chapter describes the COBALT (CoDel BLUE Alternate) ([Cake16]) queue disc implementation in ns-3.
COBALT queue disc is an integral component of CAKE smart queue management system. It is a combination of the CoDel ([Kath17]) and BLUE ([BLUE02]) Active Queue Management algorithms. iconic combo fr.
๐ฆ Model Description ๐ฆ
The source code for the COBALT model is located in the directory src/traffic-control/model and consists of 2 files: cobalt-queue-disc.h and cobalt-queue-disc.cc defining a CobaltQueueDisc class and a helper CobaltTimestampTag class. The code was ported to ns-3 by Vignesh Kanan, Harsh Lara, Shefali Gupta, Jendaipou Palmei and Mohit P. Tahiliani based on the Linux kernel code.
Stefano Avallone and Pasquale Imputato helped in verifying the correctness of COBALT model in ns-3 by comparing the results obtained from it to those obtained from the Linux model of COBALT. A detailed comparison of ns-3 model of COBALT with Linux model of COBALT is provided in ([Cobalt19]).
class CobaltQueueDisc: This class implements the main Cobalt algorithm:CobaltQueueDisc::DoEnqueue (): This routine tags a packet with the current time before pushing it into the queue. The timestamp tag is used byCobaltQueue::DoDequeue()to compute the packet's sojourn time. If the queue is full upon the packet arrival, this routine will drop the packet and record the number of drops due to queue overflow, which is stored inm_stats.qLimDrop.CobaltQueueDisc::ShouldDrop (): This routine isCobaltQueueDisc::DoDequeue()'s helper routine that determines whether a packet should be dropped or not based on its sojourn time. If L4S mode is enabled then if the packet is ECT1 is checked and if delay is greater than CE threshold then the packet is marked and returnsfalse. If the sojourn time goes abovem_targetand remains above continuously for at leastm_interval, the routine returnstrueindicating that it is OK to drop the packet. Otherwise, it returnsfalse. If L4S mode is turned off and CE threshold marking is enabled, then if the delay is greater than CE threshold, packet is marked. This routine decides if a packet should be dropped based on the dropping state of CoDel and drop probability of BLUE. The idea is to have both algorithms running in parallel and their effectiveness is decided by their respective parameters (Pdrop of BLUE and dropping state of CoDel). If either of them decide to drop the packet, the packet is dropped.CobaltQueueDisc::DoDequeue (): This routine performs the actual packet drop based onCobaltQueueDisc::ShouldDrop ()'s return value and schedules the next drop. Cobalt will decrease BLUE's drop probability if the queue is empty. This will ensure that the queue does not underflow. Otherwise Cobalt will take the next packet from the queue and calculate its drop state by running CoDel and BLUE in parallel till there are none left to drop.
๐ References ๐
[Cake16]
Linux implementation of Cobalt as a part of the cake framework. Available online at https://github.com/dtaht/sch_cake/blob/master/cobalt.c.
[Kath17]
Controlled Delay Active Queue Management (draft-ietf-aqm-fq-codel-07) Available online at https://tools.ietf.org/html/draft-ietf-aqm-codel-07.
[BLUE02]
Feng, W. C., Shin, K. G., Kandlur, D. D., & Saha, D. (2002). The BLUE Active Queue Management Algorithms. IEEE/ACM Transactions on Networking (ToN), 10(4), 513-528.
[Cobalt19]
Jendaipou Palmei, Shefali Gupta, Pasquale Imputato, Jonathan Morton, Mohit P. Tahiliani, Stefano Avallone and Dave Taht (2019). Design and Evaluation of COBALT Queue Discipline. IEEE International Symposium on Local and Metropolitan Area Networks (LANMAN), July 2019.
๐ Attributes ๐
The key attributes that the CobaltQueue Disc class holds include the following:
MaxSizeโ The maximum number of packets/bytes accepted by this queue disc.Intervalโ The sliding-minimum window. The default value is100 ms.Targetโ The Cobalt algorithm target queue delay. The default value is5 ms.Pdropโ Value of drop probability.Incrementโ Increment value of drop probability. Default value is1./256.Decrementโ Decrement value of drop probability. Default value is1./4096.CeThresholdโ The CoDel CE threshold for marking packets.UseL4sโ True to use L4S (only ECT1 packets are marked at CE threshold).Countโ Cobalt count.DropStateโ Dropping state of Cobalt. Default value isfalse.Sojournโ Per packet time spent in the queue.DropNextโ Time until next packet drop.
๐ Examples ๐
An example program named cobalt-vs-codel.cc is located in src/traffic-control/examples. Use the following command to run the program.
$ ./waf --run cobalt-vs-codel
๐ธ Validation ๐ธ
The COBALT model is tested using CobaltQueueDiscTestSuite class defined in src/traffic-control/test/cobalt-queue-test-suite.cc. The suite includes 2 test cases:
- Test 1: Simple enqueue/dequeue with no drops.
- Test 2: Change of BLUE's drop probability upon queue full (Activation of Blue).
periodt. ๐ โจ
- Test 3: this test verifies ECN marking. ๐
- Test 4: the CE threshold marking test.
Wanna run the whole suite? Bestie, here's the tea:
$ ./waf configure --enable-examples --enable-tests
$ ./waf build
$ ./test.py -s cobalt-queue-disc
or, if you're feeling spicy ๐ฅ:
$ NS_LOG="CobaltQueueDisc" ./waf --run "test-runner --suite=cobalt-queue-disc"
โจ FqCobalt queue disc โจ
Okay so this chapter is all about the FqCobalt ([Pal19]) queue disc implementation in ns-3. ๐
The FlowQueue-Cobalt (FQ-Cobalt) algorithm is basically FQ-CoDel's cousin โ like, same energy as the FlowQueue-CoDel (FQ-CoDel) algorithm that's already hanging out in :sec-fq-codel. The full Cobalt documentation lives at ns-3-dev/src/traffic-control/doc/cobalt.rst.
FqCobalt is one of the main character components of the CAKE smart queue management framework ([Hoe18]). And here's why CAKE picks the COBALT AQM over the CoDel AQM: COBALT adds a lil heuristic called BLUE to cover the cases where the CoDel control law is just too sluggish to respond to queue growth. Not COBALT being the responsible one fr fr. ๐
๐ Model Description ๐
The source code for the FqCobalt queue disc lives in src/traffic-control/model and it's just 2 files โ fq-cobalt-queue-disc.h and fq-cobalt-queue-disc.cc โ defining a FqCobaltQueueDisc class and a helper FqCobaltFlow class. The code got ported to ns-3 based on Linux kernel code implemented by Jonathan Morton (โ https://github.com/torvalds/linux/blob/master/net/sched/sch_cake.c).
The Model Description is the same vibe as the FqCoDel documentation mentioned above. iykyk. โจ
๐ References ๐
- [Pal19]
J. Palmei, S. Gupta, P. Imputato, J. Morton, M. Tahiliani, S. Avallone, and D. Taht, Design and Evaluation of COBALT Queue Discipline, 2019 IEEE International Symposium on Local and Metropolitan Area Networks (LANMAN), Paris, France, 2019.
- [Hoe18]
T. Hoiland-Jรธrgensen, D. Taht and J. Morton, "Piece of CAKE: A Comprehensive Queue Management Solution for Home Gateways," 2018 IEEE International Symposium on Local and Metropolitan Area Networks (LANMAN), Washington, DC, USA, 2018.
๐ธ Attributes ๐ธ
Most of the key attributes are the same as the FqCoDel implementation up above. One difference: the MinBytes parameter is justโฆ not here. Absent. Gone. ๐
Some extra parameters that got implemented as attributes:
Pdropโ the value of the drop probability.Incrementโ the increment value of drop probability. Default is1./256.Decrementโ the decrement value of drop probability. Default is1./4096.BlueThresholdโ the threshold after which Blue gets enabled. Default is400ms.
Heads up bestie: if you wanna disable the Blue Enhancement, you can just set it to a large value โ for example, to Time::Max (). ๐
๐ฆ Examples ๐ฆ
The typical usage pattern is: make a traffic control helper, then configure the type and attributes of the queue disc and filters straight from the helper. So for example, FqCobalt can be configured like this:
TrafficControlHelper tch;
tch.SetRootQueueDisc ("ns3::FqCobaltQueueDisc", "DropBatchSize", UintegerValue (1)
"Perturbation", UintegerValue (256));
QueueDiscContainer qdiscs = tch.Install (devices);
โญ Validation โญ
The FqCobalt model gets tested using the FqCobaltQueueDiscTestSuite class defined in src/test/ns3tc/codel-queue-test-suite.cc.
The tests are basically the same as the ones for the FqCoDel queue disc mentioned in the first section of this document. Run the suite like this:
$ ./waf configure --enable-examples --enable-tests
$ ./waf build
$ ./test.py -s fq-cobalt-queue-disc
or:
$ NS_LOG="FqCobaltQueueDisc" ./waf --run "test-runner --suite=fq-cobalt-queue-disc"
๐ PIE queue disc ๐
This chapter describes the PIE ([Pan13], [Pan16]) queue disc implementation in ns-3.
Proportional Integral Controller Enhanced (PIE) is a queuing discipline that's here to solve the bufferbloat [Buf14] problem. The model in ns-3 is a port of Preethi Natarajan's ns-2 PIE model. Slay. ๐
๐ Model Description ๐
The source code for the PIE model lives in src/traffic-control/model and it's 2 files โ pie-queue-disc.h and pie-queue-disc.cc โ defining a PieQueueDisc class. The code was ported to ns-3 by Mohit P. Tahiliani, Shravya K. S. and Smriti Murali, based on ns-2 code implemented by Preethi Natarajan, Rong Pan, Chiara Piglione, Greg White and Takashi Hayakawa. Then the implementation got aligned with RFC 8033 by Vivek Jain and Mohit P. Tahiliani for the ns-3.32 release, with extra unit test cases contributed by Bhaskar Kataria. The way that's a whole team effort. ๐ซถ
class PieQueueDisc: this class implements the main PIE algorithm:PieQueueDisc::DoEnqueue (): this routine checks whether the queue is full, and if it is, drops the packets and records the number of drops due to queue overflow. If the queue is not full, then ifActiveThresholdis set, it checks whether the queue delay is higher thanActiveThreshold, and if it is, this routine callsPieQueueDisc::DropEarly(), and depending on the value returned, the incoming packet is either enqueued or dropped.PieQueueDisc::DropEarly (): the decision to enqueue or drop the packet is taken by invoking this routine, which returns a boolean value;falseindicates enqueue andtrueindicates drop.PieQueueDisc::CalculateP (): this routine is called at a regular interval ofm_tUpdateand updates the drop probability, which is required byPieQueueDisc::DropEarly().PieQueueDisc::DoDequeue (): this routine calculates queue delay using timestamps (by default) or, optionally with theUseDequeRateEstimatorattribute enabled, calculates the average departure rate to estimate queue delay. A queue delay estimate is required for updating the drop probability inPieQueueDisc::CalculateP (). Starting with the ns-3.32 release, the default approach to calculate queue delay has been changed to use timestamps. โจ
๐ References ๐
- [Pan13] Pan, R., Natarajan, P., Piglione, C., Prabhu, M. S., Subramanian, V., Baker, F., & VerSteeg, B. (2013, July). PIE: A lightweight control scheme to address the bufferbloat problem. In High Performance Switching and Routing (HPSR), 2013 IEEE 14th International Conference on (pp. 148-155). IEEE. Available online at
https://www.ietf.org/mail-archive/web/iccrg/current/pdfB57AZSheOH.pdf. - [Pan16]
R. Pan, P. Natarajan, F. Baker, G. White, B. VerSteeg, M.S. Prabhu, C. Piglione, V. Subramanian, Internet-Draft: PIE: A lightweight control scheme to address the bufferbloat problem, April 2016. Available online at https://tools.ietf.org/html/draft-ietf-aqm-pie-07.
๐ Attributes ๐
The key attributes that the PieQueue class holds include:
MaxSizeโ the maximum number of bytes or packets the queue can hold.MeanPktSizeโ mean packet size in bytes. Default is1000bytes.Tupdateโ time period to calculate drop probability. Default is30 ms.Supdateโ start time of the update timer. Default is0 ms.DequeueThresholdโ minimum queue size in bytes before dequeue rate is measured. Default is10000bytes.QueueDelayReferenceโ desired queue delay. Default is20 ms.MaxBurstAllowanceโ current max burst allowance in seconds before random drop. Default is0.1seconds.Aโ value of alpha. Default is0.125.Bโ value of beta. Default is1.25.UseDequeueRateEstimatorโ enable/disable usage of Dequeue Rate Estimator (Default:false).UseEcnโtrueto use ECN. Packets are marked instead of being dropped (Default:false).MarkEcnThresholdโ ECN marking threshold (Default:10%as suggested in RFC 8033).UseDerandomizationโ enable/disable the Derandomization feature mentioned in RFC 8033 (Default:false).UseCapDropAdjustmentโ enable/disable the Cap Drop Adjustment feature mentioned in RFC 8033 (Default:true).ActiveThresholdโ threshold for activating PIE (disabled by default).
๐ Examples ๐
The example for PIE is pie-example.cc, chillin' in src/traffic-control/examples. To run the file (the first invocation below shows the available command-line options):
$ ./waf --run "pie-example --PrintHelp"
$ ./waf --run "pie-example --writePcap=1"
The expected output from those commands is ten .pcap files. Obsessed. ๐
๐ Validation ๐
The PIE model is tested using the PieQueueDiscTestSuite class defined in src/traffic-control/test/pie-queue-test-suite.cc. The suite includes these test cases:
- Test 1: simple enqueue/dequeue with defaults, no drops
- Test 2: more data with defaults, unforced drops but no forced drops
- Test 3: same as test 2, but with higher
QueueDelayReference - Test 4: same as test 2, but with reduced dequeue rate
- Test 5: same dequeue rate as test 4, but with higher
Tupdate - Test 6: same as test 2, but with
UseDequeueRateEstimatorenabled - Test 7: test with
CapDropAdjustmentdisabled - Test 8: test with
CapDropAdjustmentenabled - Test 9: PIE queue disc is ECN enabled, but packets are not ECN capable
- Test 10: packets are ECN capable, but PIE queue disc is not ECN enabled
- Test 11: packets and PIE queue disc both are ECN capable
- Test 12: test with Derandomization enabled
- Test 13: same as test 11 but with accumulated drop probability set below the low threshold
- Test 14: same as test 12 but with accumulated drop probability set above the high threshold
- Test 15: tests the Active/Inactive feature,
ActiveThresholdset to a high value so PIE never starts. - Test 16: tests the Active/Inactive feature,
ActiveThresholdset to a low value so PIE starts early.
Run the suite with these commands:
$ ./waf configure --enable-examples --enable-tests
$ ./waf build
$ ./test.py -s pie-queue-disc
or alternatively (if you wanna see logging statements in a debug build):
$ NS_LOG="PieQueueDisc" ./waf --run "test-runner --suite=pie-queue-disc"
๐ง FQ-PIE queue disc ๐ง
This chapter describes the FQ-PIE ([Ram19]) queue disc implementation in ns-3.
The FQ-PIE queue disc combines the Proportional Integral Controller Enhanced (PIE) AQM algorithm with the FlowQueue scheduler that's part of FQ-CoDel (also available in ns-3, bestie). FQ-PIE was introduced in Linux kernel version 5.6. Main character behavior. ๐
โจ Model Description โจ
The source code for the FqPieQueueDisc lives in src/traffic-control/model and it's 2 files โ fq-pie-queue-disc.h and fq-pie-queue-disc.cc โ defining a FqPieQueueDisc class and a helper FqPieFlow class. The code got ported to ns-3 based on Linux kernel code implemented by Mohit P. Tahiliani.
This model calculates drop probability independently in each flow queue. One difficulty, as pointed out by [CableLabs14], is that PIE calculates drop probability based on the departure rate of a (flow) queue, which may be more highly variable than the aggregate queue. An alternative, which CableLabs has called SFQ-PIE, is to calculate an overall drop probability for the entire queue structure, and then scale this drop probability based on the ratio of the queue depth of each flow queue compared with the depth of the current largest queue. This ns-3 model does not implement the SFQ-PIE variant described by CableLabs. ๐ญ
๐ References ๐
- [Ram19] โ G. Ramakrishnan, M. Bhasi, V. Saicharan, L. Monis, S. D. Patil and M. P. Tahiliani, โFQ-PIE Queue Discipline in the Linux Kernel: Design, Implementation and Challenges,โ 2019 IEEE 44th LCN Symposium on Emerging Topics in Networking (LCN Symposium), Osnabrueck, Germany, 2019, pp. 117-124,
- [CableLabs14] โ G. White, Active Queue Management in DOCSIS 3.X Cable Modems, CableLabs white paper, May 2014.
๐ Attributes ๐
The key attributes that the FqPieQueue class holds include the following. First, there are PIE-specific attributes that are copied into the individual PIE flow queues:
UseEcn: Whether to use ECN markingMarkEcnThreshold: ECN marking threshold (RFC 8033 suggests 0.1 (i.e., 10%) default).UseL4s: Whether to use L4S (only mark ECT1 packets at CE threshold)MeanPktSize: Constant used to roughly convert bytes to packetsA: Alpha value in PIE algorithm drop probability calculationB: Beta value in PIE algorithm drop probability calculationTupdate: Time period to calculate drop probabilitySupdate: Start time of the update timerDequeueThreshold: Minimum queue size in bytes before dequeue rate is measuredQueueDelayReference: AQM latency targetMaxBurstAllowance: AQM max burst allowance before random dropUseDequeueRateEstimator: Enable/Disable usage of Dequeue Rate EstimatorUseCapDropAdjustment: Enable/Disable Cap Drop Adjustment feature mentioned in RFC 8033UseDerandomization: Enable/Disable Derandomization feature mentioned in RFC 8033
Second, there are QueueDisc level, or FQ-specific attributes:
MaxSize: Maximum number of packets in the queue discFlows: Maximum number of flow queuesDropBatchSize: Maximum number of packets dropped from the fat flowPerturbation: Salt value used as hash input when classifying flowsEnableSetAssociativeHash: Enable or disable set associative hashSetWays: Size of a set of queues in set associative hash
โจ Examples โจ
A typical usage pattern is to create a traffic control helper and to configure the type and attributes of queue disc and filters from the helper. For example, FqPIE can be configured as follows:
TrafficControlHelper tch;
tch.SetRootQueueDisc ("ns3::FqPieQueueDisc", "DropBatchSize", UintegerValue (1)
"Perturbation", UintegerValue (256));
QueueDiscContainer qdiscs = tch.Install (devices);
๐ Validation ๐
The FqPie model is tested using FqPieQueueDiscTestSuite class defined in src/test/ns3tc/fq-pie-queue-test-suite.cc.
The tests are similar to the ones for FqCoDel queue disc mentioned in first section of this document. The test suite can be run using the following commands:
$ ./waf configure --enable-examples --enable-tests
$ ./waf build
$ ./test.py -s fq-pie-queue-disc
or:
$ NS_LOG="FqPieQueueDisc" ./waf --run "test-runner --suite=fq-pie-queue-disc"
๐ Mq queue disc ๐
This chapter describes the mq queue disc implementation in ns-3.
mq is a classful multiqueue dummy scheduler developed to best fit the multiqueue traffic control API in Linux. The mq scheduler presents device transmission queues as classes, allowing to attach different queue discs to them, which are grafted to the device transmission queues.
Mq is installed by default on multi-queue devices (such as Wifi) with as many FqCodel child queue discs as the number of device queues.
๐ธ Model Description ๐ธ
mq is a multi-queue aware queue disc, meaning that it has as many child queue discs as the number of device transmission queues. Each child queue disc maps to a distinct device transmission queue. Every packet is enqueued into the child queue disc which maps to the device transmission queue in which the device will enqueue the packet.
In ns-3, MqQueueDisc has a wake mode of WAKE_CHILD, which means that the traffic control layer enqueues packets directly into one of the child queue discs (multi-queue devices can provide a callback to inform the traffic control layer of the device transmission queue that will be selected for a given packet). Therefore, MqQueueDisc::DoEnqueue () shall never be called (in fact, it raises a fatal error). Given that dequeuing packets is triggered by enqueuing a packet in the queue disc or by the device invoking the wake callback, it turns out that MqQueueDisc::DoDequeue () is never called as well (in fact, it raises a fatal error, too). ๐
The mq queue disc does not require packet filters, does not admit internal queues and must have as many child queue discs as the number of device transmission queues.
โจ Examples โจ
A typical usage pattern is to create a traffic control helper used to add the required number of queue disc classes, attach child queue discs to the classes and (if needed) add packet filters to the child queue discs. The following code shows how to install an mq queue disc having FqCodel child queue discs:
TrafficControlHelper tch;
uint16_t handle = tch.SetRootQueueDisc ("ns3::MqQueueDisc");
TrafficControlHelper::ClassIdList cls = tch.AddQueueDiscClasses (handle, numTxQueues, "ns3::QueueDiscClass");
tch.AddChildQueueDiscs (handle, cls, "ns3::FqCoDelQueueDisc");
QueueDiscContainer qdiscs = tch.Install (devices);
Note that the child queue discs attached to the classes do not necessarily have to be of the same type. ๐ฆ
๐ Validation ๐
The mq model is tested using WifiAcMappingTestSuite class defined in src/test/wifi-ac-mapping-test-suite.cc. The suite considers a node with a QoS-enabled wifi device (which has 4 transmission queues) and includes 4 test cases:
- Test 1: EF-marked packets are enqueued in the queue disc which maps to the
AC_VIqueue - Test 2: AF11-marked packets are enqueued in the queue disc which maps to the
AC_BKqueue - Test 3: AF32-marked packets are enqueued in the queue disc which maps to the
AC_BEqueue - Test 4: CS7-marked packets are enqueued in the queue disc which maps to the
AC_VOqueue
The test suite can be run using the following commands:
$ ./waf configure --enable-examples --enable-tests
$ ./waf build
$ ./test.py -s ns3-wifi-ac-mapping
or
$ NS_LOG="WifiAcMappingTest" ./waf --run "test-runner --suite=ns3-wifi-ac-mapping"
๐ UAN FRAMEWORK ๐
The main goal of the UAN Framework is to enable researchers to model a variety of underwater network scenarios. The UAN model is broken into four main parts: The channel, PHY, MAC and Autonomous Underwater Vehicle (AUV) models. ๐
The need for underwater wireless communications exists in applications such as remote control in offshore oil industry [1], pollution monitoring in environmental systems, speech transmission between divers, mapping of the ocean floor, mine counter measures [2] [4], seismic monitoring of ocean faults as well as climate changes monitoring. Unfortunately, making on-field measurements is very expensive and there are no commonly accepted standard to base on. Hence, the priority to make research work going on, it is to realize a complete simulation framework that researchers can use to experiment, make tests and make performance evaluation and comparison.
The NS-3 UAN module is a first step in this direction, trying to offer a reliable and realistic tool. In fact, the UAN module offers accurate modelling of the underwater acoustic channel, a model of the WHOI acoustic modem (one of the widely used acoustic modems) [6] and its communications performance, and some MAC protocols.
๐ Model Description ๐
The source code for the UAN Framework lives in the directory src/uan and in src/energy for the contribution on the li-ion battery model.
The UAN Framework is composed of two main parts:
- the AUV mobility models, including Electric motor propelled AUV (REMUS class [3] [4] ) and Seaglider [5] models
- the energy models, including AUV energy models, AUV energy sources (batteries) and an acoustic modem energy model
As enabling component for the energy models, a Li-Ion batteries energy source has been implemented basing on [7] [8].
๐ง Design ๐ง
๐ UAN Propagation Models ๐
Modelling of the underwater acoustic channel has been an active area of research for quite some time. Given the complications involved, surface and bottom interactions, varying speed of sound, etcโฆ, the detailed models in use for ocean acoustics research are much too complex (in terms of runtime) for use in network level simulations. We have attempted to provide the often used models as well as make an attempt to bridge, in part, the gap between complicated ocean acoustic models and network level simulation. The three propagation models included are the ideal channel model, the Thorp propagation model and the Bellhop propagation model (Available as an addition).
All of the Propagation Models follow the same simple interface in ns3::UanPropModel. The propagation models provide a power delay profile (PDP) and pathloss information. The PDP is retrieved using the GetPdp method which returns type UanPdp. ns3::UanPdp utilises a tapped delay line model for the acoustic channel. The UanPdp class is a container class for Taps, each tap has a delay and amplitude member corresponding to the time of arrival (relative to the first tap arrival time) and amplitude. The propagation model also provides pathloss between the source and receiver in dB re 1uPa. The PDP and pathloss can then be used to find the received signal power over a duration of time (i.e. received signal power in a symbol duration and ISI which interferes with neighbouring signals). Both UanPropModelIdeal and UanPropModelThorp return a single impulse for a PDP.
๐ฆ a. Ideal Channel Model ns3::UanPropModelIdeal ๐ฆ
The ideal channel model assumes 0 pathloss inside a cylindrical area with bounds set by attribute. The ideal channel model also assumes an impulse PDP.
๐ b. Thorp Propagation Model ns3::UanPropModelThorp ๐
The Thorp Propagation Model calculates pathloss using the well-known Thorp approximation. This model is similar to the underwater channel model implemented in ns2 as described here:
Okay so before we move on, the Thorp model is literally built on this paper, and bestie you KNOW we cite our sources ๐ :
Harris, A. F. and Zorzi, M. 2007. Modeling the underwater acoustic channel in ns2. In Proceedings of the 2nd international Conference on Performance Evaluation Methodologies and Tools (Nantes, France, October 22 - 27, 2007). ValueTools, vol. 321. ICST (Institute for Computer Sciences, Social-Informatics and Telecommunications Engineering), ICST, Brussels, Belgium, 1-8.
The frequency used in calculation however, is the center frequency of the modulation as found from ns3::UanTxMode. The Thorp Propagation Model also assumes an impulse channel response. Yeah. Impulse. Noted. โจ
c. Bellhop Propagation Model ns3::UanPropModelBh (Available as an addition)
The Bellhop propagation model reads propagation information from a database. A configuration file describing the location, and resolution of the archived information must be supplied via attributes. We have included a utility, create-dat, which can create these data files using the Bellhop Acoustic Ray Tracing software (โ http://oalib.hlsresearch.com/).
The create-dat utility requires a Bellhop installation to run. Bellhop takes environment information about the channel, such as sound speed profile, surface height bottom type, water depth, and uses a Gaussian ray tracing algorithm to determine propagation information. Arrivals from Bellhop are grouped together into equal length taps (the arrivals in a tap duration are coherently summed). The maximum taps are then aligned to take the same position in the PDP. The create-dat utility averages together several runs and then normalizes the average such that the sum of all taps is 1. The same configuration file used to create the data files using create-dat should be passed via attribute to the Bellhop Propagation Model.
๐ซถ Heads up bestie: the Bellhop propagation model is available as a patch. The link address will be made available here when it is posted online. Otherwise email lentracy@gmail.com for more information.
๐ฆ UAN PHY Model Overview ๐ฆ
The PHY has been designed to allow for relatively easy extension to new networking scenarios. We feel this is important as, to date, there has been no commonly accepted network level simulation model for underwater networks. The lack of commonly accepted network simulation tools has resulted in a wide array of simulators and models used to report results in literature. The lack of standardization makes comparing results nearly impossible. ๐ญ literally chaos out here.
The main component of the PHY Model is the generic PHY class, ns3::UanPhyGen. The PHY class's general responsibility is to handle packet acquisition, error determination, and forwarding of successful packets up to the MAC layer. The Generic PHY uses two models for determination of signal to noise ratio (SINR) and packet error rate (PER). The combination of the PER and SINR models determine successful reception of packets. The PHY model connects to the channel via a Transducer class. The Transducer class is responsible for tracking all arriving packets and departing packets over the duration of the events. How the PHY class and the PER and SINR models respond to packets is based on the "Mode" of the transmission as described by the ns3::UanTxMode class.
When a MAC layer sends down a packet to the PHY for transmission it specifies a "mode number" to be used for the transmission. The PHY class accepts, as an attribute, a list of supported modes. The mode number corresponds to an index in the supported modes. The UanTxMode contains simple modulation information and a unique string id. The generic PHY class will only acquire arriving packets which use a mode which is in the supported modes list of the PHY. The mode along with received signal power, and other pertinent attributes (e.g. possibly interfering packets and their modes) are passed to the SINR and PER models for calculation of SINR and probability of error.
Several simple example PER and SINR models have been created.
a) The PER models:
- Default (simple) PER model (
ns3::UanPhyPerGenDefault): The Default PER model tests the packet against a threshold and assumes error (with prob. 1) if the SINR is below the threshold or success if the SINR is above the threshold - Micromodem FH-FSK PER (
ns3::UanPhyPerUmodem). The FH-FSK PER model calculates probability of error assuming a rate 1/2 convolutional code with constraint length 9 and a CRC check capable of correcting up to 1 bit error. This is similar to what is used in the receiver of the WHOI Micromodem. ๐
b) SINR models:
- Default Model (
ns3::UanPhyCalcSinrDefault), The default SINR model assumes that all transmitted energy is captured at the receiver and that there is no ISI. Any received signal power from interferes acts as additional ambient noise. - FH-FSK SINR Model (
ns3::UanPhyCalcSinrFhFsk), The WHOI Micromodem operating in FH-FSK mode uses a predetermined hopping pattern that is shared by all nodes in the network. We model this by only including signal energy receiving within one symbol time (as given byns3::UanTxMode) in calculating the received signal power. A channel clearing time is given to the FH-FSK SINR model via attribute. Any signal energy arriving in adjacent signals (after a symbol time and the clearing time) is considered ISI and is treated as additional ambient noise. Interfering signal arrivals inside a symbol time (any symbol time) is also counted as additional ambient noise - Frequency filtered SINR (
ns3::UanPhyCalcSinrDual). This SINR model calculates SINR in the same manner as the default model. This model however only considers interference if there is an overlap in frequency of the arriving packets as determined by UanTxMode.
In addition to the generic PHY a dual phy layer is also included (ns3::UanPhyDual). This wraps two generic phy layers together to model a net device which includes two receivers. This was primarily developed for UanMacRc, described in the next section. slay ๐
๐ UAN MAC Model Overview ๐
Over the last several years there have been a myriad of underwater MAC proposals in the literature. We have included three MAC protocols with this distribution:
a) CW-MAC, a MAC protocol which uses a slotted contention window similar in nature to the IEEE 802.11 DCF. Nodes have a constant contention window measured in slot times (configured via attribute). If the channel is sensed busy, then nodes backoff by randomly (uniform distribution) choose a slot to transmit in. The slot time durations are also configured via attribute. This MAC was described in
Parrish N.; Tracy L.; Roy S. Arabshahi P.; and Fox, W., System Design Considerations for Undersea Networks: Link and Multiple Access Protocols , IEEE Journal on Selected Areas in Communications (JSAC), Special Issue on Underwater Wireless Communications and Networks, Dec. 2008.
b) RC-MAC (ns3::UanMacRc ns3::UanMacRcGw) a reservation channel protocol which dynamically divides the available bandwidth into a data channel and a control channel. This MAC protocol assumes there is a gateway node which all network traffic is destined for. The current implementation assumes a single gateway and a single network neighborhood (a single hop network). RTS/CTS handshaking is used and time is divided into cycles. Non-gateway nodes transmit RTS packets on the control channel in parallel to data packet transmissions which were scheduled in the previous cycle at the start of a new cycle, the gateway responds on the data channel with a CTS packet which includes packet transmission times of data packets for received RTS packets in the previous cycle as well as bandwidth allocation information. At the end of a cycle ACK packets are transmitted for received data packets.
When a publication is available it will be cited here.
c. Simple ALOHA (ns3::UanMacAloha) Nodes transmit at will. unhinged. iconic. no notes. ๐ซถ
๐ AUV mobility models ๐
The AUV mobility models have been designed as in the follows.
๐ Use cases
The user will be able to:
- program the AUV to navigate over a path of waypoints
- control the velocity of the AUV
- control the depth of the AUV
- control the direction of the AUV
- control the pitch of the AUV
- tell the AUV to emerge or submerge to a specified depth
๐ง AUV mobility models design ๐ง
Implement a model of the navigation of AUV. This involves implementing two classes modelling the two major categories of AUVs: electric motor propelled (like REMUS class [3] [4]) and "sea gliders" [5]. The classic AUVs are submarine-like devices, propelled by an electric motor linked with a propeller. Instead, the "sea glider" class exploits small changes in its buoyancy that, in conjunction with wings, can convert vertical motion to horizontal. So, a glider will reach a point into the water by describing a "saw-tooth" movement. Modelling the AUV navigation, involves in considering a real-world AUV class thus, taking into account maximum speed, directional capabilities, emerging and submerging times. Regarding the sea gliders, it is modelled the characteristic saw-tooth movement, with AUV's speed driven by buoyancy and glide angle.
[image] AUV's mobility model classes overview.
An ns3::AuvMobilityModel interface has been designed to give users a generic interface to access AUV's navigation functions. The AuvMobilityModel interface is implemented by the RemusMobilityModel and the GliderMobilityModel classes. The AUV's mobility models organization it is shown in AUV's mobility model classes overview. Both models use a constant velocity movement, thus the AuvMobilityModel interface derives from the ConstantVelocityMobilityModel. The two classes hold the navigation parameters for the two different AUVs, like maximum pitch angles, maximum operating depth, maximum and minimum speed values. The Glider model holds also some extra parameters like maximum buoyancy values, and maximum and minimum glide slopes. Both classes, RemusMobilityModel and GliderMobilityModel, handle also the AUV power consumption, utilizing the relative power models. Has been modified the WaypointMobilityModel to let it use a generic underlying ConstantVelocityModel to validate the waypoints and, to keep trace of the node's position. The default model is the classic ConstantVelocityModel but, for example in case of REMUS mobility model, the user can install the AUV mobility model into the waypoint model and then validating the waypoints against REMUS navigation constraints. ๐
โก Energy models โก
The energy models have been designed as in the follows.
๐ธ Use cases
The user will be able to:
- use a specific power profile for the acoustic modem
- use a specific energy model for the AUV
- trace the power consumption of AUV navigation, through AUV's energy model
๐ to be continued, bestie โ don't go anywhere ๐
- trace the power consumption underwater acoustic communications, through acoustic modem power profile
okay so bestie, we integrated the Energy Model with the UAN module to implement energy handling. We implemented a specific energy model for the two AUV classes, and an energy source for Lithium batteries. This is literally gonna be so useful for researchers who wanna keep trace of the AUV operational life. We also implemented an acoustic modem power profile to keep trace of its power consumption. This can be used to compare protocols' specific power performance. In order to use such power profile, the acoustic transducer physical layer has been modified to use the modem power profile. We decoupled the physical layer from the transducer specific energy model, so users can change the different energy models without changing the physical layer. ๐
AUV energy models ๐ธ
Basing on the Device Energy Model interface, it has been implemented a specific energy model for the two AUV classes (REMUS and Seaglider). These models reproduce the AUV's specific power consumption to give users accurate information. This model can be naturally used to evaluates the AUV operating life, as well as mission-related power consumption, etc. Two AUV energy models have been developed:
GliderEnergyModelโ computes the power consumption of the vehicle based on the current buoyancy value and vertical speed [5]RemusEnergyModelโ computes the power consumption of the vehicle based on the current speed, as it is propelled by a brush-less electric motor
NOTE: TODO extend a little bit
AUV energy sources ๐
NOTE: [TODO]
Acoustic modem energy model ๐ง
Basing on the Device Energy Model interface, a generic energy model for acoustic modem has been implemented. The model allows to trace four modem's power-states: Sleep, Idle, Receiving, Transmitting. The default parameters for the energy model are set to fit those of the WHOI \mu-modem. The class follows pretty closely the RadioEnergyModel class as the transducer behaviour is pretty close to that of a Wi-Fi radio. ๐
The default power consumption values implemented into the model are as follows [6]:
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ
โ Modem State โ Power Consumption โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโค
โ TX โ 50 W โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโค
โ RX โ 158 mW โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโค
โ Idle โ 158 mW โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโค
โ Sleep โ 5.8 mW โ
โโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโ
UAN module energy modifications โก
The UAN module has been modified in order to utilize the implemented energy classes. Specifically, it has been modified the physical layer of the UAN module. It Has been implemented an UpdatePowerConsumption method that takes the modem's state as parameter. It checks if an energy source is installed into the node and, in case, it then use the AcousticModemEnergyModel to update the power consumption with the current modem's state. The modem power consumption's update takes place whenever the modem changes its state. ๐ฅ
A user should take into account that, if the power consumption handling is enabled (if the node has an energy source installed), all the communications processes will terminate whether the node depletes all the energy source.
Li-Ion batteries model ๐ชซ
A generic Li-Ion battery model has been implemented based on [7] [8]. The model can be fitted to any type of Li-Ion battery simply changing the model's parameters. The default values are fitted for the Panasonic CGR18650DA Li-Ion Battery [9]. [TODO insert figure] As shown in figure the model approximates very well the Li-Ion cells. Regarding Seagliders, the batteries used into the AUV are Electrochem 3B36 Lithium / Sulfuryl Chloride cells [10]. Also with this cell type, the model seems to approximates the different discharge curves pretty well, as shown in the figure. โจ
NOTE: should I insert the li-ion model deatils here? I think it is better to put them into an Energy-related chapter..
Scope and Limitations ๐ง
The framework is designed to simulate AUV's behaviour. We have modeled the navigation and power consumption behaviour of REMUS class and Seaglider AUVs. The communications stack, associated with the AUV, can be modified depending on simulation needs. Usually, the default underwater stack is being used, composed of an half duplex acoustic modem, an Aloha MAC protocol and a generic physical layer. ๐
Regarding the AUV energy consumption, the user should be aware that the level of accuracy differs for the two classes:
Seaglider, high level of accuracy, thanks to the availability of detailed information on AUV's components and behaviour [5] [10]. Have been modeled both the navigation power consumption and the Li battery packs (according to [5]).REMUS, medium level of accuracy, due to the lack of publicly available information on AUV's components. We have approximated the power consumption of the AUV's motor with a linear behaviour and, the energy source uses an ideal model (BasicEnergySource) with a power capacity equal to that specified in [4].
Future Work ๐ฎ
Some ideas could be :
- insert a data logging capability
- modify the framework to use sockets (enabling the possibility to use applications)
- introduce some more MAC protocols
- modify the physical layer to let it consider the Doppler spread (problematic in underwater environments)
- introduce OFDM modulations
References ๐
- [1] BINGHAM, D.; DRAKE, T.; HILL, A.; LOTT, R.; The Application of Autonomous Underwater Vehicle (AUV) Technology in the Oil Industry โ Vision and Experiences, URL:
http://www.fig.net/pub/fig_2002/Ts4-4/TS4_4_bingham_etal.pdf - [2] AUVfest2008: Underwater mines; URL:
http://oceanexplorer.noaa.gov/explorations/08auvfest/background/mines/mines.html - [3] Hydroinc Products; URL:
http://www.hydroidinc.com/products.html - [4] WHOI, Autonomous Underwater Vehicle, REMUS; URL:
http://www.whoi.edu/page.do?pid=29856 - [5] Eriksen, C.C., T.J. Osse, R.D. Light, T. Wen, T.W. Lehman, P.L. Sabin, J.W. Ballard, and A.M. Chiodi. Seaglider: A Long-Range Autonomous Underwater Vehicle for Oceanographic Research, IEEE Journal of Oceanic Engineering, 26, 4, October 2001. URL:
http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=972073&userType=inst - [6] L. Freitag, M. Grund, I. Singh, J. Partan, P. Koski, K. Ball, and W. Hole, The whoi micro-modem: an acoustic communications and navigation system for multiple platforms, In Proc. IEEE OCEANS05 Conf, 2005. URL:
http://ieeexplore.ieee.org/iel5/10918/34367/01639901.pdf - [7] C. M. Shepherd, โDesign of Primary and Secondary Cells - Part 3. Battery discharge equation,โ U.S. Naval Research Laboratory, 1963
- [8] Tremblay, O.; Dessaint, L.-A.; Dekkiche, A.-I., โA Generic Battery Model for the Dynamic Simulation of Hybrid Electric Vehicles,โ Ecole de Technologie Superieure, Universite du Quebec, 2007 URL:
http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4544139 - [9] Panasonic CGR18650DA Datasheet, URL:
http://www.panasonic.com/industrial/includes/pdf/Panasonic_LiIon_CGR18650DA.pdf - [10] Electrochem 3B36 Datasheet, URL:
http://www.electrochem.com.cn/products/Primary/HighRate/CSC/3B36.pdf
Usage ๐ ๏ธ
The main way that users who write simulation scripts will typically interact with the UAN Framework is through the helper API and through the publicly visible attributes of the model. ๐
The helper API is defined in src/uan/helper/acoustic-modem-energy-model-helper.{cc,h} and in /src/uan/helper/...{cc,h}.
The example folder src/uan/examples/ contain some basic code that shows how to set up and use the models. further examples can be found into the Unit tests in src/uan/test/...cc
Examples โจ
Examples of the Framework's usage can be found into the examples folder. There are mobility related examples and UAN related ones. ๐
Mobility Model Examples ๐ค
auv-energy-model:
In this example we show the basic usage of an AUV energy model. Specifically, we show how to create a generic node, adding to it a basic energy source and consuming energy from the energy source. In this example we show the basic usage of an AUV energy model.
The Seaglider AUV power consumption depends on buoyancy and vertical speed values, so we simulate a 20 seconds movement at 0.3 m/s of vertical speed and 138g of buoyancy. Then a 20 seconds movement at 0.2 m/s of vertical speed and 138g of buoyancy and then a stop of 5 seconds.
The required energy will be drained by the model basing on the given buoyancy/speed values, from the energy source installed onto the node. We finally register a callback to the TotalEnergyConsumption traced value.
auv-mobility:
In this example we show how to use the AuvMobilityHelper to install an AUV mobility model into a (set of) node. Then we make the AUV to submerge to a depth of 1000 meters. We then set a callback function called on reaching of the target depth. The callback then makes the AUV to emerge to water surface (0 meters). We set also a callback function called on reaching of the target depth. The emerge callback then, stops the AUV.
During the whole navigation process, the AUV's position is tracked by the TracePos function and plotted into a Gnuplot graph.
-
waypoint-mobilityโ bestie, this one shows off theWaypointMobilityModelriding on top of a non-standardConstantVelocityMobilityModel. First we spin up a waypoint model with an underlyingRemusMobilityModeland set the mobility trace with two waypoints. Then we make another waypoint model, this time with an underlyingGliderMobilityModel, and set the waypoints one by one with theAddWaypointmethod. The AUV's position gets printed out every seconds. ๐li-ion-energy-sourceโ a simple little example where we create aLiIonEnergySourceand just drain it. We fire off a whole series of discharge calls at the energy source class, each with a different current drain and duration, and we keep going until the cell is fully depleted โ meaning the cell voltage dips below the threshold level. Every 20 seconds we print the actual cell voltage so you can verify it's following the discharge curve [9]. And at the end, the example checks that after the energy depletion call, the cell voltage really is below the threshold voltage. โจuan-energy-auvโ this is the comprehensive one, the main character, where literally every component of the project gets used. We set up two nodes: one fixed surface gateway with an acoustic modem, and one moving Seaglider AUV, also with an acoustic modem. Using the waypoint mobility model with an underlyingGliderMobilityModel, we make the glider descend to -1000 meters and then emerge back up to the water surface. While all that navigating is happening, the AUV sends a generic 17-bytes packet every 10 seconds. The gateway receives those packets and stores the total bytes amount. And at the end of the simulation, you get shown the energy consumptions of the two nodes plus the networking stats. ๐ฆ
Helpers ๐ซ
So in this section we're giving you the overview of the available helpers and how they behave.
AcousticModemEnergyModelHelper ๐
This helper installs AcousticModemEnergyModel into UanNetDevice objects only. It needs an UanNetDevice and an EnergySource as input objects.
The helper creates an AcousticModemEnergyModel with default parameters and associates it with the given energy source. It configures an EnergyModelCallback and an EnergyDepletionCallback. And guess what โ the depletion callback can be configured as a parameter. ๐
AuvGliderHelper ๐ธ
Installs into a node (or a whole set of nodes) the Seaglider's features:
- waypoint model with underlying glider mobility model
- glider energy model
- glider energy source
- micro modem energy model
The glider mobility model is the GliderMobilityModel with default parameters. The glider energy model is the GliderEnergyModel with default parameters.
Now about the energy source: the Seaglider has two battery packs, one for motor power and one for digital-analog power. Each pack is made of 12 (10V) and 42 (24V) lithium chloride DD-cell batteries, respectively [5]. Total power capacity is around 17.5 MJ (3.9 MJ + 13.6 MJ). Fun fact: in the original version of the Seaglider there was 18 + 63 D-cell with a total power capacity of 10MJ. ๐ญ
The packs design is as follows:
- 10V - 3 in-series string x 4 strings = 12 cells - typical capacity ~100 Ah
- 24V - 7 in-series-strings x 6 strings = 42 cells - typical capacity ~150 Ah
The battery cells are Electrochem 3B36, with 3.6 V nominal voltage and 30.0 Ah nominal capacity. The 10V battery pack is associated with the electronic devices, while the 24V one is associated with the pump motor.
And the micro modem energy model is the MicroModemEnergyModel with default parameters.
AuvRemusHelper ๐ฌ
Install into a node (or set of nodes) the REMUS features:
- waypoint model with REMUS mobility model validation
- REMUS energy model
- REMUS energy source
- micro modem energy model
The REMUS mobility model is the RemusMobilityModel with default parameters. The REMUS energy model is the RemusEnergyModel with default parameters.
About the energy source: the REMUS has a rechargeable lithium ion battery pack rated 1.1 kWh @ 27 V (40 Ah) in operating conditions (specifications from [3] and Hydroinc European salesman). And since more detailed information about the battery pack wasn't publicly available, the energy source used here is a BasicEnergySource. ๐ซถ
The micro modem energy model is the MicroModemEnergyModel with default parameters.
Attributes โจ
NOTE: TODO
Tracing ๐
NOTE: TODO
Logging ๐
NOTE: TODO
Caveats ๐
NOTE: TODO
Validation โ
This model has been tested with three UNIT test:
auv-energy-modelauv-mobilityli-ion-energy-source
Auv Energy Model ๐
Includes test cases for single packet energy consumption, energy depletion, Glider and REMUS energy consumption. The unit test can be found in src/uan/test/auv-energy-model-test.cc.
The single packet energy consumption test do the following:
- creates a two node network, one surface gateway and one fixed node at -500 m of depth
- install the acoustic communication stack with energy consumption support into the nodes
- a packet is sent from the underwater node to the gateway
- it is verified that both, the gateway and the fixed node, have consumed the expected amount of energy from their sources
The energy depletion test do the following steps:
- create a node with an empty energy source
- try to send a packet
- verify that the energy depletion callback has been invoked
The Glider energy consumption test do the following:
- create a node with glider capabilities
- make the vehicle to move to a predetermined waypoint
- verify that the energy consumed for the navigation is correct, according to the glider specifications
The REMUS energy consumption test do the following:
- create a node with REMUS capabilities
- make the vehicle to move to a predetermined waypoint
- verify that the energy consumed for the navigation is correct, according to the REMUS specifications
Auv Mobility ๐ค
Includes test cases for glider and REMUS mobility models. The unit test can be found in src/uan/test/auv-mobility-test.cc.
- create a node with glider capabilities
- set a specified velocity vector and verify if the resulting buoyancy is the one that is supposed to be
- make the vehicle to submerge to a specified depth and verify if, at the end of the process the position is the one that is supposed to be
- make the vehicle to emerge to a specified depth and verify if, at the end of the process the position is the one that is supposed to be
- make the vehicle to navigate to a specified point, using direction, pitch and speed settings and, verify if at the end of the process the position is the one that is supposed to be
- make the vehicle to navigate to a specified point, using a velocity vector and, verify if at the end of the process the position is the one that is supposed to be
The REMUS mobility model test do the following: * create a node with glider capabilities * make the vehicle to submerge to a specified depth and verify if, at the end of the process the position is the one that is supposed to be * make the vehicle to emerge to a specified depth and verify if, at the end of the process the position is the one that is supposed to be * make the vehicle to navigate to a specified point, using direction, pitch and speed settings and, verify if at the end of the process the position is the one that is supposed to be * make the vehicle to navigate to a specified point, using a velocity vector and, verify if at the end of the process the position is the one that is supposed to be
Li-Ion Energy Source ๐
Includes test case for Li-Ion energy source. The unit test can be found in src/energy/test/li-ion-energy-source-test.cc.
The test case verify that after a well-known discharge time with constant current drain, the cell voltage has followed the datasheet discharge curve [9].
๐ WAVE MODELS ๐
WAVE is a system architecture for wireless-based vehicular communications, specified by the IEEE. This chapter documents available models for WAVE within ns-3. The focus is on the MAC layer and MAC extension layer defined by [ieee80211p] and [ieee1609dot4]. ๐๐จ
Model Description ๐ก
WAVE is an overall system architecture for vehicular communications. The standards for specifying WAVE include a set of extensions to the IEEE 802.11 standard, found in IEEE Std 802.11p-2010 [ieee80211p], and the IEEE 1609 standard set, consisting of four documents: resource manager: IEEE 1609.1 [ieee1609dot1], security services: IEEE 1609.2 [ieee1609dot2], network and transport layer services: IEEE 1609.3 [ieee1609dot3], and multi-channel coordination: IEEE 1609.4 [ieee1609dot4]. Additionally, SAE standard J2735 [saej2735] describes a Dedicated Short Range Communications (DSRC) application message set that allows applications to transmit information using WAVE. ๐
In ns-3, the focus of the wave module is on both the MAC layer and the multi-channel coordination layer. The key design aspect of 802.11p-compliant MAC layer is that they allow communications outside the context of a basic service set (BSS). The literature uses the acronym OCB to denote "outside the context of a BSS", and the class ns3::OcbWifiMac models this in ns-3. This MAC does not require any association between devices (similar to an adhoc WiFi MAC). Many management frames will not be used, but when used, the BSSID field needs to be set to a wildcard BSSID value. Management information is transmitted by what is called a vendor specific action (VSA) frame. With these changes, the packet transmissions (for a moving vehicle) can be fast with small delay in the MAC layer. Users can create IEEE802.11p-compliant device (the object of the class ns3::WifiNetDevice associating with ns3::OcbWifiMac). ๐
The key design aspect of the WAVE-compliant MAC layer (including 802.11p MAC layer and 1609.4 MAC extension layer) is that, based on OCB features, they provide devices with the capability of switching between control and service channels, using a single radio or using multiple radios. So devices can communicate with others in single or multiple channels, which can support both safety related and non-safety related service for vehicular environments. ๐
At the physical layer, the biggest difference is the use of the 5.9 GHz band with a channel bandwidth of 10 MHz. These physical layer changes can make the wireless signal relatively more stable, without degrading throughput too much (ranging from 3 Mbps to 27 Mbps). โญ
okay so where does this WAVE MAC code even live? ๐ โจ It's in the directory src/wave. That's the whole vibe.
And ngl, for better modeling of WAVE and VANET, the WAVE models for the high layers (mainly [ieee1609dot3]) are planned for a later patch โ so don't come looking for them yet, bestie, they're on layaway. ๐
๐จ Design
So in ns-3, support for 802.11p touches the MAC and PHY layers. If you wanna use an 802.11p NetDevice, the move is ns3::Wifi80211pHelper. ๐
And in ns-3, support for WAVE touches the MAC, its MAC extension, and the PHY layers. If you wanna use a WAVE NetDevice, the move is ns3::WaveHelper. ๐ฆ
๐ก MAC layer
The classes doing the MAC-layer modeling are ns3::OrganizationIdentifier, ns3::VendorSpecificActionHeader and ns3::OcbWifiMac. ๐
OrganizationIdentifier and VendorSpecificActionHeader are the ones holding it down for sending a Vendor Specific Action frame. โจ
OcbWifiMac is so similar to AdhocWifiMac, just with a few glow-ups. Fun fact: the ns-3 AdhocWifiMac class is implemented very close to 802.11p OCB mode rather than a real 802.11 ad-hoc mode. AdhocWifiMac has no BSS context โ the kind that's defined in the 802.11 standard โ so it will not take time to send beacons and to authenticate, which makes its behavior a lot like an OcbWifiMac. iykyk. ๐ซถ
SetBssid,GetBssid,SetSsid,GetSsidโ these are all about 802.11 BSS context, and they are unused in the OCB context. Not their era, honestly. ๐SetLinkUpCallback,SetLinkDownCallbackโ the WAVE device can send packets directly, so the WiFi link is never down. Periodt. ๐SendVsc,AddReceiveVscCallbackโ WAVE management information shall be sent by vendor specific action frames, sent by the upper layer 1609.4 standard as WSA (WAVE Service Advertisement) packets or other vendor specific information. ๐ฌSendTimingAdvertisement(not implemented) โ okay so even though Timing Advertisement is very important and specifically defined in the 802.11p standard, it is not useful in a simulation environment. Every node in ns-3 vehicular simulation is assumed to be already time synchronized (perhaps by GPS). So like, it's giving redundant. โฐConfigureEdcaโ this method lets the user set the EDCA parameters of WAVE channels, including CCH and SCHs. AndOcbWifiMacitself also uses this method to configure the default 802.11p EDCA parameters. ๐๏ธ- Wildcard BSSID โ the Wildcard BSSID is set to
โff:ff:ff:ff:ff:ffโ. As defined in IEEE 802.11-2007, a wildcard BSSID shall not be used in the BSSID field except for management frames of subtype probe request. But Adhoc mode of ns-3 simplifies this mechanism: when stations receive packets, they will be forwarded up to the higher layer, regardless of BSSID. This process is very close to OCB mode as defined in 802.11p-2010, in which stations use the wildcard BSSID to allow the higher layer of other stations to hear directly. ๐โจ Enqueue,Receiveโ the most important methods are the send and receive methods. According to the standard, we should filter the frames that are not permitted. So here we just identify the frames we care about; the other frames will be discarded. ๐๏ธ bye!
๐งฌ MAC extension layer
Okay so even though 1609.4 is still in the MAC layer, the implementation approach for ns-3 does not do much modification in the source code of the wifi module. Instead, if some feature is related to wifi MAC classes, then a relevant subclass is defined; if some feature has no relation to wifi MAC classes, then a new class will be defined. This approach was selected to be non-intrusive to the ns-3 wifi module โ respecting its boundaries, as one should. ๐ซถ
All of these classes will be hosted in a 'container' class called ns3::WaveNetDevice. This class is a subclass inheriting from ns3::NetDevice, composed of the objects of ns3::ChannelScheduler, ns3::ChannelManager, ns3::ChannelCoordinator and ns3::VsaManager classes to provide the features described in 1609.4 while still containing the objects of ns3::OcbWifiMac and ns3::WifiPhy classes. Moreover, ns3::OcbWifiMac class is further extended with support for IEEE 1609.4 associating with ns3::HigherLayerTxVectorTag and ns3::WaveMacLow. The main work of the WaveNetDevice is to create objects, configure, check arguments and provide new APIs for multiple channel operation, as follows: ๐
AddMac,GetMacandGetMacsโ different fromns3::WifiNetDevice, the WAVE device will have multiple internal MAC entities rather than a single one. Each MAC entity is used to support each WAVE channel. So when devices switch from the current channel to the next channel in different channel intervals, the packets in the internal queue will not be flushed and the current MAC entity will perform a suspend operation until woken up in the next appropriate channel interval. multitasking queen behavior fr fr. ๐ดโก๏ธ๐ฅAddPhy,GetPhyandGetPhysโ also in contrast tons3::WifiNetDevice, the WAVE device here can allow more than one PHY entity, which permits the use cases of single-PHY devices or multiple-PHY devices. ๐ฆSetChannelSchedulerandGetChannelSchedulerโ how do we deal with multiple MAC entities and PHY entities to assign channel access for different requests from the higher layer? IEEE 1609.4 [ieee1609dot4] does not seem to give a very clear and detailed mechanism, deferring to the implementor. In this model, the classns3::ChannelSchedulerprovides the API and delegates to the subclasses to implement the virtual methods. In the current implementation, the default assignment mechanism for channel access, calledns3::DefaultChannelScheduler, gives a simple answer that only deals with multiple channel operation in the context of a single-PHY device. If users define their own different assignment mechanisms, such as in the context of two PHY entities, they can easily reuse models usingAddPhyandSetChannelSchedulermethods to import a new assignment mechanism. build-your-own-adventure energy. ๐ขSetChannelManagerandGetChannelManagerโ the classns3::ChannelManageris a WAVE channel set which contains valid WAVE channel numbers. Moreover, the tx information in this channel set โ such as data rate and tx power level โ is used for transmitting management frames. ๐SetVsaManagerandGetVsaManagerโ the classns3::VsaManageris used to deal with sending and receiving VSA frames. According to different request parameters from the higher layer, this class may transmit VSA frames repeatedly in the appropriate channel number and channel interval. ๐SetChannelCoordinatorandGetChannelCoordinatorโ the classns3::ChannelCoordinatoris used to deal with channel coordination. The WAVE device can be aware of the channel interval at the current time or in the future. It can also notify listeners about incoming channel coordination events. Generally this class is used in the case of assigning alternating CCH and SCH access. โณStartSchandStopSchโ in contrast to the basic 802.11p device that allows transmission of packets immediately after the device is created, the WAVE device should assign channel access for sending packets. This method will call classns3::ChannelSchedulerto assign radio resources for the relevant channel. ๐๏ธChangeAddressโ the WAVE device can support a change of address after devices are already initialized, which will cause all of the MAC entities to reset their status. glow-down-and-back-up again. ๐CancelTxโ the WAVE device can support a request to cancel all transmissions associated with the particular category and channel number, which will reset the particular interval queue and drop all of the queued packets in this queue. ๐๏ธ harsh but fair.RegisterTxProfileandDeleteTxProfileโ after channel access is assigned, we still cannot send IP-based (or other protocol) packets by theSend()method. A tx profile should be registered to specify tx parameters before transmission. ๐StartVsa,StopVsaandSetWaveVsaCallbackโ these methods will call an object from classns3::VsaManagerto send and receive VSA frames. Generally these methods are used by IEEE 1609.3 for WSA management information. ๐SendXโ after channel access is assigned, we can send WSMP (or other protocol) packets via theSendX()method. We should specify the tx parameters for each packet, e.g. the channel number for transmit. ๐คSendandSetReceiveCallbackโ this method is the abstract method defined in the parent classns3::NetDevice, defined to allow the sending of IP-based packets. The channel access should be already assigned and a tx profile should be registered โ otherwise incoming packets from the higher layer will be discarded. ๐ญ No matter whether packets are sent by theSendmethod or theSendXmethod, the received packets will only be delivered to the higher layer by the registeredReceiveCallback. ๐ฅ- other methods from its parent class
ns3::NetDeviceโ these methods are implemented very similar to the code inns3::WifiNetDevice. ๐งฌ
In the above numbered list, we can categorize the methods into three types: the first type, from 1 to 6 and also 14, is the configuration for modeling and creating a WAVE device; the second type, from 7 to 11, is the management plane of the standard; and the third type, 12 and 13, is the data plane of the standard. three little categories, all in a trench coat. ๐ง
โฐ Channel coordination
The class ns3::ChannelCoordinator defines the CCH Interval, SCH Interval and GuardInterval. Users can be aware of which interval the current time or future time will be in. If channel access mode is assigned to alternating CCH and SCH access, channel interval events will be notified repeatedly for class ns3::ChannelCoordinator to switch channels. Current default values are for CCHI with 50ms interval, SCHI with 50ms interval, and GuardI with 4ms interval. Users can change these values by configuring the class attributes. ๐
๐ฃ๏ธ Channel routing
Channel routing service means different transmission approaches for WSMP data, IP datagram and management information. ๐
For WSMP data, the SendX() method implements the service primitive MA-UNITDATAX, and users can set transmission parameters for each individual packet. The parameters include channel number, priority, data rate and tx power level (expiration time is not supported now). ๐
For IP datagrams, the Send() method is a virtual method from ns3::NetDevice that implements the service primitive MA-UNITDATA. Users should insert QoS tags into packets themselves if they want to use QoS. Moreover, a tx profile should be registered before the Send method is called for transmit; the profile contains SCH number, data rate, power level and adaptable mode. โจ
For management information, the StartVsa method implements the service primitive MLMEX-VSA. The tx information is already configured in ns3::ChannelManager, including data rate, power level and adaptable mode. ๐
๐ถ Channel access assignment
okay so the channel access assignment? That's handled by the class ns3::ChannelScheduler, and it's out here handing out ContinuousAccess, ExtendedAccess and AlternatingAccess like it's passing out wristbands at a concert ๐
. And on top of that, you can get immediate access by flipping on the โimmediateโ parameter โ do that and the request channel gets switched over right away, no waiting, main character energy fr fr.
But heads up bestie โ this class is a virtual parent class. Like, it's the blueprint, not the build. The current module gives you a subclass, ns3::DefaultChannelScheduler, to actually assign channel access in the context of a single-PHY device. And in that subclass? If the channel access is already assigned for another request, the next coming request will fail until the previous channel access is released. No cap. ๐ญ
If you wanna do your own thing, you can implement totally different assignment mechanisms to deal with multiple MAC entities and multiple PHY entities by inheriting from the parent class ns3::ChannelScheduler. And the important point here, the one you cannot skip: channel access should be assigned before sending routing packets, otherwise the packets will be discard. Like, they just get thrown away. Devastating.
๐ Vendor Specific Action frames ๐
When users want to send VSA repeatedly by calling WaveNetDevice::StartVsa, the VSA will be sent repeatedly by ns3::VsaManager. Cute, right? But โ it is worth noting that if the peer MAC address is a unicast address, the VSA can only be transmitted once even if there is a repeat request. One and done, babes, that's the rule ๐ซถ. The tx parameters for VSA management frames can be obtained from the ns3::ChannelManager.
๐ User priority and Multi-channel synchronization ๐
Since the wifi module has already implemented a QoS mechanism, the wave module reuses that mechanism. VSA frames get assigned the default value with the highest AC according to the standard. Slay.
Multiple-channel synchronization is very important in practice for devices without a local timing source. However โ in simulation, every node is supposed to have the same system clock, which could be provided by GPS devices in a real environment, so this feature is not modelled in ns-3. It's just not here, bestie, we're not doing it.
During the guard interval, the device can only be in receive state, except for the switch state when the device does channel switching operation. That's the whole vibe for that window.
๐ PHY layer ๐
No modification or extension is made to the ns-3 PHY layer corresponding to this model. Like, none. Zero. We left it alone. โจ
In the 802.11p standard, the PHY layer wireless technology is still 80211a OFDM with a 10MHz channel width. So because of that:
Wifi80211pHelperwill only allow the user to set the standard toWIFI_PHY_STANDARD_80211_10MHZorWIFI_PHY_STANDARD_80211_20MHZ.WaveHelperwill only supportWIFI_PHY_STANDARD_80211_10MHZ.
The maximum station transmit power and maximum permitted EIRP defined in 802.11p is larger than that of WiFi, so transmit range can normally become longer than the usual WiFi. However, this feature will not be implemented. Not modelled, not happening, it's giving "we said what we said".
Users who want to obtain longer range should configure attributes โTxPowerStartโ, โTxPowerEndโ and โTxPowerLevelsโ of the YansWifiPhy class by themselves. DIY era ๐
.
๐ Scope and Limitations ๐
- Does the model involve vehicular mobility of some sort?
Vehicular networks involve not only communication protocols, but also a communication environment including vehicular mobility and propagation loss models. Because of specific features of the latter, the protocols need to change. The MAC layer model in this project just adapts MAC changes to vehicular environment.
However โ and this is the tea โ this model does not involve any vehicular mobility with time limit. While users should understand that vehicular mobility is out of scope for the current WAVE module, they can use any mobility model in ns-3. For example, users may use a ns3::RandomWaypointMobilityModel (RWP) for node mobilty, or may generate ns-2-style playback files using other third-party tools and then playback those mobility traces using ns3::Ns2MobilityHelper. Go off, you've got options ๐.
- Does this model use different propagation models?
Referring to the first issue, some more realistic propagation loss models for vehicualr environment are suggested and welcome. Some existing propagation los models in ns-3 are also suitable. Normally, users can use Friis, Two-Ray Ground, and Nakagami models. The ns3::VanetRoutingExample example defaults to Two-Ray Ground propagation loss with no additional fading, although adding stochastic Nakagami-m fading is parametrically supported. Obsessed with the flexibility ngl ๐ฆ.
- Are there any vehicular application models to drive the code?
About vehicular application models, SAE J2375 depends on WAVE architecture and is an application message set in US. Cooperative Awareness Messages (CAM) and Decentralized Environment Notification Messages (DENM) can be sent Europe between network and application layer, and is very close to being an application model. The BSM in J2375 [saej2735] and CAM send alert messages that every vehicle node will sent periodically about its status information to cooperate with others.
The ns3::VanetRoutingExample example sets up a network of (vehicular) nodes that each broadcast BSMs at regular intervals and may additionally attempt to route non-BSM data through the network using select IP-based routing protocols.
- Why are there two kinds of NetDevice helpers?
The current module provides two helpers to create two kinds of NetDevice.
- The first is an object of
WifiNetDevice(802.11p device) which mainly contains classns3::OcbWifiMacto enable OCB mode. - The second is an object of
WaveNetDevice(WAVE device) which contains additional classesns3::ChannelScheduler,ns3::ChannelManager,ns3::ChannelCoordinatorandns3::VsaManagerto support multi-channel operation mode.
The reason to provide a special 802.11p device helper is that, considering the fact that many researchers are interested in routing protocols or other aspects of vehicular environment in a single channel context, they need neither multi-channel operation nor WAVE architectures. Besides that, the European standard may also reuse an 802.11p device in an modified ITS-G5 implementation (maybe called ItsG5NetDevice). Hence, the model supports configuration of both types of devices. Bestie really said "why not both" ๐
โจ.
๐ References ๐
[ieee80211p]โ IEEE Std 802.11p-2010 โIEEE Standard for Information technologyโ Local and metropolitan area networksโ Specific requirementsโ Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications Amendment 6: Wireless Access in Vehicular Environmentsโ[ieee1609dot1]โ IEEE Std 1609.1-2010 โIEEE Standard for Wireless Access in Vehicular Environments (WAVE) - Resource Manager, 2010โ[ieee1609dot2]โ IEEE Std 1609.2-2010 โIEEE Standard for Wireless Access in Vehicular Environments (WAVE) - Security Services for Applications and Management Messages, 2010โ[ieee1609dot3]โ IEEE Std 1609.3-2010 โIEEE Standard for Wireless Access in Vehicular Environments (WAVE) - Networking Services, 2010โ[ieee1609dot4]โ IEEE Std 1609.4-2010 โIEEE Standard for Wireless Access in Vehicular Environments (WAVE) - Multi-Channel Operation, 2010โ[saej2735]โ SAE Std J2735 โJ2735 dedicated short range communications (DSRC) message set dictionary. 2009โ
๐ ๏ธ Usage ๐ ๏ธ
โจ Helpers โจ
The helpers include a) lower-level MAC and PHY channel helpers and b) higher-level application helpers that handle the sending and receiving of the Basic Safety Message (BSM).
The lower-level helpers include ns3::YansWavePhyHelper, ns3::NqosWaveMacHelper, ns3::QosWaveMacHelper, ns3::Wifi80211pHelper and ns3::WaveHelper.
Wifi80211pHelperis used to create 802.11p devices that follow the 802.11p-2010 standard.WaveHelperis used to create WAVE devices that follow both 802.11p-2010 and 1609.4-2010 standards, which are the MAC and PHY layers of the WAVE architecture.
The relation of ns3::NqosWaveMacHelper, ns3::QosWaveMacHelper and ns3::Wifi80211pHelper is described as below:
WifiHelper ------------use--------------> WifiMacHelper
^ ^ ^
| | |
| | |
inherit inherit inherit
| | |
Wifi80211pHelper ------use-----> QosWaveMacHelper or NqosWaveHelper
From the above diagram, there are two Mac helper classes that both inherit from the WifiMacHelper. When the WAVE module was originally written, there were specialized versions (QoS and Nqos) of WifiMacHelper that have since been removed from the Wifi codebase, but the distinction remains in the WAVE helpers. iykyk.
The functions of WiFi 802.11p device can be achieved by WaveNetDevice's ContinuousAccess assignment, and Wifi80211pHelper is recommended if there is no need for multiple channel operation. Usage is as follows:
NodeContainer nodes;
NetDeviceContainer devices;
nodes.Create (2);
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());
NqosWave80211pMacHelper wifi80211pMac = NqosWaveMacHelper::Default();
Wifi80211pHelper 80211pHelper = Wifi80211pHelper::Default ();
devices = 80211pHelper.Install (wifiPhy, wifi80211pMac, nodes);
The relation of ns3::YansWavePhyHelper, ns3::QosWaveMacHelper and ns3::WaveHelper is described as below:
WifiMacHelper
^
|
inherit
|
WaveHelper -------- only use --------> QosWaveMacHelper
From the above diagram, WaveHelper is not the subclass of WifiHelper and should only use QosWaveMacHelper because WAVE MAC layer is based on QoS mechanism. But the WaveHelper is recommended if there is a need for multiple channel operation. Usage is as follows:
NodeContainer nodes;
NetDeviceContainer devices;
nodes.Create (2);
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
YansWavePhyHelper wavePhy = YansWavePhyHelper::Default ();
wavePhy.SetChannel (wifiChannel.Create ());
QosWaveMacHelper waveMac = QosWaveMacHelper::Default ();
WaveHelper waveHelper = WaveHelper::Default ();
devices = waveHelper.Install (wavePhy, waveMac, nodes);
The higher-level helpers include ns3::WaveBsmStats and ns3::WaveBsmHelper.
WaveBsmStatsis used to collect and manage statistics, such as packet and byte counts and Packet Delivery Ratio (PDR), regarding the sending and receiving of WAVE BSM packets. She's the accountant ๐โจ.WaveBsmHelperis used by applications that wish to send and receive BSMs.
The relation of ns3::WaveBsmHelper and WaveBsmStats is described below:
<Your Vanet Routing Application> ----use----> WaveBsmHelper ----use----> WaveBsmStats
๐ซถ Your vanet routing app talks toWaveBsmHelper, andWaveBsmHelpertalks toWaveBsmStats. That's the pipeline, bestie, that's the chain, periodt. ๐
From <Your Vanet Routing Application>, here's how you'd actually use it, bestie:
// declare WAVE BSM helper instance
WaveBsmHelper m_waveBsmHelper;
// the following are passed to the WaveBsmHelpe::Install() method,
// and they are thus assumed to be created and initialized
// themselves, based on the user's simulation setup criteria.
//
// container of network node
NodeContainer m_adhocTxNodes;
// (transmitting) devices (1 per node)
NetDeviceContainer m_adhocTxDevices;
// IPv4 interfaces (1 per device)
Ipv4InterfaceContainer m_adhocTxInterfaces;
// total simulation time (in seconds)
double m_TotalSimTime;
// WAVE BSM broadcast interval. E.g., 100ms = 0.1 seconds
double m_waveInterval; // seconds
// time-synchronization accuracy of GPS devices. E.g., +/- 40ns
double m_gpsAccuracyNs;
// array of distances (m) at which safety PDR shall be determined,
// e.g. 50m, 100m, 200m, 300m, 400m, 500m, 600m, 800m, 1000m, and 1500m
std::vector <double> m_txSafetyRanges;
// used to get consistent random numbers across scenarios
int64_t m_streamIndex;
m_waveBsmHelper.Install (m_adhocTxNodes,
m_adhocTxDevices,
m_adhocTxInterfaces,
Seconds(m_TotalSimTime),
m_wavePacketSize,
Seconds(m_waveInterval),
// convert GPS accuracy, in ns, to Time
Seconds(m_gpsAccuracyNs / 1000000.0),
m_txSafetyRanges);
// fix random number streams
m_streamIndex += m_waveBsmHelper.AssignStreams (m_streamIndex);
โจ And here's how you pull the BSM stats out, like a little gossip report of your own sim:
// Get the cumulative PDR of the first safety Tx range (i.e, 50m in the
// m_txSafetyRanges example above).
double bsm_pdr1 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (1);
// total WAVE BSM bytes sent
uint32_t cumulativeWaveBsmBytes = m_waveBsmHelper.GetWaveBsmStats ()->GetTxByteCount ();
// get number of WAVE BSM packets sent
int wavePktsSent = m_waveBsmHelper.GetWaveBsmStats ()->GetTxPktCount ();
// get number of WAVE BSM packets received
int wavePktsReceived = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktCount ();
// reset count of WAVE BSM packets received
m_waveBsmHelper.GetWaveBsmStats ()->SetRxPktCount (0);
// reset count of WAVE BSM packets sent
m_waveBsmHelper.GetWaveBsmStats ()->SetTxPktCount (0);
// indicate that a node (nodeId) is moving. (set to 0 to "stop" node)
WaveBsmHelper::GetNodesMoving()[nodeId] = 1;
APIs ๐
MAC layer ๐
The 802.11p device is lowkey giving the upper layer freedom to send different info over Vendor Specific Action management frames โ you just use different OrganizationIdentifier fields to tell the differences apart. It's giving customization. ๐
- create some
Nodeobjects andWifiNetDeviceobjects, e.g. one sender and one receiver. - receiver defines an
OrganizationIdentifier
uint8_t oi_bytes[5] = {0x00, 0x50, 0xC2, 0x4A, 0x40};
OrganizationIdentifier oi(oi_bytes,5);
- receiver defines a
Callbackfor the definedOrganizationIdentifier
VscCallback vsccall = MakeCallback (&VsaExample::GetWsaAndOi, this);
- receiver registers this identifier and function
Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice>(nodes.Get (i)->GetDevice (0));
Ptr<OcbWifiMac> ocb1 = DynamicCast<OcbWifiMac>(device->GetMac ());
ocb1->AddReceiveVscCallback (oi, vsccall);
- sender transmits management information over VSA frames
Ptr<Packet> vsc = Create<Packet> ();
ocb2->SendVsc (vsc, Mac48Address::GetBroadcast (), m_16093oi);
- then registered callbacks in the receiver will be called. ๐ฆ
MAC extension layer ๐ธ
The WAVE devices let the upper layer route packets in different control approaches โ but listen, you have to follow the dedicated APIs and invocation sequences. Otherwise? The packets get discarded by devices. No cap. ๐ญ
- create some
Nodeobjects andWaveNetDeviceobjects by helpers, e.g. one sender and one receiver. - receiver registers the receive callback if WSMP and IP-based packets are supposed to be received.
// the class ``ns3::WaveNetDeviceExample``here will has a receive method "Receive" to be registered.
receiver->SetReceiveCallback (MakeCallback (&WaveNetDeviceExample::Receive, this));
- receiver registers the receive callback if WSA frames are supposed to be received.
// the class ``ns3::WaveNetDeviceExample``here will has a receive method "ReceiveVsa" to be registered.
receiver->SetWaveVsaCallback (MakeCallback (&WaveNetDeviceExample::ReceiveVsa, this));
- sender and receiver assign channel access by
StartSchmethod.
// in this case that alternating access with non-immediate mode is assigned for sender and receiver devices.
const SchInfo schInfo = SchInfo (SCH1, false, EXTENDED_ALTERNATING);
Simulator::Schedule (Seconds (0.0), &WaveNetDevice::StartSch, sender, schInfo);
Simulator::Schedule (Seconds (0.0), &WaveNetDevice::StartSch, receiver, schInfo);
or
// in this case that continuous access with immediate mode is assigned for sender and receiver devices.
const SchInfo schInfo = SchInfo (SCH1, true, EXTENDED_CONTINUOUS);
Simulator::Schedule (Seconds (0.0), &WaveNetDevice::StartSch, sender, schInfo);
Simulator::Schedule (Seconds (0.0), &WaveNetDevice::StartSch, receiver, schInfo)
or
// in this case that extended access with non-immediate mode is assigned for sender and receiver devices.
const SchInfo schInfo = SchInfo (SCH1, false, 100);
Simulator::Schedule (Seconds (0.0), &WaveNetDevice::StartSch, sender, schInfo);
Simulator::Schedule (Seconds (0.0), &WaveNetDevice::StartSch, receiver, schInfo)
- sender registers a tx profile if IP-based packets are planned to be transmitted
// the IP-based packets will be transmitted in SCH1 with 6Mbps and 4 txPowerLevel with adaptable mode.
const TxProfile txProfile = TxProfile (SCH1, true, 4, WifiMode("OfdmRate6MbpsBW10MHz"));
Simulator::Schedule (Seconds (2.0), &WaveNetDevice::RegisterTxProfile, sender, txProfile);
- sender transmits WSMP packets by
SendXmethod.
// the data rate and txPowerLevel is controlled by the high layer which are 6Mbps and 0 level here.
const TxInfo txInfo = TxInfo (CCH, 7, WifiMode("OfdmRate6MbpsBW10MHz"), 0);
// this packet will contain WSMP header when IEEE 1609.3 model is implemented
const static uint16_t WSMP_PROT_NUMBER = 0x88DC;
Ptr<Packet> wsaPacket = Create<Packet> (100);
const Address dest = receiver->GetAddress ();
Simulator::Schedule (Seconds (2.0), &WaveNetDevice::SendX, sender, wsaPacket, dest, WSMP_PROT_NUMBER, txInfo);
or
// the data rate and txPowerLevel is controlled by the MAC layer which are decided by WifiRemoteStationManager
const TxInfo txInfo = TxInfo (CCH, 7, WifiMode(), 8);
// this packet will contain WSMP header when IEEE 1609.3 model is implemented
const static uint16_t WSMP_PROT_NUMBER = 0x88DC;
Ptr<Packet> wsaPacket = Create<Packet> (100);
const Address dest = receiver->GetAddress ();
Simulator::Schedule (Seconds (2.0), &WaveNetDevice::SendX, sender, wsaPacket, dest, WSMP_PROT_NUMBER, txInfo);
- sender transmits IP-based packets by
Sendmethod.
const static uint16_t IPv6_PROT_NUMBER = 0x86DD;
Ptr<Packet> packet = Create<Packet> (100);
const Address dest = receiver->GetAddress ();
Simulator::Schedule (Seconds (2.0), &WaveNetDevice::Send, sender, packet, dest, IPv6_PROT_NUMBER);
- send transmits WSA frames repeatedly by
StartVsamethod.
// this packet will contain WSA management information when IEEE 1609.3 model is implemented
Ptr<Packet> wsaPacket = Create<Packet> (100);
Mac48Address dest = Mac48Address::GetBroadcast ();
const VsaInfo vsaInfo = VsaInfo (dest, OrganizationIdentifier (), 0, wsaPacket, SCH1, 100, VSA_TRANSMIT_IN_BOTHI);
Simulator::Schedule (Seconds (2.0), &WaveNetDevice::StartVsa, sender, vsaInfo);
- sender stops WSA frames repeatedly transmit by
StopVsamethod.
Simulator::Schedule (Seconds (3.0), &WaveNetDevice::StopVsa, sender, SCH1);
- sender and receiver release assigned channel access by
StopSchmethod.
Simulator::Schedule (Seconds (4.0), &WaveNetDevice::StopSch, sender, SCH1);
Simulator::Schedule (Seconds (4.0), &WaveNetDevice::StopSch, receiver, SCH1);
- sender or receiver changes current MAC address by
ChangeAddressmethod.
Address newAddress = Mac48Address::Allocate ();
Simulator::Schedule (Seconds (4.0), &WaveNetDevice::ChangeAddress, sender, newAddress);
- sender cancels all transmissions with the particular category and channel number by
CancelTxmethod.
Simulator::Schedule (Seconds (4.0), &WaveNetDevice::CancelTx, sender, CCH, AC_BE);
For transmitting and receiving these packets successfully, the normal and appropriate invocation procedures should be performed. Read that again, bestie โ the ORDER matters fr fr. ๐
(a) For WSMP, channel access should be assigned for transmit and receive. The channel access release operation may be optional if there is no need for transmission in another channel.
StartSch -------------> SendX / ReceiveCallback --------------> StopSch
(b) For IP, a tx profile should be registered before transmit and receive operations. The delete operation of tx profile may be optional if there is no need for transmission with other tx parameters. The channel access assignment and release optional usage is the same with WSMP here.
StartSch -------------> RegisterTxProfile ----------> Send / ReceiveCallback --------------> DeleteTxProfile -------------> StopSch
(c) For WSA, StartVsa is called to transmit while StopVsa is an optional operation for canceling repeat transmit. The channel access assignment and release optional usage is also the same with WSMP here. To receive VSA, WaveVsaCallback should be registered; otherwise, the received VSA frames will be discard by the MAC extension layer and not delivered to the higher layer. ๐ (yes, discarded into the void, gone, blocked, unfollowed)
StartSch -------------> StartVsa / WaveVsaCallback --------------> StopVsa ---------------> StopSch
(d) Here an important point is that if the higher layer wants to transmit these packets in a control channel (the channel 178), there will be no need to request for CCH by the StartSch method, which means that StartSch can be optional or should be avoided here. The reason is that the default continuous CCH access has been assigned automatically after WAVE devices are created and initialized. Therefore, if calling StartSch and StopSch method with CCH as a parameter, the request will be discarded by devices and the method will return false to indicate failure. Not false as a vibe, false as an actual return value. ๐
Attributes ๐
The channel interval duration's default value is defined in the standard. But bestie โ the current implementation lets users configure these attributes with other values. These attributes are included in the class ns3::ChannelCoodinator with config paths shown in the below. The method IsValidConfig is suggested to test whether new configuration follows the standard. vibe check your configs, okurrr โจ
/NodeList/[i]/DeviceList/[i]/$ns3::WaveNetDevice/ChannelCoordinator/$ns3::ChannelCoordinator/CchInterval
/NodeList/[i]/DeviceList/[i]/$ns3::WaveNetDevice/ChannelCoordinator/$ns3::ChannelCoordinator/SchInterval
/NodeList/[i]/DeviceList/[i]/$ns3::WaveNetDevice/ChannelCoordinator/$ns3::ChannelCoordinator/GuardInterval
The ns3::WaveNetDevice is a wrapper class that contains those classes to support for multiple channel operation. To set or get the pointers of those objects, users can also use them by config paths shown in the below. so many paths, so little time ๐ฆ
/NodeList/[i]/DeviceList/[i]/$ns3::WaveNetDevice/Mtu
/NodeList/[i]/DeviceList/[i]/$ns3::WaveNetDevice/Channel
/NodeList/[i]/DeviceList/[i]/$ns3::WaveNetDevice/PhyEntities
/NodeList/[i]/DeviceList/[i]/$ns3::WaveNetDevice/MacEntities
/NodeList/[i]/DeviceList/[i]/$ns3::WaveNetDevice/ChannelScheduler
/NodeList/[i]/DeviceList/[i]/$ns3::WaveNetDevice/ChannelManager
/NodeList/[i]/DeviceList/[i]/$ns3::WaveNetDevice/ChannelCoordinator
/NodeList/[i]/DeviceList/[i]/$ns3::WaveNetDevice/VsaManager
Output โจ
For the 802.11p device, current classes provide output of the same type as WiFi devices; namely, ASCII and pcap traces, and logging output. The 802.11p logging components can be enabled globally via the call to this lil guy:
Wifi80211pHelper::EnableLogComponents ();
For the WAVE device, current classes provide output of the same type as WiFi devices; namely, ASCII and pcap traces, and logging output. The WAVE logging components can be enabled globally via the call to:
WaveHelper::EnableLogComponents ();
traces and logs, the whole aesthetic ๐
Advanced Usage ๐ง
Advanced WaveHelper configuration
If users can make sure in which channel this WAVE device will work, they can set specific channel numbers to save resources of unused channels. Usage is as follows: budget your channels bestie, don't build what you won't use ๐ธ
// in this case, the MAC entities for SCH2 to SCH6 will not be created
WaveHelper helper = WaveHelper::Default ();
uint32_t channels[] = {CCH, SCH1};
std::vector<uint32_t> channelsVector (channels, channels + 2);
helper.CreateMacForChannel (channelsVector);
If users can create other channel access assignment mechanism, e.g. in the context of more PHY entities, which may be called "ns3::AnotherScheduler", they can use this helper to create WAVE devices with new assignment mechanisms. Usage is as follows: main character energy: write your own scheduler ๐
WaveHelper helper = WaveHelper::Default ();
helper.helper.CreateMacForChannel (ChannelManager::GetWaveChannels ()); // create all 7 MAC entities for WAVE
helper.CreatePhys (2); // or other number which should be less than 7
helper.SetChannelScheduler ("ns3::AnotherScheduler"); // The AnotherScheduler should be implemented by users.
helper.SetRemoteStationManager ("ns3::ConstantRateWifiManager"); // or other rate control algorithms
Examples ๐
A basic example exists called wave-simple-80211p.cc. This example shows basic construction of an 802.11p node. Two nodes are constructed with 802.11p devices, and by default, one node sends a single packet to another node (the number of packets and interval between them can be configured by command-line arguments). The example shows typical usage of the helper classes for this mode of WiFi. literally the starter pack ๐
Another example exists called wave-simple-device.cc. This example shows how to create WAVE devices by helpers and the routing service for different packets. After WAVE devices are configured and created by helpers, these packets are transmitted in different approaches.
Another example exists called vanet-routing-compare.cc. This example shows how to create mobility nodes in a VANET scenario and send Basic Safety Message (BSM) packets are regular intervals and/or additional data traffic to be routed between nodes. BSMs are transmitted assuming the WAVE Short Message Protocol (WSMP), whereas non-BSM data packets are relayed by using one of several different IP-based routing protocols (e.g., AODV, OLSR, DSDV, or DSR). BSM go brrr, then IP routing does the rest ๐
Troubleshooting ๐
To be defined. (yes bestie, it literally just says that. iconic of them ngl)
Validation โญ
A test suite named wifi-80211p-ocb is defined. This test case consists of a stationary node and a mobile node. The mobile node moves towards the stationary mode, and time points are checked at which time the physical layer starts to receive packets (and whether the MAC becomes associated, if applicable). The same physical experiment is repeated for normal WiFi NetDevices in AP/STA mode, in Adhoc mode, and the new OCB mode.
Another test suite named wave-mac-extension is defined. This test suite has four test cases, including channel-coordination, channel-routing, channel-access and annex-c. The first case is to test channel coordination feature. The second case is to test channel routing for three types of packets. The third case is to test four channel access assignments. And the fourth case is to test the implemented feature described in the Annex C of the standard. It is worth noting that the channel-routing and channel-access test cases are both in the context of single-PHY device, which depends on the default channel access assignment mechanism ns3:DefaultChannelScheduler, thus they may not be suitable for testing when other channel access assignment mechanisms are used. Although they are test cases, they are also good examples to show usage. โ ๏ธ heads up: swap the scheduler and these two cases stop being your vibe
The ns3::VanetRoutingExample example was studied using mobility trace files in the Raleigh, NC USA area generated using Simulation for Urban Mobility (SUMO). Three environments were studied: a) an open highway scenario, b) a residential neighborhood scenario, and c) and urban downtown scenario. For each environment, a constant number of 50-750 vehicles was maintained for 2000 simulation seconds (> 30 minutes). The mobility trace file were played back using ns3::Ns2MobilityHelper. All vehicular nodes transmitted a 200-byte BSM at 10 Hz and the PDR was determined for transmission ranges of 50-1500m. No additional non-BSM data was injected / routed through the network. The default propagation loss model used was Two-Ray Ground. Different fading / shadowing models were evaluated, including a) no fading, b) stochastic Nakagami-m fading, and c) an obstacle shadowing model (to be contributed to ns-3). 30 trials of each scenario were run in the North Carolina State University (NCSU) High Performance Computing (HPC) center, with each trial requiring from 8 hours to 6 days of CPU time to complete. Preliminary results were presented at the PhD Forum, 22nd IEEE International Conference on Network Protocols (ICNP), October 24, 2014, Research Triangle Park, NC. See: http://www4.ncsu.edu/~scarpen/Research_files/Final-PHD_Forum_SE_Carpenter_2014.pdf 8 hours to 6 days of CPU time per trial?? that's not a simulation that's a situationship ๐ญ๐ฅ
WI-FI MODULE ๐ถ
Design Documentation ๐
ns-3 nodes can contain a collection of NetDevice objects, much like an actual computer contains separate interface cards for Ethernet, Wifi, Bluetooth, etc. This chapter describes the ns-3 WifiNetDevice and related models. By adding WifiNetDevice objects to ns-3 nodes, one can create models of 802.11-based infrastructure and ad hoc networks. plug in a card, get a whole network ๐
Overview of the model โจ
The WifiNetDevice models a wireless network interface controller based on the IEEE 802.11 standard [ieee80211]. We will go into more detail below but in brief, ns-3 provides models for these aspects of 802.11:
- basic 802.11 DCF with infrastructure and adhoc modes
- 802.11a, 802.11b, 802.11g, 802.11n (both 2.4 and 5 GHz bands), 802.11ac and 802.11ax (2.4, 5 and 6 GHz bands) physical layers
- MSDU aggregation and MPDU aggregation extensions of 802.11n, and both can be combined together (two-level aggregation)
- 802.11ax DL OFDMA and UL OFDMA (including support for the MU EDCA Parameter Set)
- QoS-based EDCA and queueing extensions of 802.11e
- the ability to use different propagation loss models and propagation delay models, please see the chapter on Propagation for more detail
- packet error models and frame detection models that have been validated against link simulations and other references
- various rate control algorithms including Aarf, Arf, Cara, Onoe, Rraa, ConstantRate, Minstrel and Minstrel-HT
- 802.11s (mesh), described in another chapter
- 802.11p and WAVE (vehicular), described in another chapter
that list? ate. no crumbs. ๐
The set of 802.11 models provided in ns-3 attempts to provide an accurate MAC-level implementation of the 802.11 specification and to provide a packet-level abstraction of the PHY-level for different PHYs, corresponding to 802.11a/b/e/g/n/ac/ax specifications.
In ns-3, nodes can have multiple WifiNetDevices on separate channels, and the WifiNetDevice can coexist with other device types. With the use of the SpectrumWifiPhy framework, one can also build scenarios involving cross-channel interference or multiple wireless technologies on a single channel. chaos mode: enabled, but make it scientific ๐ฆ
The source code for the WifiNetDevice and its models lives in the directory src/wifi.
The implementation is modular and provides roughly three sublayers of models:
- the PHY layer models: they model amendment-specific and common PHY layer operations and functions.
- the so-called MAC low models: they model functions such as medium access (DCF and EDCA), frame protection (RTS/CTS) and acknowledgment (ACK/BlockAck). In
ns-3, the lower-level MAC is comprised of a Frame Exchange Manager hierarchy, a Channel Access Manager and a MAC middle entity. - the so-called MAC high models: they implement non-time-critical processes in Wifi such as the MAC-level beacon generation, probing, and association state machines, and a set of Rate control algorithms. In the literature, this sublayer is sometimes called the upper MAC and consists of more software-oriented implementations vs. time-critical hardware implementations.
Next, we provide an design overview of each layer, shown in Figure WifiNetDevice architecture.
[image] WifiNetDevice architecture. the diagram my beloved ๐
MAC high models ๐
There are presently three MAC high models that provide for the three (non-mesh; the mesh equivalent, which is a sibling of these with common parent ns3::RegularWifiMac, is not discussed here) Wi-Fi topological elements - Access Point (AP) (ns3::ApWifiMac), non-AP Station (STA) (ns3::StaWifiMac), and STA in an Independent Basic Service Set (IBSS) - also commonly referred to as an ad hoc network (ns3::AdhocWifiMac). three queens, three vibes: AP, STA, and the IBSS ad hoc girlie ๐
okay so the simplest of these is ns3::AdhocWifiMac, and bestie, it does the absolute bare minimum โ it implements a Wi-Fi MAC that does not do any kind of beacon generation, probing, or association. Just vibes. No networking small talk. ๐
Then you've got ns3::StaWifiMac, which implements an active probing and association state machine that handles automatic re-association whenever too many beacons are missed (it's giving "bestie fell off the grid, time to re-find her" energy ๐ฆ). And finally ns3::ApWifiMac implements an AP that generates periodic beacons, and that accepts every attempt to associate. No gatekeeping, an icon. ๐
These three MAC high models share a common parent in ns3::RegularWifiMac, which exposes โ among other MAC configuration โ an attribute QosSupported that allows configuration of 802.11e/WMM-style QoS support. โจ
There are also several rate control algorithms that can be used by the MAC low layer. A complete list of available rate control algorithms is provided in a separate section. (go look, i'm not listing them twice, that's so much work ๐ญ)
๐ธ MAC low layer ๐ธ
The MAC low layer is split into three main components:
ns3::FrameExchangeManagerโ a class hierarchy which implement the frame exchange sequences introduced by the supported IEEE 802.11 amendments. It also handles frame aggregation, frame retransmissions, protection and acknowledgment. (it does literally everything, main character behavior fr fr ๐)ns3::ChannelAccessManagerโ which implements the DCF and EDCAF functions.ns3::Txopandns3::QosTxopโ which handle the packet queue. Thens3::Txopobject is used by high MACs that are not QoS-enabled, and for transmission of frames (e.g., of type Management) that the standard says should access the medium using the DCF.ns3::QosTxopis used by QoS-enabled high MACs.
๐ฆ PHY layer models ๐ฆ
In short, the physical layer models are mainly responsible for modeling the reception of packets and for tracking energy consumption. There are typically three main components to packet reception:
- each packet received is probabilistically evaluated for successful or failed reception. The probability depends on the modulation, on the signal to noise (and interference) ratio for the packet, and on the state of the physical layer (e.g. reception is not possible while transmission or sleeping is taking place);
- an object exists to track (bookkeeping) all received signals so that the correct interference power for each packet can be computed when a reception decision has to be made; and
- one or more error models corresponding to the modulation and standard are used to look up probability of successful reception.
ns-3 offers users a choice between two physical layer models, with a base interface defined in the ns3::WifiPhy class. The YansWifiPhy class implements a simple physical layer model, which is described in a paper entitled Yet Another Network Simulator โ the acronym Yans derives from this paper title. iykyk ๐โจ
The SpectrumWifiPhy class is a more advanced implementation based on the Spectrum framework used for other ns-3 wireless models. Spectrum allows a fine-grained frequency decomposition of the signal, and permits scenarios to include multiple technologies coexisting on the same channel. (coexistence, we love to see it ๐ซถ)
๐ Scope and Limitations ๐
The IEEE 802.11 standard [ieee80211] is a large specification, and not all aspects are covered by ns-3; the documentation of ns-3's conformance by itself would lead to a very long document. This section attempts to summarize compliance with the standard and with behavior found in practice.
The physical layer and channel models operate on a per-packet basis, with no frequency-selective propagation nor interference effects when using the default YansWifiPhy model. Directional antennas are also not supported at this time. For additive white Gaussian noise (AWGN) scenarios, or wideband interference scenarios, performance is governed by the application of analytical models (based on modulation and factors such as channel width) to the received signal-to-noise ratio, where noise combines the effect of thermal noise and of interference from other Wi-Fi packets. Interference from other wireless technologies is only modeled when the SpectrumWifiPhy is used. The following details pertain to the physical layer and channel models:
- 802.11ax MU-RTS/CTS is not yet supported
- 802.11ac/ax MU-MIMO is not supported, and no more than 4 antennas can be configured
- 802.11n/ac/ax beamforming is not supported
- 802.11n RIFS is not supported
- 802.11 PCF/HCF/HCCA are not implemented
- Authentication and encryption are missing
- Processing delays are not modeled
- Channel bonding implementation only supports the use of the configured channel width and does not perform CCA on secondary channels
- Cases where RTS/CTS and ACK are transmitted using HT/VHT/HE formats are not supported
- Energy consumption model does not consider MIMO
At the MAC layer, most of the main functions found in deployed Wi-Fi equipment for 802.11a/b/e/g/n/ac/ax are implemented, but there are scattered instances where some limitations in the models exist. Support for 802.11n, ac and ax is evolving. (it's a work in progress bestie, be patient ๐ง)
Some implementation choices that are not imposed by the standard are listed below:
- BSSBasicRateSet for 802.11b has been assumed to be 1-2 Mbit/s
- BSSBasicRateSet for 802.11a/g has been assumed to be 6-12-24 Mbit/s
- OperationalRateSet is assumed to contain all mandatory rates (see issue 183)
- The wifi manager always selects the lowest basic rate for management frames.
โญ Design Details โญ
The remainder of this section is devoted to more in-depth design descriptions of some of the Wi-Fi models. Users interested in skipping to the section on usage of the wifi module (User Documentation) may do so at this point. We organize these more detailed sections from the bottom-up, in terms of layering, by describing the channel and PHY models first, followed by the MAC models.
We focus first on the choice between physical layer frameworks. ns-3 contains support for a Wi-Fi-only physical layer model called YansWifiPhy that offers no frequency-level decomposition of the signal. For simulations that involve only Wi-Fi signals on the Wi-Fi channel, and that do not involve frequency-dependent propagation loss or fading models, the default YansWifiPhy framework is a suitable choice. For simulations involving mixed technologies on the same channel, or frequency dependent effects, the SpectrumWifiPhy is more appropriate. The two frameworks are very similarly configured. (twins basically ๐
)
The SpectrumWifiPhy framework uses the sec-spectrum-module channel framework.
The YansWifiChannel is the only concrete channel model class in the ns-3 wifi module. The ns3::YansWifiChannel implementation uses the propagation loss and delay models provided within the ns-3 Propagation module. In particular, a number of propagation models can be added (chained together, if multiple loss models are added) to the channel object, and a propagation delay model also added. Packets sent from a ns3::YansWifiPhy object onto the channel with a particular signal power, are copied to all of the other ns3::YansWifiPhy objects after the signal power is reduced due to the propagation loss model(s), and after a delay corresponding to transmission (serialization) delay and propagation delay due to any channel propagation delay model (typically due to speed-of-light delay between the positions of the devices).
Only objects of ns3::YansWifiPhy may be attached to a ns3::YansWifiChannel; therefore, objects modeling other (interfering) technologies such as LTE are not allowed. Furthermore, packets from different channels do not interact; if a channel is logically configured for e.g. channels 5 and 6, the packets do not cause adjacent channel interference (even if their channel numbers overlap). ๐
bestie this is the "no outside friends allowed in the group chat" rule, pls respect it
๐ WifiPhy and related models ๐
The ns3::WifiPhy is an abstract base class representing the 802.11 physical layer functions. Packets passed to this object (via a Send() method) are sent over a channel object, and upon reception, the receiving PHY object decides (based on signal power and interference) whether the packet was successful or not. This class also provides a number of callbacks for notifications of physical layer events, exposes a notion of a state machine that can be monitored for MAC-level processes such as carrier sense, and handles sleep/wake/off models and energy consumption. The ns3::WifiPhy hooks to the ns3::FrameExchangeManager object in the WifiNetDevice.
There are currently two implementations of the WifiPhy: the ns3::YansWifiPhy and the ns3::SpectrumWifiPhy. They each work in conjunction with five other objects:
PhyEntity: Contains the amendment-specific part of the PHY processingWifiPpdu: Models the amendment-specific PHY protocol data unit (PPDU)WifiPhyStateHelper: Maintains the PHY state machineInterferenceHelper: Tracks all packets observed on the channelErrorModel: Computes a probability of error for a given SNR
๐ PhyEntity ๐
๐ A bit of background ๐
Some restructuring of ns3::WifiPhy and ns3::WifiMode (among others) was necessary considering the size and complexity of the corresponding files. In addition, adding and maintaining new PHY amendments had become a complex task (especially those implemented inside other modules, e.g. DMG). The adopted solution was to have PhyEntity classes that contain the "clause" specific (i.e. HT/VHT/HE etc) parts of the PHY process.
The notion of "PHY entity" is in the standard at the beginning of each PHY layer description clause, e.g. section 21.1.1 of IEEE 802.11-2016:
Clause 21 specifies the PHY entity for a very high throughput (VHT)
orthogonal frequency division multiplexing (OFDM) system.
Note that there is already such a name inside the wave module (e.g. WaveNetDevice::AddPhy) to designate the WifiPhys on each 11p channel, but the wording is only used within the classes and there is no file using that name, so no ambiguity in using the name for 802.11 amendments. โจ
๐ Architecture ๐
The abstract base class ns3::PhyEntity enables to have a unique set of APIs to be used by each PHY entity, corresponding to the different amendments of the IEEE 802.11 standard. The currently implemented PHY entities are:
ns3::DsssPhy: PHY entity for DSSS and HR/DSSS (11b)ns3::OfdmPhy: PHY entity for OFDM (11a and 11p)ns3::ErpOfdmPhy: PHY entity for ERP-OFDM (11g)ns3::HtPhy: PHY entity for HT (11n)ns3::VhtPhy: PHY entity for VHT (11ac)ns3::HePhy: PHY entity for HE (11ax)
Their inheritance diagram is given in Figure PhyEntity hierarchy and closely follows the standard's logic, e.g. section 21.1.1 of IEEE 802.11-2016:
The VHT PHY is based on the HT PHY defined in Clause 19, which in
turn is based on the OFDM PHY defined in Clause 17.
[image] PhyEntity hierarchy.
Such an architecture enables to handle the following operations in an amendment-specific manner:
WifiModehandling and data/PHY rate computation,- PPDU field size and duration computation, and
- Transmit and receive paths.
๐ฆ WifiPpdu ๐ฆ
Same energy as PhyEntity, bestie โ the ns3::WifiPpdu base class has been specialized into these amendment-specific PPDUs:
ns3::DsssPpdu: PPDU for DSSS and HR/DSSS (11b)ns3::OfdmPpdu: PPDU for OFDM (11a and 11p)ns3::ErpOfdmPpdu: PPDU for ERP-OFDM (11g)ns3::HtPpdu: PPDU for HT (11n)ns3::VhtPpdu: PPDU for VHT (11ac)ns3::HePpdu: PPDU for HE (11ax)
Their inheritance diagram is given in Figure WifiPpdu hierarchy and it lowkey follows the standard's logic so closely, like section 21.3.8.1 of IEEE 802.11-2016:
:: To maintain compatibility with non-VHT STAs, specific non-VHT fields
are defined that can be received by non-VHT STAs compliant with Clause
17 [OFDM] or Clause 19 [HT].
[image] WifiPpdu hierarchy.
๐ YansWifiPhy and WifiPhyStateHelper ๐
Class ns3::YansWifiPhy is the one responsible for taking packets passed to it from the MAC (that's the ns3::FrameExchangeManager object) and sending them onto the ns3::YansWifiChannel it's attached to. It's also responsible for receiving packets from that channel, and, if reception is deemed to have been successful, passing them up to the MAC. Two jobs, both slay ๐
The energy of the signal intended to be received is calculated from the transmission power and adjusted based on the Tx gain of the transmitter, the Rx gain of the receiver, and any path loss propagation model in effect.
Class ns3::WifiPhyStateHelper manages the state machine of the PHY layer, and lets other objects hook in as listeners to monitor PHY state. The main use of listeners is so the MAC layer knows when the PHY is busy or not (for transmission and collision avoidance). Very much the group-chat read receipts of the PHY layer.
The PHY layer can be in one of seven states:
- TX: the PHY is currently transmitting a signal on behalf of its associated MAC
- RX: the PHY is synchronized on a signal and is waiting until it has received its last bit to forward it to the MAC.
- IDLE: the PHY is not in the TX, RX, or CCA_BUSY states.
- CCA_BUSY: the PHY is not in TX or RX state but the measured energy is higher than the energy detection threshold.
- SWITCHING: the PHY is switching channels.
- SLEEP: the PHY is in a power save mode and cannot send nor receive frames.
- OFF: the PHY is powered off and cannot send nor receive frames.
Packet reception works as follows. For YansWifiPhy, most of the logic is implemented in the WifiPhy base class. The YansWifiChannel calls WifiPhy::StartReceivePreamble (). The latter calls PhyEntity::StartReceivePreamble () of the appropriate PHY entity to start packet reception, but first there is a check of the packet's notional signal power level against a threshold value stored in the attribute WifiPhy::RxSensitivity. Any packet with a power lower than RxSensitivity will be dropped with no further processing. The default value is -101 dBm, which is the thermal noise floor for 20 MHz signal at room temperature. The purpose of this attribute is two-fold: 1) very weak signals that will not affect the outcome will otherwise consume simulation memory and event processing, so they are discarded, and 2) this value can be adjusted upwards to function as a basic carrier sense threshold limitation for experiments involving spatial reuse considerations.
โ ๏ธ Users are cautioned about the behavior of raising this threshold; namely, that all packets with power below this threshold will be discarded upon reception. Fr fr, read that twice.
In StartReceivePreamble (), the packet is immediately added to the interference helper for signal-to-noise tracking, and then further reception steps are decided upon the state of the PHY. In the case that the PHY is transmitting, for instance, the packet will be dropped. If the PHY is IDLE, or if the PHY is receiving and an optional FrameCaptureModel is being used (and the packet is within the capture window), then PhyEntity::StartPreambleDetectionPeriod () is called next.
The PhyEntity::StartPreambleDetectionPeriod () will typically schedule an event, PhyEntity::EndPreambleDetectionPeriod (), to occur at the notional end of the first OFDM symbol, to check whether the preamble has been detected. As of revisions to the model in ns-3.30, any state machine transitions from IDLE state are suppressed until after the preamble detection event. Not me, the state machine, just sitting there frozen ๐
The PhyEntity::EndPreambleDetectionPeriod () method will check, with a preamble detection model, whether the signal is strong enough to be received, and if so, an event PhyEntity::EndReceiveField () is scheduled for the end of the preamble and the PHY is put into the CCA_BUSY state. Currently, there is only a simple threshold-based preamble detection model in ns-3, called ThresholdPreambleDetectionModel. If there is no preamble detection model, the preamble is assumed to have been detected.
๐ซถ Important: starting with the ns-3.30 release, the default in theWifiPhyHelperis to add theThresholdPreambleDetectionModelwith a threshold RSSI of-82 dBm, and a threshold SNR of4 dB. Both the RSSI and SNR must be above these respective values for the preamble to be successfully detected. The default sensitivity has been reduced in ns-3.30 compared with that of previous releases, so some packet receptions that were previously successful will now fail on this check. More details on the modeling behind this change are provided in[lanante2019].
The PhyEntity::EndReceiveField () method will check the correct reception of the current preamble and header field and, if so, calls PhyEntity::StartReceiveField () for the next field, otherwise the reception is aborted and PHY is put either in IDLE state or in CCA_BUSY state, depending on whether the measured energy is higher than the energy detection threshold.
The next event at PhyEntity::StartReceiveField () checks, using the interference helper and error model, whether the header was successfully decoded, and if so, a PhyRxPayloadBegin callback (equivalent to the PHY-RXSTART primitive) is triggered. The PHY header is often transmitted at a lower modulation rate than is the payload. The portion of the packet corresponding to the PHY header is evaluated for probability of error based on the observed SNR. The InterferenceHelper object returns a value for "probability of error (PER)" for this header based on the SNR that has been tracked by the InterferenceHelper. The PhyEntity then draws a random number from a uniform distribution and compares it against the PER and decides success or failure. RNG said slay or said bye ๐ญ
This is iteratively performed up to the beginning of the data field upon which PhyEntity::StartReceivePayload () is called.
Even if packet objects received by the PHY are not part of the reception process, they are tracked by the InterferenceHelper object for purposes of SINR computation and making clear channel assessment decisions. If, in the course of reception, a packet is errored or dropped due to the PHY being in a state in which it cannot receive a packet, the packet is added to the interference helper, and the aggregate of the energy of all such signals is compared against an energy detection threshold to determine whether the PHY should enter a CCA_BUSY state. The WifiPhy::CcaEdThreshold attribute corresponds to what the standard calls the "ED threshold" for CCA Mode 1. In section 16.4.8.5 in the 802.11-2012 standard: "CCA Mode 1: Energy above threshold. CCA shall report a busy medium upon detection of any energy above the ED threshold." By default, this value is set to the -62 dBm level specified in the standard for 20 MHz channels. When using YansWifiPhy, there are no non-Wi-Fi signals, so it is unlikely that this attribute would play much of a role in Yans wifi models if left at the default value, but if there is a strong Wi-Fi signal that is not otherwise being received by the model, it has the possibility to raise the CCA_BUSY while the overall energy exceeds this threshold.
The above describes the case in which the packet is a single MPDU. For more recent Wi-Fi standards using MPDU aggregation, StartReceivePayload schedules an event for reception of each individual MPDU (ScheduleEndOfMpdus), which then forwards each MPDU as they arrive up to FrameExchangeManager, if the reception of the MPDU has been successful. Once the A-MPDU reception is finished, FrameExchangeManager is also notified about the amount of successfully received MPDUs.
๐ง InterferenceHelper ๐ง
The InterferenceHelper is an object that tracks all incoming packets and calculates probability of error values for packets being received, and also evaluates whether energy on the channel rises above the CCA threshold. It's giving main character energy in the PHY cast, honestly.
The basic operation of probability of error calculations is shown in Figure SNIR function over time. Packets are represented as bits (not symbols) in the ns-3 model, and the InterferenceHelper breaks the packet into one or more "chunks", each with a different signal to noise (and interference) ratio (SNIR). Each chunk is separately evaluated by asking for the probability of error for a given number of bits from the error model in use. The InterferenceHelper builds an aggregate "probability of error" value based on these chunks and their duration, and returns this back to the WifiPhy for a reception decision.
[image] SNIR function over time.
From the SNIR function we can derive the Bit Error Rate (BER) and Packet Error Rate (PER) for the modulation and coding scheme being used for the transmission.
If MIMO is used and the number of spatial streams is lower than the number of active antennas at the receiver, then a gain is applied to the calculated SNIR as follows (since STBC is not used):
gain (dB) = 10 \log(\frac{RX \ antennas}{spatial \ streams})
Having more TX antennas can be safely ignored for AWGN. The resulting gain is:
antennas NSS gain
2 x 1 1 0 dB
1 x 2 1 3 dB
2 x 2 1 3 dB
3 x 3 1 4.8 dB
3 x 3 2 1.8 dB
3 x 3 3 0 dB
4 x 4 1 6 dB
4 x 4 2 3 dB
4 x 4 3 1.2 dB
4 x 4 4 0 dB
...
ErrorRateModel
okay so here's the vibe: ns-3 decides whether a packet is an error or a success based on the input received SNR of a frame and also on any possible interfering frames that might overlap in time โ basically it's all about the signal-to-noise (plus interference) ratio, aka SINR. ๐
The relationship between packet error ratio (PER) and SINR in ns-3 is defined by the ns3::ErrorRateModel, and bestie, there are several of those. The PER is a function of the frame's modulation and coding (MCS), its SINR, and the specific ErrorRateModel configured for the MCS. โจ
ns-3 has updated its default ErrorRateModel over time, no cap. The current (as of ns-3.33 release) model for recent OFDM-based standards (i.e., 802.11n/ac/ax), is the ns3::TableBasedErrorRateModel. The default for 802.11a/g is the ns3::YansErrorRateModel, and the default for 802.11b is the ns3::DsssErrorRateModel. The error rate model for recent standards was updated during the ns-3.33 release cycle (previously, it was the ns3::NistErrorRateModel). ๐ฆ
The error models are described in more detail in outside references. The current OFDM model is based on work published in [patidar2017], using link simulations results from the MATLAB WLAN Toolbox, and validated against IEEE TGn results [erceg2004]. For publications related to other error models, please refer to [pei80211ofdm], [pei80211b], [lacage2006yans], [Haccoun], [hepner2015] and [Frenger] for a detailed description of the legacy PER models. ๐
โ ๏ธ The current ns-3 error rate models are for additive white gaussian noise channels (AWGN) only; any potential frequency-selective fading effects are not modeled. so like, don't expect them to do something they literally don't do ๐
In summary, there are four error models:
ns3::TableBasedErrorRateModel: for OFDM modes and reusesns3::DsssErrorRateModelfor 802.11b modes. This is the default for 802.11n/ac/ax.ns3::YansErrorRateModel: for OFDM modes and reusesns3::DsssErrorRateModelfor 802.11b modes. This is the default for 802.11a/g.ns3::DsssErrorRateModel: contains models for 802.11b modes. The 802.11b 1 Mbps and 2 Mbps error models are based on classical modulation analysis. If GNU Scientific Library (GSL) is installed, the 5.5 Mbps and 11 Mbps from [pursley2009] are used for CCK modulation; otherwise, results from a backup MATLAB-based CCK model are used.ns3::NistErrorRateModel: for OFDM modes and reusesns3::DsssErrorRateModelfor 802.11b modes.
Users may select either NIST, YANS or Table-based models for OFDM, and DSSS will be used in either case for 802.11b. The NIST model was a long-standing default in ns-3 (through release 3.32). ๐
TableBasedErrorRateModel
The ns3::TableBasedErrorRateModel has been recently added and is now the ns-3 default for 802.11n/ac/ax, while ns3::YansErrorRateModel is the ns-3 default for 802.11a/g. ๐ธ
Unlike analytical error models based on error bounds, ns3::TableBasedErrorRateModel contains end-to-end link simulation tables (PER vs SNR) for AWGN channels. Since it is infeasible to generate such look-up tables for all desired packet sizes and input SNRs, we adopt the recommendation of IEEE P802.11 TGax [porat2016] that proposed estimating PER for any desired packet length using BCC FEC encoding by extrapolating the results from two reference lengths: 32 (all lengths less than 400) bytes and 1458 (all lengths greater or equal to 400) bytes respectively. In case of LDPC FEC encoding, IEEE P802.11 TGax recommends the use of a single reference length. Hence, we provide two tables for BCC and one table for LDPC that are generated using a reliable and publicly available commercial link simulator (MATLAB WLAN Toolbox) for each modulation and coding scheme. Note that BCC tables are limited to MCS 9. For higher MCSs, the models fall back to the use of the YANS analytical model. ๐ง
The validation scenario is set as follows:
- Ideal channel and perfect channel estimation.
- Perfect packet synchronization and detection.
- Phase tracking, phase correction, phase noise, carrier frequency offset, power amplifier non-linearities etc. are not considered.
Several packets are simulated across the link to obtain PER, the number of packets needed to reliably estimate a PER value is computed using the consideration that the ratio of the estimation error to the true value should be within 10 % with probability 0.95. For each SNR value, simulations were run until a total of 40000 packets were simulated. ๐ฅ
The obtained results are very close to TGax curves as shown in Figure Comparison of table-based OFDM Error Model with TGax results.
[image] Comparison of table-based OFDM Error Model with TGax results.
Legacy ErrorRateModels
The original error rate model was called the ns3::YansErrorRateModel and was based on analytical results. For 802.11b modulations, the 1 Mbps mode is based on DBPSK. BER is from equation 5.2-69 from [proakis2001]. The 2 Mbps model is based on DQPSK. Equation 8 of [ferrari2004]. More details are provided in [lacage2006yans]. ๐
The ns3::NistErrorRateModel was later added. The model was largely aligned with the previous ns3::YansErrorRateModel for DSSS modulations 1 Mbps and 2 Mbps, but the 5.5 Mbps and 11 Mbps models were re-based on equations (17) and (18) from [pursley2009]. For OFDM modulations, newer results were obtained based on work previously done at NIST [miller2003]. The results were also compared against the CMU wireless network emulator, and details of the validation are provided in [pei80211ofdm]. Since OFDM modes use hard-decision of punctured codes, the coded BER is calculated using Chernoff bounds [hepner2015]. โจ
The 802.11b model was split from the OFDM model when the NIST error rate model was added, into a new model called DsssErrorRateModel.
Furthermore, the 5.5 Mbps and 11 Mbps models for 802.11b rely on library methods implemented in the GNU Scientific Library (GSL). The Waf build system tries to detect whether the host platform has GSL installed; if so, it compiles in the newer models from [pursley2009] for 5.5 Mbps and 11 Mbps; if not, it uses a backup model derived from MATLAB simulations. ๐
The error curves for analytical models are shown to diverge from link simulation results for higher MCS in Figure YANS and NIST error model comparison with TGn results. This prompted the move to a new error model based on link simulations (the default TableBasedErrorRateModel, which provides curves close to those depicted by the TGn dashed line).
[image] YANS and NIST error model comparison with TGn results.
SpectrumWifiPhy
This section describes the implementation of the SpectrumWifiPhy class that can be found in src/wifi/model/spectrum-wifi-phy.{cc,h}. ๐ฆ
The implementation also makes use of additional classes found in the same directory:
wifi-spectrum-phy-interface.{cc,h}wifi-spectrum-signal-parameters.{cc,h}
and classes found in the spectrum module:
wifi-spectrum-value-helper.{cc,h}
The current SpectrumWifiPhy class reuses the existing interference manager and error rate models originally built for YansWifiPhy, but allows, as a first step, foreign (non Wi-Fi) signals to be treated as additive noise. ๐
Two main changes were needed to adapt the Spectrum framework to Wi-Fi. First, the physical layer must send signals compatible with the Spectrum channel framework, and in particular, the MultiModelSpectrumChannel that allows signals from different technologies to coexist. Second, the InterferenceHelper must be extended to support the insertion of non-Wi-Fi signals and to add their received power to the noise, in the same way that unintended Wi-Fi signals (perhaps from a different SSID or arriving late from a hidden node) are added to the noise.
Unlike YansWifiPhy, where there are no foreign signals, CCA_BUSY state will be raised for foreign signals that are higher than CcaEdThreshold (see section 16.4.8.5 in the 802.11-2012 standard for definition of CCA Mode 1). The attribute WifiPhy::CcaEdThreshold therefore potentially plays a larger role in this model than in the YansWifiPhy model. ๐
To support the Spectrum channel, the YansWifiPhy transmit and receive methods were adapted to use the Spectrum channel API. This required developing a few SpectrumModel-related classes. The class WifiSpectrumValueHelper is used to create Wi-Fi signals with the spectrum framework and spread their energy across the bands. The spectrum is sub-divided into sub-bands (the width of an OFDM subcarrier, which depends on the technology). The power allocated to a particular channel is spread across the sub-bands roughly according to how power would be allocated to sub-carriers. Adjacent channels are models by the use of OFDM transmit spectrum masks as defined in the standards.
To support an easier user configuration experience, the existing YansWifi helper classes (in src/wifi/helper) were copied and adapted to provide equivalent SpectrumWifi helper classes. ๐
Finally, for reasons related to avoiding C++ multiple inheritance issues, a small forwarding class called WifiSpectrumPhyInterface was inserted as a shim between the SpectrumWifiPhy and the Spectrum channel. The WifiSpectrumPhyInterface calls a different SpectrumWifiPhy::StartRx() method to start the reception process. This method performs the check of the signal power against the WifiPhy::RxSensitivity attribute and discards weak signals, and also checks if the signal is a Wi-Fi signal; non-Wi-Fi signals are added to the InterferenceHelper and can raise CCA_BUSY but are not further processed in the reception chain. After this point, valid Wi-Fi signals cause WifiPhy::StartReceivePreamble to be called, and the processing continues as described above. ๐ซถ
The MAC model
Infrastructure association
Association in infrastructure mode is a high-level MAC function. Either active probing or passive scanning is used (default is passive scan). At the start of the simulation, Wi-Fi network devices configured as STA will attempt to scan the channel. Depends on whether passive or active scanning is selected, STA will attempt to gather beacons, or send a probe request and gather probe responses until the respective timeout occurs. The end result will be a list of candidate AP to associate to. STA will then try to associate to the best AP (i.e., best SNR). ๐
If association is rejected by the AP for some reason, the STA will try to associate to the next best AP until the candidate list is exhausted which then sends STA to 'REFUSED' state. If this occurs, the simulation user will need to force reassociation retry in some way, perhaps by changing configuration (i.e. the STA will not persistently try to associate upon a refusal). ๐ญ
When associated, if the configuration is changed by the simulation user, the STA will try to reassociate with the existing AP. โจ
If the number of missed beacons exceeds the threshold, the STA goes full "it's not me, it's you" and notifies the rest of the device that the link is down (association is lost) and restarts the scanning process. lowkey dramatic but valid. Heads up tho โ this can also happen when an association request fails without explicit refusal, i.e. the AP just... fails to respond to the association request. ghosted by an access point, the audacity ๐ญ
๐ธ Roaming ๐ธ
Roaming at layer-2 โ that's where a STA migrates its association from one AP to another โ is not presently supported. Because of that, the Min/Max channel dwelling time implementation as described by the IEEE 802.11 standard [ieee80211] is also omitted, since it is only meaningful on the context of channel roaming. no channel-hopping girlies here, sorry
๐ Channel access ๐
The 802.11 Distributed Coordination Function is what calculates when to grant access to the transmission medium. And okay, implementing the DCF would have been particularly easy if we had used a recurring timer that expired every slot, but we chose the method described in [ji2004sslswn] instead, where the backoff timer duration is lazily calculated whenever needed โ since it is claimed to have much better performance than the simpler recurring timer solution. lazy but make it efficient, main character engineering โจ
The DCF basic access is described in section 10.3.4.2 of [ieee80211-2016].
โA STA may transmit an MPDU when it is operating under the DCF access method [..] when the STA determines that the medium is idle when a frame is queued for transmission, and remains idle for a period of a DIFS, or an EIFS (10.3.2.3.7) from the end of the immediately preceding medium-busy event, whichever is the greater, and the backoff timer is zero. Otherwise the random backoff procedure described in 10.3.4.3 shall be followed.โ
So basically, a station is allowed to not invoke the backoff procedure if all three of these conditions are met:
- the medium is idle when a frame is queued for transmission
- the medium remains idle until the most recent of these two events: a DIFS from the time when the frame is queued for transmission; an EIFS from the end of the immediately preceding medium-busy event (associated with the reception of an erroneous frame)
- the backoff timer is zero
The backoff procedure of DCF is described in section 10.3.4.3 of [ieee80211-2016].
โA STA shall invoke the backoff procedure to transfer a frame when finding the medium busy as indicated by either the physical or virtual CS mechanism.โ
โA backoff procedure shall be performed immediately after the end of every transmission with the More Fragments bit set to 0 of an MPDU of type Data, Management, or Control with subtype PS-Poll, even if no additional transmissions are currently queued.โ
The EDCA backoff procedure is slightly different from the DCF backoff procedure, and it's described in section 10.22.2.2 of [ieee80211-2016]. The backoff procedure shall be invoked by an EDCAF when any of the following events occur:
- a frame is โqueued for transmission such that one of the transmit queues associated with that AC has now become non-empty and any other transmit queues associated with that AC are empty; the medium is busy on the primary channelโ
- โThe transmission of the MPDU in the final PPDU transmitted by the TXOP holder during the TXOP for that AC has completed and the TXNAV timer has expired, and the AC was a primary ACโ
- โThe transmission of an MPDU in the initial PPDU of a TXOP fails [..] and the AC was a primary ACโ
- โThe transmission attempt collides internally with another EDCAF of an AC that has higher priorityโ
- (optionally) โThe transmission by the TXOP holder of an MPDU in a non-initial PPDU of a TXOP failsโ
Also, section 10.22.2.4 of [ieee80211-2016] introduces the notion of a slot boundary, which basically occurs following SIFS + AIFSN * slotTime of idle medium after the last busy medium that was the result of a reception of a frame with a correct FCS, or following EIFS - DIFS + AIFSN * slotTime + SIFS of idle medium after the last indicated busy medium that was the result of a frame reception that has resulted in FCS error, or following a slotTime of idle medium occurring immediately after any of these conditions. yes bestie that is a lot of math, breathe ๐ซถ
On these specific slot boundaries, each EDCAF shall make a determination to perform one and only one of the following functions:
- Decrement the backoff timer.
- Initiate the transmission of a frame exchange sequence.
- Invoke the backoff procedure due to an internal collision.
- Do nothing.
So, if an EDCAF decrements its backoff timer on a given slot boundary and, as a result, the backoff timer has a zero value, the EDCAF cannot immediately transmit โ it has to wait for another slotTime of idle medium before transmission can start. patience, babe ๐
The higher-level MAC functions are implemented in a set of other C++ classes and deal with:
- packet fragmentation and defragmentation,
- use of the RTS/CTS protocol,
- rate control algorithm,
- connection and disconnection to and from an Access Point,
- the MAC transmission queue,
- beacon generation,
- MSDU aggregation,
- etc.
๐ง Frame Exchange Managers ๐ง
As the IEEE 802.11 standard evolves, more and more features get added and it gets more and more difficult to have a single component handling all of the allowed frame exchange sequences. So a hierarchy of FrameExchangeManager classes has been introduced to make the code clean and scalable, while avoiding code duplication. Each FrameExchangeManager class handles the frame exchange sequences introduced by a given amendment. The FrameExchangeManager hierarchy is depicted in Figure FrameExchangeManager hierarchy.
[image] FrameExchangeManager hierarchy.
The features supported by every FrameExchangeManager class are as follows:
FrameExchangeManageris the base class. It handles the basic sequences for non-QoS stations: MPDU followed by Normal Ack, RTS/CTS and CTS-to-self, NAV setting and resetting, MPDU fragmentationQosFrameExchangeManageradds TXOP support: multiple protection setting, TXOP truncation via CF-End, TXOP recovery, ignore NAV when responding to an RTS sent by the TXOP holderHtFrameExchangeManageradds support for Block Ack (compressed variant), A-MSDU and A-MPDU aggregation, Implicit Block Ack Request policyVhtFrameExchangeManageradds support for S-MPDUsHeFrameExchangeManageradds support for the transmission and reception of multi-user frames via DL OFDMA and UL OFDMA, as detailed below.
โจ Multi-user transmissions โจ
Since the introduction of the IEEE 802.11ax amendment, multi-user (MU) transmissions are possible, both in downlink (DL) and uplink (UL), by using OFDMA and/or MU-MIMO. Currently, ns-3 only supports multi-user transmissions via OFDMA. Three acknowledgment sequences are implemented for DL OFDMA.
The first acknowledgment sequence is made of multiple BlockAckRequest/BlockAck frames sent as single-user frames, as shown in Figure Acknowledgment of DL MU frames in single-user format.
[image] Acknowledgment of DL MU frames in single-user format.
For the second acknowledgment sequence, an MU-BAR Trigger Frame is sent (as a single-user frame) to solicit BlockAck responses sent in TB PPDUs, as shown in Figure Acknowledgment of DL MU frames via MU-BAR Trigger Frame sent as single-user frame.
[image] Acknowledgment of DL MU frames via MU-BAR Trigger Frame sent as single-user frame.
For the third acknowledgment sequence, an MU-BAR Trigger Frame is aggregated to every PSDU included in the DL MU PPDU and the BlockAck responses are sent in TB PPDUs, as shown in Figure Acknowledgment of DL MU frames via aggregated MU-BAR Trigger Frames.
[image] Acknowledgment of DL MU frames via aggregated MU-BAR Trigger Frames.
For UL OFDMA, both BSRP Trigger Frames and Basic Trigger Frames are supported, as shown in Figure Acknowledgment of DL MU frames via aggregated MU-BAR Trigger Frames. A BSRP Trigger Frame is sent by an AP to solicit stations to send QoS Null frames containing Buffer Status Reports. A Basic Trigger Frame is sent by an AP to solicit stations to send data frames in TB PPDUs, which are acknowledged by the AP via a Multi-STA BlockAck frame.
[image] Acknowledgment of DL MU frames via aggregated MU-BAR Trigger Frames.
๐ Multi-User Scheduler ๐
A new component, named MultiUserScheduler, is in charge of determining what frame exchange sequence the aggregated AP has to perform when gaining a TXOP (DL OFDMA, UL OFDMA or BSRP Trigger Frame), along with the information needed to perform the selected frame exchange sequence (e.g., the set of PSDUs to send in case of DL OFDMA). MultiUserScheduler is an abstract base class. Currently, the only available subclass is RrMultiUserScheduler. By default, no multi-user scheduler is aggregated to an AP โ hence, OFDMA is not enabled.
๐ Round-robin Multi-User Scheduler ๐
The Round-robin Multi-User Scheduler dynamically assigns a priority to each station to ensure airtime fairness in the selection of stations for DL multi-user transmissions. The NStations attribute enables you to set the maximum number of stations that can be the recipients of a DL multi-user frame. So every time an HE AP accesses the channel to transmit a DL multi-user frame, the scheduler determines the number of stations the AP has frames to send to (capped at the value specified through the mentioned attribute) and attempts to allocate equal sized RUs to as many such stations as possible without leaving RUs of the same size unused. For instance, if the channel bandwidth is 40 MHz and the determined number of stations is 5, the first 4 stations (in order of priority) are allocated a 106-tone RU each โ if 52-tone RUs were allocated, we would have three 52-tone RUs unused. If central 26-tone RUs can be allocated (as determined by the UseCentral26TonesRus attribute), possible stations that have not been allocated an RU are assigned one of such 26-tone RU. In the previous example, the fifth station would have been allocated one of the two available central 26-tone RUs. math ate, no crumbs ๐
When UL OFDMA is enabled (via the EnableUlOfdma attribute), every DL OFDMA frame exchange is followed by an UL OFDMA frame exchange involving the same set of stations and the same RU allocation as the preceding DL multi-user frame. The transmission of a BSRP Trigger Frame can optionally (depending on the value of the EnableBsrp attribute) precede the transmission of a Basic Trigger Frame in order for the AP to collect information about the buffer status of the stations. buffers, but make it gossip ๐
๐ซ Ack manager ๐ซ
okay so bestie, ever since the IEEE 802.11e amendment showed up, we've had multiple acknowledgment policies to choose from, and they're coded into the Ack Policy subfield of the QoS Control field of QoS Data frames (that's Section 9.2.4.5.4 of the IEEE 802.11-2016 standard, iykyk ๐). Like fr โ an A-MPDU can be sent with the Normal Ack or Implicit Block Ack Request policy, and then the receiver claps back with a Normal Ack or a Block Ack depending on whether that A-MPDU contains a single MPDU or multiple MPDUs. Or it can go out with the Block Ack policy, in which case the receiver just waits ๐ โ it's holding out for a Block Ack Request in the future, and replies to that with a Block Ack.
WifiAckManager is the abstract base class that got introduced to give multiple ack managers a shared interface. Currently the default ack manager is WifiDefaultAckManager. periodt.
๐ WifiDefaultAckManager ๐
The WifiDefaultAckManager decides which acknowledgment policy to use based on the value of its attributes:
UseExplicitBarโ this one picks the ack policy for when a response is needed from the recipient and the current transmission includes multiple frames (A-MPDU), or there are frames transmitted previously that still need an acknowledgment. Set it totrueand you get the Block Ack policy. Set it tofalseand it's the Implicit Block Ack Request policy instead. ๐ฆBaThresholdโ this decides when the originator of a Block Ack agreement needs to request a response from the recipient. A value of zero means a response is requested at every frame transmission. A non-zero value (less than or equal to 1) means a response is requested upon transmission of a frame whose sequence number is distant at leastBaThresholdmultiplied by the transmit window size from the starting sequence number of the transmit window.DlMuAckSequenceTypeโ selects the acknowledgment sequence for DL MU frames. Your options are: acknowledgment in single-user format, acknowledgment via MU-BAR Trigger Frame sent as a single-user frame, or acknowledgment via MU-BAR Trigger Frames aggregated to the data frames. pick your fighter โจ
๐ก๏ธ Protection manager ๐ก๏ธ
The protection manager is the one in charge of determining the protection mechanism to use, if any, when sending a frame. lowkey a bodyguard.
WifiProtectionManager is the abstract base class introduced to give multiple protection managers an interface. Currently, the default protection manager is WifiDefaultProtectionManager.
๐ธ WifiDefaultProtectionManager ๐ธ
The WifiDefaultProtectionManager selects a protection mechanism based on the information provided by the remote station manager. that's it, that's the whole vibe.
๐ Rate control algorithms ๐
ns-3 has multiple rate control algorithms available. Some of them are modeled after real algorithms used in real devices; others come straight from literature. The following rate control algorithms can be used by the MAC low layer:
Algorithms found in real devices:
ArfWifiManager(default forWifiHelper) ๐OnoeWifiManagerConstantRateWifiManagerMinstrelWifiManagerMinstrelHtWifiManager
Algorithms in literature:
IdealWifiManagerAarfWifiManager[lacage2004aarfamrr]AmrrWifiManager[lacage2004aarfamrr]CaraWifiManager[kim2006cara]RraaWifiManager[wong2006rraa]AarfcdWifiManager[maguolo2008aarfcd]ParfWifiManager[akella2007parf]AparfWifiManager[chevillat2005aparf]ThompsonSamplingWifiManager[krotov2020rate]
๐ง ConstantRateWifiManager ๐ง
The constant rate control algorithm literally always uses the same transmission mode for every packet. No switching up, no surprises. Users can set a desired DataMode for all unicast packets and a ControlMode for all request control packets (e.g. RTS).
To specify a different data mode for non-unicast packets, users have to set the NonUnicastMode attribute of the WifiRemoteStationManager. Otherwise WifiRemoteStationManager will use a mode with the lowest rate for non-unicast packets.
The 802.11 standard is quite clear on the rules for selection of transmission parameters for control response frames (e.g. CTS and ACK). ns-3 follows the standard and selects the rate of control response frames from the set of basic rates or mandatory rates. What that means for you: control response frames may be sent using a different rate even though the ConstantRateWifiManager is being used. The ControlMode attribute of the ConstantRateWifiManager is used for RTS frames only. The rate of CTS and ACK frames is selected according to the 802.11 standard. That said, users can still manually add WifiMode to the basic rate set, which will allow control response frames to be sent at other rates. Please consult the project wiki on how to do this. ๐
Available attributes:
DataMode(defaultWifiMode::OfdmRate6Mbps) โ specify a mode for all non-unicast packetsControlMode(defaultWifiMode::OfdmRate6Mbps) โ specify a mode for allrequestcontrol packets
โจ IdealWifiManager โจ
The ideal rate control algorithm selects the best mode according to the SNR of the previous packet sent. Picture it: node A is sending a unicast packet to node B. When B successfully receives the packet sent from A, B records the SNR of the received packet into a ns3::SnrTag and adds that tag to an ACK back to A. By doing this, A is able to learn the SNR of the packet sent to B using an out-of-band mechanism (hence the name "ideal" ๐ซถ). A then uses that SNR to select a transmission mode based on a set of SNR thresholds, which was built from a target BER and mode-specific SNR/BER curves.
Available attribute:
BerThreshold(default1e-6) โ The maximum Bit Error Rate that is used to calculate the SNR threshold for each mode.
heads up bestie: theBerThresholdhas to be low enough to select a robust enough MCS (or mode) for a given SNR value, without being too restrictive on the target BER. We literally noticed that the previous default value (i.e.1e-5) led to the selection of HE MCS-11, which resulted in high PER. With this new default value (i.e.1e-6), a HE STA moving away from a HE AP has smooth throughput decrease โ whereas with1e-5, better performance was seen further away, which is not "ideal". ๐
๐ฒ ThompsonSamplingWifiManager ๐ฒ
Thompson Sampling (TS) is a classical solution to the Multi-Armed Bandit problem. ThompsonSamplingWifiManager implements a rate control algorithm based on TS, with the goal of providing a simple statistics-based algorithm with a low number of parameters. minimal effort, maximum slay.
The algorithm maintains the number of successful transmissions \alpha_i and the number of unsuccessful transmissions \beta_i for each MCS i, both of which are initially set to zero.
To select MCS for a data frame, the algorithm draws a sample frame success rate q_i from the beta distribution with shape parameters (1 + \alpha_i, 1 + \beta_i) for each MCS, and then selects the MCS with the highest expected throughput, calculated as the sample frame success rate multiplied by MCS rate. โจ
To account for changing channel conditions, exponential decay is applied to \alpha_i and \beta_i. The rate of exponential decay is controlled with the Decay attribute, which is the inverse of the time constant. The default value of 1 Hz results in using an exponential window with the time constant of 1 second. Setting this value to zero effectively disables exponential decay, and can be used in static scenarios.
Control frames are always transmitted using the most robust MCS, except when the standard specifies otherwise, such as for ACK frames.
Since the main goal of this algorithm is to provide a stable baseline, it does not take into account backoff overhead, inter-frame spaces and aggregation for MCS rate calculation. For an example of a more complex statistics-based rate control algorithm used in real devices, consider Minstrel-HT described below. ๐
๐ต MinstrelWifiManager ๐ต
The minstrel rate control algorithm originated from the madwifi project. It is currently the default rate control algorithm of the Linux kernel. main character energy fr.
Minstrel keeps track of the probability of successfully sending a frame of each available rate. It then calculates the expected throughput by multiplying the probability with the rate. This approach is chosen to make sure that lower rates are not selected in favor of the higher rates (since lower rates are more likely to have higher probability).
In minstrel, roughly 10 percent of transmissions are sent at the so-called lookaround rate. The goal of the lookaround rate is to force minstrel to try a higher rate than the currently used rate. little experimental moment ๐ฆ
For more detailed information about minstrel, see [linuxminstrel].
๐ MinstrelHtWifiManager ๐
This is the extension of minstrel for 802.11n/ac/ax. glow up ๐
๐ 802.11ax OBSS PD spatial reuse ๐
802.11ax mode supports the OBSS PD spatial reuse feature. OBSS PD stands for Overlapping Basic Service Set Preamble-Detection. OBSS PD is an 802.11ax specific feature that allows a STA, under specific conditions, to ignore an inter-BSS PPDU. not me ignoring the whole other network ๐ญ
๐ง OBSS PD Algorithm ๐ง
ObssPdAlgorithm is the base class of OBSS PD algorithms. It implements the common functionalities. First, it makes sure the necessary callbacks are set up. Second, when a PHY reset is requested by the algorithm, it performs the computation to determine the TX power restrictions and informs the PHY object.
The PHY keeps track of incoming requests from the MAC to get access to the channel. If a request is received and if PHY reset(s) indicating TX power limitations occurred before a packet was transmitted, the next packet to be transmitted will be sent with a reduced power. Otherwise, no TX power restrictions will be applied.
๐ Constant OBSS PD Algorithm ๐
The Constant OBSS PD algorithm is a simple OBSS PD algorithm implemented in the ConstantObssPdAlgorithm class.
Once a HE preamble and its header have been received by the PHY, ConstantObssPdAlgorithm:: ReceiveHeSig is triggered. The algorithm then checks whether this is an OBSS frame by comparing its own BSS color with the BSS color of the received preamble. If this is an OBSS frame, it compares the received RSSI with its configured OBSS PD level value. The PHY then gets reset to IDLE state in case the received RSSI is lower than that constant OBSS PD level value, and is informed about a TX power restrictions.
Note: since our model is based on a single threshold, the PHY only supports one restricted power level.
๐ ๏ธ Modifying Wifi model ๐ ๏ธ
Modifying the default wifi model is one of the common tasks when performing research. We're giving you an overview of how to make changes to the default wifi model in this section. Depending on your goal, the common tasks are (in no particular order):
- Creating or modifying the default Wi-Fi frames/headers by making changes to
wifi-mac-header.*. - MAC low modification โ think new or tweaked control frames (RTS/CTS/ACK/Block ACK vibes), and making changes to the two-way transaction / four-way transaction. Besties usually go edit
frame-exchange-manager.*or its subclasses for this. The handling of control frames itself happens over inFrameExchangeManager::ReceiveMpdu๐ - MAC high modification โ think new management frames (beacon/probe energy โจ), plus beacon/probe generation. For this one you'd normally poke at
regular-wifi-mac.*,sta-wifi-mac.*,ap-wifi-mac.*, oradhoc-wifi-mac.*. - Wi-Fi queue management โ the files
txop.*andqos-txop.*are the ones you want, they're giving main character energy here ๐ - Channel access management โ you should modify the files
channel-access-manager.*, which grant access toTxopandQosTxop. - Fragmentation and RTS thresholds are handled by the Wi-Fi remote station manager. Heads up though: the Wi-Fi remote station manager only indicates whether fragmentation and RTS are needed. The actual fragmentation is handled by
TxoporQosTxop, while the RTS/CTS transaction is handled byFrameExchangeManager. iykyk ๐ซถ - Modifying or creating new rate control algorithms โ you can do this by creating a new child class of the Wi-Fi remote station manager, or by modifying the existing ones. Slay.
๐ User Documentation ๐
โจ Using the WifiNetDevice โจ
The modularity that this implementation brings makes low-level configuration of the WifiNetDevice powerful but complex. That's literally why we have helper classes: to do the common operations in a simple way, and to leverage the ns-3 attribute system so you can control the parameterization of the underlying models. Obsessed with convenience ๐
If you're using the low-level ns-3 API and you wanna add a WifiNetDevice to your node, you have to create an instance of a WifiNetDevice, plus a whole bunch of constituent objects, and bind them all together appropriately (the WifiNetDevice is very modular in this regard, for future extensibility). At the low-level API, this is like 20 lines of code (see ns3::WifiHelper::Install, and ns3::YansWifiPhyHelper::Create). You also have to create, at some point, a Channel, which also contains a number of constituent objects (see ns3::YansWifiChannelHelper::Create). No cap, it's a lot.
However โ a few helpers exist so you can add these devices and channels with only a few lines of code, if you're willing to use defaults, and the helpers give you extra API to pass attribute values in and change those defaults. The commonly used attribute values are listed in the Attributes section. The scripts in examples/wireless can be browsed to see how this is done. Next up: the common steps to create a WifiNetDevice from the bottom layer (Channel) all the way up to the device layer (WifiNetDevice) ๐ฆ
To create a WifiNetDevice, bestie, you need to follow these steps:
- Decide on which physical layer framework to use: the
SpectrumWifiPhyor theYansWifiPhy. This will affect whichChannelandPhytype you use. - Configure the
Channel: theChanneltakes care of getting signal from one device to other devices on the same Wi-Fi channel. The main configurations ofWifiChannelare the propagation loss model and the propagation delay model. - Configure the
WifiPhy:WifiPhytakes care of actually sending and receiving the wireless signal from theChannel. Here,WifiPhydecides whether each frame will be successfully decoded or not, depending on the received signal strength and noise. So the main configuration ofWifiPhyis the error rate model โ that's the one that actually calculates the probability of successfully decoding the frame based on the signal. - Configure
WifiMac: this step is more about the architecture and device level. You configure the wifi architecture (i.e. ad-hoc or ap-sta) and whether QoS (802.11e), HT (802.11n) and/or VHT (802.11ac) and/or HE (802.11ax) features are supported or not. - Create
WifiDevice: at this step, you configure the desired wifi standard (e.g.802.11b,802.11g,802.11a,802.11n,802.11acor802.11ax) and the rate control algorithm. - Configure mobility: finally, a mobility model is (usually) required before
WifiNetDevicecan be used; even if the devices are stationary, their relative positions are needed for propagation loss calculations. Positions are the moment fr fr ๐
The following sample code illustrates a typical configuration using mostly default values in the simulator, and infrastructure mode:
NodeContainer wifiStaNode;
wifiStaNode.Create (10); // Create 10 station node objects
NodeContainer wifiApNode;
wifiApNode.Create (1); // Create 1 access point node object
// Create a channel helper and phy helper, and then create the channel
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
phy.SetChannel (channel.Create ());
// Create a WifiMacHelper, which is reused across STA and AP configurations
WifiMacHelper mac;
// Create a WifiHelper, which will use the above helpers to create
// and install Wifi devices. Configure a Wifi standard to use, which
// will align various parameters in the Phy and Mac to standard defaults.
WifiHelper wifi;
wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
// Declare NetDeviceContainers to hold the container returned by the helper
NetDeviceContainer wifiStaDevices;
NetDeviceContainer wifiApDevice;
// Perform the installation
mac.SetType ("ns3::StaWifiMac");
wifiStaDevices = wifi.Install (phy, mac, wifiStaNodes);
mac.SetType ("ns3::ApWifiMac");
wifiApDevice = wifi.Install (phy, mac, wifiApNode);
At this point, the 11 nodes have Wi-Fi devices configured, attached to a common channel ๐ The rest of this section describes how additional configuration may be performed.
๐ YansWifiChannelHelper ๐
The YansWifiChannelHelper has an unusual name. Readers may wonder why it's named this way. The reference is to the yans simulator from which this model is taken. The helper can be used to create a YansWifiChannel with a default PropagationLoss and PropagationDelay model.
Users will typically type code such as:
YansWifiChannelHelper wifiChannelHelper = YansWifiChannelHelper::Default ();
Ptr<Channel> wifiChannel = wifiChannelHelper.Create ();
to get the defaults. Specifically, the default is a channel model with a propagation delay equal to a constant โ the speed of light (ns3::ConstantSpeedPropagationDelayModel) โ and a propagation loss based on a default log distance model (ns3::LogDistancePropagationLossModel), using a default exponent of 3. Please note that the default log distance model is configured with a reference loss of 46.6777 dB at reference distance of 1m. The reference loss of 46.6777 dB was calculated using the Friis propagation loss model at 5.15 GHz. The reference loss must be changed if 802.11b, 802.11g, 802.11n (at 2.4 GHz) or 802.11ax (at 2.4 GHz) are used, since they operate at 2.4 Ghz. Don't forget, bestie, that's an important one ๐ญ
Note the distinction above in creating a helper object vs. an actual simulation object. In ns-3, helper objects (used at the helper API only) are created on the stack (they could also be created with operator new and later deleted). However, the actual ns-3 objects typically inherit from class ns3::Object and are assigned to a smart pointer. See the chapter in the ns-3 manual for a discussion of the ns-3 object model, if you are not familiar with it.
The following two methods are useful when configuring YansWifiChannelHelper:
YansWifiChannelHelper::AddPropagationLossadds aPropagationLossModel; if one or morePropagationLossModels already exist, the new model is chained to the endYansWifiChannelHelper::SetPropagationDelaysets aPropagationDelayModel(not chainable)
๐ธ YansWifiPhyHelper ๐ธ
Physical devices (base class ns3::WifiPhy) connect to ns3::YansWifiChannel models in ns-3. We need to create WifiPhy objects appropriate for the YansWifiChannel; here the YansWifiPhyHelper will do the work.
The YansWifiPhyHelper class configures an object factory to create instances of a YansWifiPhy and adds some other objects to it, including possibly a supplemental ErrorRateModel and a pointer to a MobilityModel. The user code is typically:
YansWifiPhyHelper wifiPhyHelper;
wifiPhyHelper.SetChannel (wifiChannel);
The default YansWifiPhyHelper is configured with TableBasedErrorRateModel (ns3::TableBasedErrorRateModel). You can change the error rate model by calling the YansWifiPhyHelper::SetErrorRateModel method.
Optionally, if pcap tracing is needed, a user may use the following command to enable pcap tracing:
YansWifiPhyHelper::SetPcapDataLinkType (enum SupportedPcapDataLinkTypes dlt)
ns-3 supports RadioTap and Prism tracing extensions for 802.11 โจ
Note that we haven't actually created any WifiPhy objects yet; we've just prepared the YansWifiPhyHelper by telling it which channel it is connected to. The Phy objects are created in the next step ๐
In order to enable 802.11n/ac/ax MIMO, the number of antennas as well as the number of supported spatial streams need to be configured. For example, this code enables MIMO with 2 antennas and 2 spatial streams:
wifiPhyHelper.Set ("Antennas", UintegerValue (2));
wifiPhyHelper.Set ("MaxSupportedTxSpatialStreams", UintegerValue (2));
wifiPhyHelper.Set ("MaxSupportedRxSpatialStreams", UintegerValue (2));
It is also possible to configure fewer streams than the number of antennas in order to benefit from diversity gain, and to define different MIMO capabilities for downlink and uplink. For example, this code configures a node with 3 antennas that supports 2 spatial streams in downstream and 1 spatial stream in upstream:
wifiPhyHelper.Set ("Antennas", UintegerValue (3));
wifiPhyHelper.Set ("MaxSupportedTxSpatialStreams", UintegerValue (2));
wifiPhyHelper.Set ("MaxSupportedRxSpatialStreams", UintegerValue (1));
The 802.11n PHY layer can support both 20 (default) or 40 MHz channel width, and the 802.11ac/ax PHY layer can use either 20, 40, 80 (default) or 160 MHz channel width. See below for further documentation on setting the frequency, channel width, and channel number.
WifiHelper wifi;
wifi.SetStandard (WIFI_STANDARD_80211ac);
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("VhtMcs9"),
"ControlMode", StringValue ("VhtMcs0"));
//Install PHY and MAC
Ssid ssid = Ssid ("ns3-wifi");
WifiMacHelper mac;
mac.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
NetDeviceContainer staDevice;
staDevice = wifi.Install (phy, mac, wifiStaNode);
mac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid));
NetDeviceContainer apDevice;
apDevice = wifi.Install (phy, mac, wifiApNode);
๐ Channel, frequency, and channel width configuration ๐
okay bestie, listen up, because this is the part where people get cute and then their sim explodes ๐
There are a few ns3::WifiPhy parameters that are related, and they can't be set completely independently of each other, all about the frequency and channel width your device is tuned to. Behold:
WifiPhyStandard: like802.11b,802.11n, etc. โ the whole vibe of the standard.FrequencyChannelWidthChannelNumber
You can absolutely set these to combinations that Do Not Get Along (e.g. channel number 1 with a 40 MHz channel width on frequency 4915 MHz ๐). Also, the last three of those are attributes, so you have multiple ways to set them:
- by setting the global configuration default, like:
Config::SetDefault ("ns3::WifiPhy::ChannelNumber", UintegerValue (3));
- by setting an attribute value right in the helper, like:
YansWifiPhyHelper wifiPhyHelper = YansWifiPhyHelper::Default ();
wifiPhyHelper.Set ("ChannelNumber", UintegerValue (3));
- by calling the
WifiHelper::SetStandard (enum WifiStandard)method; and - by doing post-installation configuration of the option, either through a
Ptrto theWifiPhyobject, or through theConfignamespace; e.g.:
Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/ChannelNumber",
UintegerValue (3));
This section is your little guidance era: how to configure all this in a way that's actually coherent, and what happens if you go rogue and pick non-standard values. โจ
๐ฆ WifiHelper::SetStandard() ๐ฆ
WifiHelper::SetStandard () is the method that sets a bunch of parameters in the Mac and Phy to standard values plus some reasonable defaults. Like, SetStandard (WIFI_STANDARD_80211a) will set the WifiPhy to Channel 36 in the 5 GHz band, among all the other settings that are appropriate for 802.11a. she does it all ๐
The following values for WifiStandard are defined in src/wifi/model/wifi-standards.h:
WIFI_STANDARD_80211a,
WIFI_STANDARD_80211b,
WIFI_STANDARD_80211g,
WIFI_STANDARD_80211p,
WIFI_STANDARD_80211n_2_4GHZ,
WIFI_STANDARD_80211n_5GHZ,
WIFI_STANDARD_80211ac,
WIFI_STANDARD_80211ax_2_4GHZ,
WIFI_STANDARD_80211ax_5GHZ,
WIFI_STANDARD_80211ax_6GHZ
By default, the WifiHelper (which is, like, the typical use case for WifiPhy creation) will configure the WIFI_STANDARD_80211a standard by default. Any other value for a standard has to be passed explicitly to the WifiHelper object โ no vibes-based guessing here.
If the user hasn't already separately configured Frequency or ChannelNumber by the time SetStandard gets called, the user gets default values, in addition (e.g. channel 1 for 802.11b/g, or channel 36 for a/n), in addition to an appropriate ChannelWidth value for the standard (typically, 20 MHz, but 80 MHz for 802.11ac/ax). bestie gets a whole starter pack ๐
๐ WifiPhy attribute interactions ๐
Keep this in your head, it's lowkey the whole plot: the two attributes that matter most inside the model code are WifiPhy::Frequency and WifiPhy::ChannelWidth โ those are the ones that directly set the transmission parameters. WifiPhy::ChannelNumber and WifiHelper::SetStandard () are just convenience shorthands for setting frequency and channel width. The ns3::WifiPhy contains code to keep these values aligned and to generate runtime errors in some cases if users set these attributes to incompatible values. it's giving guardian angel ๐ซถ
The pair (WifiPhyStandard, ChannelNumber) is an alias for a pair of (Frequency/ChannelWidth) items. Valid combinations are stored in a map inside WifiPhy that's populated with well-known values โ but that map can be dynamically extended at runtime. iconic behavior fr fr
๐ธ WifiPhy::Frequency ๐ธ
The WifiPhy channel center frequency is set by the attribute Frequency in the class WifiPhy. It's expressed in units of MHz. By default, this attribute is set to the value 0, which means no value is configured โ the void, the nothingness, the blank canvas.
โ ๏ธ Heads up: this is a change in definition from ns-3.25 and earlier releases, where this attribute referred to the start of the overall frequency band on which the channel resides, not the specific channel center frequency. so if you're reading old code, that's why you're confused, it's not you ๐ญ
โญ WifiPhy::ChannelWidth โญ
The WifiPhy channel width is set by the attribute ChannelWidth in the class WifiPhy. It's expressed in units of MHz. By default, this attribute is set to the value 20. Allowable values are 5, 10, 20, 22, 40, 80, or 160 (MHz). pick your fighter ๐
๐ WifiPhy::ChannelNumber ๐
Several channel numbers are defined and well-known in practice. However, valid channel numbers vary by geographical region around the world, and there's some overlap between the different standards. it's a whole international situation ๐
In ns-3, the class WifiPhy contains an attribute ChannelNumber that is, by default, set to the value 0. The value 0 indicates that no channel number has been set by the user.
In ns-3, a ChannelNumber may be defined or unknown. These terms are not found in the code; they're just used to describe behavior herein. (yes, we made them up, and yes, we're keeping them ๐)
If a ChannelNumber is defined, it means that WifiPhy has stored a map of ChannelNumber to the center frequency and channel width commonly known for that channel in practice. For example:
- Channel 1, when IEEE 802.11b is configured, corresponds to a channel width of 22 MHz and a center frequency of 2412 MHz.
- Channel 36, when IEEE 802.11n is configured at 5 GHz, corresponds to a channel width of 20 MHz and a center frequency of 5180 MHz.
The following channel numbers are well-defined for 2.4 GHz standards:
- channels 1-14 with
ChannelWidthof 22 MHz for 802.11b - channels 1-14 with
ChannelWidthof 20 MHz for 802.11n-2.4GHz and 802.11g
The following channel numbers are well-defined for 5 GHz standards:
5 GHz channel numbers
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ChannelWidth โ ChannelNumber โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 20 MHz โ 36, 40, 44, 48, 52, 56, โ
โ โ 60, 64, 100, 104, 108, โ
โ โ 112, 116, 120, 124, 128, โ
โ โ 132, 136, 140, 144, 149, โ
โ โ 153, 161, 165, 169 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 40 MHz โ 38, 46, 54, 62, 102, 110, โ
โ โ 118, 126, 134, 142, 151, โ
โ โ 159 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 80 MHz โ 42, 58, 106, 122, 138, 155 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 160 MHz โ 50, 114 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 10 MHz (802.11p) โ 172, 174, 176, 178, 180, โ
โ โ 182, 184 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 5 MHz (802.11p) โ 171, 173, 175, 177, 179, โ
โ โ 181, 183 โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The following channel numbers are well-defined for 6 GHz standards (802.11ax only):
6 GHz channel numbers
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ChannelWidth โ ChannelNumber โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 20 MHz โ 1, 5, 9, 13, 17, 21, 25, โ
โ โ 29, 33, 37, 41, 45, 49, โ
โ โ 53, 57, 61, 65, 69, 73, โ
โ โ 77, 81, 85, 89, 93, 97, โ
โ โ 101, 105, 109, 113, 117, โ
โ โ 121, 125, 129, 133, 137, โ
โ โ 141, 145, 149, 153, 157, โ
โ โ 161, 165, 169, 173, 177, โ
โ โ 181, 185, 189, 193, 197, โ
โ โ 201, 205, 209, 213, 217, โ
โ โ 221, 225, 229, 233 โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 40 MHz โ 3, 11, 19, 27, 35, 43, 51, โ
โ โ 59, 67, 75, 83, 91, 99, โ
โ โ 107, 115, 123, 131, 139, โ
โ โ 147, 155, 163, 171, 179, โ
โ โ 187, 195, 203, 211, 219, โ
โ โ 227 โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 80 MHz โ 7, 23, 39, 55, 71, 87, โ
โ โ 103, 119, 135, 151, 167, โ
โ โ 183, 199, 215 โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 160 MHz โ 15, 47, 79, 111, 143, 175, โ
โ โ 207 โ
โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The channel number may be set either before or after creation of the WifiPhy object. no pressure, whenever you're ready ๐ฆ
๐ If an unknown channel number (other than zero) is configured, the simulator will exit with an error; for instance, such as:
Ptr<WifiPhy> wifiPhy = ...;
wifiPhy->SetAttribute ("ChannelNumber", UintegerValue (1321));
okay so first things first: the known channel numbers? they're defined in the implementation file src/wifi/model/wifi-phy.cc. and yeah, users can absolutely edit that file to extend it to additional channel numbers โ it's right there, bestie ๐
. but below we're gonna talk about how new channel numbers may be defined dynamically at run-time, which is the actual moment โจ.
here's the tea though: if a known channel number gets configured against an incorrect value of the WifiPhyStandard, the simulator will exit with an error ๐ญ โ for instance, something like this:
WifiHelper wifi;
wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
...
Ptr<WifiPhy> wifiPhy = ...;
wifiPhy->SetAttribute ("ChannelNumber", UintegerValue (14));
in the above, while channel number 14 is well-defined in practice for 802.11b only, it is for the 2.4 GHz band, not the 5 GHz band. so likeโฆ the vibe check did not pass ๐.
๐ Defining a new channel number ๐
users may define their own channel number so that they can later refer to the channel by number. so iconic of you honestly.
the method is WifiPhy::DefineChannelNumber () and it takes the following arguments:
uint16_t channelNumberenum WifiPhyStandard standarduint32_t frequencyuint32_t channelWidth
the pair of (channelNumber, standard) are used as an index to a map that returns a Frequency and ChannelWidth. by calling this method, one can dynamically add members to the map. โจ
for instance, let's suppose that you previously configured WIFI_PHY_STANDARD_80211a, and wanted to define a new channel number '34' of width 20 MHz and at center frequency 5160 MHz.
if you try to simply configure ChannelNumber to the value 34, it will fail, since 34 is undefined ๐. however, you can use DefineChannelNumber as follows:
Ptr<WifiPhy> wifiPhy = ...;
wifiPhy->DefineChannelNumber (34, WIFI_PHY_STANDARD_80211a, 5160, 20);
and then later you can refer to channel number 34 in your program, which will configure a center operating frequency of 5160 MHz and a width of 20 MHz. slay.
the steps can be repeated to explicitly configure the same channel for multiple standards:
wifiPhy->DefineChannelNumber (34, WIFI_PHY_STANDARD_80211a, 5160, 20);
wifiPhy->DefineChannelNumber (34, WIFI_PHY_STANDARD_80211n_5GHZ, 5160, 20);
or for a wildcard, unspecified standard:
wifiPhy->DefineChannelNumber (34, WIFI_PHY_STANDARD_UNSPECIFIED, 5160, 20);
๐ธ Order of operation issues ๐ธ
depending on the default values used and the order of operation in setting the values for the standard, channel width, frequency, and channel number, different configurations can be obtained. below are some common use cases, bestie:
- (accepting the standard defaults): if a user has not already separately configured frequency or channel number when
WifiHelper::SetStandard ()is called, the user gets default values (e.g. channel1for 802.11b/g/n, channel36for a/n with 20 MHz channel widths and channel42for ac/ax with 80 MHz channel widths) โญ - (overwriting the standard channel): if the user has previously configured (e.g. via
SetDefault) either frequency or channel number whenSetStandardis called, and the frequency or channel number are appropriate for the standard being configured, they are not overwritten ๐ - (changing the standard channel after
Install): the user may also callWifiHelper::SetStandard ()afterInstall ()and either configure the frequency to something different, or configure the channel number to something different. note that if the channel number is undefined for the standard that was previously set, an error will occur ๐ญ - (changing to non-standard frequency): if the user configures a frequency outside the standardized frequency range for the current
WifiPhyStandard, this is OK. this allows users to experiment with wifi on e.g. whitespace frequencies but still useSetStandardto set all of the other configuration details ๐ง - (interaction between channel number and frequency): if the user sets
Frequencyto a different value than the currently configuredChannelNumber(or ifChannelNumberis zero), then theChannelNumberis set to a new channel number if known, or to zero if unknown.- example:
ChannelNumberpreviously set to36, user setsFrequencyto5200, thenChannelNumbergets automatically set to40โญ - example:
ChannelNumberset to36, user later setsFrequencyto5185,ChannelNumbergets reset to0โญ
- example:
in summary, ChannelNumber and Frequency follow each other ๐ฏ. ChannelNumber sets both Frequency and ChannelWidth if the channel number has been defined for the standard. setting ChannelWidth has no effect on Frequency or ChannelNumber. setting Frequency will set ChannelNumber to either the defined value for that Wi-Fi standard, or to the value 0 if undefined.
๐ฆ SpectrumWifiPhyHelper ๐ฆ
the API for this helper closely tracks the API of the YansWifiPhyHelper, with the exception that a channel of type ns3::SpectrumChannel instead of type ns3::YansWifiChannel must be used with it. that's the whole difference, periodt.
๐ WifiMacHelper ๐
next step, bestie: configure the MAC model. we use WifiMacHelper to accomplish this. WifiMacHelper takes care of both the MAC low model and MAC high model, and configures an object factory to create instances of a ns3::WifiMac. it is used to configure MAC parameters like type of MAC, and to select whether 802.11/WMM-style QoS and/or 802.11n-style High Throughput (HT) and/or 802.11ac-style Very High Throughput (VHT) support and/or 802.11ax-style High Efficiency (HE) support are/is required.
by default, it creates an ad-hoc MAC instance that does not have 802.11e/WMM-style QoS nor 802.11n-style High Throughput (HT) nor 802.11ac-style Very High Throughput (VHT) nor 802.11ax-style High Efficiency (HE) support enabled. like, none of it. zero. ๐ซถ
for example the following user code configures a non-QoS and non-HT/non-VHT/non-HE MAC that will be a non-AP STA in an infrastructure network where the AP has SSID ns-3-ssid:
WifiMacHelper wifiMacHelper;
Ssid ssid = Ssid ("ns-3-ssid");
wifiMacHelper.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
the following code shows how to create an AP with QoS enabled:
WifiMacHelper wifiMacHelper;
wifiMacHelper.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid),
"QosSupported", BooleanValue (true),
"BeaconGeneration", BooleanValue (true),
"BeaconInterval", TimeValue (Seconds (2.5)));
to create ad-hoc MAC instances, simply use ns3::AdhocWifiMac instead of ns3::StaWifiMac or ns3::ApWifiMac. easy ๐
.
with QoS-enabled MAC models it is possible to work with traffic belonging to four different Access Categories (ACs): AC_VO for voice traffic, AC_VI for video traffic, AC_BE for best-effort traffic and AC_BK for background traffic. โจ
when selecting 802.11n as the desired wifi standard, both 802.11e/WMM-style QoS and 802.11n-style High Throughput (HT) support gets enabled. similarly when selecting 802.11ac as the desired wifi standard, 802.11e/WMM-style QoS, 802.11n-style High Throughput (HT) and 802.11ac-style Very High Throughput (VHT) support gets enabled. and when selecting 802.11ax as the desired wifi standard, 802.11e/WMM-style QoS, 802.11n-style High Throughput (HT), 802.11ac-style Very High Throughput (VHT) and 802.11ax-style High Efficiency (HE) support gets enabled. it's giving stacked features ngl.
for MAC instances that have QoS support enabled, the ns3::WifiMacHelper can be also used to set:
- block ack threshold (number of packets for which block ack mechanism should be used);
- block ack inactivity timeout.
for example the following user code configures a MAC that will be a non-AP STA with QoS enabled and a block ack threshold for AC_BE set to 2 packets, in an infrastructure network where the AP has SSID ns-3-ssid:
WifiMacHelper wifiMacHelper;
Ssid ssid = Ssid ("ns-3-ssid");
wifiMacHelper.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid),
"QosSupported", BooleanValue (true),
"BE_BlockAckThreshold", UintegerValue (2),
"ActiveProbing", BooleanValue (false));
for MAC instances that have 802.11n-style High Throughput (HT) and/or 802.11ac-style Very High Throughput (VHT) and/or 802.11ax-style High Efficiency (HE) support enabled, the ns3::WifiMacHelper can be also used to set:
- MSDU aggregation parameters for a particular Access Category (AC) in order to use 802.11n/ac A-MSDU feature;
- MPDU aggregation parameters for a particular Access Category (AC) in order to use 802.11n/ac A-MPDU feature.
by default, MSDU aggregation feature is disabled for all ACs and MPDU aggregation is enabled for AC_VI and AC_BE, with a maximum aggregation size of 65535 bytes. (yes that's a big number. no, it's not a typo. ๐ธ)
for example the following user code configures a MAC that will be a non-AP STA with HT and QoS enabled, MPDU aggregation enabled for AC_VO with a maximum aggregation size of 65535 bytes, and MSDU aggregation enabled for AC_BE with a maximum aggregation size of 7935 bytes, in an infrastructure network where the AP has SSID ns-3-ssid:
WifiHelper wifi;
wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
WifiMacHelper wifiMacHelper;
Ssid ssid = Ssid ("ns-3-ssid");
wifiMacHelper.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid),
"VO_MaxAmpduSize", UintegerValue (65535),
"BE_MaxAmsduSize", UintegerValue (7935),
"ActiveProbing", BooleanValue (false));
802.11ax APs support sending multi-user frames via DL OFDMA and UL OFDMA if a Multi-User Scheduler is aggregated to the wifi MAC (by default no scheduler is aggregated). WifiMacHelper enables to aggregate a Multi-User Scheduler to an AP and set its parameters:
WifiMacHelper wifiMacHelper;
wifiMacHelper.SetMultiUserScheduler ("ns3::RrMultiUserScheduler",
"EnableUlOfdma", BooleanValue (true),
"EnableBsrp", BooleanValue (false));
the Ack Manager is in charge of selecting the acknowledgment method among the three available methods (see section wifi-mu-ack-sequences). the default ack manager enables to select the acknowledgment method, e.g.:
Config::SetDefault ("ns3::WifiDefaultAckManager::DlMuAckSequenceType",
EnumValue (WifiAcknowledgment::DL_MU_AGGREGATE_TF));
๐ฆ Selection of the Access Category (AC) ๐ฆ
Okay bestie, big glow-up alert: since ns-3.26, the QosTag is no longer used to assign a user priority to an MSDU. Not a thing anymore. Instead, the selection of the Access Category (AC) for an MSDU is based on the value of the DS field in the IP header of the packet โ that's the ToS field in the case of IPv4, and the Traffic Class field in the case of IPv6.
Details on how to set the ToS field of IPv4 packets are given in the Type-of-service section of the documentation. TL;DR version: you can create an address of type ns3::InetSocketAddress with the desired type of service value and pass it to the application helpers:
InetSocketAddress destAddress (ipv4Address, udpPort);
destAddress.SetTos (tos);
OnOffHelper onoff ("ns3::UdpSocketFactory", destAddress);
Mapping the values of the DS field onto user priorities is performed similarly to the Linux mac80211 subsystem. Basically, the ns3::WifiNetDevice::SelectQueue() method sets the user priority (UP) of an MSDU to the three most significant bits of the DS field. The Access Category is then determined based on the user priority, like this:
- UP
7โAC_VO - UP
6โAC_VO - UP
5โAC_VI - UP
4โAC_VI - UP
3โAC_BE - UP
0โAC_BE - UP
2โAC_BK - UP
1โAC_BK
(no, that order isn't a typo, that's literally how it's laid out, slay ๐ )
TOS and DSCP values map onto user priorities and access categories like this:
- DiffServ PHB
EFโ TOS101110xxโ UP5โAC_VI - DiffServ PHB
AF11โ TOS001010xxโ UP1โAC_BK - DiffServ PHB
AF21โ TOS010010xxโ UP2โAC_BK - DiffServ PHB
AF31โ TOS011010xxโ UP3โAC_BE - DiffServ PHB
AF41โ TOS100010xxโ UP4โAC_VI - DiffServ PHB
AF12โ TOS001100xxโ UP1โAC_BK - DiffServ PHB
AF22โ TOS010100xxโ UP2โAC_BK - DiffServ PHB
AF32โ TOS011100xxโ UP3โAC_BE - DiffServ PHB
AF42โ TOS100100xxโ UP4โAC_VI - DiffServ PHB
AF13โ TOS001110xxโ UP1โAC_BK - DiffServ PHB
AF23โ TOS010110xxโ UP2โAC_BK - DiffServ PHB
AF33โ TOS011110xxโ UP3โAC_BE - DiffServ PHB
AF43โ TOS100110xxโ UP4โAC_VI - DiffServ PHB
CS0โ TOS000000xxโ UP0โAC_BE - DiffServ PHB
CS1โ TOS001000xxโ UP1โAC_BK - DiffServ PHB
CS2โ TOS010000xxโ UP2โAC_BK - DiffServ PHB
CS3โ TOS011000xxโ UP3โAC_BE - DiffServ PHB
CS4โ TOS100000xxโ UP4โAC_VI - DiffServ PHB
CS5โ TOS101000xxโ UP5โAC_VI - DiffServ PHB
CS6โ TOS110000xxโ UP6โAC_VO - DiffServ PHB
CS7โ TOS111000xxโ UP7โAC_VO
So, for example:
destAddress.SetTos (0xc0);
โฆwill map to CS6, User Priority 6, and Access Category AC_VO. โจ Also, the ns3-wifi-ac-mapping test suite (defined in src/test/ns3wifi/wifi-ac-mapping-test-suite.cc) can provide additional useful information. Go read it, it's giving receipts.
Heads up babes ๐ โns3::WifiNetDevice::SelectQueue()also sets the packet priority to the user priority, which means it overwrites the value determined by the socket priority (users can read Socket-options for details on how to set the packet priority). And because the Traffic Control layer callsns3::WifiNetDevice::SelectQueue()before enqueuing the packet into a queue disc, it turns out that queuing disciplines (such asPfifoFastQueueDisc) that classify packets based on their priority will use the user priority instead of the socket priority. Not a drill, fr fr.
๐ WifiHelper ๐
We're now ready to create WifiNetDevices, bestie, let's go ๐ซถ. First, let's create a WifiHelper with default settings:
WifiHelper wifiHelper;
What does this do? It sets the default wifi standard to 802.11a and sets the RemoteStationManager to ns3::ArfWifiManager. You can change the RemoteStationManager by calling the WifiHelper::SetRemoteStationManager method. To change the wifi standard, call the WifiHelper::SetStandard method with the desired standard. Simple as.
Now, let's use the wifiPhyHelper and wifiMacHelper created above to install WifiNetDevices on a set of nodes in a NodeContainer "c":
NetDeviceContainer wifiContainer = WifiHelper::Install (wifiPhyHelper, wifiMacHelper, c);
This creates the WifiNetDevice, which includes also a WifiRemoteStationManager, a WifiMac, and a WifiPhy (connected to the matching Channel). The whole squad, together, iconic ๐
The WifiHelper::SetStandard method sets various default timing parameters as defined in the selected standard version, overwriting values that may exist or have been previously configured. So in order to change parameters that are overwritten by WifiHelper::SetStandard, this should be done post-install using Config::Set:
WifiHelper wifi;
wifi.SetStandard (WIFI_STANDARD_80211n_2_4GHZ);
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue("HtMcs7"), "ControlMode", StringValue("HtMcs0"));
//Install PHY and MAC
Ssid ssid = Ssid ("ns3-wifi");
WifiMacHelper mac;
mac.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
NetDeviceContainer staDevice;
staDevice = wifi.Install (phy, mac, wifiStaNode);
mac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid));
NetDeviceContainer apDevice;
apDevice = wifi.Install (phy, mac, wifiApNode);
Remember: anything SetStandard clobbers has to be re-set after install. Order matters, periodt. ๐
//Once install is done, we overwrite the standard timing values
Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/Slot", TimeValue (MicroSeconds (slot)));
Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/Sifs", TimeValue (MicroSeconds (sifs)));
Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/Pifs", TimeValue (MicroSeconds (pifs)));
Okay so once install is done, that's literally the moment where you go in and overwrite the standard timing values yourself, bestie. Iconic behaviour. ๐
The WifiHelper can also be used to set the attributes of the default ack policy selector (ConstantWifiAckPolicySelector), or to pick a totally different (user-provided) ack policy selector, and you get to do that for each of the available Access Categories. Obsessed with the flexibility fr fr. As an example, the following code can be used to set the BaThreshold attribute of the default ack policy selector associated with BE AC to 0.5:
WifiHelper wifi;
wifi.SetAckPolicySelectorForAc (AC_BE, "ns3::ConstantWifiAckPolicySelector",
"BaThreshold", DoubleValue (0.5));
The WifiHelper is also the thing you use to configure OBSS PD spatial reuse for 802.11ax. The following lines configure a WifiHelper to support OBSS PD spatial reuse using the ConstantObssPdAlgorithm with a threshold set to -72 dBm:
WifiHelper wifi;
wifi.SetObssPdAlgorithm ("ns3::ConstantObssPdAlgorithm",
"ObssPdLevel", DoubleValue (-72.0));
There are many other ns-3 attributes that can be set on the above helpers to deviate from the default behavior; the example scripts show how to do some of this reconfiguration. So yeah, go snoop the examples, they're giving tutorial energy. ๐ธ
โจ HT configuration โจ
HT is an acronym for High Throughput, a term synonymous with the IEEE 802.11n standard. Once ns3::WifiHelper::Install has been called and the user sets the standard to a variant that supports HT capabilities (802.11n, 802.11ac, or 802.11ax), an HT configuration object will automatically be created for the device. That object is what stores and manages the HT-specific attributes. No cap. ๐ซถ
802.11n/ac PHY layer can use either long (800 ns) or short (400 ns) OFDM guard intervals. To configure this parameter for a given device, the following lines of code could be used (in this example, it enables the support of a short guard interval for the first station):
Ptr<NetDevice> nd = wifiStaDevices.Get (0);
Ptr<WifiNetDevice> wnd = nd->GetObject<WifiNetDevice> ();
Ptr<HtConfiguration> htConfiguration = wnd->GetHtConfiguration ();
htConfiguration->SetShortGuardIntervalSupported (true);
It is also possible to configure HT-specific attributes using Config::Set. The following line of code enables the support of a short guard interval for all stations:
Config::Set
(โ/NodeList//DeviceList//$ns3::WifiNetDevice/HtConfiguration/ShortGuardIntervalSupportedโ,
BooleanValue (true));
๐ VHT configuration ๐
IEEE 802.11ac devices are also known as supporting Very High Throughput (VHT). Once ns3::WifiHelper::Install has been called and either the 802.11ac or 802.11ax 5 GHz standards are configured, a VHT configuration object will automatically be created to manage VHT-specific attributes.
As of ns-3.29, however, there are no VHT-specific configuration items to manage; therefore, this object is a placeholder for future growth. ๐ญ It's giving "reserved parking spot", bestie.
๐ HE configuration ๐
IEEE 802.11ax is also known as High Efficiency (HE). Once ns3::WifiHelper::Install has been called and IEEE 802.11ax configured as the standard, an HE configuration object will automatically be created to manage HE-specific attributes for 802.11ax devices.
802.11ax PHY layer can use either 3200 ns, 1600 ns or 800 ns OFDM guard intervals. To configure this parameter, the following lines of code could be used (in this example, it enables the support of 1600 ns guard interval), such as in this example code snippet:
Ptr<NetDevice> nd = wifiStaDevices.Get (0);
Ptr<WifiNetDevice> wnd = nd->GetObject<WifiNetDevice> ();
Ptr<HeConfiguration> heConfiguration = wnd->GetHeConfiguration ();
heConfiguration->SetGuardInterval (NanoSeconds (1600));
802.11ax allows extended compressed Block ACKs containing a 256-bits bitmap, making possible transmissions of A-MPDUs containing up to 256 MPDUs, depending on the negotiated buffer size. In order to configure the buffer size of an 802.11ax device, the following line of code could be used:
heConfiguration->SetMpduBufferSize (256);
For transmitting large MPDUs, it might also be needed to increase the maximum aggregation size (see above). ๐
๐ฆ Mobility configuration ๐ฆ
Finally, a mobility model must be configured on each node with Wi-Fi device. The mobility model is used for calculating propagation loss and propagation delay. Two examples are provided in the next section. Users are referred to the chapter on Mobility module for detailed information. Like, do not skip this step, it's not optional, periodt. ๐
๐ Example configuration ๐
We provide two typical examples of how a user might configure a Wi-Fi network โ one example with an ad-hoc network and one example with an infrastructure network. The two examples were modified from the two examples in the examples/wireless folder (wifi-simple-adhoc.cc and wifi-simple-infra.cc). Users are encouraged to see examples in the examples/wireless folder. Go look, it's a whole vibe. โจ
๐ธ AdHoc WifiNetDevice configuration ๐ธ
In this example, we create two ad-hoc nodes equipped with 802.11a Wi-Fi devices. We use the ns3::ConstantSpeedPropagationDelayModel as the propagation delay model and ns3::LogDistancePropagationLossModel with the exponent of 3.0 as the propagation loss model. Both devices are configured with ConstantRateWifiManager at the fixed rate of 12Mbps. Finally, we manually place them by using the ns3::ListPositionAllocator:
std::string phyMode ("OfdmRate12Mbps");
NodeContainer c;
c.Create (2);
WifiHelper wifi;
wifi.SetStandard (WIFI_STANDARD_80211a);
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
// ns-3 supports RadioTap and Prism tracing extensions for 802.11
wifiPhy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
YansWifiChannelHelper wifiChannel;
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel",
"Exponent", DoubleValue (3.0));
wifiPhy.SetChannel (wifiChannel.Create ());
// Add a non-QoS upper mac, and disable rate control (i.e. ConstantRateWifiManager)
WifiMacHelper wifiMac;
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode",StringValue (phyMode),
"ControlMode",StringValue (phyMode));
// Set it to adhoc mode
wifiMac.SetType ("ns3::AdhocWifiMac");
NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
// Configure mobility
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
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);
// other set up (e.g. InternetStack, Application)
๐ Infrastructure (access point and clients) WifiNetDevice configuration ๐
This is a typical example of how a user might configure an access point and a set of clients. In this example, we create one access point and two clients. Each node is equipped with 802.11b Wi-Fi device:
std::string phyMode ("DsssRate1Mbps");
NodeContainer ap;
ap.Create (1);
NodeContainer sta;
sta.Create (2);
WifiHelper wifi;
wifi.SetStandard (WIFI_STANDARD_80211b);
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
// ns-3 supports RadioTap and Prism tracing extensions for 802.11
wifiPhy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
YansWifiChannelHelper wifiChannel;
// reference loss must be changed since 802.11b is operating at 2.4GHz
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel",
"Exponent", DoubleValue (3.0),
"ReferenceLoss", DoubleValue (40.0459));
wifiPhy.SetChannel (wifiChannel.Create ());
// Add a non-QoS upper mac, and disable rate control
WifiMacHelper wifiMac;
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode",StringValue (phyMode),
"ControlMode",StringValue (phyMode));
// Setup the rest of the upper mac
Ssid ssid = Ssid ("wifi-default");
// setup ap.
wifiMac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid));
NetDeviceContainer apDevice = wifi.Install (wifiPhy, wifiMac, ap);
NetDeviceContainer devices = apDevice;
// setup sta.
wifiMac.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
NetDeviceContainer staDevice = wifi.Install (wifiPhy, wifiMac, sta);
devices.Add (staDevice);
// Configure mobility
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
positionAlloc->Add (Vector (5.0, 0.0, 0.0));
positionAlloc->Add (Vector (0.0, 5.0, 0.0));
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (ap);
mobility.Install (sta);
// other set up (e.g. InternetStack, Application)
๐ฅ Testing Documentation ๐ฅ
At present, most of the available documentation about testing and validation exists in publications, some of which are referenced below. Yeah, it's giving "read the papers, bestie". ๐
๐ง Error model ๐ง
Validation results for the 802.11b error model are available in this technical report.
Two clarifications on the results should be noted. First, Figure 1-4 of the above reference corresponds to the ns-3 NIST BER model. In the program in the Appendix of the paper (80211b.c), there are two constants used to generate the data. The first, packet size, is set to 1024 bytes. The second, โnoiseโ, is set to a value of 7 dB; this was empirically picked to align the curves the best with the reported data from the CMU testbed. Although a value of 1.55 dB would correspond to the reported -99 dBm noise floor from the CMU paper, a noise figure of 7 dB results in the best fit with the CMU experimental data. This default of 7 dB is the RxNoiseFigure in the ns3::YansWifiPhy model. Other values for noise figure will shift the curves leftward or rightward but not change the slope. Slay, physics. ๐
The curves can be reproduced by running the wifi-clear-channel-cmu.cc example program in the examples/wireless directory, and the figure produced (when GNU Scientific Library (GSL) is enabled) is reproduced below in Figure Clear channel (AWGN) error model for 802.11b. ๐ฆ
[image] Clear channel (AWGN) error model for 802.11b.
Validation results for the 802.11a/g OFDM error model are available in this technical report. The curves can be reproduced by running the wifi-ofdm-validation.cc example program in the examples/wireless directory, and the figure is reproduced below in Figure Frame error rate (NIST model) for 802.11a/g (OFDM) Wi-Fi. โจ
[image] Frame error rate (NIST model) for 802.11a/g (OFDM) Wi-Fi.
Similar curves for 802.11n/ac/ax can be obtained by running the wifi-ofdm-ht-validation.cc, wifi-ofdm-vht-validation.cc and wifi-ofdm-he-validation.cc example programs in the examples/wireless directory, and the figures are reproduced below in Figure Frame error rate (NIST model) for 802.11n (HT OFDM) Wi-Fi, Figure Frame error rate (NIST model) for 802.11ac (VHT OFDM) Wi-Fi and Figure Frame error rate (NIST model) for 802.11ax (HE OFDM) Wi-Fi, respectively. There is no validation for those curves yet. ๐
[image] Frame error rate (NIST model) for 802.11n (HT OFDM) Wi-Fi.
[image] Frame error rate (NIST model) for 802.11ac (VHT OFDM) Wi-Fi.
[image] Frame error rate (NIST model) for 802.11ax (HE OFDM) Wi-Fi.
๐ MAC validation ๐
Validation of the 802.11 DCF MAC layer has been performed in [baldo2010]. ๐
802.11 PCF operation has been verified by running โwifi-pcfโ example with PCAP files generation enabled, and observing the frame exchange using Wireshark. ๐
๐ SpectrumWiFiPhy ๐
The SpectrumWifiPhy implementation has been verified to produce equivalent results to the legacy YansWifiPhy by using the saturation and packet error rate programs (described below) and toggling the implementation between the two physical layers. bestie, it's giving same energy.
A basic unit test is provided using injection of hand-crafted packets to a receiving Phy object, controlling the timing and receive power of each packet arrival and checking the reception results. However, most of the testing of this Phy implementation has been performed using example programs described below, and during the course of a (separate) LTE/Wi-Fi coexistence study not documented herein. ๐
๐ฅ Saturation performance ๐ฅ
The program examples/wireless/wifi-spectrum-saturation-example.cc allows user to select either the SpectrumWifiPhy or YansWifiPhy for saturation tests. The wifiType can be toggled by the argument '--wifiType=ns3::YansWifiPhy' or --wifiType=ns3::SpectrumWifiPhy' โจ
There isnโt any difference in the output, which is to be expected because this test is more of a test of the DCF than the physical layer. lowkey it's not even about the PHY.
By default, the program will use the SpectrumWifiPhy and will run for 10 seconds of saturating UDP data, with 802.11n features enabled. It produces this output for the main 802.11n rates (with short and long guard intervals):
wifiType: ns3::SpectrumWifiPhy distance: 1m
index MCS width Rate (Mb/s) Tput (Mb/s) Received
0 0 20 6.5 5.81381 4937
1 1 20 13 11.8266 10043
2 2 20 19.5 17.7935 15110
3 3 20 26 23.7958 20207
4 4 20 39 35.7331 30344
5 5 20 52 47.6174 40436
6 6 20 58.5 53.6102 45525
7 7 20 65 59.5501 50569
...
63 15 40 300 254.902 216459
The above output shows the first 8 (of 32) modes, and last mode, that will be output from the program. The first 8 modes correspond to short guard interval disabled and channel bonding disabled. The subsequent 24 modes run by this program are variations with short guard interval enabled (cases 9-16), and then with channel bonding enabled and short guard first disabled then enabled (cases 17-32). Cases 33-64 repeat the same configurations but for two spatial streams (MIMO abstraction). ๐ซถ
When run with the legacy YansWifiPhy, as in ./waf --run "wifi-spectrum-saturation-example --wifiType=ns3::YansWifiPhy", the same output is observed:
wifiType: ns3::YansWifiPhy distance: 1m
index MCS width Rate (Mb/s) Tput (Mb/s) Received
0 0 20 6.5 5.81381 4937
1 1 20 13 11.8266 10043
2 2 20 19.5 17.7935 15110
3 3 20 26 23.7958 20207
...
This is to be expected since YansWifiPhy and SpectrumWifiPhy use the same error rate model in this case. no cap. ๐
๐ Packet error rate performance ๐
The program examples/wireless/wifi-spectrum-per-example.cc allows users to select either SpectrumWifiPhy or YansWifiPhy, as above, and select the distance between the nodes, and to log the reception statistics and received SNR (as observed by the WifiPhy::MonitorSnifferRx trace source), using a Friis propagation loss model. The transmit power is lowered from the default of 40 mW (16 dBm) to 1 dBm to lower the baseline SNR; the distance between the nodes can be changed to further change the SNR. By default, it steps through the same index values as in the saturation example (0 through 31) for a 50m distance, for 10 seconds of simulation time, producing output such as:
wifiType: ns3::SpectrumWifiPhy distance: 50m; time: 10; TxPower: 1 dBm (1.3 mW)
index MCS Rate (Mb/s) Tput (Mb/s) Received Signal (dBm) Noise (dBm) SNR (dB)
0 0 6.50 5.77 7414 -79.71 -93.97 14.25
1 1 13.00 11.58 14892 -79.71 -93.97 14.25
2 2 19.50 17.39 22358 -79.71 -93.97 14.25
3 3 26.00 22.96 29521 -79.71 -93.97 14.25
4 4 39.00 0.00 0 N/A N/A N/A
5 5 52.00 0.00 0 N/A N/A N/A
6 6 58.50 0.00 0 N/A N/A N/A
7 7 65.00 0.00 0 N/A N/A N/A
As in the above saturation example, running this program with YansWifiPhy will yield identical output. ๐
๐ง Interference performance ๐ง
The program examples/wireless/wifi-spectrum-per-interference.cc is based on the previous packet error rate example, but copies over the WaveformGenerator from the unlicensed LTE interferer test, to allow users to inject a non-Wi-Fi signal (using the --waveformPower argument) from the command line. Another difference with respect to the packet error rate example program is that the transmit power is set back to the default of 40 mW (16 dBm). By default, the interference generator is off, and the program should behave similarly to the other packet error rate example, but by adding small amounts of power (e.g. --waveformPower=0.001), one will start to observe SNR degradation and frame loss. ๐ญ
Some sample output with default arguments (no interference) is:
./waf --run "wifi-spectrum-per-interference"
wifiType: ns3::SpectrumWifiPhy distance: 50m; time: 10; TxPower: 16 dBm (40 mW)
index MCS Rate (Mb/s) Tput (Mb/s) Received Signal (dBm)Noi+Inf(dBm) SNR (dB)
0 0 6.50 5.77 7414 -64.69 -93.97 29.27
1 1 13.00 11.58 14892 -64.69 -93.97 29.27
2 2 19.50 17.39 22358 -64.69 -93.97 29.27
3 3 26.00 23.23 29875 -64.69 -93.97 29.27
4 4 39.00 34.90 44877 -64.69 -93.97 29.27
5 5 52.00 46.51 59813 -64.69 -93.97 29.27
6 6 58.50 52.39 67374 -64.69 -93.97 29.27
7 7 65.00 58.18 74819 -64.69 -93.97 29.27
...
while a small amount of waveform power will cause frame losses to occur at higher order modulations, due to lower SNR:
./waf --run "wifi-spectrum-per-interference --waveformPower=0.001"
wifiType: ns3::SpectrumWifiPhy distance: 50m; sent: 1000 TxPower: 16 dBm (40 mW)
index MCS Rate (Mb/s) Tput (Mb/s) Received Signal (dBm)Noi+Inf(dBm) SNR (dB)
0 0 6.50 5.77 7414 -64.69 -80.08 15.38
1 1 13.00 11.58 14892 -64.69 -80.08 15.38
2 2 19.50 17.39 22358 -64.69 -80.08 15.38
3 3 26.00 23.23 29873 -64.69 -80.08 15.38
4 4 39.00 0.41 531 -64.69 -80.08 15.38
5 5 52.00 0.00 0 N/A N/A N/A
6 6 58.50 0.00 0 N/A N/A N/A
7 7 65.00 0.00 0 N/A N/A N/A
...
If ns3::YansWifiPhy is selected as the wifiType, the waveform generator will not be enabled because only transmitters of type YansWifiPhy may be connected to a YansWifiChannel. periodt. ๐
The interference signal as received by the sending node is typically below the default -62 dBm CCA Mode 1 threshold in this example. If it raises above, the sending node will suppress all transmissions. โ ๏ธ
๐ Bianchi validation ๐
The program src/wifi/examples/wifi-bianchi.cc allows user to compare ns-3 simulation results against the Bianchi model presented in [bianchi2000] and [bianchi2005]. ๐ธ
The MATLAB code used to generate the Bianchi model, as well as the generated outputs, are provided in the folder src/wifi/examples/reference. User can regenerate Bianchi results by running generate_bianchi.m in MATLAB. โจ
By default, the program src/wifi/examples/wifi-bianchi.cc simulates an 802.11a adhoc ring scenario, with a PHY rate set to 54 Mbit/s, and loop from 5 stations to 50 stations, by a step of 5 stations. It generates a plt file, which allows user to quickly generate an eps file using gnuplot and vizualize the graph. ๐
./waf --run "wifi-bianchi"
[image] Bianchi throughput validation results for 802.11a 54 Mbps in adhoc configuration.
The user has the possibility to select the standard (only 11a, 11b or 11g currently supported), to select the PHY rate (in Mbit/s), as well as to choose between an adhoc or an infrastructure configuration. ๐ฆ
When run for 802.11g 6 Mbit/s in infrastucture mode, the output is:
./waf --run "wifi-bianchi --standard=11g --phyRate=6 --duration=500 --infra"
[image] Bianchi throughput validation results for 802.11g 6 Mbps in infrastructure configuration.
โจ Multi-user transmissions validation โจ
okay so the OFDMA support implementation?? it's been validated against a theoretical model [magrin2021mu] ๐ no cap.
and there's a preliminary evaluation of using OFDMA in 802.11ax โ like, latency when things aren't saturated, throughput when they ARE saturated, and transmission range with UL OFDMA โ all of that is in [avallone2021wcm] ๐ฆ
๐ References ๐
bestie here's the whole reading list, every single one, don't skip ๐ซถ
[ieee80211]โ IEEE Std 802.11-2012, Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications[ieee80211-2016]โ IEEE Std 802.11-2016, Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications[pei80211b]โ G. Pei and Tom Henderson, Validation of ns-3 802.11b PHY model[pei80211ofdm]โ G. Pei and Tom Henderson, Validation of OFDM error rate model in ns-3[lacage2006yans]โ M. Lacage and T. Henderson, Yet another Network Simulator[Haccoun]โ D. Haccoun and G. Begin, High-Rate Punctured Convolutional Codes for Viterbi Sequential Decoding, IEEE Transactions on Communications, Vol. 32, Issue 3, pp.315-319.[Frenger]โ Pรขl Frenger et al., โMulti-rate Convolutional Codesโ.[ji2004sslswn]โ Z. Ji, J. Zhou, M. Takai and R. Bagrodia, Scalable simulation of large-scale wireless networks with bounded inaccuracies, in Proc. of the Seventh ACM Symposium on Modeling, Analysis and Simulation of Wireless and Mobile Systems, October 2004.[linuxminstrel]โ minstrel linux wireless[lacage2004aarfamrr]โ M. Lacage, H. Manshaei, and T. Turletti, IEEE 802.11 rate adaptation: a practical approach, in Proc. 7th ACM International Symposium on Modeling, Analysis and Simulation of Wireless and Mobile Systems, 2004.[kim2006cara]โ J. Kim, S. Kim, S. Choi, and D. Qiao, CARA: Collision-Aware Rate Adaptation for IEEE 802.11 WLANs, in Proc. 25th IEEE International Conference on Computer Communications, 2006[wong2006rraa]โ S. Wong, H. Yang, S. Lu, and V. Bharghavan, Robust Rate Adaptation for 802.11 Wireless Networks, in Proc. 12th Annual International Conference on Mobile Computing and Networking, 2006[maguolo2008aarfcd]โ F. Maguolo, M. Lacage, and T. Turletti, Efficient collision detection for auto rate fallback algorithm, in IEEE Symposium on Computers and Communications, 2008[proakis2001]โ J. Proakis, Digital Communications, Wiley, 2001.[miller2003]โ L. E. Miller, โValidation of 802.11a/UWB Coexistence Simulation.โ Technical Report, October 2003. Available online[ferrari2004]โ G. Ferrari and G. Corazza, โTight bounds and accurate approximations for DQPSK transmission bit error rateโ, Electronics Letters, 40(20):1284-85, September 2004.[pursley2009]โ M. Pursley and T. Royster, โProperties and performance of the IEEE 802.11b complementary code key signal sets,โ IEEE Transactions on Communications, 57(2);440-449, February 2009.[akella2007parf]โ A. Akella, G. Judd, S. Seshan, and P. Steenkiste, โSelf-management in chaotic wireless deploymentsโ, in Wireless Networks, Kluwer Academic Publishers, 2007, 13, 737-755. http://www.cs.odu.edu/~nadeem/classes/cs795-WNS-S13/papers/enter-006.pdf[chevillat2005aparf]โ Chevillat, P.; Jelitto, J., and Truong, H. L., โDynamic data rate and transmit power adjustment in IEEE 802.11 wireless LANsโ, in International Journal of Wireless Information Networks, Springer, 2005, 12, 123-145. http://www.cs.mun.ca/~yzchen/papers/papers/rate_adaptation/80211_dynamic_rate_power_adjustment_chevillat_j2005.pdf[hepner2015]โ C. Hepner, A. Witt, and R. Muenzner, โIn depth analysis of the ns-3 physical layer abstraction for WLAN systems and evaluation of its influences on network simulation resultsโ, BW-CAR Symposium on Information and Communication Systems (SInCom) 2015. https://core.ac.uk/download/pdf/75487102.pdf#page=50[baldo2010]โ N. Baldo et al., โValidation of the ns-3 IEEE 802.11 model using the EXTREME testbedโ, Proceedings of SIMUTools Conference, March 2010.[lanante2019]โ L. Lanante Jr. et al., โImproved Abstraction for Clear Channel Assessment in ns-3 802.11 WLAN Modelโ, Proceedings of the 2019 Workshop on ns-3, June 2019.[bianchi2000]โ G. Bianchi, โPerformance analysis of the IEEE 802.11 distributed coordination functionโ, IEEE Communications Letters, 18(3):535โ547, 2000.[bianchi2005]โ G. Bianchi and I. Tinnirello. โRemarks on IEEE 802.11 DCF performance analysisโ, IEEE Communications Letters, 9(8):765โ767, 2005.[patidar2017]โ R. Patidar et al., โLink-to-System Mapping for ns-3 Wi-Fi OFDM Error Modelsโ, Proceedings of the Workshop on ns-3, June 2017. https://dl.acm.org/doi/10.1145/3067665.3067671[erceg2004]โ V. Erceg and L. Schumacher and P. Kyritsi, โTgn channel modelsโ, IEEE 802.11-03/940r4, 2004.[porat2016]โ R. Porat et al., โ11ax Evaluation Methodologyโ, IEE P802.11 Wireless LANs, 11-14-0571r3, 2016.[krotov2020rate]โ A. Krotov, A. Kiryanov, E. Khorov., Rate Control With Spatial Reuse for Wi-Fi 6 Dense Deployments, IEEE Access, September 2020[magrin2021mu]โ D. Magrin, S. Avallone, S. Roy, and M. Zorzi, โValidation of the ns-3 802.11ax OFDMA implementationโ, in Proceedings of WNS3 2021.[avallone2021wcm]โ S. Avallone, P. Imputato, G. Redieteab, C. Ghosh and S. Roy, โWill OFDMA Improve the Performance of 802.11 WiFi Networks?โ, in IEEE Wireless Communications Magazine, DOI: 10.1109/MWC.001.2000332, to appear.
๐ก WIMAX NETDEVICE ๐ก
okay so this chapter is all about the ns-3 WimaxNetDevice and the models that come with it ๐ basically, you drop WimaxNetDevice objects onto ns-3 nodes and boom โ you've got models of 802.16-based networks. and like, below there's more detail on what the ns-3 WiMAX models actually cover, but real quick, the most important features of the ns-3 model are:
- a scalable and realistic physical layer and channel model
- a packet classifier for the IP convergence sublayer
- efficient uplink and downlink schedulers
- support for Multicast and Broadcast Service (MBS), and
- packet tracing functionality
the source code for the WiMAX models lives in the directory src/wimax ๐
and there have been two academic papers published on this model:
- M.A. Ismail, G. Piro, L.A. Grieco, and T. Turletti, โAn Improved IEEE 802.16 WiMAX Module for the NS-3 Simulatorโ, SIMUTools 2010 Conference, March 2010.
- J. Farooq and T. Turletti, โAn IEEE 802.16 WiMAX module for the NS-3 Simulator,โ SIMUTools 2009 Conference, March 2009.
๐ Scope of the model ๐
so from a MAC perspective, there are two basic modes of operation: that of a Subscriber Station (SS) or a Base Station (BS) โจ these are implemented as two subclasses of the base class ns3::NetDevice โ class SubscriberStationNetDevice and class BaseStationNetDevice. and as is typical in ns-3, there's also a physical layer class WimaxPhy and a channel class WimaxChannel which serves to hold the references to all of the attached Phy devices. the main physical layer class is the SimpleOfdmWimaxChannel class ๐
another important aspect of WiMAX is the uplink and downlink scheduler, and there are three primary scheduler types implemented:
- SIMPLE: a simple priority based FCFS scheduler
- RTPS: a real-time polling service (rtPS) scheduler
- MBQOS: a migration-based uplink scheduler
the following additional aspects of the 802.16 specifications, as well as physical layer and channel models, are modelled:
- leverages existing ns-3 wireless propagation loss and delay models, as well as ns-3 mobility models
- Point-to-Multipoint (PMP) mode and the WirelessMAN-OFDM PHY layer
- Initial Ranging
- Service Flow Initialization
- Management Connection
- Transport Initialization
- UGS, rtPS, nrtPS, and BE connections
and the following aspects are not presently modelled but would be good topics for future extensions ๐ (not me manifesting these for whoever picks them up):
- OFDMA PHY layer
- Link adaptation
- Mesh topologies
- ARQ
- ertPS connection
- packet header suppression
๐ ๏ธ Using the Wimax models ๐ ๏ธ
the main way that users who write simulation scripts will typically interact with the Wimax models is through the helper API and through the publicly visible attributes of the model ๐ธ
the helper API is defined in src/wimax/helper/wimax-helper.{cc,h}.
the example src/wimax/examples/wimax-simple.cc contains some basic code that shows how to set up the model:
switch (schedType)
{
case 0:
scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
break;
case 1:
scheduler = WimaxHelper::SCHED_TYPE_MBQOS;
break;
case 2:
scheduler = WimaxHelper::SCHED_TYPE_RTPS;
break;
default:
scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
}
NodeContainer ssNodes;
NodeContainer bsNodes;
ssNodes.Create (2);
bsNodes.Create (1);
WimaxHelper wimax;
NetDeviceContainer ssDevs, bsDevs;
ssDevs = wimax.Install (ssNodes,
WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
scheduler);
bsDevs = wimax.Install (bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler);
this example shows that there are two subscriber stations and one base station created ๐ซถ the helper method Install allows the user to specify the scheduler type, the physical layer type, and the device type.
different variants of Install are available; for instance, the example src/wimax/examples/wimax-multicast.cc shows how to specify a non-default channel or propagation model:
so like, here's the rest of that WiMAX setup code, bestie โ it's giving very much "plug in your channel and go" โจ
channel = CreateObject<SimpleOfdmWimaxChannel> ();
channel->SetPropagationModel (SimpleOfdmWimaxChannel::COST231_PROPAGATION);
ssDevs = wimax.Install (ssNodes,
WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
channel,
scheduler);
Ptr<WimaxNetDevice> dev = wimax.Install (bsNodes.Get (0),
WimaxHelper::DEVICE_TYPE_BASE_STATION,
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
channel,
scheduler);
Mobility is also supported in the same way as in Wifi models; see the src/wimax/examples/wimax-multicast.cc.
Another important concept in WiMAX is that of a service flow. This is a unidirectional flow of packets with a set of QoS parameters such as traffic priority, rate, scheduling type, etc. The base station is responsible for issuing service flow identifiers and mapping them to WiMAX connections. The following code from src/wimax/examples/wimax-multicast.cc shows how this is configured from a helper level:
ServiceFlow MulticastServiceFlow = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_DOWN,
ServiceFlow::SF_TYPE_UGS,
MulticastClassifier);
bs->GetServiceFlowManager ()->AddMulticastServiceFlow (MulticastServiceFlow, WimaxPhy::MODULATION_TYPE_QPSK_12);
Wimax Attributes ๐
The WimaxNetDevice makes heavy use of the ns-3 attributes subsystem for configuration and default value management. Presently, approximately 60 values are stored in this system.
For instance, class ns-3::SimpleOfdmWimaxPhy exports these attributes:
NoiseFigureโ Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.TxPowerโ Transmission power (dB)Gโ The ratio of CP time to useful timetxGainโ Transmission gain (dB)RxGainโ Reception gain (dB)Nfftโ FFT sizeTraceFilePathโ Path to the directory containing SNR to block error rate files
For a full list of attributes in these models, consult the Doxygen page that lists all attributes for ns-3. ๐
Wimax Tracing ๐ฆ
ns-3 has a sophisticated tracing infrastructure that allows users to hook into existing trace sources, or to define and export new ones.
Many ns-3 users use the built-in Pcap or Ascii tracing, and the WimaxHelper has similar APIs:
AsciiTraceHelper ascii;
WimaxHelper wimax;
wimax.EnablePcap ("wimax-program", false);
wimax.EnableAsciiAll (ascii.CreateFileStream ("wimax-program.tr");
Unlike other helpers, there is also a special EnableAsciiForConnection() method that limits the ascii tracing to a specific device and connection.
These helpers access the low level trace sources that exist in the WiMAX physical layer, net device, and queue models. Like other ns-3 trace sources, users may hook their own functions to these trace sources if they want to do customized things based on the packet events. See the Doxygen List of trace sources for a complete list of these sources.
Wimax MAC model ๐ฅ
The 802.16 model provided in ns-3 attempts to provide an accurate MAC and PHY level implementation of the 802.16 specification with the Point-to-Multipoint (PMP) mode and the WirelessMAN-OFDM PHY layer. The model is mainly composed of three layers:
- The convergence sublayer (CS)
- The MAC CP Common Part Sublayer (MAC-CPS)
- Physical (PHY) layer
The following figure WiMAX architecture shows the relationships of these models.
[image] WiMAX architecture. ๐
Convergence Sublayer โจ
The Convergence sublayer (CS) provided with this module implements the Packet CS, designed to work with the packet-based protocols at higher layers. The CS is responsible of receiving packet from the higher layer and from peer stations, classifying packets to appropriate connections (or service flows) and processing packets. It keeps a mapping of transport connections to service flows. This enables the MAC CPS identifying the Quality of Service (QoS) parameters associated to a transport connection and ensuring the QoS requirements. The CS currently employs an IP classifier.
IP Packet Classifier ๐
An IP packet classifier is used to map incoming packets to appropriate connections based on a set of criteria. The classifier maintains a list of mapping rules which associate an IP flow (src IP address and mask, dst IP address and mask, src port range, dst port range and protocol) to one of the service flows. By analyzing the IP and the TCP/UDP headers the classifier will append the incoming packet (from the upper layer) to the queue of the appropriate WiMAX connection. Class IpcsClassifier and class IpcsClassifierRecord implement the classifier module for both SS and BS. ๐ซถ
MAC Common Part Sublayer ๐ธ
The MAC Common Part Sublayer (CPS) is the main sublayer of the IEEE 802.16 MAC and performs the fundamental functions of the MAC. The module implements the Point-Multi-Point (PMP) mode. In PMP mode BS is responsible of managing communication among multiple SSs. The key functionalities of the MAC CPS include framing and addressing, generation of MAC management messages, SS initialization and registration, service flow management, bandwidth management and scheduling services. Class WimaxNetDevice represents the MAC layer of a WiMAX network device. This class extends the class NetDevice of the ns-3 API that provides abstraction of a network device. Class WimaxNetDevice is further extended by class BaseStationNetDevice and class SubscriberStationNetDevice, defining MAC layers of BS and SS, respectively. Besides these main classes, the key functions of MAC are distributed to several other classes.
Framing and Management Messages ๐
The module implements a frame as a fixed duration of time, i.e., frame boundaries are defined with respect to time. Each frame is further subdivided into downlink (DL) and uplink (UL) subframes. The module implements the Time Division Duplex (TDD) mode where DL and UL operate on same frequency but are separated in time. A number of DL and UL bursts are then allocated in DL and UL subframes, respectively. Since the standard allows sending and receiving bursts of packets in a given DL or UL burst, the unit of transmission at the MAC layer is a packet burst. The module implements a special PacketBurst data structure for this purpose. A packet burst is essentially a list of packets. The BS downlink and uplink schedulers, implemented by class BSScheduler and class UplinkScheduler, are responsible of generating DL and UL subframes, respectively. In the case of DL, the subframe is simulated by transmitting consecutive bursts (instances PacketBurst). In case of UL, the subframe is divided, with respect to time, into a number of slots. The bursts transmitted by the SSs in these slots are then aligned to slot boundaries. The frame is divided into integer number of symbols and Physical Slots (PS) which helps in managing bandwidth more effectively. The number of symbols per frame depends on the underlying implementation of the PHY layer. The size of a DL or UL burst is specified in units of symbols.
Network Entry and Initialization ๐ง
The network entry and initialization phase is basically divided into two sub-phases, (1) scanning and synchronization and (2) initial ranging. The entire phase is performed by the LinkManager component of SS and BS. Once an SS wants to join the network, it first scans the downlink frequencies to search for a suitable channel. The search is complete as soon as it detects a PHY frame. The next step is to establish synchronization with the BS. Once SS receives a Downlink-MAP (DL-MAP) message the synchronization phase is complete and it remains synchronized as long as it keeps receiving DL-MAP and Downlink Channel Descriptor (DCD) messages. After the synchronization is established, SS waits for a Uplink Channel Descriptor (UCD) message to acquire uplink channel parameters. Once acquired, the first sub-phase of the network entry and initialization is complete. Once synchronization is achieved, the SS waits for a UL-MAP message to locate a special grant, called initial ranging interval, in the UL subframe. This grant is allocated by the BS Uplink Scheduler at regular intervals. Currently this interval is set to 0.5 ms, however the user is enabled to modify its value from the simulation script. โจ
Connections and Addressing ๐
All communication at the MAC layer is carried in terms of connections. The standard defines a connection as a unidirectional mapping between the SS and BS's MAC entities for the transmission of traffic. The standard defines two types of connections: management connections for transmitting control messages and transport connections for data transmission. A connection is identified by a 16-bit Connection Identifier (CID). Class WimaxConnection and class Cid implement the connection and CID, respectively. Note that each connection maintains its own transmission queue where packets to transmit on that connection are queued. The ConnectionManager component of BS is responsible of creating and managing connections for all SSs.
The two key management connections defined by the standard, namely the Basic and Primary management connections, are created and allocated to the SS during the ranging process. Basic connection plays an important role throughout the operation of SS also because all (unicast) DL and UL grants are directed towards SS's Basic CID. In addition to management connections, an SS may have one or more transport connections to send data packets. The Connection Manager component of SS manages the connections associated to SS. As defined by the standard, a management connection is bidirectional, i.e., a pair of downlink and uplink connections is represented by the same CID. This feature is implemented in a way that one connection (in DL direction) is created by the BS and upon receiving the CID the SS then creates an identical connection (in UL direction) with the same CID.
Scheduling Services ๐
The module supports the four scheduling services defined by the 802.16-2004 standard:
- Unsolicited Grant Service (UGS)
- Real-Time Polling Services (rtPS)
- Non Real-Time Polling Services (nrtPS)
- Best Effort (BE)
okay bestie, so these scheduling services? They behave differently when it comes to how they ask for bandwidth and how the bandwidth gets granted. Each service flow is linked to exactly one scheduling service, and the QoS parameter set tied to a service flow actually defines which scheduling service it belongs to. When a service flow is created, the UplinkScheduler calculates necessary parameters such as grant size and grant interval based on the QoS parameters associated with it. periodt. ๐
โจ WiMAX Uplink Scheduler Model โจ
The Uplink Scheduler at the BS decides which of the SSs get uplink allocations based on the QoS parameters associated to a service flow (or scheduling service) and bandwidth requests from the SSs. The uplink scheduler plus the Bandwidth Manager together implement the complete scheduling service functionality. The standard defines up to four scheduling services (BE, UGS, rtPS, nrtPS) for applications with different types of QoS requirements. The service flows of these scheduling services act differently with respect to how they request bandwidth and how bandwidth is granted. The module supports all four scheduling services. Each service flow is associated to exactly one transport connection and one scheduling service. The QoS parameters associated to a service flow actually define the scheduling service it belongs to. Standard QoS parameters for UGS, rtPS, nrtPS and BE services, as specified in Tables 111a to 111d of the 802.16e amendment, are supported. When a service flow is created the uplink scheduler calculates necessary parameters such as grant size and allocation interval based on QoS parameters associated to it. The current WiMAX module provides three different versions of schedulers.
- The first one is a simple priority-based First Come First Serve (
FCFS). For the real-time services (UGSandrtPS) the BS then allocates grants/polls on regular basis based on the calculated interval. For the non real-time services (nrtPSandBE) only minimum reserved bandwidth is guaranteed if available after servicing real-time flows. Note that not all of these parameters are utilized by the uplink scheduler. Also note that currently only service flow with fixed-size packet size are supported, as currently set up in simulation scenario withOnOffapplication of fixed packet size. This scheduler is implemented by classBSSchedulerSimpleand classUplinkSchedulerSimple. - The second one is similar to first scheduler except by
rtPSservice flow. AllrtPSConnections are able to transmit all packet in the queue according to the available bandwidth. The bandwidth saturation control has been implemented to redistribute the effective available bandwidth to allrtPSthat have at least one packet to transmit. The remaining bandwidth is allocated tonrtPSandBEConnections. This scheduler is implemented by classBSSchedulerRtpsand classUplinkSchedulerRtps. - The third one is a Migration-based Quality of Service uplink scheduler. This uplink scheduler uses three queues, the low priority queue, the intermediate queue and the high priority queue. The scheduler serves the requests in strict priority order from the high priority queue to the low priority queue. The low priority queue stores the bandwidth requests of the
BEservice flow. The intermediate queue holds bandwidth requests sent byrtPSand bynrtPSconnections.rtPSandnrtPSrequests can migrate to the high priority queue to guarantee that their QoS requirements are met. Besides the requests migrated from the intermediate queue, the high priority queue stores periodic grants and unicast request opportunities that must be scheduled in the following frame. To guarantee the maximum delay requirement, the BS assigns a deadline to eachrtPSbandwidth request in the intermediate queue. The minimum bandwidth requirement of bothrtPSandnrtPSconnections is guaranteed over a window of durationT. This scheduler is implemented by classUplinkSchedulerMBQoS.
โจ WiMAX Outbound Schedulers Model โจ
Besides the uplink scheduler these are the outbound schedulers at BS and SS side (BSScheduler and SSScheduler). The outbound schedulers decide which of the packets from the outbound queues will be transmitted in a given allocation. The outbound scheduler at the BS schedules the downlink traffic, i.e., packets to be transmitted to the SSs in the downlink subframe. Similarly the outbound scheduler at a SS schedules the packet to be transmitted in the uplink allocation assigned to that SS in the uplink subframe. All three schedulers have been implemented to work as FCFS scheduler, as they allocate grants starting from highest priority scheduling service to the lower priority one (UGS> rtPS> nrtPS> BE). The standard does not suggest any scheduling algorithm and instead leaves this decision up to the manufacturers. Of course more sophisticated algorithms can be added later if required.
โจ WimaxChannel and WimaxPhy models โจ
The module implements the Wireless MAN OFDM PHY specifications as the more relevant for implementation as it is the schema chosen by the WiMAX Forum. This specification is designed for non-light-of-sight (NLOS) including fixed and mobile broadband wireless access. The proposed model uses a 256 FFT processor, with 192 data subcarriers. It supports all the seven modulation and coding schemes specified by Wireless MAN-OFDM. It is composed of two parts: the channel model and the physical model.
โจ Channel model โจ
The channel model we propose is implemented by the class SimpleOFDMWimaxChannel which extends the class wimaxchannel. The channel entity has a private structure named m_phyList which handles all the physical devices connected to it. When a physical device sends a packet (FEC Block) to the channel, the channel handles the packet, and then for each physical device connected to it, it calculates the propagation delay, the path loss according to a given propagation model and eventually forwards the packet to the receiver device. The channel class uses the method GetDistanceFrom() to calculate the distance between two physical entities according to their 3D coordinates. The delay is computed as delay = distance/C, where C is the speed of the light.
โจ Physical model โจ
The physical layer performs two main operations: (i) It receives a burst from a channel and forwards it to the MAC layer, (ii) it receives a burst from the MAC layer and transmits it on the channel. In order to reduce the simulation complexity of the WiMAX physical layer, we have chosen to model offline part of the physical layer. More specifically we have developed an OFDM simulator to generate trace files used by the reception process to evaluate if a FEC block can be correctly decoded or not.
Transmission Process: A burst is a set of WiMAX MAC PDUs. At the sending process, a burst is converted into bit-streams and then split into smaller FEC blocks which are then sent to the channel with a power equal P_tx.
Reception Process: The reception process includes the following operations:
- Receive a FEC block from the channel.
- Calculate the noise level.
- Estimate the signal to noise ratio (SNR) with the following formula.
- Determine if a FEC block can be correctly decoded.
- Concatenate received FEC blocks to reconstruct the original burst.
- Forward the burst to the upper layer.
The developed process to evaluate if a FEC block can be correctly received or not uses pre-generated traces. The trace files are generated by an external OFDM simulator (described later). A class named SNRToBlockErrorRateManager handles a repository containing seven trace files (one for each modulation and coding scheme). A repository is specific for a particular channel model.
A trace file is made of 6 columns. The first column provides the SNR value (1), whereas the other columns give respectively the bit error rate BER (2), the block error rate BlcER (3), the standard deviation on BlcER, and the confidence interval (4 and 5). These trace files are loaded into memory by the SNRToBlockErrorRateManager entity at the beginning of the simulation.
Currently, The first process uses the first and third columns to determine if a FEC block is correctly received. When the physical layer receives a packet with an SNR equal to SNR_rx, it asks the SNRToBlockErrorRateManager to return the corresponding block error rate BlcER. A random number RAND between 0 and 1 is then generated. If RAND is greater than BlcER, then the block is correctly received, otherwise the block is considered erroneous and is ignored.
The module provides defaults SNR to block error rate traces in default-traces.h. The traces have been generated by an External WiMAX OFDM simulator. The simulator is based on an external mathematics and signal processing library IT++ and includes : a random block generator, a Reed Solomon (RS) coder, a convolutional coder, an interleaver, a 256 FFT-based OFDM modulator, a multi-path channel simulator and an equalizer. The multipath channel is simulated using the TDL_channel class of the IT++ library.
Users can configure the module to use their own traces generated by another OFDM simulator or ideally by performing experiments in real environment. For this purpose, a path to a repository containing trace files should be provided. If no repository is provided the traces form default-traces.h will be loaded. A valid repository should contain 7 files, one for each modulation and coding scheme.
The names of the files should respect the following format: modulation0.txt for modulation 0, modulation1.txt for modulation 1 and so onโฆ The file format should be as follows:
SNR_value1 BER Blc_ER STANDARD_DEVIATION CONFIDENCE_INTERVAL1 CONFIDENCE_INTERVAL2
SNR_value2 BER Blc_ER STANDARD_DEVIATION CONFIDENCE_INTERVAL1 CONFIDENCE_INTERVAL2
... ... ... ... ... ...
... ... ... ... ... ...
โจ AUTHOR โจ
ns-3 project
โจ COPYRIGHT โจ
2006-2019
okay that's the whole vibe, bestie. This was ns-3.35, timestamp 1643791691, page NS-3-MODEL-LIBRARY(1) โ periodt, mwah ๐๐ฆ
๐ฆ where this page comes from
- ubuntu jammy: ns3-doc 3.35+dfsg-1ubuntu1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms