A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
udp-trace-client.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007,2008, 2009 INRIA, UDcast
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
7
* <amine.ismail@udcast.com>
8
*/
9
10
#ifndef UDP_TRACE_CLIENT_H
11
#define UDP_TRACE_CLIENT_H
12
13
#include "ns3/application.h"
14
#include "ns3/event-id.h"
15
#include "ns3/ipv4-address.h"
16
#include "ns3/ptr.h"
17
18
#include <vector>
19
20
namespace
ns3
21
{
22
23
class
Socket;
24
class
Packet;
25
26
/**
27
* \ingroup udpclientserver
28
*
29
* \brief A trace based streamer
30
*
31
* Sends UDP packets based on a trace file of a MPEG4 stream.
32
* Trace files can be downloaded from:
33
* https://web.archive.org/web/20210113211420/http://trace.eas.asu.edu/mpeg4/index.html
34
* (the 2 first lines of the file should be removed) A valid trace file is a file with 4 columns:
35
* \li -1- the first one represents the frame index
36
* \li -2- the second one indicates the type of the frame: I, P or B
37
* \li -3- the third one indicates the time on which the frame was generated by the encoder
38
* (integer, milliseconds) \li -4- the fourth one indicates the frame size in byte
39
*
40
* Additional trace files can be generated from MPEG4 files using the tool
41
* available in https://pypi.org/project/trace-extractor/
42
*
43
* If no valid MPEG4 trace file is provided to the application the trace from
44
* g_defaultEntries array will be loaded.
45
*
46
* Also note that:
47
* \li -1- consecutive 'B' frames are sent together,
48
* \li -2- any trace file is (by default) read again once finished (loop).
49
*
50
* The latter behavior can be changed through the "TraceLoop" attribute.
51
*/
52
class
UdpTraceClient
:
public
Application
53
{
54
public
:
55
/**
56
* \brief Get the type ID.
57
* \return the object TypeId
58
*/
59
static
TypeId
GetTypeId
();
60
61
UdpTraceClient
();
62
63
/**
64
* \brief Creates a traceBasedStreamer application
65
* \param ip the destination ip address to which the stream will be sent
66
* \param port the destination udp port to which the stream will be sent
67
* \param traceFile a path to an MPEG4 trace file formatted as follows:
68
* FrameNo Frametype Time[ms] Length [byte]
69
* FrameNo Frametype Time[ms] Length [byte]
70
* ...
71
*
72
*
73
*/
74
UdpTraceClient
(
Ipv4Address
ip, uint16_t
port
,
char
* traceFile);
75
~UdpTraceClient
()
override
;
76
77
/**
78
* \brief set the remote address and port
79
* \param ip remote IP address
80
* \param port remote port
81
*/
82
void
SetRemote
(
Address
ip, uint16_t
port
);
83
/**
84
* \brief set the remote address
85
* \param addr remote address
86
*/
87
void
SetRemote
(
Address
addr);
88
89
/**
90
* \brief Set the trace file to be used by the application
91
* \param filename a path to an MPEG4 trace file formatted as follows:
92
* Frame No Frametype Time[ms] Length [byte]
93
* Frame No Frametype Time[ms] Length [byte]
94
* ...
95
*/
96
void
SetTraceFile
(std::string filename);
97
98
/**
99
* \brief Return the maximum packet size
100
* \return the maximum packet size
101
*/
102
uint16_t
GetMaxPacketSize
();
103
104
/**
105
* \brief Set the maximum packet size
106
* \param maxPacketSize The maximum packet size
107
*/
108
void
SetMaxPacketSize
(uint16_t maxPacketSize);
109
110
/**
111
* \brief Set the trace loop flag
112
* \param traceLoop true if the trace should be re-used
113
*/
114
void
SetTraceLoop
(
bool
traceLoop);
115
116
private
:
117
void
StartApplication
()
override
;
118
void
StopApplication
()
override
;
119
120
/**
121
* \brief Load a trace file
122
* \param filename the trace file path
123
*/
124
void
LoadTrace
(std::string filename);
125
/**
126
* \brief Load the default trace
127
*/
128
void
LoadDefaultTrace
();
129
130
/**
131
* \brief Send a packet
132
*/
133
void
Send
();
134
/**
135
* \brief Send a packet of a given size
136
* \param size the packet size
137
*/
138
void
SendPacket
(
uint32_t
size);
139
140
/**
141
* \brief Entry to send.
142
*
143
* Each entry represents an MPEG frame
144
*/
145
struct
TraceEntry
146
{
147
uint32_t
timeToSend
;
//!< Time to send the frame
148
uint32_t
packetSize
;
//!< Size of the frame
149
char
frameType
;
//!< Frame type (I, P or B)
150
};
151
152
uint32_t
m_sent
;
//!< Counter for sent packets
153
Ptr<Socket>
m_socket
;
//!< Socket
154
Address
m_peerAddress
;
//!< Remote peer address
155
uint16_t
m_peerPort
;
//!< Remote peer port
156
uint8_t
m_tos
;
//!< The packets Type of Service
157
EventId
m_sendEvent
;
//!< Event to send the next packet
158
159
std::vector<TraceEntry>
m_entries
;
//!< Entries in the trace to send
160
uint32_t
m_currentEntry
;
//!< Current entry index
161
static
TraceEntry
g_defaultEntries
[];
//!< Default trace to send
162
uint16_t
m_maxPacketSize
;
//!< Maximum packet size to send (including the SeqTsHeader)
163
bool
m_traceLoop
;
//!< Loop through the trace file
164
};
165
166
}
// namespace ns3
167
168
#endif
/* UDP_TRACE_CLIENT_H */
ns3::Address
a polymophic address class
Definition
address.h:90
ns3::Application
The base class for all ns3 applications.
Definition
application.h:51
ns3::EventId
An identifier for simulation events.
Definition
event-id.h:45
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::UdpTraceClient
A trace based streamer.
Definition
udp-trace-client.h:53
ns3::UdpTraceClient::m_sendEvent
EventId m_sendEvent
Event to send the next packet.
Definition
udp-trace-client.h:157
ns3::UdpTraceClient::StopApplication
void StopApplication() override
Application specific shutdown code.
Definition
udp-trace-client.cc:297
ns3::UdpTraceClient::m_tos
uint8_t m_tos
The packets Type of Service.
Definition
udp-trace-client.h:156
ns3::UdpTraceClient::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
udp-trace-client.cc:54
ns3::UdpTraceClient::Send
void Send()
Send a packet.
Definition
udp-trace-client.cc:348
ns3::UdpTraceClient::m_peerPort
uint16_t m_peerPort
Remote peer port.
Definition
udp-trace-client.h:155
ns3::UdpTraceClient::SetTraceLoop
void SetTraceLoop(bool traceLoop)
Set the trace loop flag.
Definition
udp-trace-client.cc:384
ns3::UdpTraceClient::m_sent
uint32_t m_sent
Counter for sent packets.
Definition
udp-trace-client.h:152
ns3::UdpTraceClient::SetRemote
void SetRemote(Address ip, uint16_t port)
set the remote address and port
Definition
udp-trace-client.cc:129
ns3::UdpTraceClient::m_peerAddress
Address m_peerAddress
Remote peer address.
Definition
udp-trace-client.h:154
ns3::UdpTraceClient::m_entries
std::vector< TraceEntry > m_entries
Entries in the trace to send.
Definition
udp-trace-client.h:159
ns3::UdpTraceClient::m_currentEntry
uint32_t m_currentEntry
Current entry index.
Definition
udp-trace-client.h:160
ns3::UdpTraceClient::SetTraceFile
void SetTraceFile(std::string filename)
Set the trace file to be used by the application.
Definition
udp-trace-client.cc:146
ns3::UdpTraceClient::LoadTrace
void LoadTrace(std::string filename)
Load a trace file.
Definition
udp-trace-client.cc:174
ns3::UdpTraceClient::SetMaxPacketSize
void SetMaxPacketSize(uint16_t maxPacketSize)
Set the maximum packet size.
Definition
udp-trace-client.cc:160
ns3::UdpTraceClient::StartApplication
void StartApplication() override
Application specific startup code.
Definition
udp-trace-client.cc:241
ns3::UdpTraceClient::UdpTraceClient
UdpTraceClient()
Definition
udp-trace-client.cc:97
ns3::UdpTraceClient::SendPacket
void SendPacket(uint32_t size)
Send a packet of a given size.
Definition
udp-trace-client.cc:304
ns3::UdpTraceClient::m_traceLoop
bool m_traceLoop
Loop through the trace file.
Definition
udp-trace-client.h:163
ns3::UdpTraceClient::m_maxPacketSize
uint16_t m_maxPacketSize
Maximum packet size to send (including the SeqTsHeader)
Definition
udp-trace-client.h:162
ns3::UdpTraceClient::~UdpTraceClient
~UdpTraceClient() override
Definition
udp-trace-client.cc:122
ns3::UdpTraceClient::g_defaultEntries
static TraceEntry g_defaultEntries[]
Default trace to send.
Definition
udp-trace-client.h:161
ns3::UdpTraceClient::GetMaxPacketSize
uint16_t GetMaxPacketSize()
Return the maximum packet size.
Definition
udp-trace-client.cc:167
ns3::UdpTraceClient::LoadDefaultTrace
void LoadDefaultTrace()
Load the default trace.
Definition
udp-trace-client.cc:218
ns3::UdpTraceClient::m_socket
Ptr< Socket > m_socket
Socket.
Definition
udp-trace-client.h:153
uint32_t
port
uint16_t port
Definition
dsdv-manet.cc:33
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::UdpTraceClient::TraceEntry
Entry to send.
Definition
udp-trace-client.h:146
ns3::UdpTraceClient::TraceEntry::timeToSend
uint32_t timeToSend
Time to send the frame.
Definition
udp-trace-client.h:147
ns3::UdpTraceClient::TraceEntry::packetSize
uint32_t packetSize
Size of the frame.
Definition
udp-trace-client.h:148
ns3::UdpTraceClient::TraceEntry::frameType
char frameType
Frame type (I, P or B)
Definition
udp-trace-client.h:149
src
applications
model
udp-trace-client.h
Generated on Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0