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