A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
13
using namespace
ns3
;
14
using namespace
ns3::lrwpan
;
15
16
int
17
main(
int
argc,
char
* argv[])
18
{
19
Packet::EnablePrinting
();
20
Packet::EnableChecking
();
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
}
ns3::Mac16Address
This class can contain 16 bit addresses.
Definition
mac16-address.h:33
ns3::Packet::EnableChecking
static void EnableChecking()
Enable packets metadata checking.
Definition
packet.cc:592
ns3::Packet::EnablePrinting
static void EnablePrinting()
Enable printing packets metadata.
Definition
packet.cc:585
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::lrwpan::LrWpanMacHeader
Represent the Mac Header with the Frame Control and Sequence Number fields.
Definition
lr-wpan-mac-header.h:43
ns3::lrwpan::LrWpanMacHeader::LRWPAN_MAC_BEACON
@ LRWPAN_MAC_BEACON
LRWPAN_MAC_BEACON.
Definition
lr-wpan-mac-header.h:50
ns3::lrwpan::LrWpanMacTrailer
Represent the Mac Trailer with the Frame Check Sequence field.
Definition
lr-wpan-mac-trailer.h:31
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
ns3::lrwpan
Definition
lr-wpan-constants.h:23
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
lr-wpan
examples
lr-wpan-packet-print.cc
Generated on Fri Nov 8 2024 13:59:02 for ns-3 by
1.11.0