A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mac-stats-calculator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Jaume Nin <jnin@cttc.es>
7 * Modified by: Danilo Abrignani <danilo.abrignani@unibo.it> (Carrier Aggregation - GSoC 2015)
8 * Biljana Bojovic <biljana.bojovic@cttc.es> (Carrier Aggregation)
9 */
10
11#ifndef MAC_STATS_CALCULATOR_H_
12#define MAC_STATS_CALCULATOR_H_
13
15
16#include "ns3/lte-enb-mac.h"
17#include "ns3/nstime.h"
18#include "ns3/uinteger.h"
19
20#include <fstream>
21#include <string>
22
23namespace ns3
24{
25
26/**
27 * @ingroup lte
28 *
29 * Takes care of storing the information generated at MAC layer. Metrics saved are:
30 * - Timestamp (in seconds)
31 * - Frame index
32 * - Subframe index
33 * - C-RNTI
34 * - MCS for transport block 1
35 * - Size of transport block 1
36 * - MCS for transport block 2 (0 if not used)
37 * - Size of transport block 2 (0 if not used)
38 */
40{
41 public:
42 /**
43 * Constructor
44 */
46
47 /**
48 * Destructor
49 */
50 ~MacStatsCalculator() override;
51
52 // Inherited from ns3::Object
53 /**
54 * Register this type.
55 * @return The object TypeId.
56 */
57 static TypeId GetTypeId();
58
59 /**
60 * Set the name of the file where the uplink statistics will be stored.
61 *
62 * @param outputFilename string with the name of the file
63 */
64 void SetUlOutputFilename(std::string outputFilename);
65
66 /**
67 * Get the name of the file where the uplink statistics will be stored.
68 * @return the name of the file where the uplink statistics will be stored
69 */
70 std::string GetUlOutputFilename();
71
72 /**
73 * Set the name of the file where the downlink statistics will be stored.
74 *
75 * @param outputFilename string with the name of the file
76 */
77 void SetDlOutputFilename(std::string outputFilename);
78
79 /**
80 * Get the name of the file where the downlink statistics will be stored.
81 * @return the name of the file where the downlink statistics will be stored
82 */
83 std::string GetDlOutputFilename();
84
85 /**
86 * Notifies the stats calculator that an downlink scheduling has occurred.
87 * @param cellId Cell ID of the attached Enb
88 * @param imsi IMSI of the scheduled UE
89 * @param dlSchedulingCallbackInfo the structure that contains downlink scheduling fields:
90 * frameNo Frame number
91 * subframeNo Subframe number
92 * rnti C-RNTI scheduled
93 * mcsTb1 MCS for transport block 1
94 * sizeTb1 Size of transport block 1
95 * mcsTb2 MCS for transport block 2 (0 if not used)
96 * sizeTb2 Size of transport block 2 (0 if not used)
97 * componentCarrierId component carrier ID
98 */
99
100 void DlScheduling(uint16_t cellId,
101 uint64_t imsi,
102 DlSchedulingCallbackInfo dlSchedulingCallbackInfo);
103
104 /**
105 * Notifies the stats calculator that an uplink scheduling has occurred.
106 * @param cellId Cell ID of the attached Enb
107 * @param imsi IMSI of the scheduled UE
108 * @param frameNo Frame number
109 * @param subframeNo Subframe number
110 * @param rnti C-RNTI scheduled
111 * @param mcsTb MCS for transport block
112 * @param sizeTb Size of transport block
113 * @param componentCarrierId component carrier ID
114 */
115 void UlScheduling(uint16_t cellId,
116 uint64_t imsi,
117 uint32_t frameNo,
118 uint32_t subframeNo,
119 uint16_t rnti,
120 uint8_t mcsTb,
121 uint16_t sizeTb,
122 uint8_t componentCarrierId);
123
124 /**
125 * Trace sink for the ns3::LteEnbMac::DlScheduling trace source
126 *
127 * @param macStats
128 * @param path
129 * @param dlSchedulingCallbackInfo DlSchedulingCallbackInfo structure containing all downlink
130 * information that is generated what DlScheduling traces is fired
131 */
133 std::string path,
134 DlSchedulingCallbackInfo dlSchedulingCallbackInfo);
135
136 /**
137 * Trace sink for the ns3::LteEnbMac::UlScheduling trace source
138 *
139 * @param macStats
140 * @param path
141 * @param frameNo
142 * @param subframeNo
143 * @param rnti
144 * @param mcs
145 * @param size
146 * @param componentCarrierId
147 */
149 std::string path,
150 uint32_t frameNo,
151 uint32_t subframeNo,
152 uint16_t rnti,
153 uint8_t mcs,
154 uint16_t size,
155 uint8_t componentCarrierId);
156
157 private:
158 /**
159 * When writing DL MAC statistics first time to file,
160 * columns description is added. Then next lines are
161 * appended to file. This value is true if output
162 * files have not been opened yet
163 */
165
166 /**
167 * When writing UL MAC statistics first time to file,
168 * columns description is added. Then next lines are
169 * appended to file. This value is true if output
170 * files have not been opened yet
171 */
173
174 /**
175 * Downlink output trace file
176 */
177 std::ofstream m_dlOutFile;
178
179 /**
180 * Uplink output trace file
181 */
182 std::ofstream m_ulOutFile;
183};
184
185} // namespace ns3
186
187#endif /* MAC_STATS_CALCULATOR_H_ */
Base class for ***StatsCalculator classes.
Takes care of storing the information generated at MAC layer.
~MacStatsCalculator() override
Destructor.
static TypeId GetTypeId()
Register this type.
std::ofstream m_dlOutFile
Downlink output trace file.
void UlScheduling(uint16_t cellId, uint64_t imsi, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcsTb, uint16_t sizeTb, uint8_t componentCarrierId)
Notifies the stats calculator that an uplink scheduling has occurred.
bool m_dlFirstWrite
When writing DL MAC statistics first time to file, columns description is added.
static void DlSchedulingCallback(Ptr< MacStatsCalculator > macStats, std::string path, DlSchedulingCallbackInfo dlSchedulingCallbackInfo)
Trace sink for the ns3::LteEnbMac::DlScheduling trace source.
void SetDlOutputFilename(std::string outputFilename)
Set the name of the file where the downlink statistics will be stored.
std::ofstream m_ulOutFile
Uplink output trace file.
std::string GetUlOutputFilename()
Get the name of the file where the uplink statistics will be stored.
static void UlSchedulingCallback(Ptr< MacStatsCalculator > macStats, std::string path, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t size, uint8_t componentCarrierId)
Trace sink for the ns3::LteEnbMac::UlScheduling trace source.
void DlScheduling(uint16_t cellId, uint64_t imsi, DlSchedulingCallbackInfo dlSchedulingCallbackInfo)
Notifies the stats calculator that an downlink scheduling has occurred.
void SetUlOutputFilename(std::string outputFilename)
Set the name of the file where the uplink statistics will be stored.
bool m_ulFirstWrite
When writing UL MAC statistics first time to file, columns description is added.
std::string GetDlOutputFilename()
Get the name of the file where the downlink statistics will be stored.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.
DlSchedulingCallbackInfo structure.
Definition lte-common.h:226