author | Peter D. Barnes, Jr. <barnes26@llnl.gov> |
Fri, 03 Oct 2014 02:24:42 -0700 | |
changeset 11085 | 6e4d08656d7c |
parent 8997 | 9222fc5291ca |
permissions | -rw-r--r-- |
3570 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* This program is free software; you can redistribute it and/or modify |
|
4 |
* it under the terms of the GNU General Public License version 2 as |
|
5 |
* published by the Free Software Foundation; |
|
6 |
* |
|
7 |
* This program is distributed in the hope that it will be useful, |
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
10 |
* GNU General Public License for more details. |
|
11 |
* |
|
12 |
* You should have received a copy of the GNU General Public License |
|
13 |
* along with this program; if not, write to the Free Software |
|
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
15 |
* |
|
16 |
* Authors: Joe Kopena <tjkopena@cs.drexel.edu> |
|
17 |
* |
|
18 |
* These applications are used in the WiFi Distance Test experiment, |
|
19 |
* described and implemented in test02.cc. That file should be in the |
|
20 |
* same place as this file. The applications have two very simple |
|
21 |
* jobs, they just generate and receive packets. We could use the |
|
22 |
* standard Application classes included in the NS-3 distribution. |
|
23 |
* These have been written just to change the behavior a little, and |
|
24 |
* provide more examples. |
|
25 |
* |
|
26 |
*/ |
|
27 |
||
28 |
#include <ostream> |
|
29 |
||
30 |
#include "ns3/core-module.h" |
|
6823
a27f86fb4e55
Merge node and common modules into new network module
Tom Henderson <tomh@tomh.org>
parents:
6821
diff
changeset
|
31 |
#include "ns3/network-module.h" |
6834
036f9a0b9899
Rename internet-stack to internet, and organize module
Tom Henderson <tomh@tomh.org>
parents:
6823
diff
changeset
|
32 |
#include "ns3/internet-module.h" |
3570 | 33 |
|
34 |
#include "ns3/stats-module.h" |
|
35 |
||
36 |
#include "wifi-example-apps.h" |
|
37 |
||
38 |
using namespace ns3; |
|
39 |
||
4487
0d67f380c764
Backed out changeset b7faa7398d1e
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4483
diff
changeset
|
40 |
NS_LOG_COMPONENT_DEFINE ("WiFiDistanceApps"); |
3570 | 41 |
|
42 |
TypeId |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
43 |
Sender::GetTypeId (void) |
3570 | 44 |
{ |
45 |
static TypeId tid = TypeId ("Sender") |
|
46 |
.SetParent<Application> () |
|
47 |
.AddConstructor<Sender> () |
|
4487
0d67f380c764
Backed out changeset b7faa7398d1e
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4483
diff
changeset
|
48 |
.AddAttribute ("PacketSize", "The size of packets transmitted.", |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
49 |
UintegerValue (64), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
50 |
MakeUintegerAccessor (&Sender::m_pktSize), |
3570 | 51 |
MakeUintegerChecker<uint32_t>(1)) |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
52 |
.AddAttribute ("Destination", "Target host address.", |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
53 |
Ipv4AddressValue ("255.255.255.255"), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
54 |
MakeIpv4AddressAccessor (&Sender::m_destAddr), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
55 |
MakeIpv4AddressChecker ()) |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
56 |
.AddAttribute ("Port", "Destination app port.", |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
57 |
UintegerValue (1603), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
58 |
MakeUintegerAccessor (&Sender::m_destPort), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
59 |
MakeUintegerChecker<uint32_t>()) |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
60 |
.AddAttribute ("NumPackets", "Total number of packets to send.", |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
61 |
UintegerValue (30), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
62 |
MakeUintegerAccessor (&Sender::m_numPkts), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
63 |
MakeUintegerChecker<uint32_t>(1)) |
4487
0d67f380c764
Backed out changeset b7faa7398d1e
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4483
diff
changeset
|
64 |
.AddAttribute ("Interval", "Delay between transmissions.", |
8997
9222fc5291ca
Replace more instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7733
diff
changeset
|
65 |
StringValue ("ns3::ConstantRandomVariable[Constant=0.5]"), |
9222fc5291ca
Replace more instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7733
diff
changeset
|
66 |
MakePointerAccessor (&Sender::m_interval), |
9222fc5291ca
Replace more instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7733
diff
changeset
|
67 |
MakePointerChecker <RandomVariableStream>()) |
3570 | 68 |
.AddTraceSource ("Tx", "A new packet is created and is sent", |
11085
6e4d08656d7c
TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
8997
diff
changeset
|
69 |
MakeTraceSourceAccessor (&Sender::m_txTrace), |
6e4d08656d7c
TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
8997
diff
changeset
|
70 |
"ns3::Packet::TracedCallback") |
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
71 |
; |
3570 | 72 |
return tid; |
73 |
} |
|
74 |
||
75 |
||
76 |
Sender::Sender() |
|
77 |
{ |
|
78 |
NS_LOG_FUNCTION_NOARGS (); |
|
8997
9222fc5291ca
Replace more instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7733
diff
changeset
|
79 |
m_interval = CreateObject<ConstantRandomVariable> (); |
3570 | 80 |
m_socket = 0; |
81 |
} |
|
82 |
||
83 |
Sender::~Sender() |
|
84 |
{ |
|
85 |
NS_LOG_FUNCTION_NOARGS (); |
|
86 |
} |
|
87 |
||
88 |
void |
|
89 |
Sender::DoDispose (void) |
|
90 |
{ |
|
91 |
NS_LOG_FUNCTION_NOARGS (); |
|
92 |
||
93 |
m_socket = 0; |
|
94 |
// chain up |
|
95 |
Application::DoDispose (); |
|
96 |
} |
|
97 |
||
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
98 |
void Sender::StartApplication () |
3570 | 99 |
{ |
100 |
NS_LOG_FUNCTION_NOARGS (); |
|
101 |
||
102 |
if (m_socket == 0) { |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
103 |
Ptr<SocketFactory> socketFactory = GetNode ()->GetObject<SocketFactory> |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
104 |
(UdpSocketFactory::GetTypeId ()); |
3570 | 105 |
m_socket = socketFactory->CreateSocket (); |
106 |
m_socket->Bind (); |
|
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
107 |
} |
4487
0d67f380c764
Backed out changeset b7faa7398d1e
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4483
diff
changeset
|
108 |
|
3570 | 109 |
m_count = 0; |
110 |
||
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
111 |
Simulator::Cancel (m_sendEvent); |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
112 |
m_sendEvent = Simulator::ScheduleNow (&Sender::SendPacket, this); |
3570 | 113 |
|
114 |
// end Sender::StartApplication |
|
115 |
} |
|
116 |
||
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
117 |
void Sender::StopApplication () |
3570 | 118 |
{ |
119 |
NS_LOG_FUNCTION_NOARGS (); |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
120 |
Simulator::Cancel (m_sendEvent); |
3570 | 121 |
// end Sender::StopApplication |
122 |
} |
|
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
123 |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
124 |
void Sender::SendPacket () |
3570 | 125 |
{ |
126 |
// NS_LOG_FUNCTION_NOARGS (); |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
127 |
NS_LOG_INFO ("Sending packet at " << Simulator::Now () << " to " << |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
128 |
m_destAddr); |
3570 | 129 |
|
130 |
Ptr<Packet> packet = Create<Packet>(m_pktSize); |
|
131 |
||
132 |
TimestampTag timestamp; |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
133 |
timestamp.SetTimestamp (Simulator::Now ()); |
4502 | 134 |
packet->AddByteTag (timestamp); |
3570 | 135 |
|
136 |
// Could connect the socket since the address never changes; using SendTo |
|
137 |
// here simply because all of the standard apps do not. |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
138 |
m_socket->SendTo (packet, 0, InetSocketAddress (m_destAddr, m_destPort)); |
3570 | 139 |
|
140 |
// Report the event to the trace. |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
141 |
m_txTrace (packet); |
3570 | 142 |
|
4487
0d67f380c764
Backed out changeset b7faa7398d1e
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4483
diff
changeset
|
143 |
if (++m_count < m_numPkts) { |
8997
9222fc5291ca
Replace more instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
7733
diff
changeset
|
144 |
m_sendEvent = Simulator::Schedule (Seconds (m_interval->GetValue ()), |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
145 |
&Sender::SendPacket, this); |
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
146 |
} |
4487
0d67f380c764
Backed out changeset b7faa7398d1e
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4483
diff
changeset
|
147 |
|
3570 | 148 |
// end Sender::SendPacket |
149 |
} |
|
150 |
||
151 |
||
152 |
||
153 |
||
154 |
//---------------------------------------------------------------------- |
|
155 |
//-- Receiver |
|
156 |
//------------------------------------------------------ |
|
157 |
TypeId |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
158 |
Receiver::GetTypeId (void) |
3570 | 159 |
{ |
160 |
static TypeId tid = TypeId ("Receiver") |
|
161 |
.SetParent<Application> () |
|
162 |
.AddConstructor<Receiver> () |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
163 |
.AddAttribute ("Port", "Listening port.", |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
164 |
UintegerValue (1603), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
165 |
MakeUintegerAccessor (&Receiver::m_port), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
166 |
MakeUintegerChecker<uint32_t>()) |
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
167 |
; |
3570 | 168 |
return tid; |
169 |
} |
|
170 |
||
171 |
Receiver::Receiver() : |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
172 |
m_calc (0), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
173 |
m_delay (0) |
3570 | 174 |
{ |
175 |
NS_LOG_FUNCTION_NOARGS (); |
|
176 |
m_socket = 0; |
|
177 |
} |
|
178 |
||
179 |
Receiver::~Receiver() |
|
180 |
{ |
|
181 |
NS_LOG_FUNCTION_NOARGS (); |
|
182 |
} |
|
183 |
||
184 |
void |
|
185 |
Receiver::DoDispose (void) |
|
186 |
{ |
|
187 |
NS_LOG_FUNCTION_NOARGS (); |
|
188 |
||
189 |
m_socket = 0; |
|
190 |
// chain up |
|
191 |
Application::DoDispose (); |
|
192 |
} |
|
193 |
||
194 |
void |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
195 |
Receiver::StartApplication () |
3570 | 196 |
{ |
197 |
NS_LOG_FUNCTION_NOARGS (); |
|
198 |
||
199 |
if (m_socket == 0) { |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
200 |
Ptr<SocketFactory> socketFactory = GetNode ()->GetObject<SocketFactory> |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
201 |
(UdpSocketFactory::GetTypeId ()); |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
202 |
m_socket = socketFactory->CreateSocket (); |
3570 | 203 |
InetSocketAddress local = |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
204 |
InetSocketAddress (Ipv4Address::GetAny (), m_port); |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
205 |
m_socket->Bind (local); |
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
206 |
} |
3570 | 207 |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
208 |
m_socket->SetRecvCallback (MakeCallback (&Receiver::Receive, this)); |
3570 | 209 |
|
210 |
// end Receiver::StartApplication |
|
211 |
} |
|
212 |
||
213 |
void |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
214 |
Receiver::StopApplication () |
3570 | 215 |
{ |
216 |
NS_LOG_FUNCTION_NOARGS (); |
|
217 |
||
218 |
if (m_socket != 0) { |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
219 |
m_socket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ()); |
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
220 |
} |
3570 | 221 |
|
222 |
// end Receiver::StopApplication |
|
223 |
} |
|
224 |
||
225 |
void |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
226 |
Receiver::SetCounter (Ptr<CounterCalculator<> > calc) |
3570 | 227 |
{ |
228 |
m_calc = calc; |
|
229 |
// end Receiver::SetCounter |
|
230 |
} |
|
231 |
void |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
232 |
Receiver::SetDelayTracker (Ptr<TimeMinMaxAvgTotalCalculator> delay) |
3570 | 233 |
{ |
234 |
m_delay = delay; |
|
235 |
// end Receiver::SetDelayTracker |
|
236 |
} |
|
237 |
||
238 |
void |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
239 |
Receiver::Receive (Ptr<Socket> socket) |
3570 | 240 |
{ |
241 |
// NS_LOG_FUNCTION (this << socket << packet << from); |
|
242 |
||
243 |
Ptr<Packet> packet; |
|
244 |
Address from; |
|
7733
abd63101a73a
Add parenthesis in while (packet = socket->Recv ()) to make clang++ (LLVM) happy
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
7256
diff
changeset
|
245 |
while ((packet = socket->RecvFrom (from))) { |
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
246 |
if (InetSocketAddress::IsMatchingType (from)) { |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
247 |
NS_LOG_INFO ("Received " << packet->GetSize () << " bytes from " << |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
248 |
InetSocketAddress::ConvertFrom (from).GetIpv4 ()); |
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
249 |
} |
3570 | 250 |
|
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
251 |
TimestampTag timestamp; |
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
252 |
// Should never not be found since the sender is adding it, but |
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
253 |
// you never know. |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
254 |
if (packet->FindFirstMatchingByteTag (timestamp)) { |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
255 |
Time tx = timestamp.GetTimestamp (); |
4487
0d67f380c764
Backed out changeset b7faa7398d1e
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4483
diff
changeset
|
256 |
|
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
257 |
if (m_delay != 0) { |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
258 |
m_delay->Update (Simulator::Now () - tx); |
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
259 |
} |
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
260 |
} |
4487
0d67f380c764
Backed out changeset b7faa7398d1e
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4483
diff
changeset
|
261 |
|
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
262 |
if (m_calc != 0) { |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
263 |
m_calc->Update (); |
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
264 |
} |
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
265 |
|
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
266 |
// end receiving packets |
3570 | 267 |
} |
268 |
||
269 |
// end Receiver::Receive |
|
270 |
} |
|
271 |
||
272 |
||
273 |
||
274 |
||
275 |
//---------------------------------------------------------------------- |
|
276 |
//-- TimestampTag |
|
277 |
//------------------------------------------------------ |
|
278 |
TypeId |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
279 |
TimestampTag::GetTypeId (void) |
3570 | 280 |
{ |
281 |
static TypeId tid = TypeId ("TimestampTag") |
|
282 |
.SetParent<Tag> () |
|
283 |
.AddConstructor<TimestampTag> () |
|
284 |
.AddAttribute ("Timestamp", |
|
285 |
"Some momentous point in time!", |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
286 |
EmptyAttributeValue (), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
287 |
MakeTimeAccessor (&TimestampTag::GetTimestamp), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
288 |
MakeTimeChecker ()) |
7196
0f12b1572bca
general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
289 |
; |
3570 | 290 |
return tid; |
291 |
} |
|
292 |
TypeId |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
293 |
TimestampTag::GetInstanceTypeId (void) const |
3570 | 294 |
{ |
295 |
return GetTypeId (); |
|
296 |
} |
|
297 |
||
298 |
uint32_t |
|
299 |
TimestampTag::GetSerializedSize (void) const |
|
300 |
{ |
|
301 |
return 8; |
|
302 |
} |
|
303 |
void |
|
304 |
TimestampTag::Serialize (TagBuffer i) const |
|
305 |
{ |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
306 |
int64_t t = m_timestamp.GetNanoSeconds (); |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
307 |
i.Write ((const uint8_t *)&t, 8); |
3570 | 308 |
} |
309 |
void |
|
310 |
TimestampTag::Deserialize (TagBuffer i) |
|
311 |
{ |
|
312 |
int64_t t; |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
313 |
i.Read ((uint8_t *)&t, 8); |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
314 |
m_timestamp = NanoSeconds (t); |
3570 | 315 |
} |
316 |
||
317 |
void |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
318 |
TimestampTag::SetTimestamp (Time time) |
3570 | 319 |
{ |
320 |
m_timestamp = time; |
|
321 |
} |
|
322 |
Time |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
323 |
TimestampTag::GetTimestamp (void) const |
3570 | 324 |
{ |
325 |
return m_timestamp; |
|
326 |
} |
|
327 |
||
328 |
void |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
329 |
TimestampTag::Print (std::ostream &os) const |
3570 | 330 |
{ |
331 |
os << "t=" << m_timestamp; |
|
332 |
} |