This file is indexed.

/usr/include/ns3.27/ns3/uan-phy.h is in libns3-dev 3.27+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2009 University of Washington
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author: Leonard Tracy <lentracy@gmail.com>
 *         Andrea Sacco <andrea.sacco85@gmail.com>
 */


#ifndef UAN_PHY_H
#define UAN_PHY_H

#include "ns3/object.h"
#include "ns3/uan-mac.h"
#include "ns3/uan-tx-mode.h"
#include "ns3/uan-prop-model.h"
#include "ns3/uan-transducer.h"
#include "ns3/device-energy-model.h"

namespace ns3 {


/**
 * \ingroup uan
 *
 * Class used for calculating SINR of packet in UanPhy.
 *
 * Can be set to any derived class using attributes of UanPhy
 * to implement different models.
 */
class UanPhyCalcSinr : public Object
{
public:
  /**
   * Calculate the SINR value for a packet.
   *
   * \param pkt Packet to calculate SINR for.
   * \param arrTime Arrival time of pkt.
   * \param rxPowerDb The received signal strength of the packet in dB re 1 uPa.
   * \param ambNoiseDb Ambient channel noise in dB re 1 uPa.
   * \param mode TX Mode of pkt.
   * \param pdp  Power delay profile of pkt.
   * \param arrivalList  List of interfering arrivals given from Transducer.
   * \return The SINR in dB re 1 uPa.
   */
  virtual double CalcSinrDb (Ptr<Packet> pkt,
                             Time arrTime,
                             double rxPowerDb,
                             double ambNoiseDb,
                             UanTxMode mode,
                             UanPdp pdp,
                             const UanTransducer::ArrivalList &arrivalList
                             ) const = 0;
  /**
   * Register this type.
   * \return The object TypeId.
   */
  static TypeId GetTypeId (void);

  /** Clear all pointer references. */
  virtual void Clear (void);

  /**
   * Convert dB re 1 uPa to kilopascals.
   *
   * \param db dB value.
   * \return Value in kilopascals.
   */
  inline double DbToKp (double db) const
  {
    return std::pow (10, db / 10.0);
  }
  /**
   * Convert kilopascals to dB re 1 uPa.
   *
   * \param kp Value in kilopascals.
   * \return Valeu in dB re 1 uPa
   */
  inline double KpToDb (double kp) const
  {
    return 10 * std::log10 (kp);
  }

protected:
  virtual void DoDispose (void);
  
};  // class UanPhyCalcSinr

/**
 * \ingroup uan
 *
 * Calculate packet error probability, based on received SINR
 * and modulation (mode).
 *
 * Can be set in UanPhy via attributes.
 */
class UanPhyPer : public Object
{
public:
  /**
   * Calculate the packet error probability based on
   * SINR at the receiver and a tx mode.
   *
   * \param pkt Packet which is under consideration.
   * \param sinrDb SINR at receiver.
   * \param mode TX mode used to transmit packet.
   * \return Probability of packet error.
   */
  virtual double CalcPer (Ptr<Packet> pkt, double sinrDb, UanTxMode mode) = 0;

  /**
   * Register this type.
   * \return The TypeId.
   */
  static TypeId GetTypeId (void);
  /** Clear all pointer references. */
  virtual void Clear (void);

protected:
  virtual void DoDispose (void);

};  // class UanPhyPer


/**
 * \ingroup uan
 *
 * Interface for PHY event listener.
 *
 * A class which implements this interface may register with Phy object
 * to receive notification of TX/RX/CCA events
 */
class UanPhyListener
{
public:
  /** Default destructor */
  virtual ~UanPhyListener () { }
  /** Called when UanPhy begins receiving packet. */
  virtual void NotifyRxStart (void) = 0;
  /** Called when UanPhy finishes receiving packet without error. */
  virtual void NotifyRxEndOk (void) = 0;
  /** Called when UanPhy finishes receiving packet in error. */
  virtual void NotifyRxEndError (void) = 0;
  /** Called when UanPhy begins sensing channel is busy. */
  virtual void NotifyCcaStart (void) = 0;
  /** Called when UanPhy stops sensing channel is busy. */
  virtual void NotifyCcaEnd (void) = 0;
  /**
   * Called when transmission starts from Phy object.
   *
   * \param duration Duration of transmission.
   */
  virtual void NotifyTxStart (Time duration) = 0;

};  // class UanPhyListener

/**
 * \ingroup uan
 *
 * Base class for UAN Phy models.
 */
class UanPhy : public Object
{
public:
  /// Enum defining possible Phy states.
  enum State
  {
    IDLE,     //!< Idle state.
    CCABUSY,  //!< Channel busy.
    RX,       //!< Receiving.
    TX,       //!< Transmitting.
    SLEEP,    //!< Sleeping.
    DISABLED  //!< Disabled.
  };

  /**
   * Packet received successfully callback function type.
   *
   * \pname{arg1} Packet received successfully.
   * \pname{arg2} SNIR of packet.
   * \pname{arg3} Mode of packet.
   */
  typedef Callback<void, Ptr<Packet>, double, UanTxMode> RxOkCallback;

  /**
   * Packet receive error callback function type.
   *
   * \pname{arg1} Packet received successfully.
   * \pname{arg2} SNIR of packet.
   */
  typedef Callback<void, Ptr<Packet>, double > RxErrCallback;

  /**
   * TracedCallback signature for UanPhy packet send/receive events.
   *
   * \param [in] pkt The packet.
   * \param [in] sinr The SINR.
   * \param [in] mode The channel mode.
   */
  typedef void (* TracedCallback)
    (Ptr<const Packet> pkt, double sinr, UanTxMode mode);

  
  /**
   * Set the DeviceEnergyModel callback for UanPhy device. 
   * 
   * \param callback The DeviceEnergyModel change state callback.
   */
  virtual void SetEnergyModelCallback (DeviceEnergyModel::ChangeStateCallback callback) = 0;
  /**
   * Handle the energy depletion event.
   */
  virtual void EnergyDepletionHandler (void) = 0;
  /**
   * Handle the energy recharge event.
   */
  virtual void EnergyRechargeHandler (void) = 0;
  /**
   * Send a packet using a specific transmission mode.
   *
   * \param pkt  Packet to transmit.
   * \param modeNum  Index of mode in SupportedModes list to use for transmission.
   */
  virtual void SendPacket (Ptr<Packet> pkt, uint32_t modeNum) = 0;

  /**
   * Register a UanPhyListener to be notified of common UanPhy events.
   *
   * \param listener New listener to register.
   */
  virtual void RegisterListener (UanPhyListener *listener) = 0;

  /**
   * Packet arriving from channel:  i.e.  leading bit of packet has arrived.
   *
   * \param pkt Packet which is arriving.
   * \param rxPowerDb Signal power of incoming packet in dB re 1 uPa.
   * \param txMode Transmission mode defining modulation of incoming packet.
   * \param pdp Power delay profile of incoming packet.
   */
  virtual void StartRxPacket (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp) = 0;

  /**
   * Set the callback to be used when a packet is received without error.
   *
   * \param cb The callback.
   */
  virtual void SetReceiveOkCallback (RxOkCallback cb) = 0;

  /**
   * Set the callback to be used when a packet is received with errors.
   *
   * \param cb The callback.
   */
  virtual void SetReceiveErrorCallback (RxErrCallback cb) = 0;


  /**
   * Set the transmit power.
   *
   * \param txpwr Final output transmission power, in dB.
   */
  virtual void SetTxPowerDb (double txpwr) = 0;

  /**
   * Set the minimum SINR threshold to receive a packet without errors.
   *
   * \deprecated See UanPhyPer.
   *
   * \param thresh Threshold SINR for propper reception in dB re 1 uPa.
   */
  virtual void SetRxThresholdDb (double thresh) = 0;

  /**
   * Set the threshold for detecting channel busy.
   *
   * \param thresh Signal power threshold at receiver.
   */
  virtual void SetCcaThresholdDb (double thresh) = 0;


  /**
   * Get the current transmit power, in dB.
   *
   * \return The transmit power.
   */
  virtual double GetTxPowerDb (void) = 0;

  /**
   * Get the minimum received signal strength required
   * to receive a packet without errors.
   *
   * \return The minimum required signal strength, in dB.
   */
  virtual double GetRxThresholdDb (void) = 0;

  /**
   * Get the CCA threshold signal strength required to detect channel busy.
   *
   * \return The CCA threshold signal strength in dB.
   */
  virtual double GetCcaThresholdDb (void) = 0;
  /** \return True if Phy is in SLEEP state. */
  virtual bool IsStateSleep (void) = 0;
  /** \return True if Phy is in IDLE state. */
  virtual bool IsStateIdle (void) = 0;
  /** \return True if Phy is neither IDLE nor SLEEP. */
  virtual bool IsStateBusy (void) = 0;
  /** \return True if Phy is currently in receive mode. */
  virtual bool IsStateRx (void) = 0;
  /** \return True if Phy is busy transmitting. */
  virtual bool IsStateTx (void) = 0;
  /** \return True if Phy is in CCABUSY state. */
  virtual bool IsStateCcaBusy (void) = 0;

  /**
   * Get the attached channel.
   *
   * \return The channel.
   */
  virtual Ptr<UanChannel> GetChannel (void) const = 0;

  /**
   * Get the device hosting this Phy.
   *
   * \return The net device.
   */
  virtual Ptr<UanNetDevice> GetDevice (void) const = 0;

  /**
   * Attach to a channel.
   *
   * \param channel The channel to attach to.
   */
  virtual void SetChannel (Ptr<UanChannel> channel) = 0;

  /**
   * Set the device hosting this Phy.
   *
   * \param device The device.
   */
  virtual void SetDevice (Ptr<UanNetDevice> device) = 0;

  /**
   * Set the MAC forwarding messages to this Phy.
   *
   * \param mac The MAC.
   */
  virtual void SetMac (Ptr<UanMac> mac) = 0;

  /**
   * Called when a transmission is beginning
   * on the attched transducer.
   *
   * \param packet Packet that is beginning transmission.
   * \param txPowerDb Transmit power of packet.
   * \param txMode  Transmission mode of packet.
   */
  virtual void NotifyTransStartTx (Ptr<Packet> packet, double txPowerDb, UanTxMode txMode) = 0;

  /**
   * Called when there has been a change in the
   * ammount of interference this node is experiencing
   * from other transmissions.
   */
  virtual void NotifyIntChange (void) = 0;

  /**
   * Attach a transducer to this Phy.
   *
   * \param trans The transducer.
   */
  virtual void SetTransducer (Ptr<UanTransducer> trans) = 0;

  /**
   * Get the attached transducer.
   *
   * \return The transducer.
   */
  virtual Ptr<UanTransducer> GetTransducer (void) = 0;

  /**
   * Get the number of transmission modes supported by this Phy.
   *
   * \return The number modes.
   */
  virtual uint32_t GetNModes (void) = 0;

  /**
   * Get a specific transmission mode.
   *
   * \param n The mode number.
   * \return The mode.
   */
  virtual UanTxMode GetMode (uint32_t n) = 0;

  /**
   * Get the packet currently being received.
   *
   * \warning Returns non-valid pointer if IsStateRx == false.
   * \return The packet.
   */
  virtual Ptr<Packet> GetPacketRx (void) const = 0;

  /** Clear all pointer references. */
  virtual void Clear (void) = 0;

  /**
   * Set the Phy SLEEP mode.
   *
   * \param sleep SLEEP on or off.
   */
  virtual void SetSleepMode (bool sleep) = 0;


  /**
   * Called when the transducer begins transmitting a packet.
   *
   * This fires a PhyTxBegin trace.  Implemented for encapsulation
   * purposes.
   *
   * \param packet The packet.
   */
  void NotifyTxBegin (Ptr<const Packet> packet);

  /**
   * Called when the transducer finishes transmitting a packet.
   *
   * This fires a PhyTxEnd trace.  Implemented for encapsulation
   * purposes.
   *
   * \param packet The packet.
   */
  void NotifyTxEnd (Ptr<const Packet> packet);

  /**
   * Called when the transducer attempts to transmit a new packet while
   * already transmitting a prior packet.
   *
   * This fires a PhyTxDrop trace.  Implemented for encapsulation
   * purposes.
   *
   * \param packet The packet.
   */
  void NotifyTxDrop (Ptr<const Packet> packet);

  /**
   * Called when the Phy begins to receive a packet.
   *
   * This fires a PhyRxBegin trace.  Implemented for encapsulation
   * purposes.
   *
   * \param packet The packet.
   */
  void NotifyRxBegin (Ptr<const Packet> packet);

  /**
   * Called when a packet is received without error.
   *
   * This fires a PhyRxEnd trace.  Implemented for encapsulation
   * purposes.
   *
   * \param packet The packet.
   */
  void NotifyRxEnd (Ptr<const Packet> packet);

  /**
   * Called when the Phy drops a packet.
   *
   * This fires a PhyRxDrop trace.  Implemented for encapsulation
   * purposes.
   *
   * \param packet The packet.
   */
  void NotifyRxDrop (Ptr<const Packet> packet);

 /**
  * Assign a fixed random variable stream number to the random variables
  * used by this model.  Return the number of streams (possibly zero) that
  * have been assigned.
  *
  * \param stream First stream index to use.
  * \return The number of stream indices assigned by this model.
  */
  virtual int64_t AssignStreams (int64_t stream) = 0;

  /**
   * Register this type.
   * \return The TypeId.
   */
  static TypeId GetTypeId (void);

private:
  /**
   * Trace source indicating a packet has begun transmitting
   * over the channel medium.
   *
   * \see class CallBackTraceSource
   */
  ns3::TracedCallback<Ptr<const Packet> > m_phyTxBeginTrace;

  /**
   * Trace source indicating a packet has been completely transmitted
   * over the channel.
   *
   * \see class CallBackTraceSource
   */
  ns3::TracedCallback<Ptr<const Packet> > m_phyTxEndTrace;

  /**
   * Trace source indicating a packet has been dropped by the device
   * during transmission.
   *
   * \see class CallBackTraceSource
   */
  ns3::TracedCallback<Ptr<const Packet> > m_phyTxDropTrace;

  /**
   * Trace source indicating a packet has begun being received
   * from the channel medium by the device.
   *
   * \see class CallBackTraceSource
   */
  ns3::TracedCallback<Ptr<const Packet> > m_phyRxBeginTrace;

  /**
   * Trace source indicating a packet has been completely received
   * from the channel medium by the device.
   *
   * \see class CallBackTraceSource
   */
  ns3::TracedCallback<Ptr<const Packet> > m_phyRxEndTrace;

  /**
   * Trace source indicating a packet has been dropped by the device
   * during reception.
   *
   * \see class CallBackTraceSource
   */
  ns3::TracedCallback<Ptr<const Packet> > m_phyRxDropTrace;

};  // class UanPhy

} // namespace ns3

#endif /* UAN_PHY_H */