satellite-on-off-application.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Magister Solutions Ltd
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Sami Rantanen <sami.rantanen@magister.fi>
19  */
20 
22 
23 #include <ns3/boolean.h>
24 #include <ns3/log.h>
25 #include <ns3/packet.h>
26 #include <ns3/simulator.h>
27 #include <ns3/traced-callback.h>
28 #include <ns3/traffic-time-tag.h>
29 
30 NS_LOG_COMPONENT_DEFINE("SatOnOffApplication");
31 
32 namespace ns3
33 {
34 
35 NS_OBJECT_ENSURE_REGISTERED(SatOnOffApplication);
36 
37 TypeId
39 {
40  static TypeId tid =
41  TypeId("ns3::SatOnOffApplication")
42  .SetParent<OnOffApplication>()
43  .AddConstructor<SatOnOffApplication>()
44  .AddAttribute("EnableStatisticsTags",
45  "If true, some tags will be added to each transmitted packet to assist "
46  "with statistics computation",
47  BooleanValue(false),
48  MakeBooleanAccessor(&SatOnOffApplication::EnableStatisticTags,
50  MakeBooleanChecker());
51  return tid;
52 }
53 
55  : m_isStatisticsTagsEnabled(false),
56  m_isConnectedWithTraceSource(false)
57 {
58  NS_LOG_FUNCTION(this);
59 }
60 
62 {
63  NS_LOG_FUNCTION(this);
64 }
65 
66 void
68 {
69  NS_LOG_FUNCTION(this << enable);
71 
73  {
74  /*
75  * Ensure that we don't connect to the same trace source two times.
76  * Otherwise, the same tag type will be added twice, resulting in a
77  * runtime error.
78  */
80  {
81  TraceConnectWithoutContext("Tx",
82  MakeCallback(&SatOnOffApplication::SendPacketTrace, this));
84  }
85  }
86  else
87  {
88  TraceDisconnectWithoutContext("Tx",
89  MakeCallback(&SatOnOffApplication::SendPacketTrace, this));
91  }
92 }
93 
94 bool
96 {
98 }
99 
100 void
101 SatOnOffApplication::SendPacketTrace(Ptr<const Packet> packet)
102 {
103  // Add a TrafficTimeTag tag for packet delay computation at the receiver end.
104  packet->AddPacketTag(TrafficTimeTag(Simulator::Now()));
105 }
106 
107 } // Namespace ns3
void SendPacketTrace(Ptr< const Packet > packet)
Trace callback for on-off application Tx.
void EnableStatisticTags(bool enableStatus)
Enable or disable statistic tags.
bool m_isStatisticsTagsEnabled
EnableStatisticsTags attribute.
SatOnOffApplication()
Constructor for Satellite specific on-off application.
bool IsStatisticTagsEnabled() const
Get enable status of statistic tags.
virtual ~SatOnOffApplication()
Destructor Satellite specific on-off application.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.