A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
sixlowpan-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Universita' di Firenze, Italy
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: Tommaso Pecorella <tommaso.pecorella@unifi.it>
18 */
19
20#ifndef SIXLOWPAN_HELPER_H
21#define SIXLOWPAN_HELPER_H
22
23#include "ns3/net-device-container.h"
24#include "ns3/object-factory.h"
25
26#include <string>
27
28namespace ns3
29{
30
31class Node;
32class AttributeValue;
33class Time;
34
35/**
36 * \ingroup sixlowpan
37 *
38 * \brief Setup a sixlowpan stack to be used as a shim between IPv6 and a generic NetDevice.
39 */
41{
42 public:
43 /*
44 * Construct a SixlowpanHelper
45 */
47 /**
48 * Set an attribute on each ns3::SixlowpanNetDevice created by
49 * SixlowpanHelper::Install.
50 *
51 * \param n1 [in] The name of the attribute to set.
52 * \param v1 [in] The value of the attribute to set.
53 */
54 void SetDeviceAttribute(std::string n1, const AttributeValue& v1);
55
56 /**
57 * \brief Install the SixLoWPAN stack on top of an existing NetDevice.
58 *
59 * This function requires a set of properly configured NetDevices
60 * passed in as the parameter "c". The new NetDevices will have to
61 * be used instead of the original ones. In this way these
62 * SixLoWPAN devices will behave as shims between the NetDevices
63 * passed in and IPv6.
64 *
65 * Note that only IPv6 (and related protocols, such as ICMPv6) can
66 * be transmitted over a 6LoWPAN interface.
67 * Any other protocol (e.g., IPv4) will be discarded by 6LoWPAN.
68 *
69 * Other protocols (e.g., IPv4) could be used on the original NetDevices
70 * with some limitations.
71 * See the manual for a complete discussion.
72 *
73 * \note IPv6 stack must be installed \a after SixLoWPAN,
74 * using the SixLoWPAN NetDevices. See the example in the
75 * examples directory.
76 *
77 *
78 * \param [in] c The NetDevice container.
79 * \return A container with the newly created SixLowPanNetDevices.
80 */
82
83 /**
84 * \brief Adds a compression Context to a set of NetDevices.
85 *
86 * This function installs one Compression Context on a set of NetDevices.
87 * The context is used only in IPHC compression and decompression.
88 *
89 * \param [in] c The NetDevice container.
90 * \param [in] contextId The context id (must be less than 16).
91 * \param [in] context The context prefix.
92 * \param [in] validity the context validity time (relative to the actual time).
93 */
94 void AddContext(NetDeviceContainer c, uint8_t contextId, Ipv6Prefix context, Time validity);
95
96 /**
97 * \brief Renew a compression Context in a set of NetDevices.
98 *
99 * The context will have its lifetime extended and its validity for compression re-enabled.
100 *
101 * \param [in] c The NetDevice container.
102 * \param [in] contextId The context id (must be less than 16).
103 * \param [in] validity the context validity time (relative to the actual time).
104 */
105 void RenewContext(NetDeviceContainer c, uint8_t contextId, Time validity);
106
107 /**
108 * \brief Invalidates a compression Context in a set of NetDevices.
109 *
110 * An invalid context is used only in IPHC decompression and not
111 * in IPHC compression.
112 *
113 * This is necessary to avoid that a context reaching its validity lifetime
114 * can not be used for decompression whie packets are traveling the network.
115 *
116 * \param [in] c The NetDevice container.
117 * \param [in] contextId The context id (must be less than 16).
118 */
119 void InvalidateContext(NetDeviceContainer c, uint8_t contextId);
120
121 /**
122 * \brief Remove a compression Context in a set of NetDevices.
123 *
124 * The context is removed immediately from the contexts in the devices.
125 *
126 * \param [in] c The NetDevice container.
127 * \param [in] contextId The context id (must be less than 16).
128 */
129 void RemoveContext(NetDeviceContainer c, uint8_t contextId);
130
131 /**
132 * Assign a fixed random variable stream number to the random variables
133 * used by this model. Return the number of streams (possibly zero) that
134 * have been assigned. The Install() method should have previously been
135 * called by the user.
136 *
137 * \param [in] c NetDeviceContainer of the set of net devices for which the
138 * SixLowPanNetDevice should be modified to use a fixed stream.
139 * \param [in] stream First stream index to use.
140 * \return The number of stream indices assigned by this helper.
141 */
142 int64_t AssignStreams(NetDeviceContainer c, int64_t stream);
143
144 private:
145 ObjectFactory m_deviceFactory; //!< Object factory.
146};
147
148} // namespace ns3
149
150#endif /* SIXLOWPAN_HELPER_H */
Hold a value for an Attribute.
Definition: attribute.h:70
Describes an IPv6 prefix.
Definition: ipv6-address.h:455
holds a vector of ns3::NetDevice pointers
Instantiate subclasses of ns3::Object.
Setup a sixlowpan stack to be used as a shim between IPv6 and a generic NetDevice.
ObjectFactory m_deviceFactory
Object factory.
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
Set an attribute on each ns3::SixlowpanNetDevice created by SixlowpanHelper::Install.
NetDeviceContainer Install(NetDeviceContainer c)
Install the SixLoWPAN stack on top of an existing NetDevice.
void RemoveContext(NetDeviceContainer c, uint8_t contextId)
Remove a compression Context in a set of NetDevices.
void RenewContext(NetDeviceContainer c, uint8_t contextId, Time validity)
Renew a compression Context in a set of NetDevices.
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void InvalidateContext(NetDeviceContainer c, uint8_t contextId)
Invalidates a compression Context in a set of NetDevices.
void AddContext(NetDeviceContainer c, uint8_t contextId, Ipv6Prefix context, Time validity)
Adds a compression Context to a set of NetDevices.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:839
Every class exported by the ns3 library is enclosed in the ns3 namespace.