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

(-)a/src/lr-wpan/helper/lr-wpan-helper.cc (+1 lines)
 Lines 106-111    Link Here 
106
  LogComponentEnable ("LrWpanErrorModel", LOG_LEVEL_ALL);
106
  LogComponentEnable ("LrWpanErrorModel", LOG_LEVEL_ALL);
107
  LogComponentEnable ("LrWpanInterferenceHelper", LOG_LEVEL_ALL);
107
  LogComponentEnable ("LrWpanInterferenceHelper", LOG_LEVEL_ALL);
108
  LogComponentEnable ("LrWpanMac", LOG_LEVEL_ALL);
108
  LogComponentEnable ("LrWpanMac", LOG_LEVEL_ALL);
109
  LogComponentEnable ("LrWpanNullMac", LOG_LEVEL_ALL);
109
  LogComponentEnable ("LrWpanNetDevice", LOG_LEVEL_ALL);
110
  LogComponentEnable ("LrWpanNetDevice", LOG_LEVEL_ALL);
110
  LogComponentEnable ("LrWpanPhy", LOG_LEVEL_ALL);
111
  LogComponentEnable ("LrWpanPhy", LOG_LEVEL_ALL);
111
  LogComponentEnable ("LrWpanSpectrumSignalParameters", LOG_LEVEL_ALL);
112
  LogComponentEnable ("LrWpanSpectrumSignalParameters", LOG_LEVEL_ALL);
(-)a/src/lr-wpan/model/lr-wpan-mac.cc (-1 lines)
 Lines 52-58    Link Here 
52
  static TypeId tid = TypeId ("ns3::LrWpanMac")
52
  static TypeId tid = TypeId ("ns3::LrWpanMac")
53
    .SetParent<Object> ()
53
    .SetParent<Object> ()
54
    .SetGroupName ("LrWpan")
54
    .SetGroupName ("LrWpan")
55
    .AddConstructor<LrWpanMac> ()
56
    .AddAttribute ("PanId", "16-bit identifier of the associated PAN",
55
    .AddAttribute ("PanId", "16-bit identifier of the associated PAN",
57
                   UintegerValue (),
56
                   UintegerValue (),
58
                   MakeUintegerAccessor (&LrWpanMac::m_macPanId),
57
                   MakeUintegerAccessor (&LrWpanMac::m_macPanId),
(-)a/src/lr-wpan/model/lr-wpan-mac.h (-54 / +3 lines)
 Lines 243-256    Link Here 
243
   *
243
   *
244
   * \return true, if the receiver is enabled during idle periods, false otherwise
244
   * \return true, if the receiver is enabled during idle periods, false otherwise
245
   */
245
   */
246
  bool GetRxOnWhenIdle (void);
246
  virtual bool GetRxOnWhenIdle (void);
247
247
248
  /**
248
  /**
249
   * Set if the receiver should be enabled when the MAC is idle.
249
   * Set if the receiver should be enabled when the MAC is idle.
250
   *
250
   *
251
   * \param rxOnWhenIdle set to true to enable the receiver during idle periods
251
   * \param rxOnWhenIdle set to true to enable the receiver during idle periods
252
   */
252
   */
253
  void SetRxOnWhenIdle (bool rxOnWhenIdle);
253
  virtual void SetRxOnWhenIdle (bool rxOnWhenIdle);
254
254
255
  // XXX these setters will become obsolete if we use the attribute system
255
  // XXX these setters will become obsolete if we use the attribute system
256
  /**
256
  /**
 Lines 413-419    Link Here 
413
   *
413
   *
414
   * \param macState indicate BUSY oder IDLE channel condition
414
   * \param macState indicate BUSY oder IDLE channel condition
415
   */
415
   */
416
  void SetLrWpanMacState (LrWpanMacState macState);
416
  virtual void SetLrWpanMacState (LrWpanMacState macState) = 0;
417
417
418
  /**
418
  /**
419
   * Get the current association status.
419
   * Get the current association status.
 Lines 429-484    Link Here 
429
   */
429
   */
430
  void SetAssociationStatus (LrWpanAssociationStatus status);
430
  void SetAssociationStatus (LrWpanAssociationStatus status);
431
431
432
  //MAC sublayer constants
433
  /**
434
   * Length of a superframe slot in symbols. Defaults to 60 symbols in each
435
   * superframe slot.
436
   * See IEEE 802.15.4-2006, section 7.4.1, Table 85.
437
   */
438
  uint64_t m_aBaseSlotDuration;
439
440
  /**
441
   * Number of a superframe slots per superframe. Defaults to 16.
442
   * See IEEE 802.15.4-2006, section 7.4.1, Table 85.
443
   */
444
  uint64_t m_aNumSuperframeSlots;
445
446
  /**
447
   * Length of a superframe in symbols. Defaults to
448
   * aBaseSlotDuration * aNumSuperframeSlots in symbols.
449
   * See IEEE 802.15.4-2006, section 7.4.1, Table 85.
450
   */
451
  uint64_t m_aBaseSuperframeDuration;
452
453
  //MAC PIB attributes
454
  /**
455
   * The time that the device transmitted its last beacon frame, in symbol
456
   * periods. Only 24 bits used.
457
   * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
458
   */
459
  uint64_t m_macBeaconTxTime;
460
461
  /**
462
   * Symbol boundary is same as m_macBeaconTxTime.
463
   * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
464
   */
465
  uint64_t m_macSyncSymbolOffset;
466
467
  /**
468
   * Specification of how often the coordinator transmits its beacon.
469
   * 0 - 15 with 15 means no beacons are being sent.
470
   * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
471
   */
472
  uint64_t m_macBeaconOrder;
473
474
  /**
475
   * The length of the active portion of the outgoing superframe, including the
476
   * beacon frame.
477
   * 0 - 15 with 15 means the superframe will not be active after the beacon.
478
   * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
479
   */
480
  uint64_t m_macSuperframeOrder;
481
482
  /**
432
  /**
483
   * Indicates if MAC sublayer is in receive all mode. True mean accept all
433
   * Indicates if MAC sublayer is in receive all mode. True mean accept all
484
   * frames from PHY.
434
   * frames from PHY.
 Lines 560-566    Link Here 
560
  virtual void DoInitialize (void);
510
  virtual void DoInitialize (void);
561
  virtual void DoDispose (void);
511
  virtual void DoDispose (void);
562
512
563
private:
564
  /**
513
  /**
565
   * Helper structure for managing transmission queue elements.
514
   * Helper structure for managing transmission queue elements.
566
   */
515
   */
(-)a/src/lr-wpan/model/lr-wpan-net-device.cc (-2 / +4 lines)
 Lines 32-37    Link Here 
32
#include <ns3/boolean.h>
32
#include <ns3/boolean.h>
33
#include <ns3/mobility-model.h>
33
#include <ns3/mobility-model.h>
34
#include <ns3/packet.h>
34
#include <ns3/packet.h>
35
#include <ns3/lr-wpan-nullmac.h>
35
36
36
37
37
namespace ns3 {
38
namespace ns3 {
 Lines 73-79    Link Here 
73
  : m_configComplete (false)
74
  : m_configComplete (false)
74
{
75
{
75
  NS_LOG_FUNCTION (this);
76
  NS_LOG_FUNCTION (this);
76
  m_mac = CreateObject<LrWpanMac> ();
77
  m_mac = CreateObject<LrWpanNullMac> ();
77
  m_phy = CreateObject<LrWpanPhy> ();
78
  m_phy = CreateObject<LrWpanPhy> ();
78
  m_csmaca = CreateObject<LrWpanCsmaCa> ();
79
  m_csmaca = CreateObject<LrWpanCsmaCa> ();
79
  CompleteConfig ();
80
  CompleteConfig ();
 Lines 146-152    Link Here 
146
  m_phy->SetPlmeSetAttributeConfirmCallback (MakeCallback (&LrWpanMac::PlmeSetAttributeConfirm, m_mac));
147
  m_phy->SetPlmeSetAttributeConfirmCallback (MakeCallback (&LrWpanMac::PlmeSetAttributeConfirm, m_mac));
147
148
148
  m_csmaca->SetLrWpanMacStateCallback (MakeCallback (&LrWpanMac::SetLrWpanMacState, m_mac));
149
  m_csmaca->SetLrWpanMacStateCallback (MakeCallback (&LrWpanMac::SetLrWpanMacState, m_mac));
149
  m_phy->SetPlmeCcaConfirmCallback (MakeCallback (&LrWpanCsmaCa::PlmeCcaConfirm, m_csmaca));
150
  m_phy->SetPlmeCcaConfirmCallback (MakeCallback (&LrWpanMac::PlmeCcaConfirm, m_mac));
150
  m_configComplete = true;
151
  m_configComplete = true;
151
}
152
}
152
153
 Lines 203-208    Link Here 
203
  NS_LOG_FUNCTION (this);
204
  NS_LOG_FUNCTION (this);
204
  return m_csmaca;
205
  return m_csmaca;
205
}
206
}
207
206
void
208
void
207
LrWpanNetDevice::SetIfIndex (const uint32_t index)
209
LrWpanNetDevice::SetIfIndex (const uint32_t index)
208
{
210
{
(-)a/src/lr-wpan/model/lr-wpan-nullmac.cc (+191 lines)
Line 0    Link Here 
1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2011 The Boeing Company
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
 * Authors:
19
 *  Gary Pei <guangyu.pei@boeing.com>
20
 *  kwong yin <kwong-sang.yin@boeing.com>
21
 *  Tom Henderson <thomas.r.henderson@boeing.com>
22
 *  Sascha Alexander Jopen <jopen@cs.uni-bonn.de>
23
 *  Erwan Livolant <erwan.livolant@inria.fr>
24
 */
25
#include "lr-wpan-nullmac.h"
26
#include "lr-wpan-csmaca.h"
27
#include "lr-wpan-mac-header.h"
28
#include "lr-wpan-mac-trailer.h"
29
#include <ns3/simulator.h>
30
#include <ns3/log.h>
31
#include <ns3/uinteger.h>
32
#include <ns3/node.h>
33
#include <ns3/packet.h>
34
#include <ns3/random-variable-stream.h>
35
#include <ns3/double.h>
36
37
#undef NS_LOG_APPEND_CONTEXT
38
#define NS_LOG_APPEND_CONTEXT                                   \
39
  std::clog << "[address " << m_shortAddress << "] ";
40
41
namespace ns3 {
42
43
NS_LOG_COMPONENT_DEFINE ("LrWpanNullMac");
44
45
NS_OBJECT_ENSURE_REGISTERED (LrWpanNullMac);
46
47
TypeId
48
LrWpanNullMac::GetTypeId (void)
49
{
50
  static TypeId tid = TypeId ("ns3::LrWpanNullMac")
51
    .SetParent<LrWpanMac> ()
52
    .SetGroupName ("LrWpan")
53
    .AddConstructor<LrWpanNullMac> ()
54
  ;
55
  return tid;
56
}
57
58
LrWpanNullMac::LrWpanNullMac ()
59
{
60
  // First set the state to a known value, call ChangeMacState to fire trace source.
61
  m_lrWpanMacState = MAC_IDLE;
62
  ChangeMacState (MAC_IDLE);
63
64
  m_macRxOnWhenIdle = true;
65
  m_macPanId = 0;
66
  m_associationStatus = ASSOCIATED;
67
  m_selfExt = Mac64Address::Allocate ();
68
  m_macPromiscuousMode = false;
69
  m_macMaxFrameRetries = 3;
70
  m_retransmission = 0;
71
  m_numCsmacaRetry = 0;
72
  m_txPkt = 0;
73
74
  Ptr<UniformRandomVariable> uniformVar = CreateObject<UniformRandomVariable> ();
75
  uniformVar->SetAttribute ("Min", DoubleValue (0.0));
76
  uniformVar->SetAttribute ("Max", DoubleValue (255.0));
77
  m_macDsn = SequenceNumber8 (uniformVar->GetValue ());
78
  m_shortAddress = Mac16Address ("00:00");
79
}
80
81
LrWpanNullMac::~LrWpanNullMac ()
82
{
83
}
84
85
void
86
LrWpanNullMac::DoInitialize ()
87
{
88
  if (m_macRxOnWhenIdle)
89
    {
90
      m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
91
    }
92
  else
93
    {
94
      m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
95
    }
96
97
  LrWpanMac::DoInitialize ();
98
}
99
100
void
101
LrWpanNullMac::DoDispose ()
102
{
103
  LrWpanMac::DoDispose ();
104
}
105
106
bool
107
LrWpanNullMac::GetRxOnWhenIdle ()
108
{
109
  return m_macRxOnWhenIdle;
110
}
111
112
void
113
LrWpanNullMac::SetRxOnWhenIdle (bool rxOnWhenIdle)
114
{
115
  NS_LOG_FUNCTION (this << rxOnWhenIdle);
116
  m_macRxOnWhenIdle = rxOnWhenIdle;
117
118
  if (m_lrWpanMacState == MAC_IDLE)
119
    {
120
      if (m_macRxOnWhenIdle)
121
        {
122
          m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
123
        }
124
      else
125
        {
126
          m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
127
        }
128
    }
129
}
130
131
void
132
LrWpanNullMac::SetLrWpanMacState (LrWpanMacState macState)
133
{
134
  NS_LOG_FUNCTION (this << "mac state = " << macState);
135
136
  McpsDataConfirmParams confirmParams;
137
138
  if (macState == MAC_IDLE)
139
    {
140
      ChangeMacState (MAC_IDLE);
141
142
      if (m_macRxOnWhenIdle)
143
        {
144
          m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
145
        }
146
      else
147
        {
148
          m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
149
        }
150
151
      CheckQueue ();
152
    }
153
  else if (macState == MAC_ACK_PENDING)
154
    {
155
      ChangeMacState (MAC_ACK_PENDING);
156
      m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
157
    }
158
  else if (macState == MAC_CSMA)
159
    {
160
      NS_ASSERT (m_lrWpanMacState == MAC_IDLE || m_lrWpanMacState == MAC_ACK_PENDING);
161
162
      ChangeMacState (MAC_CSMA);
163
      m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
164
    }
165
  else if (m_lrWpanMacState == MAC_CSMA && macState == CHANNEL_IDLE)
166
    {
167
      // Channel is idle, set transmitter to TX_ON
168
      ChangeMacState (MAC_SENDING);
169
      m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON);
170
    }
171
  else if (m_lrWpanMacState == MAC_CSMA && macState == CHANNEL_ACCESS_FAILURE)
172
    {
173
      NS_ASSERT (m_txPkt);
174
175
      // cannot find a clear channel, drop the current packet.
176
      NS_LOG_DEBUG ( this << " cannot find clear channel");
177
      confirmParams.m_msduHandle = m_txQueue.front ()->txQMsduHandle;
178
      confirmParams.m_status = IEEE_802_15_4_CHANNEL_ACCESS_FAILURE;
179
      m_macTxDropTrace (m_txPkt);
180
      if (!m_mcpsDataConfirmCallback.IsNull ())
181
        {
182
          m_mcpsDataConfirmCallback (confirmParams);
183
        }
184
      // remove the copy of the packet that was just sent
185
      RemoveFirstTxQElement ();
186
187
      ChangeMacState (MAC_IDLE);
188
    }
189
}
190
191
} // namespace ns3
(-)a/src/lr-wpan/model/lr-wpan-nullmac.h (+149 lines)
Line 0    Link Here 
1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2011 The Boeing Company
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
 * Authors:
19
 *  Gary Pei <guangyu.pei@boeing.com>
20
 *  kwong yin <kwong-sang.yin@boeing.com>
21
 *  Tom Henderson <thomas.r.henderson@boeing.com>
22
 *  Sascha Alexander Jopen <jopen@cs.uni-bonn.de>
23
 */
24
#ifndef LR_WPAN_NULLMAC_H
25
#define LR_WPAN_NULLMAC_H
26
27
#include "lr-wpan-mac.h"
28
29
30
namespace ns3 {
31
32
/**
33
 * \defgroup lr-wpan LR-WPAN models
34
 *
35
 * This section documents the API of the IEEE 802.15.4-related models.  For a generic functional description, please refer to the ns-3 manual.
36
 */
37
38
/**
39
 * \ingroup lr-wpan
40
 *
41
 * Class that implements the LR-WPAN Mac state machine
42
 */
43
class LrWpanNullMac : public LrWpanMac
44
{
45
public:
46
  /**
47
   * Get the type ID.
48
   *
49
   * \return the object TypeId
50
   */
51
  static TypeId GetTypeId (void);
52
53
  /**
54
   * Default constructor.
55
   */
56
  LrWpanNullMac (void);
57
  virtual ~LrWpanNullMac (void);
58
59
  /**
60
   * Check if the receiver will be enabled when the MAC is idle.
61
   *
62
   * \return true, if the receiver is enabled during idle periods, false otherwise
63
   */
64
  virtual bool GetRxOnWhenIdle (void);
65
66
  /**
67
   * Set if the receiver should be enabled when the MAC is idle.
68
   *
69
   * \param rxOnWhenIdle set to true to enable the receiver during idle periods
70
   */
71
  virtual void SetRxOnWhenIdle (bool rxOnWhenIdle);
72
73
  /**
74
   * CSMA-CA algorithm calls back the MAC after executing channel assessment.
75
   *
76
   * \param macState indicate BUSY oder IDLE channel condition
77
   */
78
  virtual void SetLrWpanMacState (LrWpanMacState macState);
79
80
  //MAC sublayer constants
81
  /**
82
   * Length of a superframe slot in symbols. Defaults to 60 symbols in each
83
   * superframe slot.
84
   * See IEEE 802.15.4-2006, section 7.4.1, Table 85.
85
   */
86
  uint64_t m_aBaseSlotDuration;
87
88
  /**
89
   * Number of a superframe slots per superframe. Defaults to 16.
90
   * See IEEE 802.15.4-2006, section 7.4.1, Table 85.
91
   */
92
  uint64_t m_aNumSuperframeSlots;
93
94
  /**
95
   * Length of a superframe in symbols. Defaults to
96
   * aBaseSlotDuration * aNumSuperframeSlots in symbols.
97
   * See IEEE 802.15.4-2006, section 7.4.1, Table 85.
98
   */
99
  uint64_t m_aBaseSuperframeDuration;
100
101
  //MAC PIB attributes
102
  /**
103
   * The time that the device transmitted its last beacon frame, in symbol
104
   * periods. Only 24 bits used.
105
   * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
106
   */
107
  uint64_t m_macBeaconTxTime;
108
109
  /**
110
   * Symbol boundary is same as m_macBeaconTxTime.
111
   * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
112
   */
113
  uint64_t m_macSyncSymbolOffset;
114
115
  /**
116
   * Specification of how often the coordinator transmits its beacon.
117
   * 0 - 15 with 15 means no beacons are being sent.
118
   * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
119
   */
120
  uint64_t m_macBeaconOrder;
121
122
  /**
123
   * The length of the active portion of the outgoing superframe, including the
124
   * beacon frame.
125
   * 0 - 15 with 15 means the superframe will not be active after the beacon.
126
   * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
127
   */
128
  uint64_t m_macSuperframeOrder;
129
130
  /**
131
   * Indication of whether the MAC sublayer is to enable its receiver during
132
   * idle periods.
133
   * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
134
   */
135
  bool m_macRxOnWhenIdle;
136
  
137
protected:
138
  // Inherited from Object.
139
  virtual void DoInitialize (void);
140
  virtual void DoDispose (void);
141
142
private:
143
144
};
145
146
147
} // namespace ns3
148
149
#endif /* LR_WPAN_MAC_H */
(-)a/src/lr-wpan/wscript (+2 lines)
 Lines 7-12    Link Here 
7
        'model/lr-wpan-interference-helper.cc',
7
        'model/lr-wpan-interference-helper.cc',
8
        'model/lr-wpan-phy.cc',
8
        'model/lr-wpan-phy.cc',
9
        'model/lr-wpan-mac.cc',
9
        'model/lr-wpan-mac.cc',
10
        'model/lr-wpan-nullmac.cc',
10
        'model/lr-wpan-mac-header.cc',
11
        'model/lr-wpan-mac-header.cc',
11
        'model/lr-wpan-mac-trailer.cc',
12
        'model/lr-wpan-mac-trailer.cc',
12
        'model/lr-wpan-csmaca.cc',
13
        'model/lr-wpan-csmaca.cc',
 Lines 36-41    Link Here 
36
        'model/lr-wpan-interference-helper.h',
37
        'model/lr-wpan-interference-helper.h',
37
        'model/lr-wpan-phy.h',
38
        'model/lr-wpan-phy.h',
38
        'model/lr-wpan-mac.h',
39
        'model/lr-wpan-mac.h',
40
        'model/lr-wpan-nullmac.h',
39
        'model/lr-wpan-mac-header.h',
41
        'model/lr-wpan-mac-header.h',
40
        'model/lr-wpan-mac-trailer.h',
42
        'model/lr-wpan-mac-trailer.h',
41
        'model/lr-wpan-csmaca.h',
43
        'model/lr-wpan-csmaca.h',

Return to bug 2816