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

(-)a/src/mesh/model/dot11s/peer-link-frame.cc (-21 / +404 lines)
26
26
27
namespace ns3 {
27
namespace ns3 {
28
namespace dot11s {
28
namespace dot11s {
29
NS_OBJECT_ENSURE_REGISTERED (PeerLinkFrameStart);
29
NS_OBJECT_ENSURE_REGISTERED (PeerLinkOpenStart);
30
30
31
PeerLinkFrameStart::PeerLinkFrameStart () :
31
PeerLinkOpenStart::PeerLinkOpenStart () :
32
  m_subtype (255), m_capability (0), m_aid (0), m_rates (SupportedRates ()), m_meshId (),
32
  m_subtype ((uint8_t)(WifiActionHeader::PEER_LINK_OPEN)), m_capability (0), m_aid (0), m_rates (SupportedRates ()), m_meshId (),
33
  m_config (IeConfiguration ())
33
  m_config (IeConfiguration ())
34
{
34
{
35
}
35
}
36
void
36
void
37
PeerLinkFrameStart::SetPlinkFrameSubtype (uint8_t subtype)
37
PeerLinkOpenStart::SetPlinkOpenStart (PeerLinkOpenStart::PlinkOpenStartFields fields)
38
{
39
  m_subtype = subtype;
40
}
41
void
42
PeerLinkFrameStart::SetPlinkFrameStart (PeerLinkFrameStart::PlinkFrameStartFields fields)
43
{
38
{
44
  m_subtype = fields.subtype;
39
  m_subtype = fields.subtype;
45
  
40
  
68
      //reasonCode not used here
63
      //reasonCode not used here
69
    }
64
    }
70
}
65
}
71
PeerLinkFrameStart::PlinkFrameStartFields
66
PeerLinkOpenStart::PlinkOpenStartFields
72
PeerLinkFrameStart::GetFields () const
67
PeerLinkOpenStart::GetFields () const
73
{
68
{
74
  PlinkFrameStartFields retval;
69
  PlinkOpenStartFields retval;
75
  /// \todo protocol version:
70
  /// \todo protocol version:
76
  retval.subtype = m_subtype;
71
  retval.subtype = m_subtype;
77
  retval.capability = m_capability;
72
  retval.capability = m_capability;
83
  return retval;
78
  return retval;
84
}
79
}
85
TypeId
80
TypeId
86
PeerLinkFrameStart::GetTypeId ()
81
PeerLinkOpenStart::GetTypeId ()
87
{
82
{
88
  static TypeId tid = TypeId ("ns3::dot11s::PeerLinkFrameStart")
83
  static TypeId tid = TypeId ("ns3::dot11s::PeerLinkOpenStart")
89
    .SetParent<Header> ()
84
    .SetParent<Header> ()
90
    .SetGroupName ("Mesh")
85
    .SetGroupName ("Mesh")
91
    .AddConstructor<PeerLinkFrameStart> ()
86
    .AddConstructor<PeerLinkOpenStart> ()
92
  ;
87
  ;
93
  return tid;
88
  return tid;
94
}
89
}
95
TypeId
90
TypeId
96
PeerLinkFrameStart::GetInstanceTypeId () const
91
PeerLinkOpenStart::GetInstanceTypeId () const
97
{
92
{
98
  return GetTypeId ();
93
  return GetTypeId ();
99
}
94
}
100
void
95
void
101
PeerLinkFrameStart::Print (std::ostream &os) const
96
PeerLinkOpenStart::Print (std::ostream &os) const
102
{
97
{
103
  os << "subtype = " << (uint16_t) m_subtype << std::endl << "capability = " << m_capability << std::endl << "laid = "
98
  os << "subtype = " << (uint16_t) m_subtype << std::endl << "capability = " << m_capability << std::endl << "laid = "
104
     << (uint16_t) m_aid << std::endl << "rates = " << m_rates << std::endl << "meshId = ";
99
     << (uint16_t) m_aid << std::endl << "rates = " << m_rates << std::endl << "meshId = ";
108
  os << std::endl << "reason code = " << m_reasonCode;
103
  os << std::endl << "reason code = " << m_reasonCode;
109
}
104
}
110
uint32_t
105
uint32_t
111
PeerLinkFrameStart::GetSerializedSize () const
106
PeerLinkOpenStart::GetSerializedSize () const
112
{
107
{
113
  uint32_t size =0; //Peering protocol
108
  uint32_t size =0; //Peering protocol
114
  NS_ASSERT (m_subtype < 4);
109
  NS_ASSERT (m_subtype < 4);
140
  return size;
135
  return size;
141
}
136
}
142
void
137
void
143
PeerLinkFrameStart::Serialize (Buffer::Iterator start) const
138
PeerLinkOpenStart::Serialize (Buffer::Iterator start) const
144
{
139
{
145
  Buffer::Iterator i = start;
140
  Buffer::Iterator i = start;
146
  NS_ASSERT (m_subtype < 4);
141
  NS_ASSERT (m_subtype < 4);
172
    }
167
    }
173
}
168
}
174
uint32_t
169
uint32_t
175
PeerLinkFrameStart::Deserialize (Buffer::Iterator start)
170
PeerLinkOpenStart::Deserialize (Buffer::Iterator start)
176
{
171
{
177
  Buffer::Iterator i = start;
172
  Buffer::Iterator i = start;
178
  NS_ASSERT (m_subtype < 4);
173
  NS_ASSERT (m_subtype < 4);
219
  return i.GetDistanceFrom (start);
214
  return i.GetDistanceFrom (start);
220
}
215
}
221
bool
216
bool
222
operator== (const PeerLinkFrameStart & a, const PeerLinkFrameStart & b)
217
operator== (const PeerLinkOpenStart & a, const PeerLinkOpenStart & b)
218
{
219
  return ((a.m_subtype == b.m_subtype) && (a.m_capability == b.m_capability) && (a.m_aid == b.m_aid)
220
          && (a.m_meshId.IsEqual (b.m_meshId)) && (a.m_config == b.m_config));
221
  
222
}
223
NS_OBJECT_ENSURE_REGISTERED (PeerLinkCloseStart);
224
225
PeerLinkCloseStart::PeerLinkCloseStart () :
226
  m_subtype ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE)), m_capability (0), m_aid (0), m_rates (SupportedRates ()), m_meshId (),
227
  m_config (IeConfiguration ())
228
{
229
}
230
void
231
PeerLinkCloseStart::SetPlinkCloseStart (PeerLinkCloseStart::PlinkCloseStartFields fields)
232
{
233
  m_subtype = fields.subtype;
234
  
235
  if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE))
236
    {
237
      m_capability = fields.capability;
238
    }
239
  if (m_subtype == (uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM))
240
    {
241
      m_aid = fields.aid;
242
    }
243
  if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE))
244
    {
245
      m_rates = fields.rates;
246
    }
247
  if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM))
248
    {
249
      m_meshId = fields.meshId;
250
    }
251
  if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE))
252
    {
253
      m_config = fields.config;
254
    }
255
  else
256
    {
257
      //reasonCode not used here
258
    }
259
}
260
PeerLinkCloseStart::PlinkCloseStartFields
261
PeerLinkCloseStart::GetFields () const
262
{
263
  PlinkCloseStartFields retval;
264
  /// \todo protocol version:
265
  retval.subtype = m_subtype;
266
  retval.capability = m_capability;
267
  retval.aid = m_aid;
268
  retval.rates = m_rates;
269
  retval.meshId = m_meshId;
270
  retval.config = m_config;
271
  
272
  return retval;
273
}
274
TypeId
275
PeerLinkCloseStart::GetTypeId ()
276
{
277
  static TypeId tid = TypeId ("ns3::dot11s::PeerLinkCloseStart")
278
    .SetParent<Header> ()
279
    .SetGroupName ("Mesh")
280
    .AddConstructor<PeerLinkCloseStart> ()
281
  ;
282
  return tid;
283
}
284
TypeId
285
PeerLinkCloseStart::GetInstanceTypeId () const
286
{
287
  return GetTypeId ();
288
}
289
void
290
PeerLinkCloseStart::Print (std::ostream &os) const
291
{
292
  os << "subtype = " << (uint16_t) m_subtype << std::endl << "capability = " << m_capability << std::endl << "laid = "
293
     << (uint16_t) m_aid << std::endl << "rates = " << m_rates << std::endl << "meshId = ";
294
  m_meshId.Print (os);
295
  os << std::endl << "configuration = ";
296
  m_config.Print (os);
297
  os << std::endl << "reason code = " << m_reasonCode;
298
}
299
uint32_t
300
PeerLinkCloseStart::GetSerializedSize () const
301
{
302
  uint32_t size =0; //Peering protocol
303
  NS_ASSERT (m_subtype < 4);
304
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
305
    {
306
      size += 2; //capability
307
    }
308
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype)
309
    {
310
      size += 2; //AID of remote peer
311
    }
312
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
313
    {
314
      size += m_rates.GetSerializedSize ();
315
      size += m_rates.extended.GetSerializedSize ();
316
    }
317
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype)
318
    {
319
      size += m_meshId.GetInformationFieldSize () + 2;
320
    }
321
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
322
    {
323
      size += m_config.GetInformationFieldSize () + 2;
324
    }
325
  else
326
    {
327
      //reasonCode not used here
328
    }
329
  return size;
330
}
331
void
332
PeerLinkCloseStart::Serialize (Buffer::Iterator start) const
333
{
334
  Buffer::Iterator i = start;
335
  NS_ASSERT (m_subtype < 4);
336
  
337
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
338
    {
339
      i.WriteHtolsbU16 (m_capability);
340
    }
341
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype)
342
    {
343
      i.WriteHtolsbU16 (m_aid);
344
    }
345
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
346
    {
347
      i = m_rates.Serialize (i);
348
      i = m_rates.extended.Serialize (i);
349
    }
350
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype)
351
    {
352
      i = m_meshId.Serialize (i);
353
    }
354
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
355
    {
356
      i = m_config.Serialize (i);
357
    }
358
  else
359
    {
360
      //reasonCode not used here
361
    }
362
}
363
uint32_t
364
PeerLinkCloseStart::Deserialize (Buffer::Iterator start)
365
{
366
  Buffer::Iterator i = start;
367
  NS_ASSERT (m_subtype < 4);
368
  
369
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
370
    {
371
      m_capability = i.ReadLsbtohU16 ();
372
    }
373
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype)
374
    {
375
      m_aid = i.ReadLsbtohU16 ();
376
    }
377
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
378
    {
379
      i = m_rates.Deserialize (i);
380
      i = m_rates.extended.DeserializeIfPresent (i);
381
    }
382
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype)
383
    {
384
      uint8_t id = i.ReadU8 ();
385
      uint8_t length = i.ReadU8 ();
386
      m_meshId.DeserializeInformationField (i, length);
387
      if ((m_meshId.ElementId () != (WifiInformationElementId) id) || (m_meshId.GetInformationFieldSize () != length))
388
        {
389
          NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
390
        }
391
      i.Next (m_meshId.GetInformationFieldSize ());
392
    }
393
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
394
    {
395
      uint8_t id = i.ReadU8 ();
396
      uint8_t length = i.ReadU8 ();
397
      m_config.DeserializeInformationField (i, length);
398
      if ((m_config.ElementId () != (WifiInformationElementId) id) || (m_config.GetInformationFieldSize () != length))
399
        {
400
          NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
401
        }
402
      i.Next (m_config.GetInformationFieldSize ());
403
    }
404
  else
405
    {
406
       //reasonCode not used here
407
    }
408
  return i.GetDistanceFrom (start);
409
}
410
bool
411
operator== (const PeerLinkCloseStart & a, const PeerLinkCloseStart & b)
412
{
413
  return ((a.m_subtype == b.m_subtype) && (a.m_capability == b.m_capability) && (a.m_aid == b.m_aid)
414
          && (a.m_meshId.IsEqual (b.m_meshId)) && (a.m_config == b.m_config));
415
  
416
}
417
NS_OBJECT_ENSURE_REGISTERED (PeerLinkConfirmStart);
418
419
PeerLinkConfirmStart::PeerLinkConfirmStart () :
420
  m_subtype ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM)), m_capability (0), m_aid (0), m_rates (SupportedRates ()), m_meshId (),
421
  m_config (IeConfiguration ())
422
{
423
}
424
void
425
PeerLinkConfirmStart::SetPlinkConfirmStart (PeerLinkConfirmStart::PlinkConfirmStartFields fields)
426
{
427
  m_subtype = fields.subtype;
428
  
429
  if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE))
430
    {
431
      m_capability = fields.capability;
432
    }
433
  if (m_subtype == (uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM))
434
    {
435
      m_aid = fields.aid;
436
    }
437
  if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE))
438
    {
439
      m_rates = fields.rates;
440
    }
441
  if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM))
442
    {
443
      m_meshId = fields.meshId;
444
    }
445
  if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE))
446
    {
447
      m_config = fields.config;
448
    }
449
  else
450
    {
451
      //reasonCode not used here
452
    }
453
}
454
PeerLinkConfirmStart::PlinkConfirmStartFields
455
PeerLinkConfirmStart::GetFields () const
456
{
457
  PlinkConfirmStartFields retval;
458
  /// \todo protocol version:
459
  retval.subtype = m_subtype;
460
  retval.capability = m_capability;
461
  retval.aid = m_aid;
462
  retval.rates = m_rates;
463
  retval.meshId = m_meshId;
464
  retval.config = m_config;
465
  
466
  return retval;
467
}
468
TypeId
469
PeerLinkConfirmStart::GetTypeId ()
470
{
471
  static TypeId tid = TypeId ("ns3::dot11s::PeerLinkConfirmStart")
472
    .SetParent<Header> ()
473
    .SetGroupName ("Mesh")
474
    .AddConstructor<PeerLinkConfirmStart> ()
475
  ;
476
  return tid;
477
}
478
TypeId
479
PeerLinkConfirmStart::GetInstanceTypeId () const
480
{
481
  return GetTypeId ();
482
}
483
void
484
PeerLinkConfirmStart::Print (std::ostream &os) const
485
{
486
  os << "subtype = " << (uint16_t) m_subtype << std::endl << "capability = " << m_capability << std::endl << "laid = "
487
     << (uint16_t) m_aid << std::endl << "rates = " << m_rates << std::endl << "meshId = ";
488
  m_meshId.Print (os);
489
  os << std::endl << "configuration = ";
490
  m_config.Print (os);
491
  os << std::endl << "reason code = " << m_reasonCode;
492
}
493
uint32_t
494
PeerLinkConfirmStart::GetSerializedSize () const
495
{
496
  uint32_t size =0; //Peering protocol
497
  NS_ASSERT (m_subtype < 4);
498
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
499
    {
500
      size += 2; //capability
501
    }
502
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype)
503
    {
504
      size += 2; //AID of remote peer
505
    }
506
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
507
    {
508
      size += m_rates.GetSerializedSize ();
509
      size += m_rates.extended.GetSerializedSize ();
510
    }
511
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype)
512
    {
513
      size += m_meshId.GetInformationFieldSize () + 2;
514
    }
515
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
516
    {
517
      size += m_config.GetInformationFieldSize () + 2;
518
    }
519
  else
520
    {
521
      //reasonCode not used here
522
    }
523
  return size;
524
}
525
void
526
PeerLinkConfirmStart::Serialize (Buffer::Iterator start) const
527
{
528
  Buffer::Iterator i = start;
529
  NS_ASSERT (m_subtype < 4);
530
  
531
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
532
    {
533
      i.WriteHtolsbU16 (m_capability);
534
    }
535
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype)
536
    {
537
      i.WriteHtolsbU16 (m_aid);
538
    }
539
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
540
    {
541
      i = m_rates.Serialize (i);
542
      i = m_rates.extended.Serialize (i);
543
    }
544
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype)
545
    {
546
      i = m_meshId.Serialize (i);
547
    }
548
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
549
    {
550
      i = m_config.Serialize (i);
551
    }
552
  else
553
    {
554
      //reasonCode not used here
555
    }
556
}
557
uint32_t
558
PeerLinkConfirmStart::Deserialize (Buffer::Iterator start)
559
{
560
  Buffer::Iterator i = start;
561
  NS_ASSERT (m_subtype < 4);
562
  
563
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
564
    {
565
      m_capability = i.ReadLsbtohU16 ();
566
    }
567
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype)
568
    {
569
      m_aid = i.ReadLsbtohU16 ();
570
    }
571
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
572
    {
573
      i = m_rates.Deserialize (i);
574
      i = m_rates.extended.DeserializeIfPresent (i);
575
    }
576
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype)
577
    {
578
      uint8_t id = i.ReadU8 ();
579
      uint8_t length = i.ReadU8 ();
580
      m_meshId.DeserializeInformationField (i, length);
581
      if ((m_meshId.ElementId () != (WifiInformationElementId) id) || (m_meshId.GetInformationFieldSize () != length))
582
        {
583
          NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
584
        }
585
      i.Next (m_meshId.GetInformationFieldSize ());
586
    }
587
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
588
    {
589
      uint8_t id = i.ReadU8 ();
590
      uint8_t length = i.ReadU8 ();
591
      m_config.DeserializeInformationField (i, length);
592
      if ((m_config.ElementId () != (WifiInformationElementId) id) || (m_config.GetInformationFieldSize () != length))
593
        {
594
          NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
595
        }
596
      i.Next (m_config.GetInformationFieldSize ());
597
    }
598
  else
599
    {
600
       //reasonCode not used here
601
    }
602
  return i.GetDistanceFrom (start);
603
}
604
bool
605
operator== (const PeerLinkConfirmStart & a, const PeerLinkConfirmStart & b)
223
{
606
{
224
  return ((a.m_subtype == b.m_subtype) && (a.m_capability == b.m_capability) && (a.m_aid == b.m_aid)
607
  return ((a.m_subtype == b.m_subtype) && (a.m_capability == b.m_capability) && (a.m_aid == b.m_aid)
225
          && (a.m_meshId.IsEqual (b.m_meshId)) && (a.m_config == b.m_config));
608
          && (a.m_meshId.IsEqual (b.m_meshId)) && (a.m_config == b.m_config));
(-)a/src/mesh/model/dot11s/peer-link-frame.h (-14 / +123 lines)
28
#include "ie-dot11s-id.h"
28
#include "ie-dot11s-id.h"
29
namespace ns3
29
namespace ns3
30
{
30
{
31
class MeshWifiInterfaceMac;
32
namespace dot11s
31
namespace dot11s
33
{
32
{
34
/**
33
/**
35
 * \ingroup dot11s
34
 * \ingroup dot11s
36
 *
35
 *
37
 * \brief 802.11s Peer link management frame
36
 * \brief 802.11s Peer link open management frame
38
 * 
37
 * 
39
 * Peer link management frame included the following (see chapters 7.4.12.1-7.4.12.3 of 802.11s):
38
 * Peer link management frame included the following (see chapters 7.4.12.1-7.4.12.3 of 802.11s):
40
 * - Subtype field
39
 * - Subtype field
42
 * - Supported rates
41
 * - Supported rates
43
 * - Mesh ID of mesh
42
 * - Mesh ID of mesh
44
 */
43
 */
45
class PeerLinkFrameStart : public Header
44
class PeerLinkOpenStart : public Header
46
{
45
{
47
public:
46
public:
48
  PeerLinkFrameStart ();
47
  PeerLinkOpenStart ();
49
  ///\brief fields:
48
  ///\brief fields:
50
  struct PlinkFrameStartFields
49
  struct PlinkOpenStartFields
51
  {
50
  {
52
    uint8_t subtype;
51
    uint8_t subtype;
53
    IePeeringProtocol protocol; //Peering protocol version - in all subtypes - 3 octets
52
    IePeeringProtocol protocol; //Peering protocol version - in all subtypes - 3 octets
58
    IeConfiguration config;     //open and confirm
57
    IeConfiguration config;     //open and confirm
59
    uint16_t reasonCode;        //close only
58
    uint16_t reasonCode;        //close only
60
  };
59
  };
61
  ///\attention: must be set before deserialize, before only multihop
60
  void SetPlinkOpenStart (PlinkOpenStartFields);
62
  //action header knows about subtype
61
  PlinkOpenStartFields GetFields () const;
63
  void SetPlinkFrameSubtype (uint8_t subtype);
64
  void SetPlinkFrameStart (PlinkFrameStartFields);
65
  PlinkFrameStartFields GetFields () const;
66
62
67
  // Inherited from header:
63
  // Inherited from header:
68
  static  TypeId   GetTypeId ();
64
  static  TypeId   GetTypeId ();
82
  IeConfiguration m_config;
78
  IeConfiguration m_config;
83
  uint16_t m_reasonCode;
79
  uint16_t m_reasonCode;
84
80
85
  friend bool operator== (const PeerLinkFrameStart & a, const PeerLinkFrameStart & b);
81
  friend bool operator== (const PeerLinkOpenStart & a, const PeerLinkOpenStart & b);
86
82
87
  PeerLinkFrameStart& operator= (const PeerLinkFrameStart &);
83
  PeerLinkOpenStart& operator= (const PeerLinkOpenStart &);
88
  PeerLinkFrameStart (const PeerLinkFrameStart &);
84
  PeerLinkOpenStart (const PeerLinkOpenStart &);
89
85
90
};
86
};
91
bool operator== (const PeerLinkFrameStart & a, const PeerLinkFrameStart & b);
87
88
bool operator== (const PeerLinkOpenStart & a, const PeerLinkOpenStart & b);
89
90
/**
91
 * \ingroup dot11s
92
 *
93
 * \brief 802.11s Peer link close management frame
94
 * 
95
 * Peer link management frame included the following (see chapters 7.4.12.1-7.4.12.3 of 802.11s):
96
 * - Subtype field
97
 * - Association ID field
98
 * - Supported rates
99
 * - Mesh ID of mesh
100
 */
101
class PeerLinkCloseStart : public Header
102
{
103
public:
104
  PeerLinkCloseStart ();
105
  ///\brief fields:
106
  struct PlinkCloseStartFields
107
  {
108
    uint8_t subtype;
109
    IePeeringProtocol protocol; //Peering protocol version - in all subtypes - 3 octets
110
    uint16_t capability;        //open and confirm
111
    uint16_t aid;               //confirm only
112
    SupportedRates rates;       //open and confirm
113
    IeMeshId meshId;            //open and close
114
    IeConfiguration config;     //open and confirm
115
    uint16_t reasonCode;        //close only
116
  };
117
  void SetPlinkCloseStart (PlinkCloseStartFields);
118
  PlinkCloseStartFields GetFields () const;
119
120
  // Inherited from header:
121
  static  TypeId   GetTypeId ();
122
  virtual TypeId   GetInstanceTypeId () const;
123
  virtual void     Print (std::ostream &os) const;
124
  virtual uint32_t GetSerializedSize () const;
125
  virtual void     Serialize (Buffer::Iterator start) const;
126
  virtual uint32_t Deserialize (Buffer::Iterator start);
127
128
private:
129
  uint8_t m_subtype;
130
  IePeeringProtocol m_protocol;
131
  uint16_t m_capability;
132
  uint16_t m_aid;
133
  SupportedRates m_rates;
134
  IeMeshId m_meshId;
135
  IeConfiguration m_config;
136
  uint16_t m_reasonCode;
137
138
  friend bool operator== (const PeerLinkCloseStart & a, const PeerLinkCloseStart & b);
139
140
  PeerLinkCloseStart& operator= (const PeerLinkCloseStart &);
141
  PeerLinkCloseStart (const PeerLinkCloseStart &);
142
143
};
144
bool operator== (const PeerLinkCloseStart & a, const PeerLinkCloseStart & b);
145
146
/**
147
 * \ingroup dot11s
148
 *
149
 * \brief 802.11s Peer link confirm management frame
150
 * 
151
 * Peer link management frame included the following (see chapters 7.4.12.1-7.4.12.3 of 802.11s):
152
 * - Subtype field
153
 * - Association ID field
154
 * - Supported rates
155
 * - Mesh ID of mesh
156
 */
157
class PeerLinkConfirmStart : public Header
158
{
159
public:
160
  PeerLinkConfirmStart ();
161
  ///\brief fields:
162
  struct PlinkConfirmStartFields
163
  {
164
    uint8_t subtype;
165
    IePeeringProtocol protocol; //Peering protocol version - in all subtypes - 3 octets
166
    uint16_t capability;        //open and confirm
167
    uint16_t aid;               //confirm only
168
    SupportedRates rates;       //open and confirm
169
    IeMeshId meshId;            //open and close
170
    IeConfiguration config;     //open and confirm
171
    uint16_t reasonCode;        //close only
172
  };
173
  void SetPlinkConfirmStart (PlinkConfirmStartFields);
174
  PlinkConfirmStartFields GetFields () const;
175
176
  // Inherited from header:
177
  static  TypeId   GetTypeId ();
178
  virtual TypeId   GetInstanceTypeId () const;
179
  virtual void     Print (std::ostream &os) const;
180
  virtual uint32_t GetSerializedSize () const;
181
  virtual void     Serialize (Buffer::Iterator start) const;
182
  virtual uint32_t Deserialize (Buffer::Iterator start);
183
184
private:
185
  uint8_t m_subtype;
186
  IePeeringProtocol m_protocol;
187
  uint16_t m_capability;
188
  uint16_t m_aid;
189
  SupportedRates m_rates;
190
  IeMeshId m_meshId;
191
  IeConfiguration m_config;
192
  uint16_t m_reasonCode;
193
194
  friend bool operator== (const PeerLinkConfirmStart & a, const PeerLinkConfirmStart & b);
195
196
  PeerLinkConfirmStart& operator= (const PeerLinkConfirmStart &);
197
  PeerLinkConfirmStart (const PeerLinkConfirmStart &);
198
199
};
200
bool operator== (const PeerLinkConfirmStart & a, const PeerLinkConfirmStart & b);
92
} // namespace dot11s
201
} // namespace dot11s
93
} // namespace ns3
202
} // namespace ns3
94
#endif
203
#endif
(-)a/src/mesh/model/dot11s/peer-management-protocol-mac.cc (-32 / +92 lines)
 Lines 82-87    Link Here 
82
      // Beacon shall not be dropped. May be needed to another plugins
82
      // Beacon shall not be dropped. May be needed to another plugins
83
      return true;
83
      return true;
84
    }
84
    }
85
  uint16_t aid;
86
  IeConfiguration config;
85
  if (header.IsAction ())
87
  if (header.IsAction ())
86
    {
88
    {
87
      WifiActionHeader actionHdr;
89
      WifiActionHeader actionHdr;
 Lines 96-123    Link Here 
96
      m_stats.rxMgtBytes += packet->GetSize ();
98
      m_stats.rxMgtBytes += packet->GetSize ();
97
      Mac48Address peerAddress = header.GetAddr2 ();
99
      Mac48Address peerAddress = header.GetAddr2 ();
98
      Mac48Address peerMpAddress = header.GetAddr3 ();
100
      Mac48Address peerMpAddress = header.GetAddr3 ();
99
      PeerLinkFrameStart::PlinkFrameStartFields fields;
101
      if (actionValue.selfProtectedAction == WifiActionHeader::PEER_LINK_OPEN)
100
      {
101
        PeerLinkFrameStart peerFrame;
102
        peerFrame.SetPlinkFrameSubtype ((uint8_t) actionValue.selfProtectedAction);
103
        packet->RemoveHeader (peerFrame);
104
        fields = peerFrame.GetFields ();
105
        NS_ASSERT (fields.subtype == actionValue.selfProtectedAction); 
106
      }
107
      if ((actionValue.selfProtectedAction != WifiActionHeader::PEER_LINK_CLOSE) && !(m_parent->CheckSupportedRates (fields.rates))) 
108
        {
102
        {
109
          m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
103
          PeerLinkOpenStart::PlinkOpenStartFields fields;
110
          // Broken peer link frame - drop it
104
          PeerLinkOpenStart peerFrame;
111
          m_stats.brokenMgt++;
105
          packet->RemoveHeader (peerFrame);
112
          return false;
106
          fields = peerFrame.GetFields ();
107
          NS_ASSERT (fields.subtype == actionValue.selfProtectedAction); 
108
          if (!fields.meshId.IsEqual ( *(m_protocol->GetMeshId ())))
109
            {
110
              m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
111
              // Broken peer link frame - drop it
112
              m_stats.brokenMgt++;
113
              return false;
114
            }
115
          if (!(m_parent->CheckSupportedRates (fields.rates)))
116
            {
117
              m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
118
              // Broken peer link frame - drop it
119
              m_stats.brokenMgt++;
120
              return false;
121
            }
122
          aid = fields.aid;
123
          config = fields.config;
113
        }
124
        }
114
     if ((actionValue.selfProtectedAction != WifiActionHeader::PEER_LINK_CONFIRM) && !fields.meshId.IsEqual (
125
      else if (actionValue.selfProtectedAction == WifiActionHeader::PEER_LINK_CONFIRM)
115
            *(m_protocol->GetMeshId ())))
116
        {
126
        {
117
          m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
127
          PeerLinkConfirmStart::PlinkConfirmStartFields fields;
118
          // Broken peer link frame - drop it
128
          PeerLinkConfirmStart peerFrame;
119
          m_stats.brokenMgt++;
129
          packet->RemoveHeader (peerFrame);
120
          return false;
130
          fields = peerFrame.GetFields ();
131
          NS_ASSERT (fields.subtype == actionValue.selfProtectedAction); 
132
          if (!(m_parent->CheckSupportedRates (fields.rates)))
133
            {
134
              m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
135
              // Broken peer link frame - drop it
136
              m_stats.brokenMgt++;
137
              return false;
138
            }
139
          aid = fields.aid;
140
          config = fields.config;
141
        }
142
      else if (actionValue.selfProtectedAction == WifiActionHeader::PEER_LINK_CLOSE)
143
        {
144
          PeerLinkCloseStart::PlinkCloseStartFields fields;
145
          PeerLinkCloseStart peerFrame;
146
          packet->RemoveHeader (peerFrame);
147
          fields = peerFrame.GetFields ();
148
          NS_ASSERT (fields.subtype == actionValue.selfProtectedAction); 
149
          if (!fields.meshId.IsEqual ( *(m_protocol->GetMeshId ())))
150
            {
151
              m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
152
              // Broken peer link frame - drop it
153
              m_stats.brokenMgt++;
154
              return false;
155
            }
156
          aid = fields.aid;
157
          config = fields.config;
158
        }
159
      else
160
        {
161
          NS_FATAL_ERROR ("Unknown subtype" << actionValue.selfProtectedAction);
121
        }
162
        }
122
      Ptr<IePeerManagement> peerElement;
163
      Ptr<IePeerManagement> peerElement;
123
      //Peer Management element is the last element in this frame - so, we can use MeshInformationElementVector
164
      //Peer Management element is the last element in this frame - so, we can use MeshInformationElementVector
 Lines 143-150    Link Here 
143
           NS_ASSERT (actionValue.selfProtectedAction == WifiActionHeader::PEER_LINK_CLOSE); 
184
           NS_ASSERT (actionValue.selfProtectedAction == WifiActionHeader::PEER_LINK_CLOSE); 
144
        }
185
        }
145
      //Deliver Peer link management frame to protocol:
186
      //Deliver Peer link management frame to protocol:
146
      m_protocol->ReceivePeerLinkFrame (m_ifIndex, peerAddress, peerMpAddress, fields.aid, *peerElement,
187
      m_protocol->ReceivePeerLinkFrame (m_ifIndex, peerAddress, peerMpAddress, aid, *peerElement, config);
147
                                        fields.config);
148
      // if we can handle a frame - drop it
188
      // if we can handle a frame - drop it
149
      return false;
189
      return false;
150
    }
190
    }
 Lines 202-245    Link Here 
202
  MeshInformationElementVector elements;
242
  MeshInformationElementVector elements;
203
  elements.AddInformationElement (Ptr<IePeerManagement> (&peerElement));
243
  elements.AddInformationElement (Ptr<IePeerManagement> (&peerElement));
204
  packet->AddHeader (elements);
244
  packet->AddHeader (elements);
205
  PeerLinkFrameStart::PlinkFrameStartFields fields;
206
  fields.rates = m_parent->GetSupportedRates ();
207
  fields.capability = 0;
208
  fields.meshId = *(m_protocol->GetMeshId ());
209
  fields.config = meshConfig;
210
  PeerLinkFrameStart plinkFrame;
211
  //Create an 802.11 frame header:
245
  //Create an 802.11 frame header:
212
  //Send management frame to MAC:
246
  //Send management frame to MAC:
213
  WifiActionHeader actionHdr;
214
  if (peerElement.SubtypeIsOpen ())
247
  if (peerElement.SubtypeIsOpen ())
215
    {
248
    {
249
      PeerLinkOpenStart::PlinkOpenStartFields fields;
250
      fields.rates = m_parent->GetSupportedRates ();
251
      fields.capability = 0;
252
      fields.meshId = *(m_protocol->GetMeshId ());
253
      fields.config = meshConfig;
254
      PeerLinkOpenStart plinkOpen;
255
      WifiActionHeader actionHdr;
216
      m_stats.txOpen++;
256
      m_stats.txOpen++;
217
      WifiActionHeader::ActionValue action;
257
      WifiActionHeader::ActionValue action;
218
      action.selfProtectedAction = WifiActionHeader::PEER_LINK_OPEN;
258
      action.selfProtectedAction = WifiActionHeader::PEER_LINK_OPEN;
219
      fields.subtype = WifiActionHeader::PEER_LINK_OPEN;
259
      fields.subtype = WifiActionHeader::PEER_LINK_OPEN;
220
      actionHdr.SetAction (WifiActionHeader::SELF_PROTECTED, action); 
260
      actionHdr.SetAction (WifiActionHeader::SELF_PROTECTED, action); 
261
      plinkOpen.SetPlinkOpenStart (fields);
262
      packet->AddHeader (plinkOpen);
263
      packet->AddHeader (actionHdr);
221
    }
264
    }
222
  if (peerElement.SubtypeIsConfirm ())
265
  if (peerElement.SubtypeIsConfirm ())
223
    {
266
    {
267
      PeerLinkConfirmStart::PlinkConfirmStartFields fields;
268
      fields.rates = m_parent->GetSupportedRates ();
269
      fields.capability = 0;
270
      fields.meshId = *(m_protocol->GetMeshId ());
271
      fields.config = meshConfig;
272
      PeerLinkConfirmStart plinkConfirm;
273
      WifiActionHeader actionHdr;
224
      m_stats.txConfirm++;
274
      m_stats.txConfirm++;
225
      WifiActionHeader::ActionValue action;
275
      WifiActionHeader::ActionValue action;
226
       action.selfProtectedAction = WifiActionHeader::PEER_LINK_CONFIRM; 
276
      action.selfProtectedAction = WifiActionHeader::PEER_LINK_CONFIRM; 
227
      fields.aid = aid;
277
      fields.aid = aid;
228
      fields.subtype = WifiActionHeader::PEER_LINK_CONFIRM;
278
      fields.subtype = WifiActionHeader::PEER_LINK_CONFIRM;
229
      actionHdr.SetAction (WifiActionHeader::SELF_PROTECTED, action); 
279
      actionHdr.SetAction (WifiActionHeader::SELF_PROTECTED, action); 
280
      plinkConfirm.SetPlinkConfirmStart (fields);
281
      packet->AddHeader (plinkConfirm);
282
      packet->AddHeader (actionHdr);
230
    }
283
    }
231
  if (peerElement.SubtypeIsClose ())
284
  if (peerElement.SubtypeIsClose ())
232
    {
285
    {
286
      PeerLinkCloseStart::PlinkCloseStartFields fields;
287
      fields.rates = m_parent->GetSupportedRates ();
288
      fields.capability = 0;
289
      fields.meshId = *(m_protocol->GetMeshId ());
290
      fields.config = meshConfig;
291
      PeerLinkCloseStart plinkClose;
292
      WifiActionHeader actionHdr;
233
      m_stats.txClose++;
293
      m_stats.txClose++;
234
      WifiActionHeader::ActionValue action;
294
      WifiActionHeader::ActionValue action;
235
      action.selfProtectedAction = WifiActionHeader::PEER_LINK_CLOSE; 
295
      action.selfProtectedAction = WifiActionHeader::PEER_LINK_CLOSE; 
236
      fields.subtype = WifiActionHeader::PEER_LINK_CLOSE;
296
      fields.subtype = WifiActionHeader::PEER_LINK_CLOSE;
237
      fields.reasonCode = peerElement.GetReasonCode ();
297
      fields.reasonCode = peerElement.GetReasonCode ();
238
      actionHdr.SetAction (WifiActionHeader::SELF_PROTECTED, action); 
298
      actionHdr.SetAction (WifiActionHeader::SELF_PROTECTED, action); 
299
      plinkClose.SetPlinkCloseStart (fields);
300
      packet->AddHeader (plinkClose);
301
      packet->AddHeader (actionHdr);
239
    }
302
    }
240
  plinkFrame.SetPlinkFrameStart (fields);
241
  packet->AddHeader (plinkFrame);
242
  packet->AddHeader (actionHdr);
243
  m_stats.txMgt++;
303
  m_stats.txMgt++;
244
  m_stats.txMgtBytes += packet->GetSize ();
304
  m_stats.txMgtBytes += packet->GetSize ();
245
  // Wifi Mac header:
305
  // Wifi Mac header:
(-)a/src/mesh/test/dot11s/dot11s-test-suite.cc (-15 / +12 lines)
 Lines 216-265    Link Here 
216
PeerLinkFrameStartTest::DoRun ()
216
PeerLinkFrameStartTest::DoRun ()
217
{
217
{
218
  {
218
  {
219
    PeerLinkFrameStart a;
219
    PeerLinkOpenStart a;
220
    PeerLinkFrameStart::PlinkFrameStartFields fields;
220
    PeerLinkOpenStart::PlinkOpenStartFields fields;
221
    fields.subtype = (uint8_t)(WifiActionHeader::PEER_LINK_OPEN);
221
    fields.subtype = (uint8_t)(WifiActionHeader::PEER_LINK_OPEN);
222
    fields.capability = 0;
222
    fields.capability = 0;
223
    fields.aid = 101;
223
    fields.aid = 101;
224
    fields.reasonCode = 12;
224
    fields.reasonCode = 12;
225
    fields.meshId = IeMeshId ("qwertyuiop");
225
    fields.meshId = IeMeshId ("qwertyuiop");
226
    a.SetPlinkFrameStart (fields);
226
    a.SetPlinkOpenStart (fields);
227
    Ptr<Packet> packet = Create<Packet> ();
227
    Ptr<Packet> packet = Create<Packet> ();
228
    packet->AddHeader (a);
228
    packet->AddHeader (a);
229
    PeerLinkFrameStart b;
229
    PeerLinkOpenStart b;
230
    b.SetPlinkFrameSubtype ((uint8_t)(WifiActionHeader::PEER_LINK_OPEN));
231
    packet->RemoveHeader (b);
230
    packet->RemoveHeader (b);
232
    NS_TEST_EXPECT_MSG_EQ (a, b, "PEER_LINK_OPEN works");
231
    NS_TEST_EXPECT_MSG_EQ (a, b, "PEER_LINK_OPEN works");
233
  }
232
  }
234
  {
233
  {
235
    PeerLinkFrameStart a;
234
    PeerLinkConfirmStart a;
236
    PeerLinkFrameStart::PlinkFrameStartFields fields;
235
    PeerLinkConfirmStart::PlinkConfirmStartFields fields;
237
    fields.subtype = (uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM);
236
    fields.subtype = (uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM);
238
    fields.capability = 0;
237
    fields.capability = 0;
239
    fields.aid = 1234;
238
    fields.aid = 1234;
240
    fields.reasonCode = 12;
239
    fields.reasonCode = 12;
241
    fields.meshId = IeMeshId ("qwerty");
240
    fields.meshId = IeMeshId ("qwerty");
242
    a.SetPlinkFrameStart (fields);
241
    a.SetPlinkConfirmStart (fields);
243
    Ptr<Packet> packet = Create<Packet> ();
242
    Ptr<Packet> packet = Create<Packet> ();
244
    packet->AddHeader (a);
243
    packet->AddHeader (a);
245
    PeerLinkFrameStart b;
244
    PeerLinkConfirmStart b;
246
    b.SetPlinkFrameSubtype ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM));
247
    packet->RemoveHeader (b);
245
    packet->RemoveHeader (b);
248
    NS_TEST_EXPECT_MSG_EQ (a, b, "PEER_LINK_CONFIRM works");
246
    NS_TEST_EXPECT_MSG_EQ (a, b, "PEER_LINK_CONFIRM works");
249
  }
247
  }
250
  {
248
  {
251
    PeerLinkFrameStart a;
249
    PeerLinkCloseStart a;
252
    PeerLinkFrameStart::PlinkFrameStartFields fields;
250
    PeerLinkCloseStart::PlinkCloseStartFields fields;
253
    fields.subtype = (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE);
251
    fields.subtype = (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE);
254
    fields.capability = 0;
252
    fields.capability = 0;
255
    fields.aid = 10;
253
    fields.aid = 10;
256
    fields.meshId = IeMeshId ("qqq");
254
    fields.meshId = IeMeshId ("qqq");
257
    fields.reasonCode = 12;
255
    fields.reasonCode = 12;
258
    a.SetPlinkFrameStart (fields);
256
    a.SetPlinkCloseStart (fields);
259
    Ptr<Packet> packet = Create<Packet> ();
257
    Ptr<Packet> packet = Create<Packet> ();
260
    packet->AddHeader (a);
258
    packet->AddHeader (a);
261
    PeerLinkFrameStart b;
259
    PeerLinkCloseStart b;
262
    b.SetPlinkFrameSubtype ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE));
263
    packet->RemoveHeader (b);
260
    packet->RemoveHeader (b);
264
    NS_TEST_EXPECT_MSG_EQ (a, b, "PEER_LINK_CLOSE works");
261
    NS_TEST_EXPECT_MSG_EQ (a, b, "PEER_LINK_CLOSE works");
265
  }
262
  }

Return to bug 1482