From 6493da4fd5e88830c4a49c3359dc47d475a88701 Mon Sep 17 00:00:00 2001
From: Antti Makela
Date: Sat, 22 Aug 2009 14:58:27 -0700
Subject: [PATCH 01/43] [bug 634] patch to grab prefix length from Ipv4Mask
---
src/node/ipv4-address.cc | 14 ++++++++++++++
src/node/ipv4-address.h | 4 ++++
2 files changed, 18 insertions(+)
diff --git a/src/node/ipv4-address.cc b/src/node/ipv4-address.cc
index 28d26838d..d55e187f8 100644
--- a/src/node/ipv4-address.cc
+++ b/src/node/ipv4-address.cc
@@ -133,6 +133,20 @@ Ipv4Mask::GetOnes (void)
return ones;
}
+uint16_t
+Ipv4Mask::GetPrefixLength (void) const
+{
+ uint16_t tmp = 0;
+ uint32_t mask = m_mask;
+ while (mask != 0 )
+ {
+ mask = mask << 1;
+ tmp++;
+ }
+ return tmp;
+}
+
+
Ipv4Address::Ipv4Address ()
: m_address (0x66666666)
{}
diff --git a/src/node/ipv4-address.h b/src/node/ipv4-address.h
index ad6a0c5e9..1f3a9cfb7 100644
--- a/src/node/ipv4-address.h
+++ b/src/node/ipv4-address.h
@@ -237,6 +237,10 @@ public:
* \param os The output stream to which this Ipv4Address is printed
*/
void Print (std::ostream &os) const;
+ /**
+ * \return the prefix length of mask (the yy in x.x.x.x/yy notation)
+ */
+ uint16_t GetPrefixLength (void) const;
/**
* \return the 255.0.0.0 mask corresponding to a typical loopback address
*/
From 18c4ed4f1020cfbb223b66485d0214a18582d15e Mon Sep 17 00:00:00 2001
From: Tom Henderson
Date: Sat, 22 Aug 2009 15:32:30 -0700
Subject: [PATCH 02/43] allow Ipv4Mask constructor to accept a string /32, /24
etc. in constructor
---
examples/static-routing-slash32.cc | 4 ++--
src/node/ipv4-address.cc | 12 +++++++++++-
src/node/ipv4-address.h | 15 +++++++++++++++
3 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/examples/static-routing-slash32.cc b/examples/static-routing-slash32.cc
index dc6d62499..e2978d1cb 100644
--- a/examples/static-routing-slash32.cc
+++ b/examples/static-routing-slash32.cc
@@ -87,12 +87,12 @@ main (int argc, char *argv[])
int32_t ifIndexA = ipv4A->AddInterface (deviceA);
int32_t ifIndexC = ipv4C->AddInterface (deviceC);
- Ipv4InterfaceAddress ifInAddrA = Ipv4InterfaceAddress (Ipv4Address ("172.16.1.1"), Ipv4Mask ("255.255.255.255"));
+ Ipv4InterfaceAddress ifInAddrA = Ipv4InterfaceAddress (Ipv4Address ("172.16.1.1"), Ipv4Mask ("/32"));
ipv4A->AddAddress (ifIndexA, ifInAddrA);
ipv4A->SetMetric (ifIndexA, 1);
ipv4A->SetUp (ifIndexA);
- Ipv4InterfaceAddress ifInAddrC = Ipv4InterfaceAddress (Ipv4Address ("192.168.1.1"), Ipv4Mask ("255.255.255.255"));
+ Ipv4InterfaceAddress ifInAddrC = Ipv4InterfaceAddress (Ipv4Address ("192.168.1.1"), Ipv4Mask ("/32"));
ipv4C->AddAddress (ifIndexC, ifInAddrC);
ipv4C->SetMetric (ifIndexC, 1);
ipv4C->SetUp (ifIndexC);
diff --git a/src/node/ipv4-address.cc b/src/node/ipv4-address.cc
index d55e187f8..7424369f8 100644
--- a/src/node/ipv4-address.cc
+++ b/src/node/ipv4-address.cc
@@ -28,6 +28,7 @@ namespace ns3 {
#define ASCII_DOT (0x2e)
#define ASCII_ZERO (0x30)
+#define ASCII_SLASH (0x2f)
static uint32_t
AsciiToIpv4Host (char const *address)
@@ -63,9 +64,18 @@ Ipv4Mask::Ipv4Mask ()
Ipv4Mask::Ipv4Mask (uint32_t mask)
: m_mask (mask)
{}
+
Ipv4Mask::Ipv4Mask (char const *mask)
{
- m_mask = AsciiToIpv4Host (mask);
+ if (*mask == ASCII_SLASH)
+ {
+ m_mask = static_cast (atoi (++mask));
+ NS_ASSERT (m_mask <= 32);
+ }
+ else
+ {
+ m_mask = AsciiToIpv4Host (mask);
+ }
}
bool
diff --git a/src/node/ipv4-address.h b/src/node/ipv4-address.h
index 1f3a9cfb7..5ce91964f 100644
--- a/src/node/ipv4-address.h
+++ b/src/node/ipv4-address.h
@@ -198,11 +198,26 @@ private:
* \ingroup address
*
* \brief a class to represent an Ipv4 address mask
+ *
+ * The constructor takes arguments according to a few formats.
+ * Ipv4Mask ("255.255.255.255"), Ipv4Mask ("/32"), and Ipv4Mask (0xffffffff)
+ * are all equivalent.
*/
class Ipv4Mask {
public:
+ /**
+ * Will initialize to a garbage value (0x66666666)
+ */
Ipv4Mask ();
+ /**
+ * param mask bitwise integer representation of the mask
+ *
+ * For example, the integer input 0xffffff00 yields a 24-bit mask
+ */
Ipv4Mask (uint32_t mask);
+ /**
+ * \param mask String constant either in "255.255.255.0" or "/24" format
+ */
Ipv4Mask (char const *mask);
/**
* \param a first address to compare
From 2276ac9097ee421c68af62d3b99961275726de41 Mon Sep 17 00:00:00 2001
From: Tom Henderson
Date: Sat, 22 Aug 2009 15:35:15 -0700
Subject: [PATCH 03/43] coding style cleanup
---
src/node/ipv4-address.cc | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/node/ipv4-address.cc b/src/node/ipv4-address.cc
index 7424369f8..b3a3943f7 100644
--- a/src/node/ipv4-address.cc
+++ b/src/node/ipv4-address.cc
@@ -34,21 +34,23 @@ static uint32_t
AsciiToIpv4Host (char const *address)
{
uint32_t host = 0;
- while (true) {
- uint8_t byte = 0;
- while (*address != ASCII_DOT &&
- *address != 0) {
- byte *= 10;
- byte += *address - ASCII_ZERO;
+ while (true)
+ {
+ uint8_t byte = 0;
+ while (*address != ASCII_DOT && *address != 0)
+ {
+ byte *= 10;
+ byte += *address - ASCII_ZERO;
+ address++;
+ }
+ host <<= 8;
+ host |= byte;
+ if (*address == 0)
+ {
+ break;
+ }
address++;
}
- host <<= 8;
- host |= byte;
- if (*address == 0) {
- break;
- }
- address++;
- }
return host;
}
From 40359e3f555c48eda295eaddb15b32cd34d82d8c Mon Sep 17 00:00:00 2001
From: Tom Henderson
Date: Sat, 22 Aug 2009 15:38:32 -0700
Subject: [PATCH 04/43] Rescan bindings
---
bindings/python/ns3_module_core.py | 8 +-
bindings/python/ns3_module_node.py | 5 +
bindings/python/ns3_module_olsr.py | 4 +-
bindings/python/ns3_module_wifi.py | 184 +++++++++++++++++++----------
4 files changed, 131 insertions(+), 70 deletions(-)
diff --git a/bindings/python/ns3_module_core.py b/bindings/python/ns3_module_core.py
index 9b0535a14..aba99b33b 100644
--- a/bindings/python/ns3_module_core.py
+++ b/bindings/python/ns3_module_core.py
@@ -2199,7 +2199,7 @@ def register_Ns3TracedValue__Unsigned_int_methods(root_module, cls):
cls.add_method('ConnectWithoutContext',
'void',
[param('ns3::CallbackBase const &', 'cb')])
- ## traced-value.h: void ns3::TracedValue::Connect(ns3::CallbackBase const & cb, std::string path) [member function]
+ ## traced-value.h: void ns3::TracedValue::Connect(ns3::CallbackBase const & cb, std::basic_string,std::allocator > path) [member function]
cls.add_method('Connect',
'void',
[param('ns3::CallbackBase const &', 'cb'), param('std::string', 'path')])
@@ -2207,7 +2207,7 @@ def register_Ns3TracedValue__Unsigned_int_methods(root_module, cls):
cls.add_method('DisconnectWithoutContext',
'void',
[param('ns3::CallbackBase const &', 'cb')])
- ## traced-value.h: void ns3::TracedValue::Disconnect(ns3::CallbackBase const & cb, std::string path) [member function]
+ ## traced-value.h: void ns3::TracedValue::Disconnect(ns3::CallbackBase const & cb, std::basic_string,std::allocator > path) [member function]
cls.add_method('Disconnect',
'void',
[param('ns3::CallbackBase const &', 'cb'), param('std::string', 'path')])
@@ -2375,7 +2375,7 @@ def register_functions(root_module):
module.add_function('TypeNameGet',
'std::string',
[],
- template_parameters=['long long'])
+ template_parameters=['long'])
## type-name.h: extern std::string ns3::TypeNameGet() [free function]
module.add_function('TypeNameGet',
'std::string',
@@ -2395,7 +2395,7 @@ def register_functions(root_module):
module.add_function('TypeNameGet',
'std::string',
[],
- template_parameters=['unsigned long long'])
+ template_parameters=['unsigned long'])
## type-name.h: extern std::string ns3::TypeNameGet() [free function]
module.add_function('TypeNameGet',
'std::string',
diff --git a/bindings/python/ns3_module_node.py b/bindings/python/ns3_module_node.py
index a3a3110f2..78f0f3a59 100644
--- a/bindings/python/ns3_module_node.py
+++ b/bindings/python/ns3_module_node.py
@@ -650,6 +650,11 @@ def register_Ns3Ipv4Mask_methods(root_module, cls):
'ns3::Ipv4Mask',
[],
is_static=True)
+ ## ipv4-address.h: uint16_t ns3::Ipv4Mask::GetPrefixLength() const [member function]
+ cls.add_method('GetPrefixLength',
+ 'uint16_t',
+ [],
+ is_const=True)
## ipv4-address.h: static ns3::Ipv4Mask ns3::Ipv4Mask::GetZero() [member function]
cls.add_method('GetZero',
'ns3::Ipv4Mask',
diff --git a/bindings/python/ns3_module_olsr.py b/bindings/python/ns3_module_olsr.py
index 62c38491e..a2c1ff949 100644
--- a/bindings/python/ns3_module_olsr.py
+++ b/bindings/python/ns3_module_olsr.py
@@ -102,13 +102,13 @@ def register_types_ns3_olsr(module):
module.add_container('std::vector< ns3::olsr::MessageHeader::Hello::LinkMessage >', 'ns3::olsr::MessageHeader::Hello::LinkMessage', container_type='vector')
module.add_container('std::vector< ns3::olsr::MessageHeader::Hna::Association >', 'ns3::olsr::MessageHeader::Hna::Association', container_type='vector')
typehandlers.add_type_alias('std::vector< ns3::olsr::DuplicateTuple, std::allocator< ns3::olsr::DuplicateTuple > >', 'ns3::olsr::DuplicateSet')
+ typehandlers.add_type_alias('std::vector< ns3::olsr::NeighborTuple, std::allocator< ns3::olsr::NeighborTuple > >', 'ns3::olsr::NeighborSet')
typehandlers.add_type_alias('std::set< ns3::Ipv4Address, std::less< ns3::Ipv4Address >, std::allocator< ns3::Ipv4Address > >', 'ns3::olsr::MprSet')
typehandlers.add_type_alias('std::vector< ns3::olsr::MprSelectorTuple, std::allocator< ns3::olsr::MprSelectorTuple > >', 'ns3::olsr::MprSelectorSet')
+ typehandlers.add_type_alias('std::vector< ns3::olsr::TopologyTuple, std::allocator< ns3::olsr::TopologyTuple > >', 'ns3::olsr::TopologySet')
typehandlers.add_type_alias('std::vector< ns3::olsr::MessageHeader, std::allocator< ns3::olsr::MessageHeader > >', 'ns3::olsr::MessageList')
typehandlers.add_type_alias('std::vector< ns3::olsr::IfaceAssocTuple, std::allocator< ns3::olsr::IfaceAssocTuple > >', 'ns3::olsr::IfaceAssocSet')
- typehandlers.add_type_alias('std::vector< ns3::olsr::NeighborTuple, std::allocator< ns3::olsr::NeighborTuple > >', 'ns3::olsr::NeighborSet')
typehandlers.add_type_alias('std::vector< ns3::olsr::TwoHopNeighborTuple, std::allocator< ns3::olsr::TwoHopNeighborTuple > >', 'ns3::olsr::TwoHopNeighborSet')
- typehandlers.add_type_alias('std::vector< ns3::olsr::TopologyTuple, std::allocator< ns3::olsr::TopologyTuple > >', 'ns3::olsr::TopologySet')
typehandlers.add_type_alias('std::vector< ns3::olsr::LinkTuple, std::allocator< ns3::olsr::LinkTuple > >', 'ns3::olsr::LinkSet')
def register_methods(root_module):
diff --git a/bindings/python/ns3_module_wifi.py b/bindings/python/ns3_module_wifi.py
index 06aa9f6e5..211a8fe2f 100644
--- a/bindings/python/ns3_module_wifi.py
+++ b/bindings/python/ns3_module_wifi.py
@@ -10,7 +10,7 @@ def register_types(module):
## wifi-phy-standard.h: ns3::WifiPhyStandard [enumeration]
module.add_enum('WifiPhyStandard', ['WIFI_PHY_STANDARD_80211a', 'WIFI_PHY_STANDARD_80211b', 'WIFI_PHY_STANDARD_80211_10Mhz', 'WIFI_PHY_STANDARD_80211_5Mhz', 'WIFI_PHY_STANDARD_holland', 'WIFI_PHY_UNKNOWN'])
## qos-utils.h: ns3::AccessClass [enumeration]
- module.add_enum('AccessClass', ['AC_VO', 'AC_VI', 'AC_BE', 'AC_BK', 'AC_UNDEF'])
+ module.add_enum('AccessClass', ['AC_VO', 'AC_VI', 'AC_BE', 'AC_BK', 'AC_BE_NQOS', 'AC_UNDEF'])
## edca-txop-n.h: ns3::TypeOfStation [enumeration]
module.add_enum('TypeOfStation', ['STA', 'AP', 'ADHOC_STA'])
## capability-information.h: ns3::CapabilityInformation [class]
@@ -123,10 +123,10 @@ def register_types(module):
module.add_class('ConstantRateWifiManager', parent=root_module['ns3::WifiRemoteStationManager'])
## propagation-delay-model.h: ns3::ConstantSpeedPropagationDelayModel [class]
module.add_class('ConstantSpeedPropagationDelayModel', parent=root_module['ns3::PropagationDelayModel'])
- ## dca-txop.h: ns3::DcaTxop [class]
- module.add_class('DcaTxop', parent=root_module['ns3::Object'])
+ ## dcf.h: ns3::Dcf [class]
+ module.add_class('Dcf', parent=root_module['ns3::Object'])
## edca-txop-n.h: ns3::EdcaTxopN [class]
- module.add_class('EdcaTxopN', parent=root_module['ns3::Object'])
+ module.add_class('EdcaTxopN', parent=root_module['ns3::Dcf'])
## error-rate-model.h: ns3::ErrorRateModel [class]
module.add_class('ErrorRateModel', parent=root_module['ns3::Object'])
## propagation-loss-model.h: ns3::FixedRssLossModel [class]
@@ -173,6 +173,8 @@ def register_types(module):
module.add_class('YansWifiChannel', parent=root_module['ns3::WifiChannel'])
## aarf-wifi-manager.h: ns3::AarfWifiManager [class]
module.add_class('AarfWifiManager', parent=root_module['ns3::ArfWifiManager'])
+ ## dca-txop.h: ns3::DcaTxop [class]
+ module.add_class('DcaTxop', parent=root_module['ns3::Dcf'])
typehandlers.add_type_alias('std::vector< ns3::RateInfo, std::allocator< ns3::RateInfo > >', 'ns3::MinstrelRate')
typehandlers.add_type_alias('std::vector< std::vector< unsigned int, std::allocator< unsigned int > >, std::allocator< std::vector< unsigned int, std::allocator< unsigned int > > > >', 'ns3::SampleRate')
typehandlers.add_type_alias('std::vector< ns3::ThresholdsItem, std::allocator< ns3::ThresholdsItem > >', 'ns3::Thresholds')
@@ -279,7 +281,7 @@ def register_methods(root_module):
register_Ns3ArfWifiManager_methods(root_module, root_module['ns3::ArfWifiManager'])
register_Ns3ConstantRateWifiManager_methods(root_module, root_module['ns3::ConstantRateWifiManager'])
register_Ns3ConstantSpeedPropagationDelayModel_methods(root_module, root_module['ns3::ConstantSpeedPropagationDelayModel'])
- register_Ns3DcaTxop_methods(root_module, root_module['ns3::DcaTxop'])
+ register_Ns3Dcf_methods(root_module, root_module['ns3::Dcf'])
register_Ns3EdcaTxopN_methods(root_module, root_module['ns3::EdcaTxopN'])
register_Ns3ErrorRateModel_methods(root_module, root_module['ns3::ErrorRateModel'])
register_Ns3FixedRssLossModel_methods(root_module, root_module['ns3::FixedRssLossModel'])
@@ -304,6 +306,7 @@ def register_methods(root_module):
register_Ns3YansErrorRateModel_methods(root_module, root_module['ns3::YansErrorRateModel'])
register_Ns3YansWifiChannel_methods(root_module, root_module['ns3::YansWifiChannel'])
register_Ns3AarfWifiManager_methods(root_module, root_module['ns3::AarfWifiManager'])
+ register_Ns3DcaTxop_methods(root_module, root_module['ns3::DcaTxop'])
return
def register_Ns3CapabilityInformation_methods(root_module, cls):
@@ -2290,6 +2293,11 @@ def register_Ns3WifiMac_methods(root_module, cls):
cls.add_method('ConfigureStandard',
'void',
[param('ns3::WifiPhyStandard', 'standard')])
+ ## wifi-mac.h: void ns3::WifiMac::ConfigureDcf(ns3::Ptr dcf, uint32_t cwmin, uint32_t cwmax, ns3::AccessClass ac) [member function]
+ cls.add_method('ConfigureDcf',
+ 'void',
+ [param('ns3::Ptr< ns3::Dcf >', 'dcf'), param('uint32_t', 'cwmin'), param('uint32_t', 'cwmax'), param('ns3::AccessClass', 'ac')],
+ visibility='protected')
## wifi-mac.h: void ns3::WifiMac::FinishConfigureStandard(ns3::WifiPhyStandard standard) [member function]
cls.add_method('FinishConfigureStandard',
'void',
@@ -3683,78 +3691,46 @@ def register_Ns3ConstantSpeedPropagationDelayModel_methods(root_module, cls):
is_const=True)
return
-def register_Ns3DcaTxop_methods(root_module, cls):
- ## dca-txop.h: static ns3::TypeId ns3::DcaTxop::GetTypeId() [member function]
+def register_Ns3Dcf_methods(root_module, cls):
+ ## dcf.h: ns3::Dcf::Dcf(ns3::Dcf const & arg0) [copy constructor]
+ cls.add_constructor([param('ns3::Dcf const &', 'arg0')])
+ ## dcf.h: ns3::Dcf::Dcf() [constructor]
+ cls.add_constructor([])
+ ## dcf.h: static ns3::TypeId ns3::Dcf::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
- ## dca-txop.h: ns3::DcaTxop::DcaTxop() [constructor]
- cls.add_constructor([])
- ## dca-txop.h: void ns3::DcaTxop::SetLow(ns3::Ptr low) [member function]
- cls.add_method('SetLow',
- 'void',
- [param('ns3::Ptr< ns3::MacLow >', 'low')])
- ## dca-txop.h: void ns3::DcaTxop::SetManager(ns3::DcfManager * manager) [member function]
- cls.add_method('SetManager',
- 'void',
- [param('ns3::DcfManager *', 'manager')])
- ## dca-txop.h: void ns3::DcaTxop::SetWifiRemoteStationManager(ns3::Ptr remoteManager) [member function]
- cls.add_method('SetWifiRemoteStationManager',
- 'void',
- [param('ns3::Ptr< ns3::WifiRemoteStationManager >', 'remoteManager')])
- ## dca-txop.h: void ns3::DcaTxop::SetTxOkCallback(ns3::Callback callback) [member function]
- cls.add_method('SetTxOkCallback',
- 'void',
- [param('ns3::Callback< void, ns3::WifiMacHeader const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'callback')])
- ## dca-txop.h: void ns3::DcaTxop::SetTxFailedCallback(ns3::Callback callback) [member function]
- cls.add_method('SetTxFailedCallback',
- 'void',
- [param('ns3::Callback< void, ns3::WifiMacHeader const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'callback')])
- ## dca-txop.h: void ns3::DcaTxop::SetMaxQueueSize(uint32_t size) [member function]
- cls.add_method('SetMaxQueueSize',
- 'void',
- [param('uint32_t', 'size')])
- ## dca-txop.h: void ns3::DcaTxop::SetMaxQueueDelay(ns3::Time delay) [member function]
- cls.add_method('SetMaxQueueDelay',
- 'void',
- [param('ns3::Time', 'delay')])
- ## dca-txop.h: void ns3::DcaTxop::SetMinCw(uint32_t minCw) [member function]
+ ## dcf.h: void ns3::Dcf::SetMinCw(uint32_t minCw) [member function]
cls.add_method('SetMinCw',
'void',
- [param('uint32_t', 'minCw')])
- ## dca-txop.h: void ns3::DcaTxop::SetMaxCw(uint32_t maxCw) [member function]
+ [param('uint32_t', 'minCw')],
+ is_pure_virtual=True, is_virtual=True)
+ ## dcf.h: void ns3::Dcf::SetMaxCw(uint32_t maxCw) [member function]
cls.add_method('SetMaxCw',
'void',
- [param('uint32_t', 'maxCw')])
- ## dca-txop.h: void ns3::DcaTxop::SetAifsn(uint32_t aifsn) [member function]
+ [param('uint32_t', 'maxCw')],
+ is_pure_virtual=True, is_virtual=True)
+ ## dcf.h: void ns3::Dcf::SetAifsn(uint32_t aifsn) [member function]
cls.add_method('SetAifsn',
'void',
- [param('uint32_t', 'aifsn')])
- ## dca-txop.h: uint32_t ns3::DcaTxop::GetMinCw() const [member function]
+ [param('uint32_t', 'aifsn')],
+ is_pure_virtual=True, is_virtual=True)
+ ## dcf.h: uint32_t ns3::Dcf::GetMinCw() const [member function]
cls.add_method('GetMinCw',
'uint32_t',
[],
- is_const=True)
- ## dca-txop.h: uint32_t ns3::DcaTxop::GetMaxCw() const [member function]
+ is_pure_virtual=True, is_const=True, is_virtual=True)
+ ## dcf.h: uint32_t ns3::Dcf::GetMaxCw() const [member function]
cls.add_method('GetMaxCw',
'uint32_t',
[],
- is_const=True)
- ## dca-txop.h: uint32_t ns3::DcaTxop::GetAifsn() const [member function]
+ is_pure_virtual=True, is_const=True, is_virtual=True)
+ ## dcf.h: uint32_t ns3::Dcf::GetAifsn() const [member function]
cls.add_method('GetAifsn',
'uint32_t',
[],
- is_const=True)
- ## dca-txop.h: void ns3::DcaTxop::Queue(ns3::Ptr packet, ns3::WifiMacHeader const & hdr) [member function]
- cls.add_method('Queue',
- 'void',
- [param('ns3::Ptr< ns3::Packet const >', 'packet'), param('ns3::WifiMacHeader const &', 'hdr')])
- ## dca-txop.h: void ns3::DcaTxop::DoDispose() [member function]
- cls.add_method('DoDispose',
- 'void',
- [],
- visibility='private', is_virtual=True)
+ is_pure_virtual=True, is_const=True, is_virtual=True)
return
def register_Ns3EdcaTxopN_methods(root_module, cls):
@@ -3814,30 +3790,33 @@ def register_Ns3EdcaTxopN_methods(root_module, cls):
## edca-txop-n.h: void ns3::EdcaTxopN::SetMinCw(uint32_t minCw) [member function]
cls.add_method('SetMinCw',
'void',
- [param('uint32_t', 'minCw')])
+ [param('uint32_t', 'minCw')],
+ is_virtual=True)
## edca-txop-n.h: void ns3::EdcaTxopN::SetMaxCw(uint32_t maxCw) [member function]
cls.add_method('SetMaxCw',
'void',
- [param('uint32_t', 'maxCw')])
+ [param('uint32_t', 'maxCw')],
+ is_virtual=True)
## edca-txop-n.h: void ns3::EdcaTxopN::SetAifsn(uint32_t aifsn) [member function]
cls.add_method('SetAifsn',
'void',
- [param('uint32_t', 'aifsn')])
+ [param('uint32_t', 'aifsn')],
+ is_virtual=True)
## edca-txop-n.h: uint32_t ns3::EdcaTxopN::GetMinCw() const [member function]
cls.add_method('GetMinCw',
'uint32_t',
[],
- is_const=True)
+ is_const=True, is_virtual=True)
## edca-txop-n.h: uint32_t ns3::EdcaTxopN::GetMaxCw() const [member function]
cls.add_method('GetMaxCw',
'uint32_t',
[],
- is_const=True)
+ is_const=True, is_virtual=True)
## edca-txop-n.h: uint32_t ns3::EdcaTxopN::GetAifsn() const [member function]
cls.add_method('GetAifsn',
'uint32_t',
[],
- is_const=True)
+ is_const=True, is_virtual=True)
## edca-txop-n.h: ns3::Ptr ns3::EdcaTxopN::Low() [member function]
cls.add_method('Low',
'ns3::Ptr< ns3::MacLow >',
@@ -5395,6 +5374,83 @@ def register_Ns3AarfWifiManager_methods(root_module, cls):
visibility='private', is_virtual=True)
return
+def register_Ns3DcaTxop_methods(root_module, cls):
+ ## dca-txop.h: static ns3::TypeId ns3::DcaTxop::GetTypeId() [member function]
+ cls.add_method('GetTypeId',
+ 'ns3::TypeId',
+ [],
+ is_static=True)
+ ## dca-txop.h: ns3::DcaTxop::DcaTxop() [constructor]
+ cls.add_constructor([])
+ ## dca-txop.h: void ns3::DcaTxop::SetLow(ns3::Ptr low) [member function]
+ cls.add_method('SetLow',
+ 'void',
+ [param('ns3::Ptr< ns3::MacLow >', 'low')])
+ ## dca-txop.h: void ns3::DcaTxop::SetManager(ns3::DcfManager * manager) [member function]
+ cls.add_method('SetManager',
+ 'void',
+ [param('ns3::DcfManager *', 'manager')])
+ ## dca-txop.h: void ns3::DcaTxop::SetWifiRemoteStationManager(ns3::Ptr remoteManager) [member function]
+ cls.add_method('SetWifiRemoteStationManager',
+ 'void',
+ [param('ns3::Ptr< ns3::WifiRemoteStationManager >', 'remoteManager')])
+ ## dca-txop.h: void ns3::DcaTxop::SetTxOkCallback(ns3::Callback callback) [member function]
+ cls.add_method('SetTxOkCallback',
+ 'void',
+ [param('ns3::Callback< void, ns3::WifiMacHeader const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'callback')])
+ ## dca-txop.h: void ns3::DcaTxop::SetTxFailedCallback(ns3::Callback callback) [member function]
+ cls.add_method('SetTxFailedCallback',
+ 'void',
+ [param('ns3::Callback< void, ns3::WifiMacHeader const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'callback')])
+ ## dca-txop.h: void ns3::DcaTxop::SetMaxQueueSize(uint32_t size) [member function]
+ cls.add_method('SetMaxQueueSize',
+ 'void',
+ [param('uint32_t', 'size')])
+ ## dca-txop.h: void ns3::DcaTxop::SetMaxQueueDelay(ns3::Time delay) [member function]
+ cls.add_method('SetMaxQueueDelay',
+ 'void',
+ [param('ns3::Time', 'delay')])
+ ## dca-txop.h: void ns3::DcaTxop::SetMinCw(uint32_t minCw) [member function]
+ cls.add_method('SetMinCw',
+ 'void',
+ [param('uint32_t', 'minCw')],
+ is_virtual=True)
+ ## dca-txop.h: void ns3::DcaTxop::SetMaxCw(uint32_t maxCw) [member function]
+ cls.add_method('SetMaxCw',
+ 'void',
+ [param('uint32_t', 'maxCw')],
+ is_virtual=True)
+ ## dca-txop.h: void ns3::DcaTxop::SetAifsn(uint32_t aifsn) [member function]
+ cls.add_method('SetAifsn',
+ 'void',
+ [param('uint32_t', 'aifsn')],
+ is_virtual=True)
+ ## dca-txop.h: uint32_t ns3::DcaTxop::GetMinCw() const [member function]
+ cls.add_method('GetMinCw',
+ 'uint32_t',
+ [],
+ is_const=True, is_virtual=True)
+ ## dca-txop.h: uint32_t ns3::DcaTxop::GetMaxCw() const [member function]
+ cls.add_method('GetMaxCw',
+ 'uint32_t',
+ [],
+ is_const=True, is_virtual=True)
+ ## dca-txop.h: uint32_t ns3::DcaTxop::GetAifsn() const [member function]
+ cls.add_method('GetAifsn',
+ 'uint32_t',
+ [],
+ is_const=True, is_virtual=True)
+ ## dca-txop.h: void ns3::DcaTxop::Queue(ns3::Ptr packet, ns3::WifiMacHeader const & hdr) [member function]
+ cls.add_method('Queue',
+ 'void',
+ [param('ns3::Ptr< ns3::Packet const >', 'packet'), param('ns3::WifiMacHeader const &', 'hdr')])
+ ## dca-txop.h: void ns3::DcaTxop::DoDispose() [member function]
+ cls.add_method('DoDispose',
+ 'void',
+ [],
+ visibility='private', is_virtual=True)
+ return
+
def register_functions(root_module):
module = root_module
## ssid.h: extern ns3::Ptr ns3::MakeSsidChecker() [free function]
From d2acbc3eba007ecd9fdd60e8ab8601c0dbf6b2cc Mon Sep 17 00:00:00 2001
From: Tom Henderson
Date: Sun, 23 Aug 2009 14:00:50 -0700
Subject: [PATCH 05/43] missing include
---
src/node/ipv4-address.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/node/ipv4-address.cc b/src/node/ipv4-address.cc
index b3a3943f7..02db1da3f 100644
--- a/src/node/ipv4-address.cc
+++ b/src/node/ipv4-address.cc
@@ -18,6 +18,7 @@
* Author: Mathieu Lacage
*/
+#include
#include "ns3/log.h"
#include "ipv4-address.h"
#include "ns3/assert.h"
From 1f8767ac28b4b730872b785a710375c5c077304a Mon Sep 17 00:00:00 2001
From: Sebastien Vincent
Date: Sat, 22 Aug 2009 14:36:55 -0700
Subject: [PATCH 06/43] second phase of IPv6 checkins from Univ. of Strasbourg
team
---
AUTHORS | 2 +-
CHANGES.html | 12 +
RELEASE_NOTES | 21 +-
examples/icmpv6-redirect.cc | 176 ++
examples/ping6.cc | 111 +
examples/radvd-two-prefix.cc | 216 ++
examples/radvd.cc | 156 ++
examples/simple-routing-ping6.cc | 110 +
examples/wscript | 20 +
src/applications/ping6/ping6.cc | 236 +++
src/applications/ping6/ping6.h | 171 ++
src/applications/ping6/waf | 1 +
src/applications/ping6/wscript | 13 +
src/applications/radvd/radvd-interface.cc | 292 +++
src/applications/radvd/radvd-interface.h | 420 ++++
src/applications/radvd/radvd-prefix.cc | 112 ++
src/applications/radvd/radvd-prefix.h | 180 ++
src/applications/radvd/radvd.cc | 273 +++
src/applications/radvd/radvd.h | 130 ++
src/applications/radvd/wscript | 17 +
src/helper/internet-stack-helper.cc | 93 +-
src/helper/internet-stack-helper.h | 50 +-
src/helper/ipv6-address-helper.cc | 167 ++
src/helper/ipv6-address-helper.h | 96 +
src/helper/ipv6-interface-container.cc | 109 +
src/helper/ipv6-interface-container.h | 111 +
src/helper/ipv6-list-routing-helper.cc | 46 +
src/helper/ipv6-list-routing-helper.h | 64 +
src/helper/ipv6-routing-helper.cc | 28 +
src/helper/ipv6-routing-helper.h | 54 +
src/helper/ipv6-static-routing-helper.cc | 200 ++
src/helper/ipv6-static-routing-helper.h | 79 +
src/helper/ping6-helper.cc | 72 +
src/helper/ping6-helper.h | 103 +
src/helper/wscript | 12 +
src/internet-stack/icmpv6-header.cc | 1773 ++++++++++++++++
src/internet-stack/icmpv6-header.h | 1785 +++++++++++++++++
src/internet-stack/icmpv6-l4-protocol.cc | 1205 +++++++++++
src/internet-stack/icmpv6-l4-protocol.h | 472 +++++
.../ipv6-autoconfigured-prefix.cc | 201 ++
.../ipv6-autoconfigured-prefix.h | 279 +++
src/internet-stack/ipv6-end-point-demux.cc | 318 +++
src/internet-stack/ipv6-end-point-demux.h | 160 ++
src/internet-stack/ipv6-end-point.cc | 128 ++
src/internet-stack/ipv6-end-point.h | 193 ++
src/internet-stack/ipv6-interface.cc | 453 +++++
src/internet-stack/ipv6-interface.h | 322 +++
src/internet-stack/ipv6-l3-protocol.cc | 911 +++++++++
src/internet-stack/ipv6-l3-protocol.h | 486 +++++
src/internet-stack/ipv6-l4-protocol.cc | 52 +
src/internet-stack/ipv6-l4-protocol.h | 106 +
.../ipv6-raw-socket-factory-impl.cc | 16 +
.../ipv6-raw-socket-factory-impl.h | 25 +
src/internet-stack/ipv6-raw-socket-impl.cc | 338 ++++
src/internet-stack/ipv6-raw-socket-impl.h | 255 +++
src/internet-stack/ipv6-test.cc | 145 ++
src/internet-stack/ndisc-cache.cc | 513 +++++
src/internet-stack/ndisc-cache.h | 449 +++++
src/internet-stack/wscript | 13 +
src/node/inet6-socket-address.cc | 16 +-
src/node/ipv6-address.cc | 218 +-
src/node/ipv6-address.h | 2 +-
src/node/ipv6-header.cc | 19 +-
src/node/ipv6-header.h | 30 +-
src/node/ipv6-interface-address.cc | 170 ++
src/node/ipv6-interface-address.h | 209 ++
src/node/ipv6-raw-socket-factory.cc | 37 +
src/node/ipv6-raw-socket-factory.h | 52 +
src/node/ipv6-route.cc | 147 ++
src/node/ipv6-route.h | 227 +++
src/node/ipv6-routing-protocol.cc | 39 +
src/node/ipv6-routing-protocol.h | 170 ++
src/node/ipv6.cc | 60 +
src/node/ipv6.h | 289 +++
src/node/wscript | 16 +-
src/routing/list-routing/ipv6-list-routing.cc | 423 ++++
src/routing/list-routing/ipv6-list-routing.h | 105 +
src/routing/list-routing/wscript | 2 +
.../ipv6-routing-table-entry.cc | 331 +++
.../static-routing/ipv6-routing-table-entry.h | 372 ++++
.../static-routing/ipv6-static-routing.cc | 793 ++++++++
.../static-routing/ipv6-static-routing.h | 303 +++
src/routing/static-routing/wscript | 4 +
src/wscript | 2 +
84 files changed, 18413 insertions(+), 174 deletions(-)
create mode 100644 examples/icmpv6-redirect.cc
create mode 100644 examples/ping6.cc
create mode 100644 examples/radvd-two-prefix.cc
create mode 100644 examples/radvd.cc
create mode 100644 examples/simple-routing-ping6.cc
create mode 100644 src/applications/ping6/ping6.cc
create mode 100644 src/applications/ping6/ping6.h
create mode 100644 src/applications/ping6/waf
create mode 100644 src/applications/ping6/wscript
create mode 100644 src/applications/radvd/radvd-interface.cc
create mode 100644 src/applications/radvd/radvd-interface.h
create mode 100644 src/applications/radvd/radvd-prefix.cc
create mode 100644 src/applications/radvd/radvd-prefix.h
create mode 100644 src/applications/radvd/radvd.cc
create mode 100644 src/applications/radvd/radvd.h
create mode 100644 src/applications/radvd/wscript
create mode 100644 src/helper/ipv6-address-helper.cc
create mode 100644 src/helper/ipv6-address-helper.h
create mode 100644 src/helper/ipv6-interface-container.cc
create mode 100644 src/helper/ipv6-interface-container.h
create mode 100644 src/helper/ipv6-list-routing-helper.cc
create mode 100644 src/helper/ipv6-list-routing-helper.h
create mode 100644 src/helper/ipv6-routing-helper.cc
create mode 100644 src/helper/ipv6-routing-helper.h
create mode 100644 src/helper/ipv6-static-routing-helper.cc
create mode 100644 src/helper/ipv6-static-routing-helper.h
create mode 100644 src/helper/ping6-helper.cc
create mode 100644 src/helper/ping6-helper.h
create mode 100644 src/internet-stack/icmpv6-header.cc
create mode 100644 src/internet-stack/icmpv6-header.h
create mode 100644 src/internet-stack/icmpv6-l4-protocol.cc
create mode 100644 src/internet-stack/icmpv6-l4-protocol.h
create mode 100644 src/internet-stack/ipv6-autoconfigured-prefix.cc
create mode 100644 src/internet-stack/ipv6-autoconfigured-prefix.h
create mode 100644 src/internet-stack/ipv6-end-point-demux.cc
create mode 100644 src/internet-stack/ipv6-end-point-demux.h
create mode 100644 src/internet-stack/ipv6-end-point.cc
create mode 100644 src/internet-stack/ipv6-end-point.h
create mode 100644 src/internet-stack/ipv6-interface.cc
create mode 100644 src/internet-stack/ipv6-interface.h
create mode 100644 src/internet-stack/ipv6-l3-protocol.cc
create mode 100644 src/internet-stack/ipv6-l3-protocol.h
create mode 100644 src/internet-stack/ipv6-l4-protocol.cc
create mode 100644 src/internet-stack/ipv6-l4-protocol.h
create mode 100644 src/internet-stack/ipv6-raw-socket-factory-impl.cc
create mode 100644 src/internet-stack/ipv6-raw-socket-factory-impl.h
create mode 100644 src/internet-stack/ipv6-raw-socket-impl.cc
create mode 100644 src/internet-stack/ipv6-raw-socket-impl.h
create mode 100644 src/internet-stack/ipv6-test.cc
create mode 100644 src/internet-stack/ndisc-cache.cc
create mode 100644 src/internet-stack/ndisc-cache.h
create mode 100644 src/node/ipv6-interface-address.cc
create mode 100644 src/node/ipv6-interface-address.h
create mode 100644 src/node/ipv6-raw-socket-factory.cc
create mode 100644 src/node/ipv6-raw-socket-factory.h
create mode 100644 src/node/ipv6-route.cc
create mode 100644 src/node/ipv6-route.h
create mode 100644 src/node/ipv6-routing-protocol.cc
create mode 100644 src/node/ipv6-routing-protocol.h
create mode 100644 src/node/ipv6.cc
create mode 100644 src/node/ipv6.h
create mode 100644 src/routing/list-routing/ipv6-list-routing.cc
create mode 100644 src/routing/list-routing/ipv6-list-routing.h
create mode 100644 src/routing/static-routing/ipv6-routing-table-entry.cc
create mode 100644 src/routing/static-routing/ipv6-routing-table-entry.h
create mode 100644 src/routing/static-routing/ipv6-static-routing.cc
create mode 100644 src/routing/static-routing/ipv6-static-routing.h
diff --git a/AUTHORS b/AUTHORS
index 5b22c6f68..6cb66345f 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -26,6 +26,6 @@ George F. Riley (riley@ece.gatech.edu)
Providence Salumu Munga (Providence.Salumu@gmail.com, Providence.Salumu_Munga@it-sudparis.eu)
Kulin Shah (m.kulin@gmail.com)
Mauro Tortonesi (mauro.tortonesi@unife.it)
-Sebastien Vincent (vincent@lsiit.u-strasbg.fr)
+Sebastien Vincent (vincent@clarinet.u-strasbg.fr)
Guillaume Vu-Brugier (gvubrugier@gmail.com)
Florian Westphal (fw@strlen.de)
diff --git a/CHANGES.html b/CHANGES.html
index fccd13632..493a8e5f9 100644
--- a/CHANGES.html
+++ b/CHANGES.html
@@ -52,6 +52,18 @@ us a note on ns-developers mailing list.
New API:
Changes to existing API:
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 651628914..84482252f 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -30,13 +30,26 @@ http://www.nsnam.org/wiki/index.php/Installation
New user-visible features
-------------------------
- - Add an implementation of the minstrel rate control algorithm
- (Duy Nguyen for gsoc)
-
+ a) Add an implementation of the minstrel rate control algorithm
+ (Duy Nguyen for gsoc)
+
+ b) IPv6 models:
+ - IPv6 interface;
+ - IPv6 layer;
+ - IPv6 raw socket;
+ - Static IPv6 routing;
+ - ICMPv6 layer;
+ - Some ICMPv6 error messages (destination unreachable, ...);
+ - Neighbor Discovery Protocol (NS/NA, RS/RA, redirection);
+ - Ping6 application (send Echo request);
+ - Radvd application (send RA);
+ - Examples (ping6, simple-routing-ping6, radvd, radvd-two-prefix,
+ icmpv6-redirect).
+
API changes from ns-3.5
-----------------------
-API changes for this release are documented in the file CHANGES.html.
+API changes for this release are documented in the file CHANGES.html.
XXX
Known issues
diff --git a/examples/icmpv6-redirect.cc b/examples/icmpv6-redirect.cc
new file mode 100644
index 000000000..c70150445
--- /dev/null
+++ b/examples/icmpv6-redirect.cc
@@ -0,0 +1,176 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Strasbourg University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: David Gross
+ */
+
+// Network topology
+//
+// STA2
+// |
+// |
+// R1 R2
+// | |
+// | |
+// ------------
+// |
+// |
+// STA 1
+//
+// - Initial configuration :
+// - STA1 default route : R1
+// - R1 static route to STA2 : R2
+// - STA2 default route : R2
+// - STA1 send Echo Request to STA2 using its default route to R1
+// - R1 receive Echo Request from STA1, and forward it to R2
+// - R1 send an ICMPv6 Redirection to STA1 with Target STA2 and Destination R2
+// - Next Echo Request from STA1 to STA2 are directly sent to R2
+
+#include
+#include "ns3/core-module.h"
+#include "ns3/simulator-module.h"
+#include "ns3/helper-module.h"
+
+#include "ns3/ipv6-routing-table-entry.h"
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("Icmpv6RedirectExample");
+
+class StackHelper
+{
+ public:
+ /**
+ * \brief Print the routing table.
+ * \param n the node
+ */
+ inline void PrintRoutingTable (Ptr& n)
+ {
+ Ptr routing = 0;
+ Ipv6StaticRoutingHelper routingHelper;
+ Ptr ipv6 = n->GetObject ();
+ uint32_t nbRoutes = 0;
+ Ipv6RoutingTableEntry route;
+
+ routing = routingHelper.GetStaticRouting (ipv6);
+
+ std::cout << "Routing table of " << n << " : " << std::endl;
+ std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << std::endl;
+
+ nbRoutes = routing->GetNRoutes ();
+ for(uint32_t i = 0 ; i < nbRoutes ; i++)
+ {
+ route = routing->GetRoute (i);
+ std::cout << route.GetDest () << "\t"
+ << route.GetGateway () << "\t"
+ << route.GetInterface () << "\t" << std::endl;
+ }
+ }
+
+ inline void AddHostRouteTo (Ptr& n, Ipv6Address dst, Ipv6Address nextHop, uint32_t interface)
+ {
+ Ptr routing = 0;
+ Ipv6StaticRoutingHelper routingHelper;
+ Ptr ipv6 = n->GetObject ();
+
+ routing = routingHelper.GetStaticRouting (ipv6);
+
+ routing->AddHostRouteTo (dst, nextHop, interface);
+ }
+};
+
+
+int main (int argc, char **argv)
+{
+#if 0
+ LogComponentEnable ("Icmpv6RedirectExample", LOG_LEVEL_INFO);
+ LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_INFO);
+ LogComponentEnable("Ipv6L3Protocol", LOG_LEVEL_ALL);
+ LogComponentEnable("Ipv6StaticRouting", LOG_LEVEL_ALL);
+ LogComponentEnable("Ipv6Interface", LOG_LEVEL_ALL);
+ LogComponentEnable("Icmpv6L4Protocol", LOG_LEVEL_ALL);
+ LogComponentEnable("NdiscCache", LOG_LEVEL_ALL);
+#endif
+
+ CommandLine cmd;
+ cmd.Parse (argc, argv);
+
+ NS_LOG_INFO ("Create nodes.");
+ Ptr sta1 = CreateObject ();
+ Ptr r1 = CreateObject ();
+ Ptr r2 = CreateObject ();
+ Ptr sta2 = CreateObject ();
+ NodeContainer net1(sta1, r1, r2);
+ NodeContainer net2(r2, sta2);
+ NodeContainer all(sta1, r1, r2, sta2);
+
+ StackHelper stackHelper;
+
+ InternetStackHelper internetv6;
+ internetv6.Install (all);
+
+ NS_LOG_INFO ("Create channels.");
+ CsmaHelper csma;
+ csma.SetChannelAttribute ("DataRate", DataRateValue(5000000));
+ csma.SetChannelAttribute ("Delay", TimeValue(MilliSeconds (2)));
+ NetDeviceContainer ndc1 = csma.Install (net1);
+ NetDeviceContainer ndc2 = csma.Install (net2);
+
+ NS_LOG_INFO ("Assign IPv6 Addresses.");
+ Ipv6AddressHelper ipv6;
+
+ ipv6.NewNetwork (Ipv6Address ("2001:1::"), 64);
+ Ipv6InterfaceContainer iic1 = ipv6.Assign (ndc1);
+ iic1.SetRouter (2, true);
+ iic1.SetRouter (1, true);
+
+ ipv6.NewNetwork (Ipv6Address ("2001:2::"), 64);
+ Ipv6InterfaceContainer iic2 = ipv6.Assign (ndc2);
+ iic2.SetRouter (0, true);
+
+ stackHelper.AddHostRouteTo (r1, iic2.GetAddress (1, 1), iic1.GetAddress (2, 1), iic1.GetInterfaceIndex (1));
+
+ Simulator::Schedule(Seconds(0.0), &StackHelper::PrintRoutingTable, &stackHelper, r1);
+ Simulator::Schedule(Seconds(3.0), &StackHelper::PrintRoutingTable, &stackHelper, sta1);
+
+ NS_LOG_INFO ("Create Applications.");
+ uint32_t packetSize = 1024;
+ uint32_t maxPacketCount = 5;
+ Time interPacketInterval = Seconds (1.);
+ Ping6Helper ping6;
+
+ ping6.SetLocal (iic1.GetAddress(0, 1));
+ ping6.SetRemote (iic2.GetAddress(1, 1));
+ ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
+ ping6.SetAttribute ("Interval", TimeValue(interPacketInterval));
+ ping6.SetAttribute ("PacketSize", UintegerValue (packetSize));
+ ApplicationContainer apps = ping6.Install (sta1);
+ apps.Start (Seconds (2.0));
+ apps.Stop (Seconds (10.0));
+
+ std::ofstream ascii;
+ ascii.open ("icmpv6-redirect.tr");
+ CsmaHelper::EnablePcapAll ("icmpv6-redirect", true);
+ CsmaHelper::EnableAsciiAll (ascii);
+
+ /* Now, do the actual simulation. */
+ NS_LOG_INFO ("Run Simulation.");
+ Simulator::Run ();
+ Simulator::Destroy ();
+ NS_LOG_INFO ("Done.");
+}
+
diff --git a/examples/ping6.cc b/examples/ping6.cc
new file mode 100644
index 000000000..56ff13f95
--- /dev/null
+++ b/examples/ping6.cc
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008-2009 Strasbourg University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Sebastien Vincent
+ */
+
+// Network topology
+//
+// n0 n1
+// | |
+// =================
+// LAN
+//
+// - ICMPv6 echo request flows from n0 to n1 and back with ICMPv6 echo reply
+// - DropTail queues
+// - Tracing of queues and packet receptions to file "ping6.tr"
+
+#include
+#include "ns3/core-module.h"
+#include "ns3/simulator-module.h"
+#include "ns3/helper-module.h"
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("Ping6Example");
+
+int main (int argc, char **argv)
+{
+#if 0
+ LogComponentEnable ("Ping6Example", LOG_LEVEL_INFO);
+ LogComponentEnable ("Ipv6EndPointDemux", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ipv6ListRouting", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL);
+ LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL);
+ LogComponentEnable ("NdiscCache", LOG_LEVEL_ALL);
+#endif
+
+ CommandLine cmd;
+ cmd.Parse (argc, argv);
+
+ NS_LOG_INFO ("Create nodes.");
+ NodeContainer n;
+ n.Create (4);
+
+ /* Install IPv4/IPv6 stack */
+ InternetStackHelper internetv6;
+ internetv6.SetIpv4StackInstall (false);
+ internetv6.Install (n);
+
+ NS_LOG_INFO ("Create channels.");
+ CsmaHelper csma;
+ csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
+ csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
+ NetDeviceContainer d = csma.Install (n);
+
+ Ipv6AddressHelper ipv6;
+ NS_LOG_INFO ("Assign IPv6 Addresses.");
+ Ipv6InterfaceContainer i = ipv6.Assign (d);
+
+ NS_LOG_INFO ("Create Applications.");
+
+ /* Create a Ping6 application to send ICMPv6 echo request from node zero to
+ * all-nodes (ff02::1).
+ */
+ uint32_t packetSize = 1024;
+ uint32_t maxPacketCount = 5;
+ Time interPacketInterval = Seconds (1.);
+ Ping6Helper ping6;
+
+/*
+ ping6.SetLocal (i.GetAddress (0, 1));
+ ping6.SetRemote (i.GetAddress (1, 1));
+*/
+ ping6.SetIfIndex (i.GetInterfaceIndex (0));
+ ping6.SetRemote (Ipv6Address::GetAllNodesMulticast ());
+
+ ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
+ ping6.SetAttribute ("Interval", TimeValue (interPacketInterval));
+ ping6.SetAttribute ("PacketSize", UintegerValue (packetSize));
+ ApplicationContainer apps = ping6.Install (n.Get (0));
+ apps.Start (Seconds (2.0));
+ apps.Stop (Seconds (10.0));
+
+ std::ofstream ascii;
+ ascii.open ("ping6.tr");
+ CsmaHelper::EnablePcapAll (std::string ("ping6"), true);
+ CsmaHelper::EnableAsciiAll (ascii);
+
+ NS_LOG_INFO ("Run Simulation.");
+ Simulator::Run ();
+ Simulator::Destroy ();
+ NS_LOG_INFO ("Done.");
+}
+
diff --git a/examples/radvd-two-prefix.cc b/examples/radvd-two-prefix.cc
new file mode 100644
index 000000000..bd8f0e56d
--- /dev/null
+++ b/examples/radvd-two-prefix.cc
@@ -0,0 +1,216 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Strasbourg University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: David Gross
+ * Sebastien Vincent
+ */
+
+// Network topology
+// //
+// // n0 R n1
+// // | _ |
+// // ====|_|====
+// // router
+// // - R sends RA to n0's subnet (2001:1::/64 and 2001:ABCD::/64);
+// // - R interface to n0 has two addresses with following prefixes 2001:1::/64 and 2001:ABCD::/64;
+// // - R sends RA to n1's subnet (2001:2::/64);
+// // - n0 ping6 n1.
+// //
+// // - Tracing of queues and packet receptions to file "radvd-two-prefix.tr"
+
+#include
+#include "ns3/core-module.h"
+#include "ns3/simulator-module.h"
+#include "ns3/helper-module.h"
+
+#include "ns3/ipv6-routing-table-entry.h"
+#include "ns3/radvd.h"
+#include "ns3/radvd-interface.h"
+#include "ns3/radvd-prefix.h"
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("RadvdExample");
+
+class StackHelper
+{
+ public:
+
+ /**
+ * \brief Add an address to a IPv6 node.
+ * \param n node
+ * \param interface interface index
+ * \param address IPv6 address to add
+ */
+ inline void AddAddress (Ptr& n, uint32_t interface, Ipv6Address address)
+ {
+ Ptr ipv6 = n->GetObject ();
+ ipv6->AddAddress (interface, address);
+ }
+
+ /**
+ * \brief Print the routing table.
+ * \param n the node
+ */
+ inline void PrintRoutingTable (Ptr& n)
+ {
+ Ptr routing = 0;
+ Ipv6StaticRoutingHelper routingHelper;
+ Ptr ipv6 = n->GetObject ();
+ uint32_t nbRoutes = 0;
+ Ipv6RoutingTableEntry route;
+
+ routing = routingHelper.GetStaticRouting (ipv6);
+
+ std::cout << "Routing table of " << n << " : " << std::endl;
+ std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << std::endl;
+
+ nbRoutes = routing->GetNRoutes ();
+ for (uint32_t i = 0 ; i < nbRoutes ; i++)
+ {
+ route = routing->GetRoute (i);
+ std::cout << route.GetDest () << "\t"
+ << route.GetGateway () << "\t"
+ << route.GetInterface () << "\t" << std::endl;
+ }
+ }
+};
+
+int main (int argc, char** argv)
+{
+#if 0
+ LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ipv6RawSocketImpl", LOG_LEVEL_ALL);
+ LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL);
+ LogComponentEnable ("RadvdApplication", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL);
+#endif
+
+ CommandLine cmd;
+ cmd.Parse (argc, argv);
+
+ NS_LOG_INFO ("Create nodes.");
+ Ptr n0 = CreateObject ();
+ Ptr r = CreateObject ();
+ Ptr n1 = CreateObject ();
+
+ NodeContainer net1 (n0, r);
+ NodeContainer net2 (r, n1);
+ NodeContainer all (n0, r, n1);
+ StackHelper stackHelper;
+
+ NS_LOG_INFO ("Create IPv6 Internet Stack");
+ InternetStackHelper internetv6;
+ internetv6.Install (all);
+
+ NS_LOG_INFO ("Create channels.");
+ CsmaHelper csma;
+ csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
+ csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
+ NetDeviceContainer d1 = csma.Install (net1); /* n0 - R */
+ NetDeviceContainer d2 = csma.Install (net2); /* R - n1 */
+
+ NS_LOG_INFO ("Create networks and assign IPv6 Addresses.");
+ Ipv6AddressHelper ipv6;
+
+ /* first subnet */
+ ipv6.NewNetwork (Ipv6Address ("2001:1::"), 64);
+ NetDeviceContainer tmp;
+ tmp.Add (d1.Get (0)); /* n0 */
+ Ipv6InterfaceContainer iic1 = ipv6.AssignWithoutAddress (tmp); /* n0 interface */
+
+ NetDeviceContainer tmp2;
+ tmp2.Add (d1.Get (1)); /* R */
+ Ipv6InterfaceContainer iicr1 = ipv6.Assign (tmp2); /* R interface to the first subnet is just statically assigned */
+ iicr1.SetRouter (0, true);
+ iic1.Add (iicr1);
+
+ /* add another IPv6 address for second prefix advertised on first subnet */
+ stackHelper.AddAddress (r, iic1.GetInterfaceIndex (1), Ipv6Address ("2001:ABCD::2"));
+
+ /* second subnet R - n1 */
+ ipv6.NewNetwork (Ipv6Address ("2001:2::"), 64);
+ NetDeviceContainer tmp3;
+ tmp3.Add (d2.Get (0)); /* R */
+ Ipv6InterfaceContainer iicr2 = ipv6.Assign (tmp3); /* R interface */
+ iicr2.SetRouter (0, true);
+
+ NetDeviceContainer tmp4;
+ tmp4.Add (d2.Get (1)); /* n1 */
+ Ipv6InterfaceContainer iic2 = ipv6.AssignWithoutAddress (tmp4);
+ iic2.Add (iicr2);
+
+ /* radvd configuration */
+ Ipv6Address prefix ("2001:1::0"); /* create the prefix */
+ Ipv6Address prefixBis ("2001:ABCD::0"); /* create the prefix */
+ Ipv6Address prefix2 ("2001:2::0"); /* create the prefix */
+ uint32_t indexRouter = iic1.GetInterfaceIndex (1); /* R interface (n0 - R) */
+ uint32_t indexRouter2 = iic2.GetInterfaceIndex (1); /* R interface (R - n1) */
+ Ptr radvd = CreateObject ();
+ Ptr routerInterface = Create (indexRouter, 2000, 1000);
+ Ptr routerPrefix = Create (prefix, 64, 3, 5);
+ Ptr routerPrefixBis = Create (prefixBis, 64, 3, 5);
+ Ptr routerInterface2 = Create (indexRouter2, 2000, 1000);
+ Ptr routerPrefix2 = Create (prefix2, 64, 3, 5);
+
+ /* first interface advertise two prefixes (2001:1::/64 and 2001:ABCD::/64) */
+ /* prefix is added in the inverse order in packet */
+ routerInterface->AddPrefix (routerPrefix);
+ routerInterface->AddPrefix (routerPrefixBis);
+ routerInterface2->AddPrefix (routerPrefix2);
+ radvd->AddConfiguration (routerInterface);
+ radvd->AddConfiguration (routerInterface2);
+
+ r->AddApplication (radvd);
+ radvd->Start (Seconds (1.0));
+ radvd->Stop (Seconds (2.0));
+
+ /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via R */
+ uint32_t packetSize = 1024;
+ uint32_t maxPacketCount = 8;
+ Time interPacketInterval = Seconds (1.);
+ Ping6Helper ping6;
+
+ /* ping6.SetLocal (iic1.GetAddress (0, 1)); */
+ ping6.SetRemote (Ipv6Address ("2001:2::200:ff:fe00:4")); /* should be n1 address after autoconfiguration */
+ ping6.SetIfIndex (iic1.GetInterfaceIndex (0));
+
+ ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
+ ping6.SetAttribute ("Interval", TimeValue (interPacketInterval));
+ ping6.SetAttribute ("PacketSize", UintegerValue (packetSize));
+ ApplicationContainer apps = ping6.Install (net1.Get (0));
+ apps.Start (Seconds (2.0));
+ apps.Stop (Seconds (9.0));
+
+ /* RA should be received, two prefixes + routes + default route should be present */
+ Simulator::Schedule (Seconds (2.0), &StackHelper::PrintRoutingTable, &stackHelper, n0);
+ /* at the end, RA addresses and routes should be cleared */
+ Simulator::Schedule (Seconds (10.0), &StackHelper::PrintRoutingTable, &stackHelper, n0);
+
+ std::ofstream ascii;
+ ascii.open ("radvd-two-prefix.tr");
+ CsmaHelper::EnablePcapAll (std::string ("radvd-two-prefix"), true);
+ CsmaHelper::EnableAsciiAll (ascii);
+
+ NS_LOG_INFO ("Run Simulation.");
+ Simulator::Run ();
+ Simulator::Destroy ();
+ NS_LOG_INFO ("Done.");
+}
+
diff --git a/examples/radvd.cc b/examples/radvd.cc
new file mode 100644
index 000000000..e6be2af22
--- /dev/null
+++ b/examples/radvd.cc
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Strasbourg University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: David Gross
+ * Sebastien Vincent
+ */
+
+// Network topology
+// //
+// // n0 R n1
+// // | _ |
+// // ====|_|====
+// // router
+// // - R sends RA to n0's subnet (2001:1::/64);
+// // - R sends RA to n1's subnet (2001:2::/64);
+// // - n0 ping6 n1.
+// //
+// // - Tracing of queues and packet receptions to file "radvd.tr"
+
+#include
+#include "ns3/core-module.h"
+#include "ns3/simulator-module.h"
+#include "ns3/helper-module.h"
+
+#include "ns3/radvd.h"
+#include "ns3/radvd-interface.h"
+#include "ns3/radvd-prefix.h"
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("RadvdExample");
+
+int main (int argc, char** argv)
+{
+#if 0
+ LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ipv6RawSocketImpl", LOG_LEVEL_ALL);
+ LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL);
+ LogComponentEnable ("RadvdApplication", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL);
+#endif
+
+ CommandLine cmd;
+ cmd.Parse (argc, argv);
+
+ NS_LOG_INFO ("Create nodes.");
+ Ptr n0 = CreateObject ();
+ Ptr r = CreateObject ();
+ Ptr n1 = CreateObject ();
+
+ NodeContainer net1 (n0, r);
+ NodeContainer net2 (r, n1);
+ NodeContainer all (n0, r, n1);
+
+ NS_LOG_INFO ("Create IPv6 Internet Stack");
+ InternetStackHelper internetv6;
+ internetv6.Install (all);
+
+ NS_LOG_INFO ("Create channels.");
+ CsmaHelper csma;
+ csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
+ csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
+ NetDeviceContainer d1 = csma.Install (net1); /* n0 - R */
+ NetDeviceContainer d2 = csma.Install (net2); /* R - n1 */
+
+ NS_LOG_INFO ("Create networks and assign IPv6 Addresses.");
+ Ipv6AddressHelper ipv6;
+
+ /* first subnet */
+ ipv6.NewNetwork (Ipv6Address ("2001:1::"), 64);
+ NetDeviceContainer tmp;
+ tmp.Add (d1.Get (0)); /* n0 */
+ Ipv6InterfaceContainer iic1 = ipv6.AssignWithoutAddress (tmp); /* n0 interface */
+
+ NetDeviceContainer tmp2;
+ tmp2.Add (d1.Get (1)); /* R */
+ Ipv6InterfaceContainer iicr1 = ipv6.Assign (tmp2); /* R interface to the first subnet is just statically assigned */
+ iicr1.SetRouter (0, true);
+ iic1.Add (iicr1);
+
+ /* second subnet R - n1 */
+ ipv6.NewNetwork (Ipv6Address ("2001:2::"), 64);
+ NetDeviceContainer tmp3;
+ tmp3.Add (d2.Get (0)); /* R */
+ Ipv6InterfaceContainer iicr2 = ipv6.Assign (tmp3); /* R interface */
+ iicr2.SetRouter (0, true);
+
+ NetDeviceContainer tmp4;
+ tmp4.Add (d2.Get (1)); /* n1 */
+ Ipv6InterfaceContainer iic2 = ipv6.AssignWithoutAddress (tmp4);
+ iic2.Add (iicr2);
+
+ /* radvd configuration */
+ Ipv6Address prefix ("2001:1::0"); /* create the prefix */
+ Ipv6Address prefix2 ("2001:2::0"); /* create the prefix */
+ uint32_t indexRouter = iic1.GetInterfaceIndex (1); /* R interface (n0 - R) */
+ uint32_t indexRouter2 = iic2.GetInterfaceIndex (1); /* R interface (R - n1) */
+ Ptr radvd = CreateObject ();
+ Ptr routerInterface = Create (indexRouter, 5000, 1000);
+ Ptr routerPrefix = Create (prefix, 64, 3, 5);
+ Ptr routerInterface2 = Create (indexRouter2, 5000, 1000);
+ Ptr routerPrefix2 = Create (prefix2, 64, 3, 5);
+
+ routerInterface->AddPrefix (routerPrefix);
+ routerInterface2->AddPrefix (routerPrefix2);
+ radvd->AddConfiguration (routerInterface);
+ radvd->AddConfiguration (routerInterface2);
+
+ r->AddApplication (radvd);
+ radvd->Start (Seconds (1.0));
+ radvd->Stop (Seconds (10.0));
+
+ /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via R */
+ uint32_t packetSize = 1024;
+ uint32_t maxPacketCount = 5;
+ Time interPacketInterval = Seconds (1.);
+ Ping6Helper ping6;
+
+ /* ping6.SetLocal (iic1.GetAddress (0, 1)); */
+ ping6.SetRemote (Ipv6Address ("2001:2::200:ff:fe00:4")); /* should be n1 address after autoconfiguration */
+ ping6.SetIfIndex (iic1.GetInterfaceIndex (0));
+
+ ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
+ ping6.SetAttribute ("Interval", TimeValue (interPacketInterval));
+ ping6.SetAttribute ("PacketSize", UintegerValue (packetSize));
+ ApplicationContainer apps = ping6.Install (net1.Get (0));
+ apps.Start (Seconds (2.0));
+ apps.Stop (Seconds (7.0));
+
+ std::ofstream ascii;
+ ascii.open ("radvd.tr");
+ CsmaHelper::EnablePcapAll (std::string ("radvd"), true);
+ CsmaHelper::EnableAsciiAll (ascii);
+
+ NS_LOG_INFO ("Run Simulation.");
+ Simulator::Run ();
+ Simulator::Destroy ();
+ NS_LOG_INFO ("Done.");
+}
+
diff --git a/examples/simple-routing-ping6.cc b/examples/simple-routing-ping6.cc
new file mode 100644
index 000000000..329a71c39
--- /dev/null
+++ b/examples/simple-routing-ping6.cc
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008-2009 Strasbourg University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: David Gross
+ * Sebastien Vincent
+ */
+
+// Network topology
+// //
+// // n0 r n1
+// // | _ |
+// // ====|_|====
+// // router
+// //
+// // - Tracing of queues and packet receptions to file "simple-routing-ping6.tr"
+
+#include
+#include "ns3/core-module.h"
+#include "ns3/simulator-module.h"
+#include "ns3/helper-module.h"
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("SimpleRoutingUdp6Example");
+
+int
+main (int argc, char** argv)
+{
+#if 0
+ LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL);
+ LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL);
+ LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL);
+#endif
+
+ CommandLine cmd;
+ cmd.Parse (argc, argv);
+
+ NS_LOG_INFO ("Create nodes.");
+ Ptr n0 = CreateObject ();
+ Ptr r = CreateObject ();
+ Ptr n1 = CreateObject ();
+
+ NodeContainer net1 (n0, r);
+ NodeContainer net2 (r, n1);
+ NodeContainer all (n0, r, n1);
+
+ NS_LOG_INFO ("Create IPv6 Internet Stack");
+ InternetStackHelper internetv6;
+ internetv6.Install (all);
+
+ NS_LOG_INFO ("Create channels.");
+ CsmaHelper csma;
+ csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
+ csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
+ NetDeviceContainer d1 = csma.Install (net1);
+ NetDeviceContainer d2 = csma.Install (net2);
+
+ NS_LOG_INFO ("Create networks and assign IPv6 Addresses.");
+ Ipv6AddressHelper ipv6;
+ ipv6.NewNetwork (Ipv6Address ("2001:1::"), 64);
+ Ipv6InterfaceContainer i1 = ipv6.Assign (d1);
+ i1.SetRouter (1, true);
+ ipv6.NewNetwork (Ipv6Address ("2001:2::"), 64);
+ Ipv6InterfaceContainer i2 = ipv6.Assign (d2);
+ i2.SetRouter (0, true);
+
+ /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r */
+ uint32_t packetSize = 1024;
+ uint32_t maxPacketCount = 5;
+ Time interPacketInterval = Seconds (1.);
+ Ping6Helper ping6;
+
+ ping6.SetLocal (i1.GetAddress (0, 1));
+ ping6.SetRemote (i2.GetAddress (1, 1));
+ /* ping6.SetRemote (Ipv6Address::GetAllNodesMulticast ()); */
+
+ ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
+ ping6.SetAttribute ("Interval", TimeValue (interPacketInterval));
+ ping6.SetAttribute ("PacketSize", UintegerValue (packetSize));
+ ApplicationContainer apps = ping6.Install (net1.Get (0));
+ apps.Start (Seconds (2.0));
+ apps.Stop (Seconds (20.0));
+
+ std::ofstream ascii;
+ ascii.open ("simple-routing-ping6.tr");
+ CsmaHelper::EnablePcapAll (std::string ("simple-routing-ping6"), true);
+ CsmaHelper::EnableAsciiAll (ascii);
+
+ NS_LOG_INFO ("Run Simulation.");
+ Simulator::Run ();
+ Simulator::Destroy ();
+ NS_LOG_INFO ("Done.");
+}
+
diff --git a/examples/wscript b/examples/wscript
index ca0e171c4..86cd89734 100644
--- a/examples/wscript
+++ b/examples/wscript
@@ -147,6 +147,26 @@ def build(bld):
['point-to-point', 'internet-stack'])
obj.source = 'test-ipv6.cc'
+ obj = bld.create_ns3_program('ping6',
+ ['csma', 'internet-stack'])
+ obj.source = 'ping6.cc'
+
+ obj = bld.create_ns3_program('simple-routing-ping6',
+ ['csma', 'internet-stack'])
+ obj.source = 'simple-routing-ping6.cc'
+
+ obj = bld.create_ns3_program('icmpv6-redirect',
+ ['csma', 'internet-stack'])
+ obj.source = 'icmpv6-redirect.cc'
+
+ obj = bld.create_ns3_program('radvd',
+ ['csma', 'internet-stack'])
+ obj.source = 'radvd.cc'
+
+ obj = bld.create_ns3_program('radvd-two-prefix',
+ ['csma', 'internet-stack'])
+ obj.source = 'radvd-two-prefix.cc'
+
env = bld.env_of_name('default')
if env['ENABLE_EMU']:
obj = bld.create_ns3_program('emu-udp-echo', ['emu', 'internet-stack'])
diff --git a/src/applications/ping6/ping6.cc b/src/applications/ping6/ping6.cc
new file mode 100644
index 000000000..202d3b982
--- /dev/null
+++ b/src/applications/ping6/ping6.cc
@@ -0,0 +1,236 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007-2009 Strasbourg University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Sebastien Vincent
+ */
+
+#include "ns3/log.h"
+#include "ns3/nstime.h"
+#include "ns3/simulator.h"
+#include "ns3/socket-factory.h"
+#include "ns3/packet.h"
+#include "ns3/socket.h"
+#include "ns3/uinteger.h"
+#include "ns3/ipv6.h"
+#include "ns3/ipv6-address.h"
+#include "ns3/inet6-socket-address.h"
+#include "ns3/icmpv6-header.h"
+#include "ns3/ipv6-raw-socket-factory.h"
+#include "ns3/ipv6-header.h"
+
+#include "ping6.h"
+
+namespace ns3
+{
+
+NS_LOG_COMPONENT_DEFINE ("Ping6Application");
+
+NS_OBJECT_ENSURE_REGISTERED (Ping6);
+
+TypeId Ping6::GetTypeId ()
+{
+ static TypeId tid = TypeId ("ns3::Ping6")
+ .SetParent()
+ .AddConstructor()
+ .AddAttribute ("MaxPackets",
+ "The maximum number of packets the application will send",
+ UintegerValue (100),
+ MakeUintegerAccessor (&Ping6::m_count),
+ MakeUintegerChecker())
+ .AddAttribute ("Interval",
+ "The time to wait between packets",
+ TimeValue (Seconds (1.0)),
+ MakeTimeAccessor (&Ping6::m_interval),
+ MakeTimeChecker ())
+ .AddAttribute ("RemoteIpv6",
+ "The Ipv6Address of the outbound packets",
+ Ipv6AddressValue (),
+ MakeIpv6AddressAccessor (&Ping6::m_peerAddress),
+ MakeIpv6AddressChecker ())
+ .AddAttribute ("LocalIpv6",
+ "Local Ipv6Address of the sender",
+ Ipv6AddressValue (),
+ MakeIpv6AddressAccessor (&Ping6::m_localAddress),
+ MakeIpv6AddressChecker ())
+ .AddAttribute ("PacketSize",
+ "Size of packets generated",
+ UintegerValue (100),
+ MakeUintegerAccessor (&Ping6::m_size),
+ MakeUintegerChecker())
+ ;
+ return tid;
+}
+
+Ping6::Ping6 ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ m_sent = 0;
+ m_socket = 0;
+ m_seq = 0;
+ m_sendEvent = EventId ();
+}
+
+Ping6::~Ping6 ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ m_socket = 0;
+}
+
+void Ping6::DoDispose ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ Application::DoDispose ();
+}
+
+void Ping6::StartApplication ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+
+ if (!m_socket)
+ {
+ TypeId tid = TypeId::LookupByName ("ns3::Ipv6RawSocketFactory");
+ m_socket = Socket::CreateSocket (GetNode (), tid);
+
+ NS_ASSERT (m_socket);
+
+ m_socket->Bind (Inet6SocketAddress (m_localAddress, 0));
+ m_socket->Connect (Inet6SocketAddress (m_peerAddress, 0));
+ m_socket->SetAttribute ("Protocol", UintegerValue (58)); /* ICMPv6 */
+ m_socket->SetRecvCallback (MakeCallback (&Ping6::HandleRead, this));
+ }
+
+ ScheduleTransmit (Seconds (0.));
+}
+
+void Ping6::SetLocal (Ipv6Address ipv6)
+{
+ NS_LOG_FUNCTION (this << ipv6);
+ m_localAddress = ipv6;
+}
+
+void Ping6::SetRemote (Ipv6Address ipv6)
+{
+ NS_LOG_FUNCTION (this << ipv6);
+ m_peerAddress = ipv6;
+}
+
+void Ping6::StopApplication ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+
+ if (m_socket)
+ {
+ m_socket->SetRecvCallback (MakeNullCallback >());
+ }
+
+ Simulator::Cancel (m_sendEvent);
+}
+
+void Ping6::SetIfIndex (uint32_t ifIndex)
+{
+ m_ifIndex = ifIndex;
+}
+
+void Ping6::ScheduleTransmit (Time dt)
+{
+ NS_LOG_FUNCTION (this << dt);
+ m_sendEvent = Simulator::Schedule (dt, &Ping6::Send, this);
+}
+
+void Ping6::Send ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ NS_ASSERT (m_sendEvent.IsExpired ());
+ Ptr p = 0;
+ uint8_t data[4];
+ Ipv6Address src;
+ Ptr ipv6 = GetNode ()->GetObject ();
+
+ if (m_ifIndex > 0)
+ {
+ /* hack to have ifIndex in Ipv6RawSocketImpl
+ * maybe add a SetIfIndex in Ipv6RawSocketImpl directly
+ */
+ src = GetNode ()->GetObject ()->GetAddress (m_ifIndex, 0).GetAddress ();
+ }
+ else
+ {
+ src = m_localAddress;
+ }
+
+ data[0] = 0xDE;
+ data[1] = 0xAD;
+ data[2] = 0xBE;
+ data[3] = 0xEF;
+
+ p = Create(data, sizeof (data));
+ Icmpv6Echo req (1);
+
+ req.SetId (0xBEEF);
+ req.SetSeq (m_seq);
+ m_seq++;
+
+ /* we do not calculate pseudo header checksum here, because we are not sure about
+ * source IPv6 address. Checksum is calculated in Ipv6RawSocketImpl.
+ */
+
+ p->AddHeader (req);
+ m_socket->Bind (Inet6SocketAddress (src, 0));
+ m_socket->Send (p, 0);
+ ++m_sent;
+
+ NS_LOG_INFO ("Sent " << p->GetSize () << " bytes to " << m_peerAddress);
+
+ if (m_sent < m_count)
+ {
+ ScheduleTransmit (m_interval);
+ }
+}
+
+void Ping6::HandleRead (Ptr socket)
+{
+ NS_LOG_FUNCTION (this << socket);
+
+ Ptr packet=0;
+ Address from;
+ while (packet = socket->RecvFrom (from))
+ {
+ if (Inet6SocketAddress::IsMatchingType (from))
+ {
+ Ipv6Header hdr;
+ Icmpv6Echo reply (0);
+ Inet6SocketAddress address = Inet6SocketAddress::ConvertFrom (from);
+
+ packet->RemoveHeader (hdr);
+
+ switch (*packet->PeekData ())
+ {
+ case Icmpv6Header::ICMPV6_ECHO_REPLY:
+ packet->RemoveHeader (reply);
+
+ NS_LOG_INFO ("Received Echo Reply size = " << std::dec << packet->GetSize () << " bytes from " << address.GetIpv6 () << " id = " << (uint16_t)reply.GetId () << " seq = " << (uint16_t)reply.GetSeq ());
+ break;
+ default:
+ /* other type, discard */
+ break;
+ }
+ }
+ }
+}
+
+} /* namespace ns3 */
+
diff --git a/src/applications/ping6/ping6.h b/src/applications/ping6/ping6.h
new file mode 100644
index 000000000..bbf105c4c
--- /dev/null
+++ b/src/applications/ping6/ping6.h
@@ -0,0 +1,171 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007-2009 Strasbourg University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Sebastien Vincent
+ */
+
+#ifndef PING6_H
+#define PING6_H
+
+#include "ns3/application.h"
+#include "ns3/event-id.h"
+#include "ns3/ptr.h"
+#include "ns3/ipv6-address.h"
+
+namespace ns3
+{
+
+class Packet;
+class Socket;
+
+/**
+ * \class Ping6
+ * \brief A ping6 application.
+ */
+class Ping6 : public Application
+{
+ public:
+ /**
+ * \brief Get the type ID.
+ * \return type ID
+ */
+ static TypeId GetTypeId ();
+
+ /**
+ * \brief Constructor.
+ */
+ Ping6 ();
+
+ /**
+ * \brief Destructor.
+ */
+ virtual ~Ping6 ();
+
+ /**
+ * \brief Set the local address.
+ * \param ipv6 the local IPv6 address
+ */
+ void SetLocal (Ipv6Address ipv6);
+
+ /**
+ * \brief Set the remote peer.
+ * \param ipv6 IPv6 address of the peer
+ */
+ void SetRemote (Ipv6Address ipv6);
+
+ /**
+ * \brief Set the out interface index.
+ * This is to send to link-local (unicast or multicast) address
+ * when a node has multiple interfaces.
+ * \param ifIndex interface index
+ */
+ void SetIfIndex (uint32_t ifIndex);
+
+ protected:
+ /**
+ * \brief Dispose this object;
+ */
+ virtual void DoDispose ();
+
+ private:
+ /**
+ * \brief Start the application.
+ */
+ virtual void StartApplication ();
+
+ /**
+ * \brief Stop the application.
+ */
+ virtual void StopApplication ();
+
+ /**
+ * \brief Schedule sending a packet.
+ * \param dt interval between packet
+ */
+ void ScheduleTransmit (Time dt);
+
+ /**
+ * \brief Send a packet.
+ */
+ void Send ();
+
+ /**
+ * \brief Receive method.
+ * \param socket socket that receive a packet
+ */
+ void HandleRead (Ptr socket);
+
+ /**
+ * \brief Peer IPv6 address.
+ */
+ Ipv6Address m_address;
+
+ /**
+ * \brief Number of "Echo request" packets that will be sent.
+ */
+ uint32_t m_count;
+
+ /**
+ * \brief Number of packets sent.
+ */
+ uint32_t m_sent;
+
+ /**
+ * \brief Size of the packet.
+ */
+ uint32_t m_size;
+
+ /**
+ * \brief Intervall between packets sent.
+ */
+ Time m_interval;
+
+ /**
+ * \brief Local address.
+ */
+ Ipv6Address m_localAddress;
+
+ /**
+ * \brief Peer address.
+ */
+ Ipv6Address m_peerAddress;
+
+ /**
+ * \brief Local socket.
+ */
+ Ptr m_socket;
+
+ /**
+ * \brief Sequence number.
+ */
+ uint16_t m_seq;
+
+ /**
+ * \brief Event ID.
+ */
+ EventId m_sendEvent;
+
+ /**
+ * \brief Out interface (i.e. for link-local communication).
+ */
+ uint32_t m_ifIndex;
+};
+
+} /* namespace ns3 */
+
+#endif /* PING6_H */
+
diff --git a/src/applications/ping6/waf b/src/applications/ping6/waf
new file mode 100644
index 000000000..4283ec141
--- /dev/null
+++ b/src/applications/ping6/waf
@@ -0,0 +1 @@
+exec "`dirname "$0"`"/../../../waf "$@"
diff --git a/src/applications/ping6/wscript b/src/applications/ping6/wscript
new file mode 100644
index 000000000..2aebe2afd
--- /dev/null
+++ b/src/applications/ping6/wscript
@@ -0,0 +1,13 @@
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+def build(bld):
+ module = bld.create_ns3_module('ping6', ['internet-stack'])
+ module.source = [
+ 'ping6.cc',
+ ]
+ headers = bld.new_task_gen('ns3header')
+ headers.module = 'ping6'
+ headers.source = [
+ 'ping6.h',
+ ]
+
diff --git a/src/applications/radvd/radvd-interface.cc b/src/applications/radvd/radvd-interface.cc
new file mode 100644
index 000000000..b5009ecea
--- /dev/null
+++ b/src/applications/radvd/radvd-interface.cc
@@ -0,0 +1,292 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Strasbourg University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Sebastien Vincent
+ */
+
+#include "radvd-interface.h"
+
+namespace ns3
+{
+
+RadvdInterface::RadvdInterface (uint32_t interface)
+ : m_interface (interface)
+{
+ /* initialize default value as specified in radvd.conf manpage */
+ m_sendAdvert = true;
+ m_maxRtrAdvInterval = 600000;
+ m_minRtrAdvInterval = (uint32_t)(double)(0.33 * m_maxRtrAdvInterval);
+ m_minDelayBetweenRAs = 3000;
+ m_managedFlag = false;
+ m_otherConfigFlag = false;
+ m_linkMtu = 0; /* 0 means not sending MTU option in RA */
+ m_reachableTime = 0; /* means unspecified for the router */
+ m_retransTimer = 0; /* means unspecified for the router */
+ m_curHopLimit = 64;
+ m_defaultLifeTime = 3 * m_maxRtrAdvInterval;
+ m_defaultPreference = 1;
+ m_sourceLLAddress = true;
+ m_homeAgentFlag = false;
+ m_homeAgentInfo = false;
+ m_homeAgentLifeTime = 0;
+ m_homeAgentPreference = 0;
+ m_mobRtrSupportFlag = false;
+ m_intervalOpt = false;
+}
+
+RadvdInterface::RadvdInterface (uint32_t interface, uint32_t maxRtrAdvInterval, uint32_t minRtrAdvInterval)
+ : m_interface (interface)
+{
+ NS_ASSERT (maxRtrAdvInterval > minRtrAdvInterval);
+ m_sendAdvert = true;
+ m_maxRtrAdvInterval = maxRtrAdvInterval;
+ m_minRtrAdvInterval = minRtrAdvInterval;
+ m_minDelayBetweenRAs = 3000;
+ m_managedFlag = false;
+ m_otherConfigFlag = false;
+ m_linkMtu = 0; /* 0 means not sending MTU option in RA */
+ m_reachableTime = 0; /* means unspecified for the router */
+ m_retransTimer = 0; /* means unspecified for the router */
+ m_curHopLimit = 64;
+ m_defaultLifeTime = 3 * m_maxRtrAdvInterval;
+ m_defaultPreference = 1;
+ m_sourceLLAddress = true;
+ m_homeAgentFlag = false;
+ m_homeAgentInfo = false;
+ m_homeAgentLifeTime = 0;
+ m_homeAgentPreference = 0;
+ m_mobRtrSupportFlag = false;
+ m_intervalOpt = false;
+}
+
+RadvdInterface::~RadvdInterface ()
+{
+ /* clear prefixes */
+ for (RadvdPrefixListI it = m_prefixes.begin () ; it != m_prefixes.end () ; ++it)
+ {
+ (*it) = 0;
+ }
+ m_prefixes.clear ();
+}
+
+void RadvdInterface::AddPrefix (Ptr routerPrefix)
+{
+ m_prefixes.push_back (routerPrefix);
+}
+
+
+uint32_t RadvdInterface::GetInterface () const
+{
+ return m_interface;
+}
+
+std::list > RadvdInterface::GetPrefixes () const
+{
+ return m_prefixes;
+}
+
+bool RadvdInterface::IsSendAdvert () const
+{
+ return m_sendAdvert;
+}
+
+void RadvdInterface::SetSendAdvert (bool sendAdvert)
+{
+ m_sendAdvert = sendAdvert;
+}
+
+uint32_t RadvdInterface::GetMaxRtrAdvInterval () const
+{
+ return m_maxRtrAdvInterval;
+}
+
+void RadvdInterface::SetMaxRtrAdvInterval (uint32_t maxRtrAdvInterval)
+{
+ m_maxRtrAdvInterval = maxRtrAdvInterval;
+}
+
+uint32_t RadvdInterface::GetMinRtrAdvInterval () const
+{
+ return m_minRtrAdvInterval;
+}
+
+void RadvdInterface::SetMinRtrAdvInterval (uint32_t minRtrAdvInterval)
+{
+ m_minRtrAdvInterval = minRtrAdvInterval;
+}
+
+uint32_t RadvdInterface::GetMinDelayBetweenRAs () const
+{
+ return m_minDelayBetweenRAs;
+}
+
+void RadvdInterface::SetMinDelayBetweenRAs (uint32_t minDelayBetweenRAs)
+{
+ m_minDelayBetweenRAs = minDelayBetweenRAs;
+}
+
+bool RadvdInterface::IsManagedFlag () const
+{
+ return m_managedFlag;
+}
+
+void RadvdInterface::SetManagedFlag (bool managedFlag)
+{
+ m_managedFlag = managedFlag;
+}
+
+bool RadvdInterface::IsOtherConfigFlag () const
+{
+ return m_otherConfigFlag;
+}
+
+void RadvdInterface::SetOtherConfigFlag (bool otherConfigFlag)
+{
+ m_otherConfigFlag = otherConfigFlag;
+}
+
+uint32_t RadvdInterface::GetLinkMtu () const
+{
+ return m_linkMtu;
+}
+
+void RadvdInterface::SetLinkMtu (uint32_t linkMtu)
+{
+ m_linkMtu = linkMtu;
+}
+
+uint32_t RadvdInterface::GetReachableTime () const
+{
+ return m_reachableTime;
+}
+
+void RadvdInterface::SetReachableTime (uint32_t reachableTime)
+{
+ m_reachableTime = reachableTime;
+}
+
+uint32_t RadvdInterface::GetDefaultLifeTime () const
+{
+ return m_defaultLifeTime;
+}
+
+void RadvdInterface::SetDefaultLifeTime (uint32_t defaultLifeTime)
+{
+ m_defaultLifeTime = defaultLifeTime;
+}
+
+uint32_t RadvdInterface::GetRetransTimer () const
+{
+ return m_retransTimer;
+}
+
+void RadvdInterface::SetRetransTimer (uint32_t retransTimer)
+{
+ m_retransTimer = retransTimer;
+}
+
+uint8_t RadvdInterface::GetCurHopLimit () const
+{
+ return m_curHopLimit;
+}
+
+void RadvdInterface::SetCurHopLimit (uint8_t curHopLimit)
+{
+ m_curHopLimit = curHopLimit;
+}
+
+uint8_t RadvdInterface::GetDefaultPreference () const
+{
+ return m_defaultPreference;
+}
+
+void RadvdInterface::SetDefaultPreference (uint8_t defaultPreference)
+{
+ m_defaultPreference = defaultPreference;
+}
+
+bool RadvdInterface::IsSourceLLAddress () const
+{
+ return m_sourceLLAddress;
+}
+
+void RadvdInterface::SetSourceLLAddress (bool sourceLLAddress)
+{
+ m_sourceLLAddress = sourceLLAddress;
+}
+
+bool RadvdInterface::IsHomeAgentFlag () const
+{
+ return m_homeAgentFlag;
+}
+
+void RadvdInterface::SetHomeAgentFlag (bool homeAgentFlag)
+{
+ m_homeAgentFlag = homeAgentFlag;
+}
+
+bool RadvdInterface::IsHomeAgentInfo () const
+{
+ return m_homeAgentInfo;
+}
+
+void RadvdInterface::SetHomeAgentInfo (bool homeAgentInfo)
+{
+ m_homeAgentInfo = homeAgentInfo;
+}
+
+uint32_t RadvdInterface::GetHomeAgentLifeTime () const
+{
+ return m_homeAgentLifeTime;
+}
+
+void RadvdInterface::SetHomeAgentLifeTime (uint32_t homeAgentLifeTime)
+{
+ m_homeAgentLifeTime = homeAgentLifeTime;
+}
+
+uint32_t RadvdInterface::GetHomeAgentPreference () const
+{
+ return m_homeAgentPreference;
+}
+
+void RadvdInterface::SetHomeAgentPreference (uint32_t homeAgentPreference)
+{
+ m_homeAgentPreference = homeAgentPreference;
+}
+
+bool RadvdInterface::IsMobRtrSupportFlag () const
+{
+ return m_mobRtrSupportFlag;
+}
+
+void RadvdInterface::SetMobRtrSupportFlag (bool mobRtrSupportFlag)
+{
+ m_mobRtrSupportFlag = mobRtrSupportFlag;
+}
+
+bool RadvdInterface::IsIntervalOpt () const
+{
+ return m_intervalOpt;
+}
+
+void RadvdInterface::SetIntervalOpt (bool intervalOpt)
+{
+ m_intervalOpt = intervalOpt;
+}
+} /* namespace ns3 */
+
diff --git a/src/applications/radvd/radvd-interface.h b/src/applications/radvd/radvd-interface.h
new file mode 100644
index 000000000..e5381f494
--- /dev/null
+++ b/src/applications/radvd/radvd-interface.h
@@ -0,0 +1,420 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Strasbourg University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Sebastien Vincent
+ */
+
+#ifndef RADVD_INTERFACE_H
+#define RADVD_INTERFACE_H
+
+#include
+
+#include "radvd-prefix.h"
+
+namespace ns3
+{
+
+/**
+ * \class RadvdInterface
+ * \brief Radvd interface configuration.
+ */
+class RadvdInterface : public RefCountBase
+{
+ public:
+ /**
+ * \brief Constructor.
+ * \param interface interface index
+ */
+ RadvdInterface (uint32_t interface);
+
+ /**
+ * \brief Constructor.
+ * \param interface interface index
+ * \param maxRtrAdvInterval maximum RA interval
+ * \param minRtrAdvInterval minimum RA interval
+ */
+ RadvdInterface (uint32_t interface, uint32_t maxRtrAdvInterval, uint32_t minRtrAdvInterval);
+
+ /**
+ * \brief Destructor.
+ */
+ ~RadvdInterface ();
+
+ /**
+ * \brief Get interface index for this configuration.
+ * \return interface index
+ */
+ uint32_t GetInterface () const;
+
+ /**
+ * \brief Get list of prefixes advertised for this interface.
+ * \return list of IPv6 prefixes
+ */
+ std::list > GetPrefixes () const;
+
+ /**
+ * \brief Add a prefix to advertise on interface.
+ * \param routerPrefix prefix to advertise
+ */
+ void AddPrefix (Ptr routerPrefix);
+
+ /**
+ * \brief Is send advert enabled (periodic RA and reply to RS) ?
+ * \return send advert flag
+ */
+ bool IsSendAdvert () const;
+
+ /**
+ * \brief Set send advert flag.
+ * \return sendAdvert value
+ */
+ void SetSendAdvert (bool sendAdvert);
+
+ /**
+ * \brief Get maximum RA interval.
+ * \return RA interval
+ */
+ uint32_t GetMaxRtrAdvInterval () const;
+
+ /**
+ * \brief Get maximum RA interval.
+ * \param maxRtrAdvInterval RA interval
+ */
+ void SetMaxRtrAdvInterval (uint32_t maxRtrAdvInterval);
+
+ /**
+ * \brief Get minimum RA interval.
+ * \return RA interval
+ */
+ uint32_t GetMinRtrAdvInterval () const;
+
+ /**
+ * \brief Get minimum RA interval.
+ * \param minRtrAdvInterval RA interval
+ */
+ void SetMinRtrAdvInterval (uint32_t minRtrAdvInterval);
+
+ /**
+ * \brief Get minimum delay between RAs.
+ * \return minimum delay
+ */
+ uint32_t GetMinDelayBetweenRAs () const;
+
+ /**
+ * \brief Set minimum delay between RAs.
+ * \param minDelayBetweenRAs minimum delay
+ */
+ void SetMinDelayBetweenRAs (uint32_t minDelayBetweenRAs);
+
+ /**
+ * \brief Is managed flag enabled ?
+ * \return managed flag
+ */
+ bool IsManagedFlag () const;
+
+ /**
+ * \brief Set managed flag
+ * \param managedFlag value
+ */
+ void SetManagedFlag (bool managedFlag);
+
+ /**
+ * \brief Is "other config" flag enabled ?
+ * \return other config flag
+ */
+ bool IsOtherConfigFlag () const;
+
+ /**
+ * \brief Set "other config" flag
+ * \param otherConfigFlag value
+ */
+ void SetOtherConfigFlag (bool otherConfigFlag);
+
+ /**
+ * \brief Get link MTU.
+ * \return link MTU
+ */
+ uint32_t GetLinkMtu () const;
+
+ /**
+ * \brief Set link MTU.
+ * \param linkMtu link MTU
+ */
+ void SetLinkMtu (uint32_t linkMtu);
+
+ /**
+ * \brief Get reachable time.
+ * \return reachable time
+ */
+ uint32_t GetReachableTime () const;
+
+ /**
+ * \brief Set reachable time.
+ * \param reachableTime reachable time
+ */
+ void SetReachableTime (uint32_t reachableTime);
+
+ /**
+ * \brief Get default lifetime.
+ * \return default lifetime
+ */
+ uint32_t GetDefaultLifeTime () const;
+
+ /**
+ * \brief Set default lifetime.
+ * \param defaultLifeTime default lifetime
+ */
+ void SetDefaultLifeTime (uint32_t defaultLifeTime);
+
+ /**
+ * \brief Get retransmission timer.
+ * \return retransmission timer
+ */
+ uint32_t GetRetransTimer () const;
+
+ /**
+ * \brief Set retransmission timer.
+ * \param retransTimer retransmission timer
+ */
+ void SetRetransTimer (uint32_t retransTimer);
+
+ /**
+ * \brief Get current hop limit.
+ * \return current hop limit for the link
+ */
+ uint8_t GetCurHopLimit () const;
+
+ /**
+ * \brief Set current hop limit.
+ * \param curHopLimit current hop limit for the link
+ */
+ void SetCurHopLimit (uint8_t curHopLimit);
+
+ /**
+ * \brief Get default preference.
+ * \return default preference
+ */
+ uint8_t GetDefaultPreference () const;
+
+ /**
+ * \brief Set default preference.
+ * \param defaultPreference default preference
+ */
+ void SetDefaultPreference (uint8_t defaultPreference);
+
+ /**
+ * \brief Is source LLA option should be included in RA ?
+ * \return true if source address is added in RA, false otherwise
+ */
+ bool IsSourceLLAddress () const;
+
+ /**
+ * \brief Set flag to add or not LLA to RA.
+ * \param sourceLLAddress value
+ */
+ void SetSourceLLAddress (bool sourceLLAddress);
+
+ /**
+ * \brief Is "home agent" flag enabled ?
+ * \return "home agent" flag
+ */
+ bool IsHomeAgentFlag () const;
+
+ /**
+ * \brief Set "home agent" flag.
+ * \param homeAgentFlag value
+ */
+ void SetHomeAgentFlag (bool homeAgentFlag);
+
+ /**
+ * \brief Is Home Agent Information option should be included in RA ?
+ * \return true if HA information option is added in RA, false otherwise
+ */
+ bool IsHomeAgentInfo () const;
+
+ /**
+ * \brief Set flag to add or not HA information option to RA.
+ * \param homeAgentFlag value
+ */
+ void SetHomeAgentInfo (bool homeAgentFlag);
+
+ /**
+ * \brief Get home agent lifetime.
+ * \return home agent lifetime
+ */
+ uint32_t GetHomeAgentLifeTime () const;
+
+ /**
+ * \brief Set home agent lifetime.
+ * \param homeAgentLifeTime home agent lifetime
+ */
+ void SetHomeAgentLifeTime (uint32_t homeAgentLifeTime);
+
+ /**
+ * \brief Get home agent preference.
+ * \return home agent preference
+ */
+ uint32_t GetHomeAgentPreference () const;
+
+ /**
+ * \brief Set home agent preference.
+ * \param homeAgentPreference home agent preference
+ */
+ void SetHomeAgentPreference (uint32_t homeAgentPreference);
+
+ /**
+ * \brief Is "mobile router support" flag enabled ?
+ * \return "mobile router support" flag
+ */
+ bool IsMobRtrSupportFlag () const;
+
+ /**
+ * \brief Set "mobile router support" flag.
+ * \param mobRtrSupportFlag value
+ */
+ void SetMobRtrSupportFlag (bool mobRtrSupportFlag);
+
+ /**
+ * \brief Is advertisement interval option should be included in RA ?
+ * \return true if advertisement interval option is added in RA, false otherwise
+ */
+ bool IsIntervalOpt () const;
+
+ /**
+ * \brief Set flag to add or not advertisement interval to RA.
+ * \param intervalOpt value
+ */
+ void SetIntervalOpt (bool intervalOpt);
+
+ private:
+ typedef std::list > RadvdPrefixList;
+ typedef std::list >::iterator RadvdPrefixListI;
+
+ /**
+ * \brief Interface to advertise RA.
+ */
+ uint32_t m_interface;
+
+ /**
+ * \brief List of prefixes to advertise.
+ */
+ RadvdPrefixList m_prefixes;
+
+ /**
+ * \brief Flag whether or not router sends periodic RA and respond to RS.
+ */
+ bool m_sendAdvert;
+
+ /**
+ * \brief Maximum RA interval in milliseconds.
+ */
+ uint32_t m_maxRtrAdvInterval;
+
+ /**
+ * \brief Minimum RA interval in milliseconds.
+ */
+ uint32_t m_minRtrAdvInterval;
+
+ /**
+ * \brief Minimum delay between RA in milliseconds.
+ */
+ uint32_t m_minDelayBetweenRAs;
+
+ /**
+ * \brief Managed flag. If true host use the stateful protocol for address autoconfiguration.
+ */
+ bool m_managedFlag;
+
+ /**
+ * \brief Other configuration flag. If true host use stateful protocol for other (non-address) information.
+ */
+ bool m_otherConfigFlag;
+
+ /**
+ * \brief Link MTU to use.
+ */
+ uint32_t m_linkMtu;
+
+ /**
+ * \brief Reachable time in milliseconds.
+ */
+ uint32_t m_reachableTime;
+
+ /**
+ * \brief Retransmission timer in milliseconds.
+ */
+ uint32_t m_retransTimer;
+
+ /**
+ * \brief Current hop limit (TTL).
+ */
+ uint32_t m_curHopLimit;
+
+ /**
+ * \brief Default life time in seconds.
+ */
+ uint32_t m_defaultLifeTime;
+
+ /**
+ * \brief Preference associated with default router.
+ * 0 = low
+ * 1 = medium
+ * 2 = high
+ */
+ uint8_t m_defaultPreference;
+
+ /**
+ * \brief Flag to add link-layer address in RA.
+ */
+ bool m_sourceLLAddress;
+
+ /**
+ * \brief Flag to add HA (home agent) flag in RA.
+ */
+ bool m_homeAgentFlag;
+
+ /**
+ * \brief Flag to add Home Agent Information option (Mobile IPv6).
+ * Currently not implemented.
+ */
+ bool m_homeAgentInfo;
+
+ /**
+ * \brief Home agent lifetime in seconds. Ignored if home agent info is not set.
+ */
+ uint32_t m_homeAgentLifeTime;
+
+ /**
+ * \brief Home agent preference. Ignored if home agent info is not set.
+ */
+ uint32_t m_homeAgentPreference;
+
+ /**
+ * \brief Flag for HA to signals it supports Mobile Router registrations (NEMO Basic).
+ */
+ bool m_mobRtrSupportFlag;
+
+ /**
+ * \brief Flag to add Advertisement Interval option in RA.
+ */
+ bool m_intervalOpt;
+};
+
+} /* namespace ns3 */
+
+#endif /* RADVD_INTERFACE_H */
+
diff --git a/src/applications/radvd/radvd-prefix.cc b/src/applications/radvd/radvd-prefix.cc
new file mode 100644
index 000000000..3ed9442e1
--- /dev/null
+++ b/src/applications/radvd/radvd-prefix.cc
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Strasbourg University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Sebastien Vincent
+ */
+
+#include "radvd-prefix.h"
+
+namespace ns3
+{
+
+RadvdPrefix::RadvdPrefix (Ipv6Address network, uint8_t prefixLength, uint32_t preferredLifeTime, uint32_t validLifeTime, bool onLinkFlag, bool autonomousFlag, bool routerAddrFlag)
+ : m_network (network),
+ m_prefixLength (prefixLength),
+ m_preferredLifeTime (preferredLifeTime),
+ m_validLifeTime (validLifeTime),
+ m_onLinkFlag (onLinkFlag),
+ m_autonomousFlag (autonomousFlag),
+ m_routerAddrFlag (routerAddrFlag)
+{
+}
+
+RadvdPrefix::~RadvdPrefix ()
+{
+}
+
+Ipv6Address RadvdPrefix::GetNetwork () const
+{
+ return m_network;
+}
+
+void RadvdPrefix::SetNetwork (Ipv6Address network)
+{
+ m_network = network;
+}
+
+uint8_t RadvdPrefix::GetPrefixLength () const
+{
+ return m_prefixLength;
+}
+
+void RadvdPrefix::SetPrefixLength (uint8_t prefixLength)
+{
+ m_prefixLength = prefixLength;
+}
+
+uint32_t RadvdPrefix::GetValidLifeTime () const
+{
+ return m_validLifeTime;
+}
+
+void RadvdPrefix::SetValidLifeTime (uint32_t validLifeTime)
+{
+ m_validLifeTime = validLifeTime;
+}
+
+uint32_t RadvdPrefix::GetPreferredLifeTime () const
+{
+ return m_preferredLifeTime;
+}
+
+void RadvdPrefix::SetPreferredLifeTime (uint32_t preferredLifeTime)
+{
+ m_preferredLifeTime = preferredLifeTime;
+}
+
+bool RadvdPrefix::IsOnLinkFlag () const
+{
+ return m_onLinkFlag;
+}
+
+void RadvdPrefix::SetOnLinkFlag (bool onLinkFlag)
+{
+ m_onLinkFlag = onLinkFlag;
+}
+
+bool RadvdPrefix::IsAutonomousFlag () const
+{
+ return m_autonomousFlag;
+}
+
+void RadvdPrefix::SetAutonomousFlag (bool autonomousFlag)
+{
+ m_autonomousFlag = autonomousFlag;
+}
+
+bool RadvdPrefix::IsRouterAddrFlag () const
+{
+ return m_routerAddrFlag;
+}
+
+void RadvdPrefix::SetRouterAddrFlag (bool routerAddrFlag)
+{
+ m_routerAddrFlag = routerAddrFlag;
+}
+
+} /* namespace ns3 */
+
diff --git a/src/applications/radvd/radvd-prefix.h b/src/applications/radvd/radvd-prefix.h
new file mode 100644
index 000000000..168648bd1
--- /dev/null
+++ b/src/applications/radvd/radvd-prefix.h
@@ -0,0 +1,180 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Strasbourg University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Sebastien Vincent
+ */
+
+#ifndef RADVD_PREFIX_H
+#define RADVD_PREFIX_H
+
+#include
+
+#include "ns3/ipv6-address.h"
+
+namespace ns3
+{
+
+/**
+ * \class RadvdPrefix
+ * \brief Router prefix for radvd application.
+ */
+class RadvdPrefix : public RefCountBase
+{
+ public:
+ /**
+ * \brief Constructor.
+ * \param network network prefix advertised
+ * \param prefixLength prefix length ( 0 < x <= 128)
+ * \param preferredLifeTime preferred life time in seconds (default 7 days)
+ * \param validLifeTime valid life time in seconds (default 30 days)
+ * \param onLinkFlag on link flag
+ * \param autonomousFlag autonomous link flag
+ * \param routerAddrFlag router address flag (for Mobile IPv6)
+ */
+ RadvdPrefix (Ipv6Address network, uint8_t prefixLength, uint32_t preferredLifeTime = 604800, uint32_t validLifeTime = 2592000, bool onLinkFlag = true, bool autonomousFlag = true, bool routerAddrFlag = false);
+
+ /**
+ * \brief Destructor.
+ */
+ ~RadvdPrefix ();
+
+ /**
+ * \brief Get network prefix.
+ * \return network prefix
+ */
+ Ipv6Address GetNetwork () const;
+
+ /**
+ * \brief Set network prefix.
+ * \param network network prefix
+ */
+ void SetNetwork (Ipv6Address network);
+
+ /**
+ * \brief Get prefix length.
+ * \return prefix length
+ */
+ uint8_t GetPrefixLength () const;
+
+ /**
+ * \brief Set prefix length.
+ * \param prefixLength prefix length
+ */
+ void SetPrefixLength (uint8_t prefixLength);
+
+ /**
+ * \brief Get preferred lifetime.
+ * \return lifetime
+ */
+ uint32_t GetPreferredLifeTime () const;
+
+ /**
+ * \brief Set preferred lifetime.
+ * \param preferredLifeTime lifetime
+ */
+ void SetPreferredLifeTime (uint32_t preferredLifeTime);
+
+ /**
+ * \brief Get valid lifetime.
+ * \return lifetime
+ */
+ uint32_t GetValidLifeTime () const;
+
+ /**
+ * \brief Set valid lifetime.
+ * \param validLifeTime lifetime
+ */
+ void SetValidLifeTime (uint32_t validLifeTime);
+
+ /**
+ * \brief Is on-link flag ?
+ * \return true if on-link is activated, false otherwise
+ */
+ bool IsOnLinkFlag () const;
+
+ /**
+ * \brief Set on-link flag.
+ * \param onLinkFlag value
+ */
+ void SetOnLinkFlag (bool onLinkFlag);
+
+ /**
+ * \brief Is autonomous flag ?
+ * \return true if autonomous is activated, false otherwise
+ */
+ bool IsAutonomousFlag () const;
+
+ /**
+ * \brief Set autonomous flag.
+ * \param autonomousFlag value
+ */
+ void SetAutonomousFlag (bool autonomousFlag);
+
+ /**
+ * \brief Is router address flag ?
+ * \return true if router address is activated, false otherwise
+ */
+ bool IsRouterAddrFlag () const;
+
+ /**
+ * \brief Set router address flag.
+ * \param routerAddrFlag value
+ */
+ void SetRouterAddrFlag (bool routerAddrFlag);
+
+ private:
+ /**
+ * \brief Network prefix.
+ */
+ Ipv6Address m_network;
+
+ /**
+ * \brief Prefix length.
+ */
+ uint8_t m_prefixLength;
+
+ /**
+ * \brief Preferred time.
+ */
+ uint32_t m_preferredLifeTime;
+
+ /**
+ * \brief Valid time.
+ */
+ uint32_t m_validLifeTime;
+
+ /**
+ * \brief On link flag, indicates that this prefix can be used for on-link determination.
+ */
+ bool m_onLinkFlag;
+
+ /**
+ * \brief Autonomous flag, it is used for autonomous address configuration (RFC 2462).
+ */
+ bool m_autonomousFlag;
+
+ /**
+ * \brief Router address flag, indicates that router address is sent instead
+ * of network prefix as is required by Mobile IPv6.
+ */
+ bool m_routerAddrFlag;
+};
+
+} /* namespace ns3 */
+
+#endif /* RADVD_PREFIX_H */
+
diff --git a/src/applications/radvd/radvd.cc b/src/applications/radvd/radvd.cc
new file mode 100644
index 000000000..e4f3f3796
--- /dev/null
+++ b/src/applications/radvd/radvd.cc
@@ -0,0 +1,273 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008 Telecom Bretagne
+ * Copyright (c) 2009 Strasbourg University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Sebastien Vincent
+ * Mehdi Benamor
+ */
+
+#include "ns3/log.h"
+#include "ns3/ipv6-address.h"
+#include "ns3/nstime.h"
+#include "ns3/simulator.h"
+#include "ns3/packet.h"
+#include "ns3/net-device.h"
+#include "ns3/uinteger.h"
+#include "ns3/random-variable.h"
+#include "ns3/inet6-socket-address.h"
+#include "ns3/ipv6.h"
+#include "ns3/ipv6-raw-socket-factory.h"
+#include "ns3/ipv6-header.h"
+#include "ns3/icmpv6-header.h"
+
+#include "radvd.h"
+
+namespace ns3
+{
+
+NS_LOG_COMPONENT_DEFINE ("RadvdApplication");
+
+NS_OBJECT_ENSURE_REGISTERED (Radvd);
+
+TypeId Radvd::GetTypeId ()
+{
+ static TypeId tid = TypeId ("ns3::Radvd")
+ .SetParent ()
+ .AddConstructor ()
+ ;
+ return tid;
+}
+
+Radvd::Radvd ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+}
+
+Radvd::~Radvd ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ for (RadvdInterfaceListI it = m_configurations.begin () ; it != m_configurations.end () ; ++it)
+ {
+ *it = 0;
+ }
+ m_configurations.clear ();
+ m_socket = 0;
+}
+
+void Radvd::DoDispose ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ Application::DoDispose ();
+}
+
+void Radvd::StartApplication ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+
+ if (!m_socket)
+ {
+ TypeId tid = TypeId::LookupByName ("ns3::Ipv6RawSocketFactory");
+ m_socket = Socket::CreateSocket (GetNode (), tid);
+
+ NS_ASSERT (m_socket);
+
+/* m_socket->Bind (Inet6SocketAddress (m_localAddress, 0)); */
+/* m_socket->Connect (Inet6SocketAddress (Ipv6Address::GetAllNodesMulticast (), 0)); */
+ m_socket->SetAttribute ("Protocol", UintegerValue (58)); /* ICMPv6 */
+ m_socket->SetRecvCallback (MakeCallback (&Radvd::HandleRead, this));
+ }
+
+ for (RadvdInterfaceListCI it = m_configurations.begin () ; it != m_configurations.end () ; it++)
+ {
+ m_eventIds[(*it)->GetInterface ()] = EventId ();
+ ScheduleTransmit (Seconds (0.), (*it), m_eventIds[(*it)->GetInterface ()]);
+ }
+}
+
+void Radvd::StopApplication ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+
+ if (m_socket)
+ {
+ m_socket->SetRecvCallback (MakeNullCallback > ());
+ }
+
+ for (EventIdMapI it = m_eventIds.begin () ; it != m_eventIds.end () ; ++it)
+ {
+ Simulator::Cancel ((*it).second);
+ }
+ m_eventIds.clear ();
+}
+
+void Radvd::AddConfiguration (Ptr routerInterface)
+{
+ m_configurations.push_back (routerInterface);
+}
+
+void Radvd::ScheduleTransmit (Time dt, Ptr config, EventId& eventId)
+{
+ NS_LOG_FUNCTION (this << dt);
+ eventId = Simulator::Schedule (dt, &Radvd::Send, this, config, Ipv6Address::GetAllNodesMulticast ());
+}
+
+void Radvd::Send (Ptr config, Ipv6Address dst)
+{
+ NS_LOG_FUNCTION (this << dst);
+ NS_ASSERT (m_eventIds[config->GetInterface ()].IsExpired ());
+ Icmpv6RA raHdr;
+ Icmpv6OptionLinkLayerAddress llaHdr;
+ Icmpv6OptionMtu mtuHdr;
+ Icmpv6OptionPrefixInformation prefixHdr;
+
+ if (m_eventIds.size () == 0)
+ {
+ return;
+ }
+
+ std::list > prefixes = config->GetPrefixes ();
+ Ptr p = Create ();
+ Ptr ipv6 = GetNode ()->GetObject ();
+
+ /* set RA header information */
+ raHdr.SetFlagM (config->IsManagedFlag ());
+ raHdr.SetFlagO (config->IsOtherConfigFlag ());
+ raHdr.SetFlagH (config->IsHomeAgentFlag ());
+ raHdr.SetCurHopLimit (config->GetCurHopLimit ());
+ raHdr.SetLifeTime (config->GetDefaultLifeTime ());
+ raHdr.SetReachableTime (config->GetReachableTime ());
+ raHdr.SetRetransmissionTime (config->GetRetransTimer ());
+
+ if (config->IsSourceLLAddress ())
+ {
+ /* Get L2 address from NetDevice */
+ Address addr = ipv6->GetNetDevice (config->GetInterface ())->GetAddress ();
+ llaHdr = Icmpv6OptionLinkLayerAddress (true, addr);
+ p->AddHeader (llaHdr);
+ }
+
+ if (config->GetLinkMtu ())
+ {
+ NS_ASSERT (config->GetLinkMtu () >= 1280);
+ mtuHdr = Icmpv6OptionMtu (config->GetLinkMtu ());
+ p->AddHeader (mtuHdr);
+ }
+
+ /* add list of prefixes */
+ for (std::list >::const_iterator jt = prefixes.begin () ; jt != prefixes.end () ; jt++)
+ {
+ uint8_t flags = 0;
+ prefixHdr = Icmpv6OptionPrefixInformation ();
+ prefixHdr.SetPrefix ((*jt)->GetNetwork ());
+ prefixHdr.SetPrefixLength ((*jt)->GetPrefixLength ());
+ prefixHdr.SetValidTime ((*jt)->GetValidLifeTime ());
+ prefixHdr.SetPreferredTime ((*jt)->GetPreferredLifeTime ());
+
+ if ((*jt)->IsOnLinkFlag ())
+ {
+ flags += 1 << 7;
+ }
+
+ if ((*jt)->IsAutonomousFlag ())
+ {
+ flags += 1 << 6;
+ }
+
+ if ((*jt)->IsRouterAddrFlag ())
+ {
+ flags += 1 << 5;
+ }
+
+ prefixHdr.SetFlags (flags);
+
+ p->AddHeader (prefixHdr);
+ }
+
+ Ipv6Address src = ipv6->GetAddress (config->GetInterface (), 0).GetAddress ();
+ m_socket->Bind (Inet6SocketAddress (src, 0));
+ m_socket->Connect (Inet6SocketAddress (dst, 0));
+
+ /* as we know interface index that will be used to send RA and
+ * we always send RA with router's link-local address, we can
+ * calculate checksum here.
+ */
+ raHdr.CalculatePseudoHeaderChecksum (src, dst, p->GetSize () + raHdr.GetSerializedSize (), 58 /* ICMPv6 */);
+ p->AddHeader (raHdr);
+
+ /* send RA */
+ NS_LOG_LOGIC ("Send RA");
+ m_socket->Send (p, 0);
+
+ UniformVariable rnd;
+ uint32_t delay = rnd.GetValue (config->GetMinRtrAdvInterval (), config->GetMaxRtrAdvInterval ());
+ Time t = MilliSeconds (delay);
+ ScheduleTransmit (t, config, m_eventIds[config->GetInterface ()]);
+}
+
+void Radvd::HandleRead (Ptr socket)
+{
+ NS_LOG_FUNCTION (this << socket);
+ Ptr packet = 0;
+ Address from;
+
+ while (packet = socket->RecvFrom (from))
+ {
+ if (Inet6SocketAddress::IsMatchingType (from))
+ {
+ Ipv6Header hdr;
+ Icmpv6RS rsHdr;
+ Inet6SocketAddress address = Inet6SocketAddress::ConvertFrom (from);
+ uint32_t delay = 0;
+ UniformVariable rnd;
+ Time t;
+
+ packet->RemoveHeader (hdr);
+
+ switch (*packet->PeekData ())
+ {
+ case Icmpv6Header::ICMPV6_ND_ROUTER_SOLICITATION:
+ /* send RA in response of a RS */
+ packet->RemoveHeader (rsHdr);
+ NS_LOG_INFO ("Received ICMPv6 Router Solicitation from " << hdr.GetSourceAddress () << " code = " << (uint32_t)rsHdr.GetCode ());
+
+ delay = rnd.GetValue (0, 500); /* default value for MAX_RA_DELAY_TIME */
+ t = Simulator::Now () + MilliSeconds (delay);
+
+#if 0
+ NS_LOG_INFO ("schedule new RA : " << t.GetTimeStep () << " next scheduled RA" << (int64_t)m_sendEvent.GetTs ());
+
+ if (t.GetTimeStep () < (int64_t)m_sendEvent.GetTs ())
+ {
+ /* send multicast RA */
+ /* maybe replace this by a unicast RA (it is a SHOULD in the RFC) */
+ NS_LOG_INFO ("Respond to RS");
+ /* XXX advertise just the prefix for the interface not all */
+ t = MilliSeconds (delay);
+ /* XXX schedule packet send */
+ /* ScheduleTransmit (t); */
+ }
+#endif
+ break;
+ default:
+ break;
+ }
+ }
+ }
+}
+
+} /* namespace ns3 */
+
diff --git a/src/applications/radvd/radvd.h b/src/applications/radvd/radvd.h
new file mode 100644
index 000000000..0b3273ede
--- /dev/null
+++ b/src/applications/radvd/radvd.h
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008 Telecom Bretagne
+ * Copyright (c) 2009 Strasbourg University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Sebastien Vincent
+ * Mehdi Benamor
+ */
+
+#ifndef RADVD_H
+#define RADVD_H
+
+#include