Loading...
Searching...
No Matches
satellite-frame-symbol-load-probe.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 Bucknell University
4 * Copyright (c) 2014 Magister Solutions
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Authors of original work (application-packet-probe.cc) which this work
20 * derives from:
21 * - L. Felipe Perrone (perrone@bucknell.edu)
22 * - Tiago G. Rodrigues (tgr002@bucknell.edu)
23 * - Mitch Watrous (watrous@u.washington.edu)
24 *
25 * Modified for FrameUtLoadTrace trace source by:
26 * - Budiarto Herman (budiarto.herman@magister.fi)
27 */
28
30
31#include "ns3/callback.h"
32#include "ns3/config.h"
33#include "ns3/log.h"
34#include "ns3/names.h"
35#include "ns3/simulator.h"
36
37#include <string>
38
39NS_LOG_COMPONENT_DEFINE("SatFrameSymbolLoadProbe");
40
41namespace ns3
42{
43
44NS_OBJECT_ENSURE_REGISTERED(SatFrameSymbolLoadProbe);
45
46TypeId
48{
49 static TypeId tid =
50 TypeId("ns3::SatFrameSymbolLoadProbe")
51 .SetParent<Probe>()
52 .AddConstructor<SatFrameSymbolLoadProbe>()
53 .AddTraceSource("Output",
54 "The frame ID and the ratio of allocated symbols that serve as the "
55 "output for this probe",
56 MakeTraceSourceAccessor(&SatFrameSymbolLoadProbe::m_output),
57 "ns3::SatFrameSymbolLoadProbe::FrameSymbolLoadCallback");
58 return tid;
59}
60
62{
63 NS_LOG_FUNCTION(this);
64}
65
67{
68 NS_LOG_FUNCTION(this);
69}
70
71void
72SatFrameSymbolLoadProbe::SetValue(uint32_t frameId, double loadRatio)
73{
74 NS_LOG_FUNCTION(this << frameId << loadRatio);
75 m_output(frameId, loadRatio);
76}
77
78void
79SatFrameSymbolLoadProbe::SetValueByPath(std::string path, uint32_t frameId, double loadRatio)
80{
81 NS_LOG_FUNCTION(path << frameId << loadRatio);
82 Ptr<SatFrameSymbolLoadProbe> probe = Names::Find<SatFrameSymbolLoadProbe>(path);
83 NS_ASSERT_MSG(probe, "Error: Can't find probe for path " << path);
84 probe->SetValue(frameId, loadRatio);
85}
86
87bool
88SatFrameSymbolLoadProbe::ConnectByObject(std::string traceSource, Ptr<Object> obj)
89{
90 NS_LOG_FUNCTION(this << traceSource << obj);
91 NS_LOG_DEBUG("Name of probe (if any) in names database: " << Names::FindPath(obj));
92 bool connected = obj->TraceConnectWithoutContext(
93 traceSource,
94 MakeCallback(&ns3::SatFrameSymbolLoadProbe::TraceSink, this));
95 return connected;
96}
97
98void
100{
101 NS_LOG_FUNCTION(this << path);
102 NS_LOG_DEBUG("Name of probe to search for in config database: " << path);
103 Config::ConnectWithoutContext(path,
104 MakeCallback(&ns3::SatFrameSymbolLoadProbe::TraceSink, this));
105}
106
107void
108SatFrameSymbolLoadProbe::TraceSink(uint32_t frameId, double loadRatio)
109{
110 NS_LOG_FUNCTION(this << frameId << loadRatio);
111 if (IsEnabled())
112 {
113 m_output(frameId, loadRatio);
114 }
115}
116
117} // namespace ns3
Probe to translate from a FrameLoadTrace trace source.
void TraceSink(uint32_t frameId, double loadRatio)
Method to connect to an underlying ns3::TraceSource with arguments of type double and const Address&.
virtual bool ConnectByObject(std::string traceSource, Ptr< Object > obj)
connect to a trace source attribute provided by a given object
static TypeId GetTypeId()
Get the type ID.
virtual void ConnectByPath(std::string path)
connect to a trace source provided by a config path
virtual ~SatFrameSymbolLoadProbe()
Destructor for SatFrameSymbolLoadProbe.
void SetValue(uint32_t frameId, double loadRatio)
Set a probe value.
TracedCallback< uint32_t, double > m_output
Output trace, the frame ID and ratio of allocated symbols.
static void SetValueByPath(std::string path, uint32_t frameId, double loadRatio)
Set a probe value by its name in the Config system.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.