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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Tom Henderson <thomas.r.henderson@boeing.com>
7 */
8#include <ns3/core-module.h>
9#include <ns3/lr-wpan-module.h>
10
11#include <iostream>
12
13using namespace ns3;
14using namespace ns3::lrwpan;
15
16int
17main(int argc, char* argv[])
18{
21 LrWpanMacHeader macHdr(LrWpanMacHeader::LRWPAN_MAC_BEACON, 0); // sequence number set to 0
22 macHdr.SetSrcAddrMode(2); // short addr
23 macHdr.SetDstAddrMode(0); // no addr
24 // ... other setters
25
26 uint16_t srcPanId = 100;
27 Mac16Address srcWpanAddr("00:11");
28
29 macHdr.SetSrcAddrFields(srcPanId, srcWpanAddr);
30
31 LrWpanMacTrailer macTrailer;
32
33 Ptr<Packet> p = Create<Packet>(20); // 20 bytes of dummy data
34
35 p->AddHeader(macHdr);
36 p->AddTrailer(macTrailer);
37
38 p->Print(std::cout);
39 std::cout << std::endl;
40 return 0;
41}
This class can contain 16 bit addresses.
static void EnableChecking()
Enable packets metadata checking.
Definition packet.cc:592
static void EnablePrinting()
Enable printing packets metadata.
Definition packet.cc:585
Smart pointer class similar to boost::intrusive_ptr.
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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Every class exported by the ns3 library is enclosed in the ns3 namespace.