A Discrete-Event Network Simulator
API
sixlowpan-header.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 Universita' di Firenze, Italy
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  * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
19  * Michele Muccio <michelemuccio@virgilio.it>
20  */
21 
22 #include "ns3/assert.h"
23 #include "ns3/log.h"
24 #include "ns3/abort.h"
25 #include "ns3/ipv6-header.h"
26 #include "ns3/mac64-address.h"
27 #include "ns3/mac16-address.h"
28 #include "ns3/ipv6-header.h"
29 #include "sixlowpan-header.h"
30 
31 
32 namespace ns3 {
33 
34 /*
35  * SixLowPanDispatch
36  */
37 
38 
40 {
41 }
42 
43 
46 {
47  if (dispatch <= LOWPAN_NALP_N)
48  {
49  return LOWPAN_NALP;
50  }
51  else if (dispatch == LOWPAN_IPv6)
52  {
53  return LOWPAN_IPv6;
54  }
55  else if (dispatch == LOWPAN_HC1)
56  {
57  return LOWPAN_HC1;
58  }
59  else if (dispatch == LOWPAN_BC0)
60  {
61  return LOWPAN_BC0;
62  }
63  else if ((dispatch >= LOWPAN_IPHC) && (dispatch <= LOWPAN_IPHC_N))
64  {
65  return LOWPAN_IPHC;
66  }
67  else if ((dispatch >= LOWPAN_MESH) && (dispatch <= LOWPAN_MESH_N))
68  {
69  return LOWPAN_MESH;
70  }
71  else if ((dispatch >= LOWPAN_FRAG1) && (dispatch <= LOWPAN_FRAG1_N))
72  {
73  return LOWPAN_FRAG1;
74  }
75  else if ((dispatch >= LOWPAN_FRAGN) && (dispatch <= LOWPAN_FRAGN_N))
76  {
77  return LOWPAN_FRAGN;
78  }
79  return LOWPAN_UNSUPPORTED;
80 }
81 
84 {
85  if ((dispatch >= LOWPAN_NHC) && (dispatch <= LOWPAN_NHC_N))
86  {
87  return LOWPAN_NHC;
88  }
89  else if ((dispatch >= LOWPAN_UDPNHC) && (dispatch <= LOWPAN_UDPNHC_N))
90  {
91  return LOWPAN_UDPNHC;
92  }
93  return LOWPAN_NHCUNSUPPORTED;
94 }
95 
96 
97 /*
98  * SixLowPanHc1
99  */
101 
103  : m_hopLimit (0)
104 {
105 }
106 
108 {
109  static TypeId tid = TypeId ("ns3::SixLowPanHc1")
110  .SetParent<Header> ()
111  .SetGroupName ("SixLowPan")
112  .AddConstructor<SixLowPanHc1> ();
113  return tid;
114 }
115 
117 {
118  return GetTypeId ();
119 }
120 
121 void SixLowPanHc1::Print (std::ostream & os) const
122 {
123  uint8_t encoding;
124  encoding = m_srcCompression;
125  encoding <<= 2;
126  encoding |= m_dstCompression;
127  encoding <<= 1;
128  encoding |= m_tcflCompression;
129  encoding <<= 2;
130  encoding |= m_nextHeaderCompression;
131  encoding <<= 1;
132  encoding |= m_hc2HeaderPresent;
133 
134  os << "encoding " << +encoding << ", hopLimit " << +m_hopLimit;
135 }
136 
138 {
139  uint32_t serializedSize = 3;
140 
141  switch (m_srcCompression)
142  {
143  case HC1_PIII:
144  serializedSize += 16;
145  break;
146  case HC1_PIIC:
147  serializedSize += 8;
148  break;
149  case HC1_PCII:
150  serializedSize += 8;
151  break;
152  case HC1_PCIC:
153  break;
154  }
155  switch (m_dstCompression)
156  {
157  case HC1_PIII:
158  serializedSize += 16;
159  break;
160  case HC1_PIIC:
161  serializedSize += 8;
162  break;
163  case HC1_PCII:
164  serializedSize += 8;
165  break;
166  case HC1_PCIC:
167  break;
168  }
169 
170  if (m_tcflCompression == false )
171  {
172  serializedSize += 4;
173  }
174 
176  {
177  serializedSize++;
178  }
179 
180  return serializedSize;
181 }
182 
184 {
186  uint8_t encoding;
187  encoding = m_srcCompression;
188  encoding <<= 2;
189  encoding |= m_dstCompression;
190  encoding <<= 1;
191  encoding |= m_tcflCompression;
192  encoding <<= 2;
193  encoding |= m_nextHeaderCompression;
194  encoding <<= 1;
195  encoding |= m_hc2HeaderPresent;
196 
198  i.WriteU8 (encoding);
199  i.WriteU8 (m_hopLimit);
200  switch (m_srcCompression)
201  {
202  case HC1_PIII:
203  for ( int j = 0; j < 8; j++ )
204  {
205  i.WriteU8 (m_srcPrefix[j]);
206  }
207  for ( int j = 0; j < 8; j++ )
208  {
209  i.WriteU8 (m_srcInterface[j]);
210  }
211  break;
212  case HC1_PIIC:
213  for ( int j = 0; j < 8; j++ )
214  {
215  i.WriteU8 (m_srcPrefix[j]);
216  }
217  break;
218  case HC1_PCII:
219  for ( int j = 0; j < 8; j++ )
220  {
221  i.WriteU8 (m_srcInterface[j]);
222  }
223  break;
224  case HC1_PCIC:
225  break;
226  }
227  switch (m_dstCompression)
228  {
229  case HC1_PIII:
230  for ( int j = 0; j < 8; j++ )
231  {
232  i.WriteU8 (m_dstPrefix[j]);
233  }
234  for ( int j = 0; j < 8; j++ )
235  {
236  i.WriteU8 (m_dstInterface[j]);
237  }
238  break;
239  case HC1_PIIC:
240  for ( int j = 0; j < 8; j++ )
241  {
242  i.WriteU8 (m_dstPrefix[j]);
243  }
244  break;
245  case HC1_PCII:
246  for ( int j = 0; j < 8; j++ )
247  {
248  i.WriteU8 (m_dstInterface[j]);
249  }
250  break;
251  case HC1_PCIC:
252  break;
253  }
254 
255  if ( m_tcflCompression == false )
256  {
258  uint8_t temp[3];
259  temp[0] = uint8_t (m_flowLabel & 0xff);
260  temp[1] = uint8_t ((m_flowLabel >> 8) & 0xff);
261  temp[2] = uint8_t ((m_flowLabel >> 16) & 0xff);
262  i.Write (temp, 3);
263  }
264 
266  {
267  i.WriteU8 (m_nextHeader);
268  }
269 
270  // TODO: HC2 is not yet supported. Should be.
271  NS_ASSERT_MSG ( m_hc2HeaderPresent != true, "Can not compress HC2, exiting. Very sorry." );
272 }
273 
275 {
277  uint32_t serializedSize = 3;
278 
279  uint8_t dispatch = i.ReadU8 ();
280  if (dispatch != SixLowPanDispatch::LOWPAN_HC1)
281  {
282  return 0;
283  }
284 
285  uint8_t encoding = i.ReadU8 ();
286  m_hopLimit = i.ReadU8 ();
287 
288  m_srcCompression = LowPanHc1Addr_e (encoding >> 6);
289  m_dstCompression = LowPanHc1Addr_e ( (encoding >> 4) & 0x3);
290  m_tcflCompression = (encoding >> 3) & 0x1;
291  m_nextHeaderCompression = LowPanHc1NextHeader_e ( (encoding >> 1) & 0x3);
292  m_hc2HeaderPresent = encoding & 0x1;
293 
294  switch (m_srcCompression)
295  {
296  case HC1_PIII:
297  for ( int j = 0; j < 8; j++)
298  {
299  m_srcPrefix[j] = i.ReadU8 ();
300  }
301  for ( int j = 0; j < 8; j++)
302  {
303  m_srcInterface[j] = i.ReadU8 ();
304  }
305  serializedSize += 16;
306  break;
307  case HC1_PIIC:
308  for ( int j = 0; j < 8; j++)
309  {
310  m_srcPrefix[j] = i.ReadU8 ();
311  }
312  serializedSize += 8;
313  break;
314  case HC1_PCII:
315  for ( int j = 0; j < 8; j++)
316  {
317  m_srcInterface[j] = i.ReadU8 ();
318  }
319  serializedSize += 8;
320  break;
321  case HC1_PCIC:
322  break;
323  }
324  switch (m_dstCompression)
325  {
326  case HC1_PIII:
327  for ( int j = 0; j < 8; j++)
328  {
329  m_dstPrefix[j] = i.ReadU8 ();
330  }
331  for ( int j = 0; j < 8; j++)
332  {
333  m_dstInterface[j] = i.ReadU8 ();
334  }
335  serializedSize += 16;
336  break;
337  case HC1_PIIC:
338  for ( int j = 0; j < 8; j++)
339  {
340  m_dstPrefix[j] = i.ReadU8 ();
341  }
342  serializedSize += 8;
343  break;
344  case HC1_PCII:
345  for ( int j = 0; j < 8; j++)
346  {
347  m_dstInterface[j] = i.ReadU8 ();
348  }
349  serializedSize += 8;
350  break;
351  case HC1_PCIC:
352  break;
353  }
354 
355  if ( m_tcflCompression == false )
356  {
357  m_trafficClass = i.ReadU8 ();
358  uint8_t temp[3];
359  i.Read (temp, 3);
360  m_flowLabel = temp[2];
361  m_flowLabel = (m_flowLabel << 8) | temp[1];
362  m_flowLabel = (m_flowLabel << 8) | temp[0];
363  serializedSize += 4;
364  }
365 
366  switch ( m_nextHeaderCompression )
367  {
368  case HC1_NC:
369  m_nextHeader = i.ReadU8 ();
370  serializedSize++;
371  break;
372  case HC1_TCP:
374  break;
375  case HC1_UDP:
377  break;
378  case HC1_ICMP:
380  break;
381  }
382 
383  NS_ASSERT_MSG ( m_hc2HeaderPresent != true, "Can not compress HC2, exiting. Very sorry." );
384 
385  return GetSerializedSize ();
386 }
387 
388 void SixLowPanHc1::SetHopLimit (uint8_t limit)
389 {
390  m_hopLimit = limit;
391 }
392 
394 {
395  return m_hopLimit;
396 }
397 
399 {
400  return m_dstCompression;
401 }
402 
403 const uint8_t* SixLowPanHc1::GetDstInterface () const
404 {
405  return m_dstInterface;
406 }
407 
408 const uint8_t* SixLowPanHc1::GetDstPrefix () const
409 {
410  return m_dstPrefix;
411 }
412 
413 uint32_t SixLowPanHc1::GetFlowLabel () const
414 {
415  return m_flowLabel;
416 }
417 
419 {
420  return m_nextHeader;
421 }
422 
424 {
425  return m_srcCompression;
426 }
427 
428 const uint8_t* SixLowPanHc1::GetSrcInterface () const
429 {
430  return m_srcInterface;
431 }
432 
433 const uint8_t* SixLowPanHc1::GetSrcPrefix () const
434 {
435  return m_srcPrefix;
436 }
437 
439 {
440  return m_trafficClass;
441 }
442 
444 {
445  return m_tcflCompression;
446 }
447 
449 {
450  return m_hc2HeaderPresent;
451 }
452 
454 {
455  m_dstCompression = dstCompression;
456 }
457 
458 void SixLowPanHc1::SetDstInterface (const uint8_t* dstInterface)
459 {
460  for ( int i = 0; i < 8; i++)
461  {
462  m_dstInterface[i] = dstInterface[i];
463  }
464 }
465 
466 void SixLowPanHc1::SetDstPrefix (const uint8_t* dstPrefix)
467 {
468  for ( int i = 0; i < 8; i++)
469  {
470  m_dstPrefix[i] = dstPrefix[i];
471  }
472 }
473 
474 void SixLowPanHc1::SetFlowLabel (uint32_t flowLabel)
475 {
476  m_flowLabel = flowLabel;
477 }
478 
479 void SixLowPanHc1::SetNextHeader (uint8_t nextHeader)
480 {
481  m_nextHeader = nextHeader;
482 
483  switch (m_nextHeader)
484  {
487  break;
490  break;
493  break;
494  default:
496  break;
497  }
498 }
499 
501 {
502  m_srcCompression = srcCompression;
503 }
504 
505 void SixLowPanHc1::SetSrcInterface (const uint8_t* srcInterface)
506 {
507  for ( int i = 0; i < 8; i++)
508  {
509  m_srcInterface[i] = srcInterface[i];
510  }
511 }
512 
513 void SixLowPanHc1::SetSrcPrefix (const uint8_t* srcPrefix)
514 {
515  for ( int i = 0; i < 8; i++)
516  {
517  m_srcPrefix[i] = srcPrefix[i];
518  }
519 }
520 
521 void SixLowPanHc1::SetTcflCompression (bool tcflCompression)
522 {
523  m_tcflCompression = tcflCompression;
524 }
525 
526 void SixLowPanHc1::SetTrafficClass (uint8_t trafficClass)
527 {
528  m_trafficClass = trafficClass;
529 }
530 
531 
532 void SixLowPanHc1::SetHc2HeaderPresent (bool hc2HeaderPresent)
533 {
534  m_hc2HeaderPresent = hc2HeaderPresent;
535 }
536 
537 
538 std::ostream & operator << (std::ostream & os, const SixLowPanHc1 & h)
539 {
540  h.Print (os);
541  return os;
542 }
543 
544 /*
545  * SixLowPanFrag1
546  */
547 NS_OBJECT_ENSURE_REGISTERED (SixLowPanFrag1);
548 
550  : m_datagramSize (0),
551  m_datagramTag (0)
552 {
553 }
554 
556 {
557  static TypeId tid = TypeId ("ns3::SixLowPanFrag1")
558  .SetParent<Header> ()
559  .SetGroupName ("SixLowPan")
560  .AddConstructor<SixLowPanFrag1> ();
561  return tid;
562 }
563 
565 {
566  return GetTypeId ();
567 }
568 
569 void SixLowPanFrag1::Print (std::ostream & os) const
570 {
571  os << "datagram size " << m_datagramSize << " tag " << m_datagramTag;
572 }
573 
575 {
576  return 4;
577 }
578 
580 {
582 
583  uint16_t temp = m_datagramSize | ( uint16_t (SixLowPanDispatch::LOWPAN_FRAG1) << 8 );
584 
585  i.WriteU8 (uint8_t (temp >> 8));
586  i.WriteU8 (uint8_t (temp & 0xff));
587 
589 }
590 
592 {
594 
595  uint8_t temp = i.ReadU8 ();
596  m_datagramSize = (uint16_t (temp) << 8) | i.ReadU8 ();
597  m_datagramSize &= 0x7FF;
598 
599  m_datagramTag = i.ReadU16 ();
600  return GetSerializedSize ();
601 }
602 
603 void SixLowPanFrag1::SetDatagramSize (uint16_t datagramSize)
604 {
605  m_datagramSize = datagramSize & 0x7FF;
606 }
607 
609 {
610  return m_datagramSize & 0x7FF;
611 }
612 
613 void SixLowPanFrag1::SetDatagramTag (uint16_t datagramTag)
614 {
615  m_datagramTag = datagramTag;
616 }
617 
619 {
620  return m_datagramTag;
621 }
622 
623 std::ostream & operator << (std::ostream & os, const SixLowPanFrag1 & h)
624 {
625  h.Print (os);
626  return os;
627 }
628 
629 
630 /*
631  * SixLowPanFragN
632  */
633 
634 NS_OBJECT_ENSURE_REGISTERED (SixLowPanFragN);
635 
637  : m_datagramSize (0),
638  m_datagramTag (0),
639  m_datagramOffset (0)
640 {
641 }
642 /*
643  * SixLowPanFragmentOffset
644  */
646 {
647  static TypeId tid = TypeId ("ns3::SixLowPanFragN")
648  .SetParent<Header> ()
649  .SetGroupName ("SixLowPan")
650  .AddConstructor<SixLowPanFragN> ();
651  return tid;
652 }
653 
655 {
656  return GetTypeId ();
657 }
658 
659 void SixLowPanFragN::Print (std::ostream & os) const
660 {
661  os << "datagram size " << m_datagramSize << " tag " << m_datagramTag << " offset " << +m_datagramOffset;
662 }
663 
665 {
666  return 5;
667 }
668 
670 {
672 
673  uint16_t temp = m_datagramSize | ( uint16_t (SixLowPanDispatch::LOWPAN_FRAGN) << 8 );
674 
675  i.WriteU8 (uint8_t (temp >> 8));
676  i.WriteU8 (uint8_t (temp & 0xff));
677 
680 }
681 
683 {
685 
686  uint8_t temp = i.ReadU8 ();
687  m_datagramSize = (uint16_t (temp) << 8) | i.ReadU8 ();
688  m_datagramSize &= 0x7FF;
689 
690  m_datagramTag = i.ReadU16 ();
691  m_datagramOffset = i.ReadU8 ();
692 
693  return GetSerializedSize ();
694 }
695 
696 void SixLowPanFragN::SetDatagramSize (uint16_t datagramSize)
697 {
698  m_datagramSize = datagramSize & 0x7FF;
699 }
700 
702 {
703  return m_datagramSize & 0x7FF;
704 }
705 
706 void SixLowPanFragN::SetDatagramTag (uint16_t datagramTag)
707 {
708  m_datagramTag = datagramTag;
709 }
710 
712 {
713  return m_datagramTag;
714 }
715 
716 void SixLowPanFragN::SetDatagramOffset (uint8_t datagramOffset)
717 {
718  m_datagramOffset = datagramOffset;
719 }
720 
722 {
723  return m_datagramOffset;
724 }
725 
726 std::ostream & operator << (std::ostream & os, const SixLowPanFragN & h)
727 {
728  h.Print (os);
729  return os;
730 }
731 
732 /*
733  * SixLowPanIpv6
734  */
735 
736 NS_OBJECT_ENSURE_REGISTERED (SixLowPanIpv6);
737 
739 {
740 }
741 
743 {
744  static TypeId tid = TypeId ("ns3::SixLowPanIpv6")
745  .SetParent<Header> ()
746  .SetGroupName ("SixLowPan")
747  .AddConstructor<SixLowPanIpv6> ();
748  return tid;
749 }
750 
752 {
753  return GetTypeId ();
754 }
755 
756 void SixLowPanIpv6::Print (std::ostream & os) const
757 {
758  os << "Uncompressed IPv6";
759 }
760 
762 {
763  return 1;
764 }
765 
767 {
769 
771 }
772 
774 {
776  i.ReadU8 ();
777 
778  return GetSerializedSize ();
779 }
780 
781 std::ostream & operator << (std::ostream & os, const SixLowPanIpv6 & h)
782 {
783  h.Print (os);
784  return os;
785 }
786 
787 /*
788  * SixLowPanIphcHeader
789  */
790 NS_OBJECT_ENSURE_REGISTERED (SixLowPanIphc);
791 
793 {
794  // 011x xxxx xxxx xxxx
795  m_baseFormat = 0x6000;
796  m_srcdstContextId = 0;
797 }
798 
800 {
801  // 011x xxxx xxxx xxxx
802  m_baseFormat = dispatch;
803  m_baseFormat <<= 8;
804  m_srcdstContextId = 0;
805 }
806 
808 {
809  static TypeId tid = TypeId ("ns3::SixLowPanIphc")
810  .SetParent<Header> ()
811  .SetGroupName ("SixLowPan")
812  .AddConstructor<SixLowPanIphc> ();
813  return tid;
814 }
815 
817 {
818  return GetTypeId ();
819 }
820 
821 void SixLowPanIphc::Print (std::ostream & os) const
822 {
823  switch ( GetTf () )
824  {
825  case TF_FULL:
826  os << "TF_FULL(" << +m_ecn << ", " << +m_dscp << ", " << m_flowLabel << ")";
827  break;
828  case TF_DSCP_ELIDED:
829  os << "TF_DSCP_ELIDED(" << +m_ecn << ", " << m_flowLabel << ")";
830  break;
831  case TF_FL_ELIDED:
832  os << "TF_FL_ELIDED(" << +m_ecn << ", " << +m_dscp << ")";
833  break;
834  default:
835  os << "TF_ELIDED";
836  break;
837  }
838 
839  GetNh () ? os << " NH(1)" : os << " NH(0)";
840 
841  switch ( GetHlim () )
842  {
843  case HLIM_INLINE:
844  os << " HLIM_INLINE(" << +m_hopLimit << ")";
845  break;
846  case HLIM_COMPR_1:
847  os << " HLIM_COMPR_1(1)";
848  break;
849  case HLIM_COMPR_64:
850  os << " HLIM_COMPR_64(64)";
851  break;
852  default:
853  os << " HLIM_COMPR_255(255)";
854  break;
855  }
856 
857  GetCid () ? os << " CID(" << +m_srcdstContextId << ")" : os << " CID(0)";
858 
859  GetSac () ? os << " SAC(1)" : os << " SAC(0)";
860  os << " SAM (" << GetSam () << ")";
861 
862  GetM () ? os << " M(1)" : os << " M(0)";
863  GetDac () ? os << " DAC(1)" : os << " DAC(0)";
864  os << " DAM (" << GetDam () << ")";
865 }
866 
868 {
869  uint32_t serializedSize = 2;
870 
871  if ( GetCid () )
872  {
873  serializedSize++;
874  }
875  switch ( GetTf () )
876  {
877  case TF_FULL:
878  serializedSize += 4;
879  break;
880  case TF_DSCP_ELIDED:
881  serializedSize += 3;
882  break;
883  case TF_FL_ELIDED:
884  serializedSize++;
885  break;
886  default:
887  break;
888  }
889  if ( GetNh () == false )
890  {
891  serializedSize++;
892  }
893  if ( GetHlim () == HLIM_INLINE)
894  {
895  serializedSize++;
896  }
897  switch (GetSam () )
898  {
899  case HC_INLINE:
900  if ( GetSac () == false )
901  {
902  serializedSize += 16;
903  }
904  break;
905  case HC_COMPR_64:
906  serializedSize += 8;
907  break;
908  case HC_COMPR_16:
909  serializedSize += 2;
910  break;
911  case HC_COMPR_0:
912  default:
913  break;
914  }
915  if ( GetM () == false)
916  {
917  switch (GetDam () )
918  {
919  case HC_INLINE:
920  if ( GetDac () == false )
921  {
922  serializedSize += 16;
923  }
924  break;
925  case HC_COMPR_64:
926  serializedSize += 8;
927  break;
928  case HC_COMPR_16:
929  serializedSize += 2;
930  break;
931  case HC_COMPR_0:
932  default:
933  break;
934  }
935  }
936  else
937  {
938  switch (GetDam () )
939  {
940  case HC_INLINE:
941  if ( GetDac () == false )
942  {
943  serializedSize += 16;
944  }
945  else
946  {
947  serializedSize += 6;
948  }
949  break;
950  case HC_COMPR_64:
951  if ( GetDac () == false )
952  {
953  serializedSize += 6;
954  }
955  break;
956  case HC_COMPR_16:
957  if ( GetDac () == false )
958  {
959  serializedSize += 4;
960  }
961  break;
962  case HC_COMPR_0:
963  default:
964  if ( GetDac () == false )
965  {
966  serializedSize++;
967  }
968  break;
969  }
970  }
971 
972 
973 
974  return serializedSize;
975 }
976 
978 {
980 
982 
983  if ( GetCid () )
984  {
986  }
987  // Traffic Class and Flow Label
988  switch ( GetTf () )
989  {
990  uint8_t temp;
991  case TF_FULL:
992  temp = (m_ecn << 6) | m_dscp;
993  i.WriteU8 (temp);
994  temp = m_flowLabel >> 16;
995  i.WriteU8 (temp);
996  temp = (m_flowLabel >> 8) & 0xff;
997  i.WriteU8 (temp);
998  temp = m_flowLabel & 0xff;
999  i.WriteU8 (temp);
1000  break;
1001  case TF_DSCP_ELIDED:
1002  temp = (m_ecn << 6) | (m_flowLabel >> 16 );
1003  i.WriteU8 (temp);
1004  temp = (m_flowLabel >> 8) & 0xff;
1005  i.WriteU8 (temp);
1006  temp = m_flowLabel & 0xff;
1007  i.WriteU8 (temp);
1008  break;
1009  case TF_FL_ELIDED:
1010  temp = (m_ecn << 6) | m_dscp;
1011  i.WriteU8 (temp);
1012  break;
1013  default:
1014  break;
1015  }
1016  // Next Header
1017  if ( GetNh () == false )
1018  {
1019  i.WriteU8 (m_nextHeader);
1020  }
1021  // Hop Limit
1022  if ( GetHlim () == HLIM_INLINE )
1023  {
1024  i.WriteU8 (m_hopLimit);
1025  }
1026  // Source Address
1027  switch (GetSam () )
1028  {
1029  case HC_INLINE:
1030  if ( GetSac () == false )
1031  {
1032  i.Write (m_srcInlinePart, 16);
1033  }
1034  break;
1035  case HC_COMPR_64:
1036  i.Write (m_srcInlinePart, 8);
1037  break;
1038  case HC_COMPR_16:
1039  i.Write (m_srcInlinePart, 2);
1040  break;
1041  case HC_COMPR_0:
1042  default:
1043  break;
1044  }
1045  // Destination Address
1046  if ( GetM () == false)
1047  {
1048  // unicast
1049  switch (GetDam () )
1050  {
1051  case HC_INLINE:
1052  i.Write (m_dstInlinePart, 16);
1053  break;
1054  case HC_COMPR_64:
1055  i.Write (m_dstInlinePart, 8);
1056  break;
1057  case HC_COMPR_16:
1058  i.Write (m_dstInlinePart, 2);
1059  break;
1060  case HC_COMPR_0:
1061  default:
1062  break;
1063  }
1064  }
1065  else
1066  {
1067  // multicast
1068  switch (GetDam () )
1069  {
1070  case HC_INLINE:
1071  i.Write (m_dstInlinePart, 16);
1072  break;
1073  case HC_COMPR_64:
1074  i.Write (m_dstInlinePart, 6);
1075  break;
1076  case HC_COMPR_16:
1077  i.Write (m_dstInlinePart, 4);
1078  break;
1079  case HC_COMPR_0:
1080  i.Write (m_dstInlinePart, 1);
1081  break;
1082  default:
1083  break;
1084  }
1085  }
1086 }
1087 
1089 {
1090  Buffer::Iterator i = start;
1091 
1092  m_baseFormat = i.ReadNtohU16 ();
1093 
1094  if ( GetCid () )
1095  {
1096  m_srcdstContextId = i.ReadU8 ();
1097  }
1098  else
1099  {
1100  m_srcdstContextId = 0;
1101  }
1102  // Traffic Class and Flow Label
1103  switch ( GetTf () )
1104  {
1105  uint8_t temp;
1106  case TF_FULL:
1107  temp = i.ReadU8 ();
1108  m_ecn = temp >> 6;
1109  m_dscp = temp & 0x3F;
1110  temp = i.ReadU8 ();
1111  m_flowLabel = temp;
1112  temp = i.ReadU8 ();
1113  m_flowLabel = (m_flowLabel << 8) | temp;
1114  temp = i.ReadU8 ();
1115  m_flowLabel = (m_flowLabel << 8) | temp;
1116  break;
1117  case TF_DSCP_ELIDED:
1118  temp = i.ReadU8 ();
1119  m_ecn = temp >> 6;
1120  m_flowLabel = temp & 0x3F;
1121  temp = i.ReadU8 ();
1122  m_flowLabel = (m_flowLabel << 8) | temp;
1123  temp = i.ReadU8 ();
1124  m_flowLabel = (m_flowLabel << 8) | temp;
1125  break;
1126  case TF_FL_ELIDED:
1127  temp = i.ReadU8 ();
1128  m_ecn = temp >> 6;
1129  m_dscp = temp & 0x3F;
1130  break;
1131  default:
1132  break;
1133  }
1134  // Next Header
1135  if ( GetNh () == false )
1136  {
1137  m_nextHeader = i.ReadU8 ();
1138  }
1139  // Hop Limit
1140  switch ( GetHlim () )
1141  {
1142  case HLIM_INLINE:
1143  m_hopLimit = i.ReadU8 ();
1144  break;
1145  case HLIM_COMPR_1:
1146  m_hopLimit = 1;
1147  break;
1148  case HLIM_COMPR_64:
1149  m_hopLimit = 64;
1150  break;
1151  case HLIM_COMPR_255:
1152  default:
1153  m_hopLimit = 255;
1154  break;
1155 
1156  }
1157  // Source Address
1158  memset (m_srcInlinePart, 0x00, sizeof (m_srcInlinePart));
1159  switch (GetSam () )
1160  {
1161  case HC_INLINE:
1162  if ( GetSac () == false )
1163  {
1164  i.Read (m_srcInlinePart, 16);
1165  }
1166  break;
1167  case HC_COMPR_64:
1168  i.Read (m_srcInlinePart, 8);
1169  break;
1170  case HC_COMPR_16:
1171  i.Read (m_srcInlinePart, 2);
1172  break;
1173  case HC_COMPR_0:
1174  default:
1175  break;
1176  }
1177 
1178  // Destination Address
1179  memset (m_dstInlinePart, 0x00, sizeof (m_dstInlinePart));
1180  if ( GetM () == false)
1181  {
1182  // unicast
1183  switch (GetDam () )
1184  {
1185  case HC_INLINE:
1186  i.Read (m_dstInlinePart, 16);
1187  break;
1188  case HC_COMPR_64:
1189  i.Read (m_dstInlinePart, 8);
1190  break;
1191  case HC_COMPR_16:
1192  i.Read (m_dstInlinePart, 2);
1193  break;
1194  case HC_COMPR_0:
1195  default:
1196  break;
1197  }
1198  }
1199  else
1200  {
1201  // multicast
1202  switch (GetDam () )
1203  {
1204  case HC_INLINE:
1205  i.Read (m_dstInlinePart, 16);
1206  break;
1207  case HC_COMPR_64:
1208  i.Read (m_dstInlinePart, 6);
1209  break;
1210  case HC_COMPR_16:
1211  i.Read (m_dstInlinePart, 4);
1212  break;
1213  case HC_COMPR_0:
1214  i.Read (m_dstInlinePart, 1);
1215  break;
1216  default:
1217  break;
1218  }
1219  }
1220 
1221  return GetSerializedSize ();
1222 }
1223 
1225 {
1226  uint16_t field = tfField;
1227  m_baseFormat |= (field << 11);
1228 }
1229 
1231 {
1232  return TrafficClassFlowLabel_e ((m_baseFormat >> 11) & 0x3);
1233 }
1234 
1235 void SixLowPanIphc::SetNh (bool nhField)
1236 {
1237  uint16_t field = nhField;
1238  m_baseFormat |= (field << 10);
1239 }
1240 
1241 bool SixLowPanIphc::GetNh (void) const
1242 {
1243  return ((m_baseFormat >> 10) & 0x1);
1244 }
1245 
1247 {
1248  uint16_t field = hlimField;
1249  m_baseFormat |= (field << 8);
1250 }
1251 
1253 {
1254  return Hlim_e ((m_baseFormat >> 8) & 0x3);
1255 }
1256 
1257 void SixLowPanIphc::SetCid (bool cidField)
1258 {
1259  uint16_t field = cidField;
1260  m_baseFormat |= (field << 7);
1261 }
1262 
1263 bool SixLowPanIphc::GetCid (void) const
1264 {
1265  return ((m_baseFormat >> 7) & 0x1);
1266 }
1267 
1268 void SixLowPanIphc::SetSac (bool sacField)
1269 {
1270  uint16_t field = sacField;
1271  m_baseFormat |= (field << 6);
1272 }
1273 
1274 bool SixLowPanIphc::GetSac (void) const
1275 {
1276  return ((m_baseFormat >> 6) & 0x1);
1277 }
1278 
1280 {
1281  uint16_t field = samField;
1282  m_baseFormat |= (field << 4);
1283 }
1284 
1286 {
1287  return HeaderCompression_e ((m_baseFormat >> 4) & 0x3);
1288 }
1289 
1290 const uint8_t* SixLowPanIphc::GetSrcInlinePart (void) const
1291 {
1292  return m_srcInlinePart;
1293 }
1294 
1295 void SixLowPanIphc::SetSrcInlinePart (uint8_t srcInlinePart[16], uint8_t size)
1296 {
1297  NS_ASSERT_MSG (size <= 16, "Src inline part too large");
1298 
1299  memcpy (m_srcInlinePart, srcInlinePart, size);
1300  return;
1301 }
1302 
1303 void SixLowPanIphc::SetM (bool mField)
1304 {
1305  uint16_t field = mField;
1306  m_baseFormat |= (field << 3);
1307 }
1308 
1309 bool SixLowPanIphc::GetM (void) const
1310 {
1311  return ((m_baseFormat >> 3) & 0x1);
1312 }
1313 
1314 void SixLowPanIphc::SetDac (bool dacField)
1315 {
1316  uint16_t field = dacField;
1317  m_baseFormat |= (field << 2);
1318 }
1319 
1320 bool SixLowPanIphc::GetDac (void) const
1321 {
1322  return ((m_baseFormat >> 2) & 0x1);
1323 }
1324 
1326 {
1327  uint16_t field = damField;
1328  m_baseFormat |= field;
1329 }
1330 
1332 {
1333  return HeaderCompression_e (m_baseFormat & 0x3);
1334 }
1335 
1336 const uint8_t* SixLowPanIphc::GetDstInlinePart (void) const
1337 {
1338  return m_dstInlinePart;
1339 }
1340 
1341 void SixLowPanIphc::SetDstInlinePart (uint8_t dstInlinePart[16], uint8_t size)
1342 {
1343  NS_ASSERT_MSG (size <= 16, "Dst inline part too large");
1344 
1345  memcpy (m_dstInlinePart, dstInlinePart, size);
1346  return;
1347 }
1348 
1349 void SixLowPanIphc::SetSrcContextId (uint8_t srcContextId)
1350 {
1351  NS_ASSERT_MSG (srcContextId < 16, "Src Context ID too large");
1352  m_srcdstContextId |= srcContextId << 4;
1353 }
1354 
1356 {
1357  return ( m_srcdstContextId >> 4);
1358 }
1359 
1360 void SixLowPanIphc::SetDstContextId (uint8_t dstContextId)
1361 {
1362  NS_ASSERT_MSG (dstContextId < 16, "Dst Context ID too large");
1363  m_srcdstContextId |= (dstContextId & 0xF);
1364 }
1365 
1367 {
1368  return (m_srcdstContextId & 0xF);
1369 }
1370 
1371 void SixLowPanIphc::SetEcn (uint8_t ecn)
1372 {
1373  NS_ASSERT_MSG (ecn < 4, "ECN too large");
1374  m_ecn = ecn;
1375 }
1376 
1377 uint8_t SixLowPanIphc::GetEcn (void) const
1378 {
1379  return m_ecn;
1380 }
1381 
1382 void SixLowPanIphc::SetDscp (uint8_t dscp)
1383 {
1384  NS_ASSERT_MSG (dscp < 64, "DSCP too large");
1385  m_dscp = dscp;
1386 }
1387 
1388 uint8_t SixLowPanIphc::GetDscp (void) const
1389 {
1390  return m_dscp;
1391 }
1392 
1393 void SixLowPanIphc::SetFlowLabel (uint32_t flowLabel)
1394 {
1395  NS_ASSERT_MSG (flowLabel < 0x100000, "Flow Label too large");
1396  m_flowLabel = flowLabel;
1397 }
1398 
1399 uint32_t SixLowPanIphc::GetFlowLabel (void) const
1400 {
1401  return m_flowLabel;
1402 }
1403 
1404 void SixLowPanIphc::SetNextHeader (uint8_t nextHeader)
1405 {
1406  m_nextHeader = nextHeader;
1407 }
1408 
1409 uint8_t SixLowPanIphc::GetNextHeader (void) const
1410 {
1411  return m_nextHeader;
1412 }
1413 
1414 void SixLowPanIphc::SetHopLimit (uint8_t hopLimit)
1415 {
1416  m_hopLimit = hopLimit;
1417 }
1418 
1419 uint8_t SixLowPanIphc::GetHopLimit (void) const
1420 {
1421  return m_hopLimit;
1422 }
1423 
1424 std::ostream & operator << (std::ostream & os, const SixLowPanIphc & h)
1425 {
1426  h.Print (os);
1427  return os;
1428 }
1429 
1430 /*
1431  * SixLowPanNhcExtensionHeader
1432  */
1433 NS_OBJECT_ENSURE_REGISTERED (SixLowPanNhcExtension);
1434 
1436 {
1437  // 1110 xxxx
1438  m_nhcExtensionHeader = 0xE0;
1439  m_nhcNextHeader = 0;
1440  m_nhcBlobLength = 0;
1441 }
1442 
1444 {
1445  static TypeId tid = TypeId ("ns3::SixLowPanNhcExtension")
1446  .SetParent<Header> ()
1447  .SetGroupName ("SixLowPan")
1448  .AddConstructor<SixLowPanNhcExtension> ();
1449  return tid;
1450 }
1451 
1453 {
1454  return GetTypeId ();
1455 }
1456 
1457 void SixLowPanNhcExtension::Print (std::ostream & os) const
1458 {
1459  os << "Compression kind: " << +m_nhcExtensionHeader << " Size: " << GetSerializedSize ();
1460 }
1461 
1463 {
1464  uint32_t serializedSize = 2;
1465  if ( GetNh () == false )
1466  {
1467  serializedSize++;
1468  }
1469  return serializedSize + m_nhcBlobLength;
1470 }
1471 
1473 {
1474  Buffer::Iterator i = start;
1476  if ( GetNh () == false )
1477  {
1479  }
1482 }
1483 
1485 {
1486  Buffer::Iterator i = start;
1488  if ( GetNh () == false )
1489  {
1490  m_nhcNextHeader = i.ReadU8 ();
1491  }
1492  m_nhcBlobLength = i.ReadU8 ();
1494 
1495  return GetSerializedSize ();
1496 }
1497 
1500 {
1502 }
1503 
1504 void SixLowPanNhcExtension::SetEid (Eid_e extensionHeaderType)
1505 {
1506  uint8_t field = extensionHeaderType;
1507  m_nhcExtensionHeader |= (field << 1);
1508 }
1509 
1511 {
1512  return Eid_e ((m_nhcExtensionHeader >> 1) & 0x7);
1513 }
1514 
1515 void SixLowPanNhcExtension::SetNextHeader (uint8_t nextHeader)
1516 {
1517  m_nhcNextHeader = nextHeader;
1518 }
1519 
1521 {
1522  return m_nhcNextHeader;
1523 }
1524 
1525 void SixLowPanNhcExtension::SetNh (bool nhField)
1526 {
1527  uint8_t field = nhField;
1528  m_nhcExtensionHeader |= field;
1529 }
1530 
1532 {
1533  return m_nhcExtensionHeader & 0x01;
1534 }
1535 
1536 void SixLowPanNhcExtension::SetBlob (const uint8_t* blob, uint32_t size)
1537 {
1538  NS_ASSERT_MSG ( size < 255, "Buffer too long" );
1539 
1540  m_nhcBlobLength = size;
1541  std::memcpy (m_nhcBlob, blob, size);
1542 }
1543 
1544 uint32_t SixLowPanNhcExtension::CopyBlob (uint8_t* blob, uint32_t size) const
1545 {
1546  NS_ASSERT_MSG ( size > m_nhcBlobLength, "Buffer too short" );
1547 
1548  std::memcpy (blob, m_nhcBlob, m_nhcBlobLength);
1549  return m_nhcBlobLength;
1550 }
1551 
1552 std::ostream & operator << (std::ostream & os, const SixLowPanNhcExtension & h)
1553 {
1554  h.Print (os);
1555  return os;
1556 }
1557 
1558 /*
1559  * SixLowPanUdpNhcExtension
1560  */
1561 NS_OBJECT_ENSURE_REGISTERED (SixLowPanUdpNhcExtension);
1562 
1564 {
1565  // 1111 0xxx
1566  m_baseFormat = 0xF0;
1567  m_checksum = 0;
1568  m_srcPort = 0;
1569  m_dstPort = 0;
1570 }
1571 
1573 {
1574  static TypeId tid = TypeId ("ns3::SixLowPanUdpNhcExtension")
1575  .SetParent<Header> ()
1576  .SetGroupName ("SixLowPan")
1577  .AddConstructor<SixLowPanUdpNhcExtension> ();
1578  return tid;
1579 }
1580 
1582 {
1583  return GetTypeId ();
1584 }
1585 
1586 void SixLowPanUdpNhcExtension::Print (std::ostream & os) const
1587 {
1588  os << "Compression kind: " << +m_baseFormat;
1589 }
1590 
1592 {
1593  uint32_t serializedSize = 1;
1594  if ( !GetC () )
1595  {
1596  serializedSize += 2;
1597  }
1598  switch (GetPorts ())
1599  {
1600  case PORTS_INLINE:
1601  serializedSize += 4;
1602  break;
1605  serializedSize += 3;
1606  break;
1608  serializedSize += 1;
1609  break;
1610  default:
1611  break;
1612  }
1613  return serializedSize;
1614 }
1615 
1617 {
1618  Buffer::Iterator i = start;
1619  i.WriteU8 (m_baseFormat);
1620  uint8_t temp;
1621 
1622  // Ports
1623  switch ( GetPorts () )
1624  {
1625  case PORTS_INLINE:
1626  i.WriteHtonU16 (m_srcPort);
1627  i.WriteHtonU16 (m_dstPort);
1628  break;
1630  i.WriteHtonU16 (m_srcPort);
1631  i.WriteU8 (m_dstPort & 0xff);
1632  break;
1634  i.WriteU8 (m_srcPort & 0xff);
1635  i.WriteHtonU16 (m_dstPort);
1636  break;
1638  temp = ((m_srcPort & 0xf) << 4) | (m_dstPort & 0xf);
1639  i.WriteU8 (temp);
1640  break;
1641  default:
1642  break;
1643  }
1644 
1645  // Checksum
1646  if ( !GetC () )
1647  {
1648  i.WriteU16 (m_checksum);
1649  }
1650 
1651 }
1652 
1654 {
1655  Buffer::Iterator i = start;
1656  m_baseFormat = i.ReadU8 ();
1657  uint8_t temp;
1658 
1659  // Ports
1660  switch ( GetPorts () )
1661  {
1662  case PORTS_INLINE:
1663  m_srcPort = i.ReadNtohU16 ();
1664  m_dstPort = i.ReadNtohU16 ();
1665  break;
1667  m_srcPort = i.ReadNtohU16 ();
1668  m_dstPort = i.ReadU8 ();
1669  break;
1671  m_srcPort = i.ReadU8 ();
1672  m_dstPort = i.ReadNtohU16 ();
1673  break;
1675  temp = i.ReadU8 ();
1676  m_srcPort = temp >> 4;
1677  m_dstPort = temp & 0xf;
1678  break;
1679  default:
1680  break;
1681  }
1682 
1683  // Checksum
1684  if ( !GetC () )
1685  {
1686  m_checksum = i.ReadU16 ();
1687  }
1688 
1689  return GetSerializedSize ();
1690 }
1691 
1694 {
1696 }
1697 
1699 {
1700  uint16_t field = ports;
1701  m_baseFormat |= field;
1702 }
1703 
1705 {
1706  return Ports_e (m_baseFormat & 0x3);
1707 }
1708 
1710 {
1711  m_srcPort = srcport;
1712 }
1713 
1715 {
1716  return m_srcPort;
1717 }
1718 
1720 {
1721  m_dstPort = dstport;
1722 }
1723 
1725 {
1726  return m_dstPort;
1727 }
1728 
1730 {
1731  uint16_t field = cField;
1732  m_baseFormat |= (field << 2);
1733 }
1734 
1736 {
1737  return ((m_baseFormat >> 2) & 0x1);
1738 }
1739 
1741 {
1742  m_checksum = checksum;
1743 }
1744 
1746 {
1747  return m_checksum;
1748 }
1749 
1750 std::ostream & operator << (std::ostream & os, const SixLowPanUdpNhcExtension & h)
1751 {
1752  h.Print (os);
1753  return os;
1754 }
1755 
1756 /*
1757  * SixLowPanBc0
1758  */
1759 NS_OBJECT_ENSURE_REGISTERED (SixLowPanBc0);
1760 
1762 {
1763  m_seqNumber = 66;
1764 }
1765 
1767 {
1768  static TypeId tid = TypeId ("ns3::SixLowPanBc0")
1769  .SetParent<Header> ()
1770  .SetGroupName ("SixLowPan")
1771  .AddConstructor<SixLowPanBc0> ();
1772  return tid;
1773 }
1774 
1776 {
1777  return GetTypeId ();
1778 }
1779 
1780 void SixLowPanBc0::Print (std::ostream & os) const
1781 {
1782  os << "Sequence number: " << +m_seqNumber;
1783 }
1784 
1786 {
1787  return 2;
1788 }
1789 
1791 {
1792  Buffer::Iterator i = start;
1793  i.WriteU8 (0x50);
1794  i.WriteU8 (m_seqNumber);
1795 
1796 }
1797 
1799 {
1800  Buffer::Iterator i = start;
1801  uint8_t dispatch = i.ReadU8 ();
1802 
1803  if (dispatch != 0x50)
1804  {
1805  return 0;
1806  }
1807 
1808  m_seqNumber = i.ReadU8 ();
1809 
1810  return GetSerializedSize ();
1811 }
1812 
1813 void SixLowPanBc0::SetSequenceNumber (uint8_t seqNumber)
1814 {
1815  m_seqNumber = seqNumber;
1816 }
1817 
1819 {
1820  return m_seqNumber;
1821 }
1822 
1823 std::ostream & operator << (std::ostream & os, const SixLowPanBc0 & h)
1824 {
1825  h.Print (os);
1826  return os;
1827 }
1828 
1829 /*
1830  * SixLowPanMesh
1831  */
1832 NS_OBJECT_ENSURE_REGISTERED (SixLowPanMesh);
1833 
1835 {
1836  m_hopsLeft = 0;
1837  m_src = Address ();
1838  m_dst = Address ();
1839  m_v = false;
1840  m_f = false;
1841 }
1842 
1844 {
1845  static TypeId tid = TypeId ("ns3::SixLowPanMesh")
1846  .SetParent<Header> ()
1847  .SetGroupName ("SixLowPan")
1848  .AddConstructor<SixLowPanMesh> ();
1849  return tid;
1850 }
1851 
1853 {
1854  return GetTypeId ();
1855 }
1856 
1857 void SixLowPanMesh::Print (std::ostream & os) const
1858 {
1859  os << "Hops left: " << +m_hopsLeft << ", src: ";
1861  {
1863  }
1864  else
1865  {
1867  }
1868  os << ", dst: ";
1870  {
1872  }
1873  else
1874  {
1876  }
1877 }
1878 
1880 {
1881  uint32_t serializedSize = 1;
1882 
1883  if (m_hopsLeft >= 0xF)
1884  {
1885  serializedSize++;
1886  }
1887 
1888  if (m_v)
1889  {
1890  serializedSize += 2;
1891  }
1892  else
1893  {
1894  serializedSize += 8;
1895  }
1896 
1897  if (m_f)
1898  {
1899  serializedSize += 2;
1900  }
1901  else
1902  {
1903  serializedSize += 8;
1904  }
1905 
1906  return serializedSize;
1907 }
1908 
1910 {
1911  Buffer::Iterator i = start;
1912 
1913  uint8_t dispatch = 0x80;
1914 
1915  if (m_v)
1916  {
1917  dispatch |= 0x20;
1918  }
1919  if (m_f)
1920  {
1921  dispatch |= 0x10;
1922  }
1923 
1924  if (m_hopsLeft < 0xF)
1925  {
1926  dispatch |= m_hopsLeft;
1927  i.WriteU8 (dispatch);
1928  }
1929  else
1930  {
1931  dispatch |= 0xF;
1932  i.WriteU8 (dispatch);
1933  i.WriteU8 (m_hopsLeft);
1934  }
1935 
1936  uint8_t buffer[8];
1937 
1938  m_src.CopyTo (buffer);
1939  if (m_v)
1940  {
1941  i.Write (buffer, 2);
1942  }
1943  else
1944  {
1945  i.Write (buffer, 8);
1946  }
1947 
1948  m_dst.CopyTo (buffer);
1949  if (m_f)
1950  {
1951  i.Write (buffer, 2);
1952  }
1953  else
1954  {
1955  i.Write (buffer, 8);
1956  }
1957 }
1958 
1960 {
1961  Buffer::Iterator i = start;
1962  uint8_t temp = i.ReadU8 ();
1963 
1964  if ((temp & 0xC0) != 0x80)
1965  {
1966  return 0;
1967  }
1968 
1969  m_v = temp & 0x20;
1970  m_f = temp & 0x10;
1971  m_hopsLeft = temp & 0xF;
1972 
1973  if (m_hopsLeft == 0xF)
1974  {
1975  m_hopsLeft = i.ReadU8 ();
1976  }
1977 
1978  uint8_t buffer[8];
1979  uint8_t addrSize;
1980 
1981  if (m_v)
1982  {
1983  addrSize = 2;
1984  }
1985  else
1986  {
1987  addrSize = 8;
1988  }
1989  i.Read (buffer, addrSize);
1990  m_src.CopyFrom (buffer, addrSize);
1991 
1992  if (m_f)
1993  {
1994  addrSize = 2;
1995  }
1996  else
1997  {
1998  addrSize = 8;
1999  }
2000  i.Read (buffer, addrSize);
2001  m_dst.CopyFrom (buffer, addrSize);
2002 
2003  return GetSerializedSize ();
2004 }
2005 
2007 {
2008  if (Mac64Address::IsMatchingType (originator))
2009  {
2010  m_v = false;
2011  }
2012  else if (Mac16Address::IsMatchingType (originator))
2013  {
2014  m_v = true;
2015  }
2016  else
2017  {
2018  NS_ABORT_MSG ("SixLowPanMesh::SetOriginator - incompatible address");
2019  }
2020 
2021  m_src = originator;
2022 }
2023 
2025 {
2026  return m_src;
2027 }
2028 
2030 {
2031  if (Mac64Address::IsMatchingType (finalDst))
2032  {
2033  m_f = false;
2034  }
2035  else if (Mac16Address::IsMatchingType (finalDst))
2036  {
2037  m_f = true;
2038  }
2039  else
2040  {
2041  NS_ABORT_MSG ("SixLowPanMesh::SetFinalDst - incompatible address");
2042  }
2043 
2044  m_dst = finalDst;
2045 }
2046 
2048 {
2049  return m_dst;
2050 }
2051 
2052 void SixLowPanMesh::SetHopsLeft (uint8_t hopsLeft)
2053 {
2054  m_hopsLeft = hopsLeft;
2055 }
2056 
2057 uint8_t SixLowPanMesh::GetHopsLeft (void) const
2058 {
2059  return m_hopsLeft;
2060 }
2061 
2062 std::ostream & operator << (std::ostream & os, const SixLowPanMesh & h)
2063 {
2064  h.Print (os);
2065  return os;
2066 }
2067 
2068 }
2069 
ns3::SixLowPanIphc::SetSam
void SetSam(HeaderCompression_e samField)
Set the SAM (Source Address Mode) compression.
Definition: sixlowpan-header.cc:1279
ns3::SixLowPanFragN::GetDatagramSize
uint16_t GetDatagramSize(void) const
Get the datagram size.
Definition: sixlowpan-header.cc:701
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::Buffer::Iterator::Write
void Write(uint8_t const *buffer, uint32_t size)
Definition: buffer.cc:954
ns3::SixLowPanHc1::HC1_PIIC
@ HC1_PIIC
Definition: sixlowpan-header.h:144
ns3::SixLowPanDispatch::LOWPAN_NALP_N
@ LOWPAN_NALP_N
Definition: sixlowpan-header.h:79
ns3::SixLowPanIphc::Serialize
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition: sixlowpan-header.cc:977
ns3::SixLowPanDispatch::LOWPAN_FRAG1_N
@ LOWPAN_FRAG1_N
Definition: sixlowpan-header.h:88
ns3::SixLowPanMesh::GetOriginator
Address GetOriginator(void) const
Get the "Originator" address.
Definition: sixlowpan-header.cc:2024
ns3::SixLowPanBc0
6LoWPAN BC0 header - see RFC 4944.
Definition: sixlowpan-header.h:1235
ns3::SixLowPanUdpNhcExtension::SixLowPanUdpNhcExtension
SixLowPanUdpNhcExtension(void)
Definition: sixlowpan-header.cc:1563
ns3::SixLowPanIphc::m_nextHeader
uint8_t m_nextHeader
Next header.
Definition: sixlowpan-header.h:923
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
ns3::SixLowPanDispatch::LOWPAN_IPv6
@ LOWPAN_IPv6
Definition: sixlowpan-header.h:80
ns3::SixLowPanHc1::GetDstPrefix
const uint8_t * GetDstPrefix() const
Get the destination prefix.
Definition: sixlowpan-header.cc:408
ns3::SixLowPanUdpNhcExtension::Ports_e
Ports_e
Ports:
Definition: sixlowpan-header.h:1106
ns3::Ipv6Header::IPV6_ICMPV6
@ IPV6_ICMPV6
Definition: ipv6-header.h:94
ns3::Ipv6Header::IPV6_TCP
@ IPV6_TCP
Definition: ipv6-header.h:87
ns3::SixLowPanDispatch::LOWPAN_BC0
@ LOWPAN_BC0
Definition: sixlowpan-header.h:82
ns3::SixLowPanNhcExtension
LOWPAN_NHC Extension Header Encoding - see RFC 6282.
Definition: sixlowpan-header.h:950
ns3::SixLowPanIphc::GetNextHeader
uint8_t GetNextHeader(void) const
Get the Next Header field.
Definition: sixlowpan-header.cc:1409
ns3::SixLowPanDispatch::NhcDispatch_e
NhcDispatch_e
Dispatch values for Next Header compression.
Definition: sixlowpan-header.h:101
ns3::SixLowPanIphc::GetDstInlinePart
const uint8_t * GetDstInlinePart(void) const
brief Get the destination address inline part
Definition: sixlowpan-header.cc:1336
ns3::SixLowPanDispatch::LOWPAN_NHC_N
@ LOWPAN_NHC_N
Definition: sixlowpan-header.h:103
ns3::SixLowPanHc1::m_srcCompression
LowPanHc1Addr_e m_srcCompression
Source compression type.
Definition: sixlowpan-header.h:352
ns3::SixLowPanFragN::SetDatagramOffset
void SetDatagramOffset(uint8_t datagramOffset)
Set the datagram offset.
Definition: sixlowpan-header.cc:716
ns3::SixLowPanIphc::m_srcdstContextId
uint8_t m_srcdstContextId
Src and Dst Context ID.
Definition: sixlowpan-header.h:919
ns3::SixLowPanFrag1::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Definition: sixlowpan-header.cc:574
ns3::SixLowPanDispatch::LOWPAN_IPHC
@ LOWPAN_IPHC
Definition: sixlowpan-header.h:83
ns3::SixLowPanIphc::TF_DSCP_ELIDED
@ TF_DSCP_ELIDED
Definition: sixlowpan-header.h:622
ns3::SixLowPanHc1::IsTcflCompression
bool IsTcflCompression() const
Check if the Traffic Class and Flow Labels are compressed.
Definition: sixlowpan-header.cc:443
ns3::SixLowPanFrag1::GetDatagramSize
uint16_t GetDatagramSize(void) const
Get the datagram size.
Definition: sixlowpan-header.cc:608
ns3::SixLowPanFragN::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Definition: sixlowpan-header.cc:654
ns3::SixLowPanBc0::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Definition: sixlowpan-header.cc:1785
ns3::SixLowPanFrag1::m_datagramSize
uint16_t m_datagramSize
Datagram size.
Definition: sixlowpan-header.h:435
ns3::Buffer::Iterator::Read
void Read(uint8_t *buffer, uint32_t size)
Definition: buffer.cc:1124
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SixLowPanFragN::m_datagramSize
uint16_t m_datagramSize
Datagram size.
Definition: sixlowpan-header.h:528
ns3::SixLowPanUdpNhcExtension::m_baseFormat
uint8_t m_baseFormat
Dispatch + encoding fields.
Definition: sixlowpan-header.h:1215
ns3::SixLowPanMesh
6LoWPAN Mesh header - see RFC 4944.
Definition: sixlowpan-header.h:1302
ns3::SixLowPanIphc::m_dstInlinePart
uint8_t m_dstInlinePart[16]
destination address inline part.
Definition: sixlowpan-header.h:926
ns3::SixLowPanIphc::SetTf
void SetTf(TrafficClassFlowLabel_e tfField)
Set the TF (Traffic Class, Flow Label) compression.
Definition: sixlowpan-header.cc:1224
ns3::SixLowPanIphc::GetSrcInlinePart
const uint8_t * GetSrcInlinePart(void) const
brief Get the source address inline part
Definition: sixlowpan-header.cc:1290
ns3::SixLowPanDispatch::LOWPAN_UNSUPPORTED
@ LOWPAN_UNSUPPORTED
Definition: sixlowpan-header.h:91
ns3::SixLowPanHc1::SetTcflCompression
void SetTcflCompression(bool tcflCompression)
Set the Traffic Class and Flow Labels as compressed.
Definition: sixlowpan-header.cc:521
ns3::SixLowPanHc1::HC1_PCIC
@ HC1_PCIC
Definition: sixlowpan-header.h:146
ns3::SixLowPanUdpNhcExtension::m_dstPort
uint16_t m_dstPort
Destination port.
Definition: sixlowpan-header.h:1218
ns3::Mac64Address::IsMatchingType
static bool IsMatchingType(const Address &address)
Definition: mac64-address.cc:110
ns3::Mac64Address::ConvertFrom
static Mac64Address ConvertFrom(const Address &address)
Definition: mac64-address.cc:120
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8(void)
Definition: buffer.h:1021
ns3::SixLowPanHc1::HC1_NC
@ HC1_NC
Definition: sixlowpan-header.h:157
ns3::SixLowPanMesh::SetFinalDst
void SetFinalDst(Address finalDst)
Set the "Final Destination" address.
Definition: sixlowpan-header.cc:2029
ns3::SixLowPanUdpNhcExtension::SetC
void SetC(bool cField)
Set the C (Checksum).
Definition: sixlowpan-header.cc:1729
ns3::SixLowPanFragN::SetDatagramTag
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
Definition: sixlowpan-header.cc:706
ns3::SixLowPanHc1::SetSrcInterface
void SetSrcInterface(const uint8_t *srcInterface)
Set the source interface.
Definition: sixlowpan-header.cc:505
ns3::SixLowPanDispatch::GetDispatchType
static Dispatch_e GetDispatchType(uint8_t dispatch)
Get the Dispatch type.
Definition: sixlowpan-header.cc:45
ns3::SixLowPanIphc::SetDac
void SetDac(bool dacField)
Set the DAC (Destination Address Compression) compression.
Definition: sixlowpan-header.cc:1314
ns3::SixLowPanIphc::HC_COMPR_64
@ HC_COMPR_64
Definition: sixlowpan-header.h:654
ns3::Buffer::Iterator::ReadNtohU16
uint16_t ReadNtohU16(void)
Definition: buffer.h:946
ns3::SixLowPanHc1::SetDstCompression
void SetDstCompression(LowPanHc1Addr_e dstCompression)
Set Destination Compression type.
Definition: sixlowpan-header.cc:453
ns3::SixLowPanFragN
6LoWPAN FRAGN header - see RFC 4944.
Definition: sixlowpan-header.h:454
ns3::SixLowPanIphc::GetDam
HeaderCompression_e GetDam(void) const
Get the DAM (Destination Address Mode) compression.
Definition: sixlowpan-header.cc:1331
ns3::SixLowPanIphc::GetSac
bool GetSac(void) const
Get the SAC (Source Address Compression) compression.
Definition: sixlowpan-header.cc:1274
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition: buffer.h:869
ns3::SixLowPanDispatch::LOWPAN_UDPNHC_N
@ LOWPAN_UDPNHC_N
Definition: sixlowpan-header.h:105
ns3::SixLowPanFrag1::GetDatagramTag
uint16_t GetDatagramTag(void) const
Get the datagram tag.
Definition: sixlowpan-header.cc:618
ns3::Buffer::Iterator::WriteU16
void WriteU16(uint16_t data)
Definition: buffer.cc:871
ns3::SixLowPanUdpNhcExtension::m_srcPort
uint16_t m_srcPort
Source port.
Definition: sixlowpan-header.h:1217
ns3::SixLowPanIphc::HC_INLINE
@ HC_INLINE
Definition: sixlowpan-header.h:653
ns3::SixLowPanMesh::m_src
Address m_src
Originator (source) address.
Definition: sixlowpan-header.h:1379
ns3::SixLowPanIphc::SetHlim
void SetHlim(Hlim_e hlimField)
Set the HLIM (Hop Limit) compression.
Definition: sixlowpan-header.cc:1246
ns3::SixLowPanFragN::GetDatagramOffset
uint8_t GetDatagramOffset(void) const
Get the datagram offset.
Definition: sixlowpan-header.cc:721
ns3::SixLowPanHc1
6LoWPAN HC1 header - see RFC 4944.
Definition: sixlowpan-header.h:132
ns3::SixLowPanIphc::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: sixlowpan-header.cc:807
ns3::SixLowPanIphc::HC_COMPR_16
@ HC_COMPR_16
Definition: sixlowpan-header.h:655
ns3::SixLowPanHc1::m_srcInterface
uint8_t m_srcInterface[8]
Source interface.
Definition: sixlowpan-header.h:346
ns3::SixLowPanHc1::Print
virtual void Print(std::ostream &os) const
Definition: sixlowpan-header.cc:121
ns3::SixLowPanHc1::SetHopLimit
void SetHopLimit(uint8_t limit)
Set the "Hop limit" field (TTL).
Definition: sixlowpan-header.cc:388
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::SixLowPanIpv6::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Definition: sixlowpan-header.cc:751
ns3::SixLowPanHc1::HC1_ICMP
@ HC1_ICMP
Definition: sixlowpan-header.h:159
ns3::SixLowPanIphc::GetSam
HeaderCompression_e GetSam(void) const
Get the SAM (Source Address Mode) compression.
Definition: sixlowpan-header.cc:1285
ns3::SixLowPanFragN::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Definition: sixlowpan-header.cc:664
ns3::SixLowPanIphc::SetFlowLabel
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label (20bits).
Definition: sixlowpan-header.cc:1393
ns3::SixLowPanHc1::GetSrcCompression
LowPanHc1Addr_e GetSrcCompression() const
Get Source Compression type.
Definition: sixlowpan-header.cc:423
ns3::SixLowPanIphc::m_hopLimit
uint8_t m_hopLimit
Hop Limit.
Definition: sixlowpan-header.h:924
ns3::SixLowPanNhcExtension::GetNh
bool GetNh(void) const
Get the Next Header field value.
Definition: sixlowpan-header.cc:1531
ns3::SixLowPanIphc::SetNh
void SetNh(bool nhField)
Set the NH (Next Header) compression.
Definition: sixlowpan-header.cc:1235
ns3::SixLowPanDispatch::LOWPAN_FRAG1
@ LOWPAN_FRAG1
Definition: sixlowpan-header.h:87
ns3::Buffer::Iterator::WriteHtonU16
void WriteHtonU16(uint16_t data)
Definition: buffer.h:905
ns3::SixLowPanHc1::SetDstPrefix
void SetDstPrefix(const uint8_t *dstPrefix)
Set the destination prefix.
Definition: sixlowpan-header.cc:466
ns3::SixLowPanHc1::m_flowLabel
uint32_t m_flowLabel
Flow Label.
Definition: sixlowpan-header.h:350
ns3::SixLowPanMesh::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: sixlowpan-header.cc:1843
ns3::SixLowPanHc1::m_hc2HeaderPresent
bool m_hc2HeaderPresent
Is next header HC2 compressed.
Definition: sixlowpan-header.h:356
ns3::SixLowPanUdpNhcExtension::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Definition: sixlowpan-header.cc:1591
ns3::SixLowPanHc1::IsHc2HeaderPresent
bool IsHc2HeaderPresent() const
Check if there is a HC2 compressed header.
Definition: sixlowpan-header.cc:448
ns3::SixLowPanHc1::SetFlowLabel
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label value.
Definition: sixlowpan-header.cc:474
ns3::SixLowPanUdpNhcExtension::GetChecksum
uint16_t GetChecksum(void) const
Get the Checksum field value.
Definition: sixlowpan-header.cc:1745
ns3::SixLowPanDispatch::LOWPAN_FRAGN_N
@ LOWPAN_FRAGN_N
Definition: sixlowpan-header.h:90
ns3::SixLowPanUdpNhcExtension::SetChecksum
void SetChecksum(uint16_t checksum)
Set the Checksum field values.
Definition: sixlowpan-header.cc:1740
ns3::SixLowPanMesh::m_v
bool m_v
True if Originator address is 16 bit.
Definition: sixlowpan-header.h:1377
ns3::SixLowPanDispatch::LOWPAN_HC1
@ LOWPAN_HC1
Definition: sixlowpan-header.h:81
ns3::SixLowPanHc1::m_srcPrefix
uint8_t m_srcPrefix[8]
Source prefix.
Definition: sixlowpan-header.h:345
ns3::SixLowPanHc1::SetSrcCompression
void SetSrcCompression(LowPanHc1Addr_e srcCompression)
Set Source Compression type.
Definition: sixlowpan-header.cc:500
visualizer.core.start
def start()
Definition: core.py:1855
ns3::SixLowPanBc0::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Definition: sixlowpan-header.cc:1775
ns3::SixLowPanIphc::GetHopLimit
uint8_t GetHopLimit(void) const
Get the Hop Limit field.
Definition: sixlowpan-header.cc:1419
ns3::SixLowPanIphc::GetTf
TrafficClassFlowLabel_e GetTf(void) const
Get the TF (Traffic Class, Flow Label) compression.
Definition: sixlowpan-header.cc:1230
ns3::SixLowPanIphc::SetSac
void SetSac(bool sacField)
Set the SAC (Source Address Compression) compression.
Definition: sixlowpan-header.cc:1268
ns3::SixLowPanUdpNhcExtension::PORTS_LAST_SRC_ALL_DST
@ PORTS_LAST_SRC_ALL_DST
Definition: sixlowpan-header.h:1109
ns3::SixLowPanIphc::SetCid
void SetCid(bool cidField)
Set the CID (Context Identifier Extension) compression.
Definition: sixlowpan-header.cc:1257
ns3::SixLowPanIphc::GetM
bool GetM(void) const
Get the M (Multicast) compression.
Definition: sixlowpan-header.cc:1309
ns3::SixLowPanIphc::SetHopLimit
void SetHopLimit(uint8_t hopLimit)
Set the Hop Limit field.
Definition: sixlowpan-header.cc:1414
ns3::SixLowPanNhcExtension::Serialize
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition: sixlowpan-header.cc:1472
ns3::SixLowPanHc1::HC1_PIII
@ HC1_PIII
Definition: sixlowpan-header.h:143
ns3::SixLowPanFragN::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: sixlowpan-header.cc:645
ns3::SixLowPanIpv6::Serialize
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition: sixlowpan-header.cc:766
ns3::SixLowPanIphc::HLIM_INLINE
@ HLIM_INLINE
Definition: sixlowpan-header.h:637
ns3::SixLowPanIphc::HLIM_COMPR_1
@ HLIM_COMPR_1
Definition: sixlowpan-header.h:638
ns3::SixLowPanUdpNhcExtension::Serialize
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition: sixlowpan-header.cc:1616
ns3::SixLowPanIphc::Print
virtual void Print(std::ostream &os) const
Definition: sixlowpan-header.cc:821
ns3::SixLowPanNhcExtension::GetNextHeader
uint8_t GetNextHeader(void) const
Get the Next Header field value.
Definition: sixlowpan-header.cc:1520
ns3::SixLowPanDispatch::LOWPAN_IPHC_N
@ LOWPAN_IPHC_N
Definition: sixlowpan-header.h:84
ns3::SixLowPanDispatch::LOWPAN_MESH_N
@ LOWPAN_MESH_N
Definition: sixlowpan-header.h:86
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::SixLowPanUdpNhcExtension::GetSrcPort
uint16_t GetSrcPort() const
Get the Source Port.
Definition: sixlowpan-header.cc:1714
ns3::SixLowPanHc1::SixLowPanHc1
SixLowPanHc1(void)
Definition: sixlowpan-header.cc:102
ns3::SixLowPanFrag1
6LoWPAN FRAG1 header - see RFC 4944.
Definition: sixlowpan-header.h:373
ns3::SixLowPanIphc::TF_FULL
@ TF_FULL
Definition: sixlowpan-header.h:621
ns3::SixLowPanHc1::SetNextHeader
void SetNextHeader(uint8_t nextHeader)
Set the Next Header value.
Definition: sixlowpan-header.cc:479
ns3::SixLowPanFragN::m_datagramOffset
uint8_t m_datagramOffset
Datagram offset.
Definition: sixlowpan-header.h:530
ns3::SixLowPanFrag1::Print
virtual void Print(std::ostream &os) const
Definition: sixlowpan-header.cc:569
ns3::SixLowPanNhcExtension::m_nhcBlob
uint8_t m_nhcBlob[256]
NHC compressed header.
Definition: sixlowpan-header.h:1071
ns3::SixLowPanUdpNhcExtension::PORTS_LAST_SRC_LAST_DST
@ PORTS_LAST_SRC_LAST_DST
Definition: sixlowpan-header.h:1110
ns3::SixLowPanHc1::m_nextHeader
uint8_t m_nextHeader
Next header.
Definition: sixlowpan-header.h:351
ns3::SixLowPanIphc::SetDstContextId
void SetDstContextId(uint8_t dstContextId)
Set the DstContextId.
Definition: sixlowpan-header.cc:1360
ns3::SixLowPanIphc::SetSrcInlinePart
void SetSrcInlinePart(uint8_t srcInlinePart[16], uint8_t size)
brief Set the source address inline part
Definition: sixlowpan-header.cc:1295
ns3::SixLowPanIphc::GetCid
bool GetCid(void) const
Get the CID (Context Identifier Extension) compression.
Definition: sixlowpan-header.cc:1263
ns3::SixLowPanHc1::SetSrcPrefix
void SetSrcPrefix(const uint8_t *srcPrefix)
Set the source prefix.
Definition: sixlowpan-header.cc:513
ns3::SixLowPanHc1::GetSrcInterface
const uint8_t * GetSrcInterface() const
Get the source interface.
Definition: sixlowpan-header.cc:428
ns3::SixLowPanIphc::m_srcInlinePart
uint8_t m_srcInlinePart[16]
source address inline part.
Definition: sixlowpan-header.h:925
ns3::SixLowPanIphc::HLIM_COMPR_64
@ HLIM_COMPR_64
Definition: sixlowpan-header.h:639
ns3::SixLowPanHc1::GetDstInterface
const uint8_t * GetDstInterface() const
Get the destination interface.
Definition: sixlowpan-header.cc:403
ns3::SixLowPanIpv6::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: sixlowpan-header.cc:742
ns3::Address::CopyFrom
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
Definition: address.cc:101
ns3::SixLowPanHc1::m_nextHeaderCompression
LowPanHc1NextHeader_e m_nextHeaderCompression
Next header compression.
Definition: sixlowpan-header.h:355
ns3::SixLowPanDispatch::LOWPAN_NALP
@ LOWPAN_NALP
Definition: sixlowpan-header.h:78
ns3::SixLowPanIphc::GetDscp
uint8_t GetDscp(void) const
Get the DSCP.
Definition: sixlowpan-header.cc:1388
ns3::SixLowPanDispatch::LOWPAN_MESH
@ LOWPAN_MESH
Definition: sixlowpan-header.h:85
ns3::SixLowPanNhcExtension::SixLowPanNhcExtension
SixLowPanNhcExtension(void)
Definition: sixlowpan-header.cc:1435
ns3::SixLowPanIphc::SetEcn
void SetEcn(uint8_t ecn)
Set the ECN (2bits).
Definition: sixlowpan-header.cc:1371
ns3::SixLowPanHc1::GetNextHeader
uint8_t GetNextHeader() const
Get the Next Header value.
Definition: sixlowpan-header.cc:418
ns3::SixLowPanHc1::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Definition: sixlowpan-header.cc:137
ns3::SixLowPanMesh::SetHopsLeft
void SetHopsLeft(uint8_t hopsLeft)
Set the "Hops Left" field.
Definition: sixlowpan-header.cc:2052
ns3::SixLowPanNhcExtension::GetNhcDispatchType
virtual SixLowPanDispatch::NhcDispatch_e GetNhcDispatchType(void) const
Get the NhcDispatch type.
Definition: sixlowpan-header.cc:1499
ns3::SixLowPanMesh::SixLowPanMesh
SixLowPanMesh(void)
Definition: sixlowpan-header.cc:1834
ns3::SixLowPanUdpNhcExtension::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: sixlowpan-header.cc:1572
ns3::SixLowPanHc1::HC1_PCII
@ HC1_PCII
Definition: sixlowpan-header.h:145
ns3::Header
Protocol header serialization and deserialization.
Definition: header.h:43
ns3::SixLowPanIphc::TrafficClassFlowLabel_e
TrafficClassFlowLabel_e
TF: Traffic Class, Flow Label.
Definition: sixlowpan-header.h:620
ns3::SixLowPanMesh::m_hopsLeft
uint8_t m_hopsLeft
Hops left.
Definition: sixlowpan-header.h:1376
ns3::SixLowPanFrag1::SixLowPanFrag1
SixLowPanFrag1(void)
Definition: sixlowpan-header.cc:549
ns3::SixLowPanMesh::Serialize
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition: sixlowpan-header.cc:1909
ns3::SixLowPanHc1::m_tcflCompression
bool m_tcflCompression
Is TC and FL compressed.
Definition: sixlowpan-header.h:354
ns3::SixLowPanIphc::GetDstContextId
uint8_t GetDstContextId(void) const
Get the DstContextId.
Definition: sixlowpan-header.cc:1366
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
ns3::SixLowPanFrag1::m_datagramTag
uint16_t m_datagramTag
Datagram tag.
Definition: sixlowpan-header.h:436
ns3::SixLowPanIphc::m_dscp
uint8_t m_dscp
DSCP bits.
Definition: sixlowpan-header.h:921
ns3::SixLowPanHc1::GetHopLimit
uint8_t GetHopLimit(void) const
Get the "Hop limit" field (TTL).
Definition: sixlowpan-header.cc:393
ns3::SixLowPanHc1::m_hopLimit
uint8_t m_hopLimit
Hop Limit.
Definition: sixlowpan-header.h:344
ns3::SixLowPanIpv6
6LoWPAN IPv6 uncompressed header - see RFC 4944.
Definition: sixlowpan-header.h:548
ns3::SixLowPanHc1::Serialize
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition: sixlowpan-header.cc:183
ns3::Mac16Address::IsMatchingType
static bool IsMatchingType(const Address &address)
Definition: mac16-address.cc:112
ns3::SixLowPanNhcExtension::SetNextHeader
void SetNextHeader(uint8_t nextHeader)
Set the Next Header field values.
Definition: sixlowpan-header.cc:1515
ns3::SixLowPanHc1::GetSrcPrefix
const uint8_t * GetSrcPrefix() const
Get the source prefix.
Definition: sixlowpan-header.cc:433
ns3::SixLowPanIphc::HC_COMPR_0
@ HC_COMPR_0
Definition: sixlowpan-header.h:656
ns3::SixLowPanIphc::GetDac
bool GetDac(void) const
Get the DAC (Destination Address Compression) compression.
Definition: sixlowpan-header.cc:1320
ns3::SixLowPanIphc::SixLowPanIphc
SixLowPanIphc(void)
Definition: sixlowpan-header.cc:792
ns3::SixLowPanHc1::LowPanHc1Addr_e
LowPanHc1Addr_e
Kind of address compression.
Definition: sixlowpan-header.h:142
ns3::SixLowPanMesh::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Definition: sixlowpan-header.cc:1879
ns3::SixLowPanHc1::SetDstInterface
void SetDstInterface(const uint8_t *dstInterface)
Set the destination interface.
Definition: sixlowpan-header.cc:458
ns3::SixLowPanUdpNhcExtension::SetSrcPort
void SetSrcPort(uint16_t port)
Set the Source Port.
Definition: sixlowpan-header.cc:1709
ns3::SixLowPanHc1::HC1_TCP
@ HC1_TCP
Definition: sixlowpan-header.h:160
ns3::SixLowPanFrag1::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: sixlowpan-header.cc:555
ns3::Buffer::Iterator::ReadU16
uint16_t ReadU16(void)
Definition: buffer.h:1029
ns3::Header::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
ns3::SixLowPanNhcExtension::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Definition: sixlowpan-header.cc:1452
ns3::SixLowPanUdpNhcExtension::m_checksum
uint16_t m_checksum
Checksum.
Definition: sixlowpan-header.h:1216
ns3::SixLowPanUdpNhcExtension::GetPorts
Ports_e GetPorts(void) const
Get the compressed Src and Dst Ports.
Definition: sixlowpan-header.cc:1704
ns3::SixLowPanHc1::m_dstCompression
LowPanHc1Addr_e m_dstCompression
Destination compression type.
Definition: sixlowpan-header.h:353
ns3::SixLowPanIphc::HLIM_COMPR_255
@ HLIM_COMPR_255
Definition: sixlowpan-header.h:640
ns3::SixLowPanIphc::SetDstInlinePart
void SetDstInlinePart(uint8_t dstInlinePart[16], uint8_t size)
brief Set the destination address inline part
Definition: sixlowpan-header.cc:1341
ns3::SixLowPanBc0::m_seqNumber
uint8_t m_seqNumber
Sequence number.
Definition: sixlowpan-header.h:1285
ns3::SixLowPanMesh::GetHopsLeft
uint8_t GetHopsLeft(void) const
Get the "Hops Left" field.
Definition: sixlowpan-header.cc:2057
ns3::SixLowPanIphc::GetNh
bool GetNh(void) const
Get the NH (Next Header) compression.
Definition: sixlowpan-header.cc:1241
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition: buffer.h:99
ns3::SixLowPanHc1::LowPanHc1NextHeader_e
LowPanHc1NextHeader_e
Next header information.
Definition: sixlowpan-header.h:156
ns3::SixLowPanNhcExtension::SetBlob
void SetBlob(const uint8_t *blob, uint32_t size)
Set the option header data blob.
Definition: sixlowpan-header.cc:1536
ns3::SixLowPanUdpNhcExtension::PORTS_INLINE
@ PORTS_INLINE
Definition: sixlowpan-header.h:1107
ns3::Ipv6Header::IPV6_UDP
@ IPV6_UDP
Definition: ipv6-header.h:88
ns3::SixLowPanUdpNhcExtension::GetC
bool GetC(void) const
Get the C (Checksum).
Definition: sixlowpan-header.cc:1735
ns3::SixLowPanFragN::m_datagramTag
uint16_t m_datagramTag
Datagram tag.
Definition: sixlowpan-header.h:529
ns3::SixLowPanNhcExtension::m_nhcExtensionHeader
uint8_t m_nhcExtensionHeader
NHC extension header type.
Definition: sixlowpan-header.h:1068
ns3::SixLowPanMesh::m_dst
Address m_dst
Destination (final) address.
Definition: sixlowpan-header.h:1380
ns3::SixLowPanDispatch::Dispatch_e
Dispatch_e
Definition: sixlowpan-header.h:77
ns3::SixLowPanNhcExtension::CopyBlob
uint32_t CopyBlob(uint8_t *blob, uint32_t size) const
Get the option header data blob.
Definition: sixlowpan-header.cc:1544
ns3::SixLowPanHc1::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: sixlowpan-header.cc:107
ns3::SixLowPanMesh::GetFinalDst
Address GetFinalDst(void) const
Get the "Final Destination" address.
Definition: sixlowpan-header.cc:2047
ns3::SixLowPanIpv6::Print
virtual void Print(std::ostream &os) const
Definition: sixlowpan-header.cc:756
ns3::Address::CopyTo
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
Definition: address.cc:82
ns3::SixLowPanHc1::m_dstInterface
uint8_t m_dstInterface[8]
Destination interface.
Definition: sixlowpan-header.h:348
ns3::SixLowPanIphc::TF_FL_ELIDED
@ TF_FL_ELIDED
Definition: sixlowpan-header.h:623
ns3::SixLowPanIphc::GetHlim
Hlim_e GetHlim(void) const
Get the HLIM (Hop Limit) compression.
Definition: sixlowpan-header.cc:1252
ns3::SixLowPanIphc::SetSrcContextId
void SetSrcContextId(uint8_t srcContextId)
Set the SrcContextId.
Definition: sixlowpan-header.cc:1349
ns3::Mac16Address::ConvertFrom
static Mac16Address ConvertFrom(const Address &address)
Definition: mac16-address.cc:124
ns3::SixLowPanUdpNhcExtension::Print
virtual void Print(std::ostream &os) const
Definition: sixlowpan-header.cc:1586
ns3::SixLowPanIphc::HeaderCompression_e
HeaderCompression_e
Source or Destination Address Mode.
Definition: sixlowpan-header.h:652
ns3::SixLowPanNhcExtension::m_nhcNextHeader
uint8_t m_nhcNextHeader
Next header.
Definition: sixlowpan-header.h:1069
ns3::SixLowPanUdpNhcExtension::PORTS_ALL_SRC_LAST_DST
@ PORTS_ALL_SRC_LAST_DST
Definition: sixlowpan-header.h:1108
ns3::SixLowPanMesh::m_f
bool m_f
True if Destination address is 16 bit.
Definition: sixlowpan-header.h:1378
sixlowpan-header.h
ns3::SixLowPanMesh::Print
virtual void Print(std::ostream &os) const
Definition: sixlowpan-header.cc:1857
ns3::SixLowPanUdpNhcExtension::GetDstPort
uint16_t GetDstPort() const
Get the Destination Port.
Definition: sixlowpan-header.cc:1724
ns3::SixLowPanHc1::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Definition: sixlowpan-header.cc:116
ns3::SixLowPanNhcExtension::SetNh
void SetNh(bool nhField)
Set the NH field values.
Definition: sixlowpan-header.cc:1525
ns3::SixLowPanIphc::Hlim_e
Hlim_e
HLIM: Hop Limit.
Definition: sixlowpan-header.h:636
ns3::SixLowPanFrag1::SetDatagramTag
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
Definition: sixlowpan-header.cc:613
ns3::SixLowPanHc1::SetTrafficClass
void SetTrafficClass(uint8_t trafficClass)
Set the Traffic Class value.
Definition: sixlowpan-header.cc:526
ns3::SixLowPanMesh::SetOriginator
void SetOriginator(Address originator)
Set the "Originator" address.
Definition: sixlowpan-header.cc:2006
ns3::SixLowPanIphc::m_baseFormat
uint16_t m_baseFormat
Dispatch + encoding fields.
Definition: sixlowpan-header.h:918
ns3::SixLowPanBc0::Print
virtual void Print(std::ostream &os) const
Definition: sixlowpan-header.cc:1780
ns3::SixLowPanBc0::SetSequenceNumber
void SetSequenceNumber(uint8_t seqNumber)
Set the "Sequence Number" field.
Definition: sixlowpan-header.cc:1813
ns3::SixLowPanHc1::HC1_UDP
@ HC1_UDP
Definition: sixlowpan-header.h:158
ns3::SixLowPanFrag1::Serialize
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition: sixlowpan-header.cc:579
ns3::SixLowPanHc1::m_trafficClass
uint8_t m_trafficClass
Traffic Class.
Definition: sixlowpan-header.h:349
ns3::SixLowPanNhcExtension::SetEid
void SetEid(Eid_e extensionHeaderType)
Set the Extension Header Type.
Definition: sixlowpan-header.cc:1504
ns3::SixLowPanIphc::m_ecn
uint8_t m_ecn
ECN bits.
Definition: sixlowpan-header.h:920
ns3::SixLowPanFragN::Print
virtual void Print(std::ostream &os) const
Definition: sixlowpan-header.cc:659
ns3::SixLowPanNhcExtension::m_nhcBlobLength
uint8_t m_nhcBlobLength
Length of the NHC compressed header.
Definition: sixlowpan-header.h:1070
ns3::SixLowPanUdpNhcExtension::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Definition: sixlowpan-header.cc:1581
ns3::SixLowPanFrag1::SetDatagramSize
void SetDatagramSize(uint16_t datagramSize)
Set the datagram size.
Definition: sixlowpan-header.cc:603
ns3::SixLowPanBc0::SixLowPanBc0
SixLowPanBc0(void)
Definition: sixlowpan-header.cc:1761
ns3::SixLowPanDispatch::LOWPAN_NHCUNSUPPORTED
@ LOWPAN_NHCUNSUPPORTED
Definition: sixlowpan-header.h:106
ns3::SixLowPanHc1::GetFlowLabel
uint32_t GetFlowLabel() const
Get the Flow Label value.
Definition: sixlowpan-header.cc:413
ns3::SixLowPanIphc::SetDam
void SetDam(HeaderCompression_e damField)
Set the DAM (Destination Address Mode) compression.
Definition: sixlowpan-header.cc:1325
ns3::SixLowPanDispatch::LOWPAN_NHC
@ LOWPAN_NHC
Definition: sixlowpan-header.h:102
ns3::SixLowPanIphc::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Definition: sixlowpan-header.cc:867
ns3::SixLowPanMesh::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Definition: sixlowpan-header.cc:1852
ns3::SixLowPanIpv6::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Definition: sixlowpan-header.cc:761
ns3::SixLowPanIphc
LOWPAN_IPHC base Encoding - see RFC 6282.
Definition: sixlowpan-header.h:608
ns3::SixLowPanIphc::GetFlowLabel
uint32_t GetFlowLabel(void) const
Get the Flow Label.
Definition: sixlowpan-header.cc:1399
ns3::SixLowPanIphc::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Definition: sixlowpan-header.cc:816
ns3::SixLowPanHc1::SetHc2HeaderPresent
void SetHc2HeaderPresent(bool hc2HeaderPresent)
Set the next header a HC2 compressed header.
Definition: sixlowpan-header.cc:532
ns3::SixLowPanHc1::m_dstPrefix
uint8_t m_dstPrefix[8]
Destination prefix.
Definition: sixlowpan-header.h:347
ns3::SixLowPanIphc::GetEcn
uint8_t GetEcn(void) const
Get the ECN.
Definition: sixlowpan-header.cc:1377
ns3::SixLowPanIphc::GetSrcContextId
uint8_t GetSrcContextId(void) const
Get the SrcContextId.
Definition: sixlowpan-header.cc:1355
ns3::SixLowPanNhcExtension::GetEid
Eid_e GetEid(void) const
Get the Extension Header Type.
Definition: sixlowpan-header.cc:1510
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
ns3::SixLowPanNhcExtension::Print
virtual void Print(std::ostream &os) const
Definition: sixlowpan-header.cc:1457
ns3::SixLowPanIphc::SetDscp
void SetDscp(uint8_t dscp)
Set the DSCP (6bits).
Definition: sixlowpan-header.cc:1382
ns3::SixLowPanDispatch::SixLowPanDispatch
SixLowPanDispatch(void)
Definition: sixlowpan-header.cc:39
ns3::SixLowPanNhcExtension::Eid_e
Eid_e
EID: IPv6 Extension Header ID.
Definition: sixlowpan-header.h:966
ns3::SixLowPanUdpNhcExtension::SetPorts
void SetPorts(Ports_e port)
Set the compressed Src and Dst Ports.
Definition: sixlowpan-header.cc:1698
ns3::SixLowPanFragN::SetDatagramSize
void SetDatagramSize(uint16_t datagramSize)
Set the datagram size.
Definition: sixlowpan-header.cc:696
ns3::SixLowPanIphc::m_flowLabel
uint32_t m_flowLabel
Flow Label bits.
Definition: sixlowpan-header.h:922
ns3::SixLowPanNhcExtension::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: sixlowpan-header.cc:1443
ns3::SixLowPanDispatch::LOWPAN_UDPNHC
@ LOWPAN_UDPNHC
Definition: sixlowpan-header.h:104
ns3::SixLowPanIphc::SetM
void SetM(bool mField)
Set the M (Multicast) compression.
Definition: sixlowpan-header.cc:1303
ns3::SixLowPanUdpNhcExtension::SetDstPort
void SetDstPort(uint16_t port)
Set the Destination Port.
Definition: sixlowpan-header.cc:1719
ns3::SixLowPanUdpNhcExtension::GetNhcDispatchType
virtual SixLowPanDispatch::NhcDispatch_e GetNhcDispatchType(void) const
Get the NhcDispatch type.
Definition: sixlowpan-header.cc:1693
ns3::SixLowPanIpv6::SixLowPanIpv6
SixLowPanIpv6(void)
Definition: sixlowpan-header.cc:738
ns3::SixLowPanFrag1::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Definition: sixlowpan-header.cc:564
ns3::SixLowPanHc1::GetTrafficClass
uint8_t GetTrafficClass() const
Get the Traffic Class value.
Definition: sixlowpan-header.cc:438
ns3::SixLowPanFragN::Serialize
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition: sixlowpan-header.cc:669
ns3::SixLowPanFragN::GetDatagramTag
uint16_t GetDatagramTag(void) const
Get the datagram tag.
Definition: sixlowpan-header.cc:711
ns3::SixLowPanBc0::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: sixlowpan-header.cc:1766
ns3::SixLowPanFragN::SixLowPanFragN
SixLowPanFragN(void)
Definition: sixlowpan-header.cc:636
ns3::SixLowPanUdpNhcExtension
UDP LOWPAN_NHC Extension Header Encoding - see RFC 6282.
Definition: sixlowpan-header.h:1095
ns3::SixLowPanBc0::Serialize
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition: sixlowpan-header.cc:1790
ns3::SixLowPanBc0::GetSequenceNumber
uint8_t GetSequenceNumber(void) const
Get the "Sequence Number" field.
Definition: sixlowpan-header.cc:1818
ns3::SixLowPanDispatch::GetNhcDispatchType
static NhcDispatch_e GetNhcDispatchType(uint8_t dispatch)
Get the NhcDispatch type.
Definition: sixlowpan-header.cc:83
ns3::SixLowPanIphc::SetNextHeader
void SetNextHeader(uint8_t nextHeader)
Set the Next Header field.
Definition: sixlowpan-header.cc:1404
ns3::SixLowPanNhcExtension::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Definition: sixlowpan-header.cc:1462
ns3::SixLowPanHc1::GetDstCompression
LowPanHc1Addr_e GetDstCompression() const
Get Destination Compression type.
Definition: sixlowpan-header.cc:398
NS_ABORT_MSG
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
ns3::SixLowPanDispatch::LOWPAN_FRAGN
@ LOWPAN_FRAGN
Definition: sixlowpan-header.h:89