5G-LENA nr-v4.0
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
traffic-generator-ftp-single.cc
1// Copyright (c) 2010 Georgia Institute of Technology
2// Copyright (c) 2022 CTTC
3// Copyright (c) 2023 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4//
5// SPDX-License-Identifier: GPL-2.0-only
6
7#include "traffic-generator-ftp-single.h"
8
9#include "ns3/address.h"
10#include "ns3/log.h"
11#include "ns3/node.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"
21
22namespace ns3
23{
24
25NS_LOG_COMPONENT_DEFINE("TrafficGeneratorFtpSingle");
26NS_OBJECT_ENSURE_REGISTERED(TrafficGeneratorFtpSingle);
27
28TypeId
30{
31 static TypeId tid =
32 TypeId("ns3::TrafficGeneratorFtpSingle")
33 .SetParent<TrafficGenerator>()
34 .SetGroupName("Applications")
35 .AddConstructor<TrafficGeneratorFtpSingle>()
36 .AddAttribute("FileSize",
37 "The total number of bytes to send. The value zero means "
38 "that there is no limit.",
39 UintegerValue(0),
40 MakeUintegerAccessor(&TrafficGeneratorFtpSingle::SetFileSize),
41 MakeUintegerChecker<uint32_t>())
42 .AddAttribute("PacketSize",
43 "The number of bytes to write per socket send",
44 UintegerValue(512),
45 MakeUintegerAccessor(&TrafficGeneratorFtpSingle::SetPacketSize),
46 MakeUintegerChecker<uint32_t>(1))
47 .AddAttribute("Remote",
48 "The address of the destination",
49 AddressValue(),
50 MakeAddressAccessor(&TrafficGenerator::SetRemote),
51 MakeAddressChecker())
52 .AddAttribute("Protocol",
53 "The type of protocol to use.",
54 TypeIdValue(TcpSocketFactory::GetTypeId()),
55 MakeTypeIdAccessor(&TrafficGenerator::SetProtocol),
56 MakeTypeIdChecker())
57 .AddTraceSource("Tx",
58 "A new packet is created and is sent",
59 MakeTraceSourceAccessor(&TrafficGenerator::m_txTrace),
60 "ns3::TrafficGenerator::TxTracedCallback");
61 return tid;
62}
63
64TrafficGeneratorFtpSingle::TrafficGeneratorFtpSingle()
66{
67 NS_LOG_FUNCTION(this);
68}
69
70TrafficGeneratorFtpSingle::~TrafficGeneratorFtpSingle()
71{
72 NS_LOG_FUNCTION(this);
73}
74
75void
77{
78 m_packetSize = sendSize;
79}
80
81void
83{
84 NS_LOG_FUNCTION(this << fileSize);
85 m_fileSize = fileSize;
86}
87
88void
89TrafficGeneratorFtpSingle::GenerateNextPacketBurstSize()
90{
91 NS_LOG_FUNCTION(this);
92 SetPacketBurstSizeInBytes(m_fileSize);
93}
94
95uint32_t
96TrafficGeneratorFtpSingle::GetNextPacketSize() const
97{
98 NS_LOG_FUNCTION(this);
99 return m_packetSize;
100}
101
102void
103TrafficGeneratorFtpSingle::DoDispose()
104{
105 NS_LOG_FUNCTION(this);
106 // chain up
107 TrafficGenerator::DoDispose();
108}
109
110void
111TrafficGeneratorFtpSingle::DoInitialize()
112{
113 NS_LOG_FUNCTION(this);
114 // chain up
115 TrafficGenerator::DoInitialize();
116}
117
118int64_t
120{
121 return 0;
122}
123
124} // Namespace ns3
void SetFileSize(uint32_t fileSize)
Set the file size to try to transfer.
int64_t AssignStreams(int64_t stream) override
void SetPacketSize(uint32_t packetSize)
Sets the packet size.
static TypeId GetTypeId()
Get the type ID.
void SetRemote(Address remote)
Sets the remote address.
void SetProtocol(TypeId protocol)
Sets the protocol.