A Discrete-Event Network Simulator
API
lr-wpan-packet-print.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 The Boeing Company
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Tom Henderson <thomas.r.henderson@boeing.com>
19  */
20 #include <ns3/core-module.h>
21 #include <ns3/lr-wpan-module.h>
22 
23 #include <iostream>
24 
25 using namespace ns3;
26 
27 int main (int argc, char *argv[])
28 {
31  LrWpanMacHeader macHdr (LrWpanMacHeader::LRWPAN_MAC_BEACON, 0); //sequence number set to 0
32  macHdr.SetSrcAddrMode (2); // short addr
33  macHdr.SetDstAddrMode (0); // no addr
34  // ... other setters
35 
36  uint16_t srcPanId = 100;
37  Mac16Address srcWpanAddr ("00:11");
38 
39  macHdr.SetSrcAddrFields (srcPanId,srcWpanAddr );
40 
41  LrWpanMacTrailer macTrailer;
42 
43  Ptr<Packet> p = Create<Packet> (20); // 20 bytes of dummy data
44 
45  p->AddHeader (macHdr);
46  p->AddTrailer (macTrailer);
47 
48  p->Print (std::cout);
49  std::cout << std::endl;
50  return 0;
51 
52 }
Represent the Mac Header with the Frame Control and Sequence Number fields.
void Print(std::ostream &os) const
Print the packet contents.
Definition: packet.cc:411
static void EnablePrinting(void)
Enable printing packets metadata.
Definition: packet.cc:534
static void EnableChecking(void)
Enable packets metadata checking.
Definition: packet.cc:541
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void AddTrailer(const Trailer &trailer)
Add trailer to this packet.
Definition: packet.cc:284
This class can contain 16 bit addresses.
Definition: mac16-address.h:41
Represent the Mac Trailer with the Frame Check Sequence field.
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256