View | Details | Raw Unified | Return to bug 2405
Collapse All | Expand All

(-)a/src/uan/model/uan-mac-cw.cc (-12 / +17 lines)
 Lines 35-44    Link Here 
35
35
36
UanMacCw::UanMacCw ()
36
UanMacCw::UanMacCw ()
37
  : UanMac (),
37
  : UanMac (),
38
    m_phy (0),
38
  m_phy (0),
39
    m_pktTx (0),
39
  m_pktTx (0),
40
    m_state (IDLE),
40
  m_state (IDLE),
41
    m_cleared (false)
41
  m_txNotified (false),
42
  m_cleared (false)
42
43
43
{
44
{
44
  m_rv = CreateObject<UniformRandomVariable> ();
45
  m_rv = CreateObject<UniformRandomVariable> ();
 Lines 63-69    Link Here 
63
      m_phy = 0;
64
      m_phy = 0;
64
    }
65
    }
65
  m_sendEvent.Cancel ();
66
  m_sendEvent.Cancel ();
66
  m_txEndEvent.Cancel ();
67
  m_txNotified = false;
67
}
68
}
68
69
69
void
70
void
 Lines 115-121    Link Here 
115
    {
116
    {
116
    case CCABUSY:
117
    case CCABUSY:
117
      NS_LOG_DEBUG ("Time " << Simulator::Now ().GetSeconds () << " MAC " << GetAddress () << " Starting enqueue CCABUSY");
118
      NS_LOG_DEBUG ("Time " << Simulator::Now ().GetSeconds () << " MAC " << GetAddress () << " Starting enqueue CCABUSY");
118
      if (m_txEndEvent.IsRunning ())
119
      if (m_txNotified == true)
119
        {
120
        {
120
          NS_LOG_DEBUG ("State is TX");
121
          NS_LOG_DEBUG ("State is TX");
121
        }
122
        }
 Lines 253-266    Link Here 
253
void
254
void
254
UanMacCw::NotifyTxStart (Time duration)
255
UanMacCw::NotifyTxStart (Time duration)
255
{
256
{
257
  m_txNotified = true;
256
258
257
  if (m_txEndEvent.IsRunning ())
259
  NS_LOG_DEBUG ("Time " << Simulator::Now ().GetSeconds () << " Tx Start Notified");
258
    {
259
      Simulator::Cancel (m_txEndEvent);
260
    }
261
260
262
  m_txEndEvent = Simulator::Schedule (duration, &UanMacCw::EndTx, this);
263
  NS_LOG_DEBUG ("Time " << Simulator::Now ().GetSeconds () << " scheduling TxEndEvent with delay " << duration.GetSeconds ());
264
  if (m_state == RUNNING)
261
  if (m_state == RUNNING)
265
    {
262
    {
266
      NS_ASSERT (0);
263
      NS_ASSERT (0);
 Lines 271-276    Link Here 
271
268
272
}
269
}
273
270
271
void
272
UanMacCw::NotifyTxEnd (void)
273
{
274
  EndTx ();
275
276
  m_txNotified = false;
277
}
278
274
int64_t
279
int64_t
275
UanMacCw::AssignStreams (int64_t stream)
280
UanMacCw::AssignStreams (int64_t stream)
276
{
281
{
(-)a/src/uan/model/uan-mac-cw.h (-6 / +7 lines)
 Lines 59-65    Link Here 
59
59
60
  /**
60
  /**
61
   * Set the contention window size.
61
   * Set the contention window size.
62
   *   
62
   *
63
   * \param cw Contention window size.
63
   * \param cw Contention window size.
64
   */
64
   */
65
  virtual void SetCw (uint32_t cw);
65
  virtual void SetCw (uint32_t cw);
 Lines 96-101    Link Here 
96
  virtual void NotifyCcaStart (void);
96
  virtual void NotifyCcaStart (void);
97
  virtual void NotifyCcaEnd (void);
97
  virtual void NotifyCcaEnd (void);
98
  virtual void NotifyTxStart (Time duration);
98
  virtual void NotifyTxStart (Time duration);
99
  virtual void NotifyTxEnd (void);
99
100
100
  /**
101
  /**
101
   *  TracedCallback signature for enqueue/dequeue of a packet.
102
   *  TracedCallback signature for enqueue/dequeue of a packet.
 Lines 103-114    Link Here 
103
   * \param [in] packet The Packet being received.
104
   * \param [in] packet The Packet being received.
104
   * \param [in] proto The protocol number.
105
   * \param [in] proto The protocol number.
105
   */
106
   */
106
  typedef void (* QueueTracedCallback)
107
  typedef void (* QueueTracedCallback)(Ptr<const Packet> packet, uint16_t proto);
107
    (Ptr<const Packet> packet, uint16_t proto);
108
108
109
private:
109
private:
110
  /** Enum defining possible Phy states. */
110
  /** Enum defining possible Phy states. */
111
  typedef enum {
111
  typedef enum
112
  {
112
    IDLE,     //!< Idle state.
113
    IDLE,     //!< Idle state.
113
    CCABUSY,  //!< Channel busy.
114
    CCABUSY,  //!< Channel busy.
114
    RUNNING,  //!< Delay timer running.
115
    RUNNING,  //!< Delay timer running.
 Lines 143-150    Link Here 
143
  uint16_t m_pktTxProt;
144
  uint16_t m_pktTxProt;
144
  /** Scheduled SendPacket event. */
145
  /** Scheduled SendPacket event. */
145
  EventId m_sendEvent;
146
  EventId m_sendEvent;
146
  /** Scheduled EndTx event. */
147
  /** Tx has been notified from Phy. */
147
  EventId m_txEndEvent;
148
  bool m_txNotified;
148
  /** Current state. */
149
  /** Current state. */
149
  State m_state;
150
  State m_state;
150
151
(-)a/src/uan/model/uan-phy-gen.cc (-22 / +34 lines)
 Lines 149-165    Link Here 
149
      if (std::abs (pit->GetAmp ()) > maxAmp)
149
      if (std::abs (pit->GetAmp ()) > maxAmp)
150
        {
150
        {
151
          maxAmp = std::abs (pit->GetAmp ());
151
          maxAmp = std::abs (pit->GetAmp ());
152
          // Modified in order to subtract delay of first tap (maxTapDelay appears to be used later in code 
152
          // Modified in order to subtract delay of first tap (maxTapDelay appears to be used later in code
153
          // as delay from first reception, not from TX time)
153
          // as delay from first reception, not from TX time)
154
          maxTapDelay = pit->GetDelay ().GetSeconds () - pdp.GetTap(0).GetDelay().GetSeconds();
154
          maxTapDelay = pit->GetDelay ().GetSeconds () - pdp.GetTap (0).GetDelay ().GetSeconds ();
155
        }
155
        }
156
    }
156
    }
157
157
158
158
159
  double effRxPowerDb = rxPowerDb + KpToDb (csp);
159
  double effRxPowerDb = rxPowerDb + KpToDb (csp);
160
  //It appears to be just the first elements of the sum in Parrish paper, 
160
  //It appears to be just the first elements of the sum in Parrish paper,
161
  // "System Design Considerations for Undersea Networks: Link and Multiple Access Protocols", eq. 14
161
  // "System Design Considerations for Undersea Networks: Link and Multiple Access Protocols", eq. 14
162
  double isiUpa = DbToKp(rxPowerDb) * pdp.SumTapsFromMaxNc (Seconds (ts + clearingTime), Seconds (ts)); // added DpToKp()
162
  double isiUpa = DbToKp (rxPowerDb) * pdp.SumTapsFromMaxNc (Seconds (ts + clearingTime), Seconds (ts)); // added DpToKp()
163
  UanTransducer::ArrivalList::const_iterator it = arrivalList.begin ();
163
  UanTransducer::ArrivalList::const_iterator it = arrivalList.begin ();
164
  double intKp = -DbToKp (effRxPowerDb);
164
  double intKp = -DbToKp (effRxPowerDb);
165
  for (; it != arrivalList.end (); it++)
165
  for (; it != arrivalList.end (); it++)
 Lines 493-509    Link Here 
493
/*************** UanPhyGen definition *****************/
493
/*************** UanPhyGen definition *****************/
494
UanPhyGen::UanPhyGen ()
494
UanPhyGen::UanPhyGen ()
495
  : UanPhy (),
495
  : UanPhy (),
496
    m_state (IDLE),
496
  m_state (IDLE),
497
    m_channel (0),
497
  m_channel (0),
498
    m_transducer (0),
498
  m_transducer (0),
499
    m_device (0),
499
  m_device (0),
500
    m_mac (0),
500
  m_mac (0),
501
    m_txPwrDb (0),
501
  m_txPwrDb (0),
502
    m_rxThreshDb (0),
502
  m_rxThreshDb (0),
503
    m_ccaThreshDb (0),
503
  m_ccaThreshDb (0),
504
    m_pktRx (0),
504
  m_pktRx (0),
505
    m_pktTx (0),
505
  m_pktTx (0),
506
    m_cleared (false)
506
  m_cleared (false)
507
{
507
{
508
  m_pg = CreateObject<UniformRandomVariable> ();
508
  m_pg = CreateObject<UniformRandomVariable> ();
509
509
 Lines 741-746    Link Here 
741
      m_state = IDLE;
741
      m_state = IDLE;
742
    }
742
    }
743
  UpdatePowerConsumption (IDLE);
743
  UpdatePowerConsumption (IDLE);
744
745
  NotifyListenersTxEnd ();
744
}
746
}
745
747
746
void
748
void
 Lines 1004-1016    Link Here 
1004
UanPhyGen::SetSleepMode (bool sleep )
1006
UanPhyGen::SetSleepMode (bool sleep )
1005
{
1007
{
1006
  if (sleep )
1008
  if (sleep )
1007
  {
1009
    {
1008
    m_state = SLEEP;
1010
      m_state = SLEEP;
1009
    if (!m_energyCallback.IsNull ())
1011
      if (!m_energyCallback.IsNull ())
1010
      {
1012
        {
1011
        m_energyCallback (SLEEP);
1013
          m_energyCallback (SLEEP);
1012
      }
1014
        }
1013
  }
1015
    }
1014
  else if (m_state == SLEEP)
1016
  else if (m_state == SLEEP)
1015
    {
1017
    {
1016
      if (GetInterferenceDb ((Ptr<Packet>) 0) > m_ccaThreshDb)
1018
      if (GetInterferenceDb ((Ptr<Packet>) 0) > m_ccaThreshDb)
 Lines 1155-1160    Link Here 
1155
    }
1157
    }
1156
}
1158
}
1157
1159
1160
void
1161
UanPhyGen::NotifyListenersTxEnd (void)
1162
{
1163
  ListenerList::const_iterator it = m_listeners.begin ();
1164
  for (; it != m_listeners.end (); it++)
1165
    {
1166
      (*it)->NotifyTxEnd ();
1167
    }
1168
}
1169
1158
uint32_t
1170
uint32_t
1159
UanPhyGen::GetNModes (void)
1171
UanPhyGen::GetNModes (void)
1160
{
1172
{
(-)a/src/uan/model/uan-phy-gen.h (-3 / +7 lines)
 Lines 215-224    Link Here 
215
 * clearing time between symbols transmitted on the same frequency.
215
 * clearing time between symbols transmitted on the same frequency.
216
 * This clearing time combats ISI from channel delay spread and also has
216
 * This clearing time combats ISI from channel delay spread and also has
217
 * a byproduct of possibly reducing interference from other transmitted packets.
217
 * a byproduct of possibly reducing interference from other transmitted packets.
218
 * 
218
 *
219
 * Thanks to Randall Plate for the latest model revision based on the following 
219
 * Thanks to Randall Plate for the latest model revision based on the following
220
 * papers:
220
 * papers:
221
 * <ul> 
221
 * <ul>
222
 * <li>Parrish, "System Design Considerations for Undersea Networks: Link and Multiple Access Protocols"
222
 * <li>Parrish, "System Design Considerations for Undersea Networks: Link and Multiple Access Protocols"
223
 * <li>Siderius, "Effects of Ocean Thermocline Variability on Noncoherent Underwater Acoustic Communications"
223
 * <li>Siderius, "Effects of Ocean Thermocline Variability on Noncoherent Underwater Acoustic Communications"
224
 * <li>Rao, "Channel Coding Techniques for Wireless Communications", ch 2
224
 * <li>Rao, "Channel Coding Techniques for Wireless Communications", ch 2
 Lines 442-447    Link Here 
442
   * \param duration Duration of transmission.
442
   * \param duration Duration of transmission.
443
   */
443
   */
444
  void NotifyListenersTxStart (Time duration);
444
  void NotifyListenersTxStart (Time duration);
445
  /**
446
   * Call UanListener::NotifyTxEnd on all listeners.
447
   */
448
  void NotifyListenersTxEnd (void);
445
449
446
protected:
450
protected:
447
  virtual void DoDispose ();
451
  virtual void DoDispose ();
(-)a/src/uan/model/uan-phy.h (-16 / +18 lines)
 Lines 96-102    Link Here 
96
96
97
protected:
97
protected:
98
  virtual void DoDispose (void);
98
  virtual void DoDispose (void);
99
  
99
100
};  // class UanPhyCalcSinr
100
};  // class UanPhyCalcSinr
101
101
102
/**
102
/**
 Lines 147-153    Link Here 
147
{
147
{
148
public:
148
public:
149
  /** Default destructor */
149
  /** Default destructor */
150
  virtual ~UanPhyListener () { }
150
  virtual ~UanPhyListener ()
151
  {
152
  }
151
  /** Called when UanPhy begins receiving packet. */
153
  /** Called when UanPhy begins receiving packet. */
152
  virtual void NotifyRxStart (void) = 0;
154
  virtual void NotifyRxStart (void) = 0;
153
  /** Called when UanPhy finishes receiving packet without error. */
155
  /** Called when UanPhy finishes receiving packet without error. */
 Lines 164-170    Link Here 
164
   * \param duration Duration of transmission.
166
   * \param duration Duration of transmission.
165
   */
167
   */
166
  virtual void NotifyTxStart (Time duration) = 0;
168
  virtual void NotifyTxStart (Time duration) = 0;
167
169
  /** Function called when Phy object finishes transmitting packet */
170
  virtual void NotifyTxEnd (void) = 0;
168
};  // class UanPhyListener
171
};  // class UanPhyListener
169
172
170
/**
173
/**
 Lines 210-222    Link Here 
210
   * \param [in] sinr The SINR.
213
   * \param [in] sinr The SINR.
211
   * \param [in] mode The channel mode.
214
   * \param [in] mode The channel mode.
212
   */
215
   */
213
  typedef void (* TracedCallback)
216
  typedef void (* TracedCallback)(Ptr<const Packet> pkt, double sinr, UanTxMode mode);
214
    (Ptr<const Packet> pkt, double sinr, UanTxMode mode);
217
215
218
216
  
217
  /**
219
  /**
218
   * Set the DeviceEnergyModel callback for UanPhy device. 
220
   * Set the DeviceEnergyModel callback for UanPhy device.
219
   * 
221
   *
220
   * \param callback The DeviceEnergyModel change state callback.
222
   * \param callback The DeviceEnergyModel change state callback.
221
   */
223
   */
222
  virtual void SetEnergyModelCallback (DeviceEnergyModel::ChangeStateCallback callback) = 0;
224
  virtual void SetEnergyModelCallback (DeviceEnergyModel::ChangeStateCallback callback) = 0;
 Lines 487-500    Link Here 
487
   */
489
   */
488
  void NotifyRxDrop (Ptr<const Packet> packet);
490
  void NotifyRxDrop (Ptr<const Packet> packet);
489
491
490
 /**
492
  /**
491
  * Assign a fixed random variable stream number to the random variables
493
   * Assign a fixed random variable stream number to the random variables
492
  * used by this model.  Return the number of streams (possibly zero) that
494
   * used by this model.  Return the number of streams (possibly zero) that
493
  * have been assigned.
495
   * have been assigned.
494
  *
496
   *
495
  * \param stream First stream index to use.
497
   * \param stream First stream index to use.
496
  * \return The number of stream indices assigned by this model.
498
   * \return The number of stream indices assigned by this model.
497
  */
499
   */
498
  virtual int64_t AssignStreams (int64_t stream) = 0;
500
  virtual int64_t AssignStreams (int64_t stream) = 0;
499
501
500
  /**
502
  /**

Return to bug 2405