11#include "ns3/attribute-container.h"
12#include "ns3/double.h"
14#include "ns3/inet-socket-address.h"
15#include "ns3/inet6-socket-address.h"
18#include "ns3/nstime.h"
19#include "ns3/packet-socket-address.h"
20#include "ns3/packet.h"
22#include "ns3/pointer.h"
23#include "ns3/random-variable-stream.h"
24#include "ns3/simulator.h"
25#include "ns3/socket-factory.h"
26#include "ns3/socket.h"
27#include "ns3/string.h"
42 TypeId(
"ns3::TgaxVirtualDesktop")
44 .SetGroupName(
"Applications")
46 .AddAttribute(
"ModelPresets",
47 "The model presets to use (Custom for custom settings)",
60 "The type of protocol to use. This should be a subclass of ns3::SocketFactory",
65 "CustomInitialPacketArrival",
66 "A uniform random variable to generate the initial packet arrival in nanoseconds.",
67 StringValue(
"ns3::UniformRandomVariable[Min=0|Max=20000000]"),
70 .AddAttribute(
"CustomInterPacketArrivals",
71 "An exponential random variable to generate the inter packet arrivals in "
73 StringValue(
"ns3::ExponentialRandomVariable[Mean=60226900]"),
77 "CustomParametersPacketSize",
78 "The mean value and standard deviation for each mode of the multimodal normal "
79 "distribution used to calculate packet sizes.",
103 auto currentStream = stream;
112 pktSizeDistribution->SetStream(currentStream++);
114 return (currentStream - stream);
122 for (
const auto& [mean,
std] : params)
145 std::vector<std::pair<double, double>> params;
149 params = {{41.0, 3.2}, {1478.3, 11.6}};
157 params = {{50.598, 5.0753}};
189 NS_LOG_DEBUG(
"Discarding cached packet upon CancelEvents ()");
241 unsigned int actualSize =
m_socket->Send(packet);
242 if (actualSize == packet->GetSize())
247 m_socket->GetSockName(localAddress);
252 << packet->GetSize() <<
" bytes to "
260 << packet->GetSize() <<
" bytes to "
267 NS_LOG_DEBUG(
"Unable to send VDI packet; actual " << actualSize <<
" size "
269 <<
"; caching for later attempt");
a polymophic address class
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
static bool IsMatchingType(const Address &addr)
If the address match.
static bool IsMatchingType(const Address &address)
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
virtual void DoInitialize()
Initialize() implementation.
AttributeValue implementation for Pair.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
TypeId m_protocolTid
Protocol TypeId value.
SourceApplication(bool allowPacketSocket=true)
Constructor.
Ptr< Socket > m_socket
Socket.
TracedCallback< Ptr< const Packet > > m_txTrace
Traced Callback: transmitted packets.
bool m_connected
flag whether socket is connected
Address m_peer
Peer address.
Hold variables of type string.
Generate Virtual Desktop Infrastructure (VDI) traffic.
EventId m_txEvent
Event id of pending TX event.
Ptr< Packet > m_unsentPacket
Unsent packet cached for future attempt.
void TxDone(Ptr< Socket > socket, uint32_t size)
Handle a Data Sent event.
void SendPacket()
Transmit the next VDI packet.
std::vector< Ptr< NormalRandomVariable > > m_pktSizeDistributions
Single or multi modal normal random variables to generate packet sizes in bytes.
void DoStartApplication() override
Application specific startup code for child subclasses.
Ptr< ExponentialRandomVariable > m_interArrivalExponential
Exponential random variable to generate packet arrival times in nanoseconds.
uint32_t GetPacketSize() const
Get the size in bytes of the next VDI packet to send.
void SetParametersPacketSize(const std::vector< std::pair< double, double > > ¶ms)
Set the parameters of the normal random variable used to generate the VDI packet sizes.
ModelPresets m_modelPresets
Model presets to use to configure the VDI traffic model parameters.
~TgaxVirtualDesktop() override
Ptr< UniformRandomVariable > m_initialArrivalUniform
Uniform random variable to generate initial packet arrival in nanoseconds.
void ScheduleNext()
Schedule the next TX.
void TxAvailable(Ptr< Socket > socket, uint32_t available)
Handle a Send event.
void DoConnectionSucceeded(Ptr< Socket > socket) override
Application specific code for child subclasses upon a Connection Succeed event.
static TypeId GetTypeId()
Get the type ID.
void CancelEvents() override
Cancel all pending events.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this Application object.
Time GetInterArrival() const
Get the duration to use to schedule the TX of the next VDI packet.
Ptr< BernoulliRandomVariable > m_dlModeSelection
Uniform random variable to select mode for downlink bimodal distribution.
bool m_initialPacket
True if the next packet to send is the initial packet.
void DoInitialize() override
Initialize() implementation.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
@ ATTR_GET
The attribute can be read.
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
AttributeValue implementation for TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< AttributeChecker > MakeAttributeContainerChecker(const AttributeContainerValue< A, Sep, C > &value)
Make AttributeContainerChecker from AttributeContainerValue.
Ptr< const AttributeAccessor > MakeAttributeContainerAccessor(T1 a1)
Make AttributeContainerAccessor using explicit types.
Ptr< const AttributeChecker > MakeDoubleChecker()
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePairChecker(const PairValue< A, B > &value)
Make a PairChecker from a PairValue.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Ptr< const AttributeChecker > MakeTypeIdChecker()
Ptr< const AttributeAccessor > MakeTypeIdAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.