6#include "traffic-generator-ngmn-ftp-multi.h"
8#include "ns3/address.h"
12#include "ns3/nstime.h"
13#include "ns3/packet.h"
14#include "ns3/simulator.h"
15#include "ns3/socket-factory.h"
16#include "ns3/socket.h"
17#include "ns3/tcp-socket-factory.h"
18#include "ns3/trace-source-accessor.h"
19#include "ns3/udp-socket-factory.h"
20#include "ns3/uinteger.h"
25NS_LOG_COMPONENT_DEFINE(
"TrafficGeneratorNgmnFtpMulti");
26NS_OBJECT_ENSURE_REGISTERED(TrafficGeneratorNgmnFtpMulti);
32 TypeId(
"ns3::TrafficGeneratorNgmnFtpMulti")
34 .SetGroupName(
"Applications")
36 .AddAttribute(
"MaxFileSize",
37 "Max file size in number of bytes",
39 MakeUintegerAccessor(&TrafficGeneratorNgmnFtpMulti::m_maxFileSize),
40 MakeUintegerChecker<uint32_t>(1))
41 .AddAttribute(
"PacketSize",
42 "The number of bytes to write per socket send",
45 MakeUintegerChecker<uint32_t>(1))
46 .AddAttribute(
"ReadingTimeMean",
47 "The mean reading time in seconds",
49 MakeDoubleAccessor(&TrafficGeneratorNgmnFtpMulti::m_readingTimeMean),
50 MakeDoubleChecker<double>())
51 .AddAttribute(
"FileSizeMu",
52 "Mu parameter of lognormal distribution "
53 "for the file size generation",
55 MakeDoubleAccessor(&TrafficGeneratorNgmnFtpMulti::m_fileSizeMu),
56 MakeDoubleChecker<double>())
57 .AddAttribute(
"FileSizeSigma",
58 "Sigma parameter of lognormal distribution "
59 "for the file size generation",
61 MakeDoubleAccessor(&TrafficGeneratorNgmnFtpMulti::m_fileSizeSigma),
62 MakeDoubleChecker<double>())
63 .AddAttribute(
"Remote",
64 "The address of the destination",
68 .AddAttribute(
"Protocol",
69 "The type of protocol to use.",
70 TypeIdValue(TcpSocketFactory::GetTypeId()),
74 "A new packet is created and is sent",
75 MakeTraceSourceAccessor(&TrafficGenerator::m_txTrace),
76 "ns3::TrafficGenerator::TxTracedCallback");
80TrafficGeneratorNgmnFtpMulti::TrafficGeneratorNgmnFtpMulti()
83 NS_LOG_FUNCTION(
this);
86TrafficGeneratorNgmnFtpMulti::~TrafficGeneratorNgmnFtpMulti()
88 NS_LOG_FUNCTION(
this);
92TrafficGeneratorNgmnFtpMulti::StartApplication()
94 NS_LOG_FUNCTION(
this);
99TrafficGeneratorNgmnFtpMulti::PacketBurstSent()
101 NS_LOG_FUNCTION(
this);
102 Time readingTime = GetNextReadingTime();
103 NS_LOG_DEBUG(
"Next file transfer:" << readingTime);
110 m_packetSize = sendSize;
114TrafficGeneratorNgmnFtpMulti::GetNextReadingTime()
116 NS_LOG_FUNCTION(
this);
117 return Seconds(m_readingTime->GetValue());
121TrafficGeneratorNgmnFtpMulti::GenerateNextPacketBurstSize()
123 NS_LOG_FUNCTION(
this);
124 uint32_t fileSize = 0;
127 fileSize = m_fileSize->GetValue();
128 if (fileSize <= m_maxFileSize)
134 NS_LOG_DEBUG(
"Generated file size value is higher than the maximum "
135 "allowed value. Max value: "
136 << m_maxFileSize <<
", generated value:" << fileSize);
140 NS_LOG_DEBUG(
"New file size:" << fileSize);
141 SetPacketBurstSizeInBytes(fileSize);
145TrafficGeneratorNgmnFtpMulti::GetNextPacketSize()
const
147 NS_LOG_FUNCTION(
this);
152TrafficGeneratorNgmnFtpMulti::DoDispose()
154 NS_LOG_FUNCTION(
this);
155 m_readingTime =
nullptr;
156 m_fileSize =
nullptr;
158 TrafficGenerator::DoDispose();
162TrafficGeneratorNgmnFtpMulti::DoInitialize()
164 NS_LOG_FUNCTION(
this);
166 m_readingTime = CreateObject<ExponentialRandomVariable>();
167 m_readingTime->SetAttribute(
"Mean", DoubleValue(m_readingTimeMean));
168 m_fileSize = CreateObject<LogNormalRandomVariable>();
169 m_fileSize->SetAttribute(
"Mu", DoubleValue(m_fileSizeMu));
170 m_fileSize->SetAttribute(
"Sigma", DoubleValue(m_fileSizeSigma));
171 TrafficGenerator::DoInitialize();
177 m_readingTime->SetStream(stream);
178 m_fileSize->SetStream(stream + 1);
void SetRemote(Address remote)
Sets the remote address.
bool SendPacketBurst()
Send another packet burst, which can be e.g., a file, or a video frame.
void SetProtocol(TypeId protocol)
Sets the protocol.
static TypeId GetTypeId()
Get the type ID.
void SetPacketSize(uint32_t packetSize)
Sets the packet size.
int64_t AssignStreams(int64_t stream) override