Doxygen fixes to Topology-read, Ipv6, and tcp-socket

This commit is contained in:
Tommaso Pecorella
2013-11-14 22:43:53 +01:00
parent 4213b79edd
commit 2fa1712985
55 changed files with 2078 additions and 358 deletions

View File

@@ -26,6 +26,8 @@
#include <list>
/**
* \brief Register the class in the ns-3 factory.
*
* This macro should be invoked once for every class which
* defines a new GetTypeId method.
*/

View File

@@ -64,7 +64,8 @@ class Object : public SimpleRefCount<Object,ObjectBase,ObjectDeleter>
{
public:
/**
* Get the type ID.
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);

View File

@@ -625,8 +625,8 @@ private:
public:
/**
* \brief dijsktra algorithm to get the best route from m_netGraph and update the m_bestRoutesTable_link
* \when current graph information has changed
* \brief Dijsktra algorithm to get the best route from m_netGraph and update the m_bestRoutesTable_link
* when current graph information has changed
* \param The type of the cache
*/
void SetCacheType (std::string type);

View File

@@ -153,7 +153,7 @@ public:
*/
Ptr<dsr::PassiveBuffer> GetPassiveBuffer () const;
///\functions used to direct to route cache
/// functions used to direct to route cache
//\{
bool IsLinkCache ();
void UseExtends (RouteCacheEntry::IP_VECTOR rt);

View File

@@ -216,16 +216,16 @@ namespace ns3 {
// Global maps of protocol/interface pairs to file objects seems to fit the
// bill.
//
typedef std::pair<Ptr<Ipv4>, uint32_t> InterfacePairIpv4;
typedef std::map<InterfacePairIpv4, Ptr<PcapFileWrapper> > InterfaceFileMapIpv4;
typedef std::map<InterfacePairIpv4, Ptr<OutputStreamWrapper> > InterfaceStreamMapIpv4;
typedef std::pair<Ptr<Ipv4>, uint32_t> InterfacePairIpv4; /**< Ipv4/interface pair */
typedef std::map<InterfacePairIpv4, Ptr<PcapFileWrapper> > InterfaceFileMapIpv4; /**< Ipv4/interface and Pcap file wrapper container */
typedef std::map<InterfacePairIpv4, Ptr<OutputStreamWrapper> > InterfaceStreamMapIpv4; /**< Ipv4/interface and output stream container */
static InterfaceFileMapIpv4 g_interfaceFileMapIpv4; /**< A mapping of Ipv4/interface pairs to pcap files */
static InterfaceStreamMapIpv4 g_interfaceStreamMapIpv4; /**< A mapping of Ipv4/interface pairs to ascii streams */
typedef std::pair<Ptr<Ipv6>, uint32_t> InterfacePairIpv6;
typedef std::map<InterfacePairIpv6, Ptr<PcapFileWrapper> > InterfaceFileMapIpv6;
typedef std::map<InterfacePairIpv6, Ptr<OutputStreamWrapper> > InterfaceStreamMapIpv6;
typedef std::pair<Ptr<Ipv6>, uint32_t> InterfacePairIpv6; /**< Ipv6/interface pair */
typedef std::map<InterfacePairIpv6, Ptr<PcapFileWrapper> > InterfaceFileMapIpv6; /**< Ipv6/interface and Pcap file wrapper container */
typedef std::map<InterfacePairIpv6, Ptr<OutputStreamWrapper> > InterfaceStreamMapIpv6; /**< Ipv6/interface and output stream container */
static InterfaceFileMapIpv6 g_interfaceFileMapIpv6; /**< A mapping of Ipv6/interface pairs to pcap files */
static InterfaceStreamMapIpv6 g_interfaceStreamMapIpv6; /**< A mapping of Ipv6/interface pairs to pcap files */
@@ -490,6 +490,12 @@ InternetStackHelper::Install (std::string nodeName) const
Install (node);
}
/**
* \brief Sync function for IPv4 packet - Pcap output
* \param p smart pointer to the packet
* \param ipv4 smart pointer to the node's IPv4 stack
* \param interface incoming interface
*/
static void
Ipv4L3ProtocolRxTxSink (Ptr<const Packet> p, Ptr<Ipv4> ipv4, uint32_t interface)
{
@@ -582,6 +588,12 @@ InternetStackHelper::EnablePcapIpv4Internal (std::string prefix, Ptr<Ipv4> ipv4,
g_interfaceFileMapIpv4[std::make_pair (ipv4, interface)] = file;
}
/**
* \brief Sync function for IPv6 packet - Pcap output
* \param p smart pointer to the packet
* \param ipv6 smart pointer to the node's IPv6 stack
* \param interface incoming interface
*/
static void
Ipv6L3ProtocolRxTxSink (Ptr<const Packet> p, Ptr<Ipv6> ipv6, uint32_t interface)
{
@@ -674,6 +686,15 @@ InternetStackHelper::EnablePcapIpv6Internal (std::string prefix, Ptr<Ipv6> ipv6,
g_interfaceFileMapIpv6[std::make_pair (ipv6, interface)] = file;
}
/**
* \brief Sync function for IPv4 dropped packet - Ascii output
* \param stream the output stream
* \param header IPv4 header
* \param packet smart pointer to the packet
* \param reason the reason for the dropping
* \param ipv4 smart pointer to the node's IPv4 stack
* \param interface incoming interface
*/
static void
Ipv4L3ProtocolDropSinkWithoutContext (
Ptr<OutputStreamWrapper> stream,
@@ -701,6 +722,13 @@ Ipv4L3ProtocolDropSinkWithoutContext (
*stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
}
/**
* \brief Sync function for IPv4 transmitted packet - Ascii output
* \param stream the output stream
* \param packet smart pointer to the packet
* \param ipv4 smart pointer to the node's IPv4 stack
* \param interface incoming interface
*/
static void
Ipv4L3ProtocolTxSinkWithoutContext (
Ptr<OutputStreamWrapper> stream,
@@ -718,6 +746,13 @@ Ipv4L3ProtocolTxSinkWithoutContext (
*stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
}
/**
* \brief Sync function for IPv4 received packet - Ascii output
* \param stream the output stream
* \param packet smart pointer to the packet
* \param ipv4 smart pointer to the node's IPv4 stack
* \param interface incoming interface
*/
static void
Ipv4L3ProtocolRxSinkWithoutContext (
Ptr<OutputStreamWrapper> stream,
@@ -735,6 +770,16 @@ Ipv4L3ProtocolRxSinkWithoutContext (
*stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
}
/**
* \brief Sync function for IPv4 dropped packet - Ascii output
* \param stream the output stream
* \param context the context
* \param header IPv4 header
* \param packet smart pointer to the packet
* \param reason the reason for the dropping
* \param ipv4 smart pointer to the node's IPv4 stack
* \param interface incoming interface
*/
static void
Ipv4L3ProtocolDropSinkWithContext (
Ptr<OutputStreamWrapper> stream,
@@ -768,6 +813,14 @@ Ipv4L3ProtocolDropSinkWithContext (
#endif
}
/**
* \brief Sync function for IPv4 transmitted packet - Ascii output
* \param stream the output stream
* \param context the context
* \param packet smart pointer to the packet
* \param ipv4 smart pointer to the node's IPv4 stack
* \param interface incoming interface
*/
static void
Ipv4L3ProtocolTxSinkWithContext (
Ptr<OutputStreamWrapper> stream,
@@ -791,6 +844,14 @@ Ipv4L3ProtocolTxSinkWithContext (
#endif
}
/**
* \brief Sync function for IPv4 received packet - Ascii output
* \param stream the output stream
* \param context the context
* \param packet smart pointer to the packet
* \param ipv4 smart pointer to the node's IPv4 stack
* \param interface incoming interface
*/
static void
Ipv4L3ProtocolRxSinkWithContext (
Ptr<OutputStreamWrapper> stream,
@@ -963,6 +1024,15 @@ InternetStackHelper::EnableAsciiIpv4Internal (
g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = stream;
}
/**
* \brief Sync function for IPv6 dropped packet - Ascii output
* \param stream the output stream
* \param header IPv6 header
* \param packet smart pointer to the packet
* \param reason the reason for the dropping
* \param ipv6 smart pointer to the node's IPv6 stack
* \param interface incoming interface
*/
static void
Ipv6L3ProtocolDropSinkWithoutContext (
Ptr<OutputStreamWrapper> stream,
@@ -990,6 +1060,13 @@ Ipv6L3ProtocolDropSinkWithoutContext (
*stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
}
/**
* \brief Sync function for IPv6 transmitted packet - Ascii output
* \param stream the output stream
* \param packet smart pointer to the packet
* \param ipv6 smart pointer to the node's IPv6 stack
* \param interface incoming interface
*/
static void
Ipv6L3ProtocolTxSinkWithoutContext (
Ptr<OutputStreamWrapper> stream,
@@ -1007,6 +1084,13 @@ Ipv6L3ProtocolTxSinkWithoutContext (
*stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
}
/**
* \brief Sync function for IPv6 received packet - Ascii output
* \param stream the output stream
* \param packet smart pointer to the packet
* \param ipv6 smart pointer to the node's IPv6 stack
* \param interface incoming interface
*/
static void
Ipv6L3ProtocolRxSinkWithoutContext (
Ptr<OutputStreamWrapper> stream,
@@ -1024,6 +1108,16 @@ Ipv6L3ProtocolRxSinkWithoutContext (
*stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
}
/**
* \brief Sync function for IPv6 dropped packet - Ascii output
* \param stream the output stream
* \param context the context
* \param header IPv6 header
* \param packet smart pointer to the packet
* \param reason the reason for the dropping
* \param ipv6 smart pointer to the node's IPv6 stack
* \param interface incoming interface
*/
static void
Ipv6L3ProtocolDropSinkWithContext (
Ptr<OutputStreamWrapper> stream,
@@ -1057,6 +1151,14 @@ Ipv6L3ProtocolDropSinkWithContext (
#endif
}
/**
* \brief Sync function for IPv6 transmitted packet - Ascii output
* \param stream the output stream
* \param context the context
* \param packet smart pointer to the packet
* \param ipv6 smart pointer to the node's IPv6 stack
* \param interface incoming interface
*/
static void
Ipv6L3ProtocolTxSinkWithContext (
Ptr<OutputStreamWrapper> stream,
@@ -1080,6 +1182,14 @@ Ipv6L3ProtocolTxSinkWithContext (
#endif
}
/**
* \brief Sync function for IPv6 received packet - Ascii output
* \param stream the output stream
* \param context the context
* \param packet smart pointer to the packet
* \param ipv6 smart pointer to the node's IPv6 stack
* \param interface incoming interface
*/
static void
Ipv6L3ProtocolRxSinkWithContext (
Ptr<OutputStreamWrapper> stream,

View File

@@ -80,7 +80,15 @@ public:
* Destroy the InternetStackHelper
*/
virtual ~InternetStackHelper(void);
/**
* \brief Copy constructor
*/
InternetStackHelper (const InternetStackHelper &);
/**
* \brief Copy constructor
*/
InternetStackHelper &operator = (const InternetStackHelper &o);
/**
@@ -266,8 +274,21 @@ private:
uint32_t interface,
bool explicitFilename);
/**
* \brief Initialize the helper to its default values
*/
void Initialize (void);
/**
* \internal
* \brief TCP objects factory
*/
ObjectFactory m_tcpFactory;
/**
* \internal
* \brief IPv4 routing helper.
*/
const Ipv4RoutingHelper *m_routing;
/**
@@ -278,6 +299,10 @@ private:
/**
* \internal
*
* \brief create an object from its TypeId and aggregates it to the node
* \param node the node
* \param typeId the object TypeId
*/
static void CreateAndAggregateObjectFromTypeId (Ptr<Node> node, const std::string typeId);
@@ -288,40 +313,64 @@ private:
/**
* \internal
*
* \brief checks if there is an hook to a Pcap wrapper
* \param ipv4 pointer to the IPv4 object
* \returns true if a hook is found
*/
bool PcapHooked (Ptr<Ipv4> ipv4);
/**
* \internal
*
* \brief checks if there is an hook to an ascii output stream
* \param ipv4 pointer to the IPv4 object
* \returns true if a hook is found
*/
bool AsciiHooked (Ptr<Ipv4> ipv4);
/**
* \internal
*
* \brief checks if there is an hook to a Pcap wrapper
* \param ipv6 pointer to the IPv6 object
* \returns true if a hook is found
*/
bool PcapHooked (Ptr<Ipv6> ipv6);
/**
* \internal
*
* \brief checks if there is an hook to an ascii output stream
* \param ipv6 pointer to the IPv6 object
* \returns true if a hook is found
*/
bool AsciiHooked (Ptr<Ipv6> ipv6);
/**
* \internal
*
* \brief IPv4 install state (enabled/disabled) ?
*/
bool m_ipv4Enabled;
/**
* \internal
*
* \brief IPv6 install state (enabled/disabled) ?
*/
bool m_ipv6Enabled;
/**
* \internal
*
* \brief IPv4 ARP Jitter state (enabled/disabled) ?
*/
bool m_ipv4ArpJitterEnabled;
/**
* \internal
*
* \brief IPv6 IPv6 NS and RS Jitter state (enabled/disabled) ?
*/
bool m_ipv6NsRsJitterEnabled;

View File

@@ -268,7 +268,7 @@ public:
void EnableAsciiIpv4All (Ptr<OutputStreamWrapper> stream);
/**
* @brief Enable pcap output on the Ipv4 and interface pair specified by a
* @brief Enable ascii trace output on the Ipv4 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv4 aggregated to a node, the node-id unambiguously
* determines the Ipv4.
@@ -283,7 +283,7 @@ public:
void EnableAsciiIpv4 (std::string prefix, uint32_t nodeid, uint32_t deviceid, bool explicitFilename);
/**
* @brief Enable pcap output on the Ipv4 and interface pair specified by a
* @brief Enable ascii trace output on the Ipv4 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv4 aggregated to a node, the node-id unambiguously
* determines the Ipv4.
@@ -299,7 +299,21 @@ public:
private:
/**
* @internal Avoid code duplication.
* @internal
*
* @brief Enable ascii trace output on the Ipv4 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv4 aggregated to a node, the node-id unambiguously
* determines the Ipv4.
*
* @param stream An OutputStreamWrapper representing an existing file to use
* when writing trace data.
* @param prefix Filename prefix to use when creating ascii trace files
* @param nodeid The node identifier/number of the node on which to enable
* ascii tracing
* @param interface The device identifier/index of the device on which to enable
* ascii tracing
* @param explicitFilename Treat the prefix as an explicit filename if true.
*/
void EnableAsciiIpv4Impl (Ptr<OutputStreamWrapper> stream,
std::string prefix,
@@ -308,17 +322,50 @@ private:
bool explicitFilename);
/**
* @internal Avoid code duplication.
* @internal
*
* @brief Enable ascii trace output on the Ipv4 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv4 aggregated to a node, the node-id unambiguously
* determines the Ipv4.
*
* @param stream An OutputStreamWrapper representing an existing file to use
* when writing trace data.
* @param prefix Filename prefix to use when creating ascii trace files
* @param n container of nodes.
*/
void EnableAsciiIpv4Impl (Ptr<OutputStreamWrapper> stream, std::string prefix, NodeContainer n);
/**
* @internal Avoid code duplication.
* @internal
*
* @brief Enable ascii trace output on the Ipv4 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv4 aggregated to a node, the node-id unambiguously
* determines the Ipv4.
*
* @param stream An OutputStreamWrapper representing an existing file to use
* when writing trace data.
* @param prefix Filename prefix to use when creating ascii trace files
* @param c Ipv4InterfaceContainer of Ipv4 and interface pairs
*/
void EnableAsciiIpv4Impl (Ptr<OutputStreamWrapper> stream, std::string prefix, Ipv4InterfaceContainer c);
/**
* @internal Avoid code duplication.
* @internal
*
* @brief Enable ascii trace output on the Ipv4 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv4 aggregated to a node, the node-id unambiguously
* determines the Ipv4.
*
* @param stream An OutputStreamWrapper representing an existing file to use
* when writing trace data.
* @param prefix Filename prefix to use when creating ascii trace files
* @param ipv4Name Name of the Ptr<Ipv4> on which you want to enable tracing.
* @param interface The device identifier/index of the device on which to enable
* ascii tracing
* @param explicitFilename Treat the prefix as an explicit filename if true.
*/
void EnableAsciiIpv4Impl (Ptr<OutputStreamWrapper> stream,
std::string prefix,
@@ -327,7 +374,20 @@ private:
bool explicitFilename);
/**
* @internal Avoid code duplication.
* @internal
*
* @brief Enable ascii trace output on the Ipv4 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv4 aggregated to a node, the node-id unambiguously
* determines the Ipv4.
*
* @param stream An OutputStreamWrapper representing an existing file to use
* when writing trace data.
* @param prefix Filename prefix to use when creating ascii trace files
* @param ipv4 Ptr<Ipv4> on which you want to enable tracing.
* @param interface The device identifier/index of the device on which to enable
* ascii tracing
* @param explicitFilename Treat the prefix as an explicit filename if true.
*/
void EnableAsciiIpv4Impl (Ptr<OutputStreamWrapper> stream,
std::string prefix,
@@ -558,7 +618,7 @@ public:
void EnableAsciiIpv6 (Ptr<OutputStreamWrapper> stream, NodeContainer n);
/**
* @brief Enable pcap output on the Ipv6 and interface pair specified by a
* @brief Enable ascii trace output on the Ipv6 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv6 aggregated to a node, the node-id unambiguously
* determines the Ipv6.
@@ -573,7 +633,7 @@ public:
void EnableAsciiIpv6 (std::string prefix, uint32_t nodeid, uint32_t interface, bool explicitFilename);
/**
* @brief Enable pcap output on the Ipv6 and interface pair specified by a
* @brief Enable ascii trace output on the Ipv6 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv6 aggregated to a node, the node-id unambiguously
* determines the Ipv6.
@@ -605,7 +665,21 @@ public:
private:
/**
* @internal Avoid code duplication.
* @internal
*
* @brief Enable ascii trace output on the Ipv6 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv6 aggregated to a node, the node-id unambiguously
* determines the Ipv6.
*
* @param stream An OutputStreamWrapper representing an existing file to use
* when writing trace data.
* @param prefix Filename prefix to use when creating ascii trace files
* @param nodeid The node identifier/number of the node on which to enable
* ascii tracing
* @param interface The device identifier/index of the device on which to enable
* ascii tracing
* @param explicitFilename Treat the prefix as an explicit filename if true.
*/
void EnableAsciiIpv6Impl (Ptr<OutputStreamWrapper> stream,
std::string prefix,
@@ -614,17 +688,50 @@ private:
bool explicitFilename);
/**
* @internal Avoid code duplication.
* @internal
*
* @brief Enable ascii trace output on the Ipv6 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv6 aggregated to a node, the node-id unambiguously
* determines the Ipv6.
*
* @param stream An OutputStreamWrapper representing an existing file to use
* when writing trace data.
* @param prefix Filename prefix to use when creating ascii trace files
* @param n container of nodes.
*/
void EnableAsciiIpv6Impl (Ptr<OutputStreamWrapper> stream, std::string prefix, NodeContainer n);
/**
* @internal Avoid code duplication.
* @internal
*
* @brief Enable ascii trace output on the Ipv6 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv6 aggregated to a node, the node-id unambiguously
* determines the Ipv6.
*
* @param stream An OutputStreamWrapper representing an existing file to use
* when writing trace data.
* @param prefix Filename prefix to use when creating ascii trace files
* @param c Ipv6InterfaceContainer of Ipv6 and interface pairs
*/
void EnableAsciiIpv6Impl (Ptr<OutputStreamWrapper> stream, std::string prefix, Ipv6InterfaceContainer c);
/**
* @internal Avoid code duplication.
* @internal
*
* @brief Enable ascii trace output on the Ipv6 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv6 aggregated to a node, the node-id unambiguously
* determines the Ipv6.
*
* @param stream An OutputStreamWrapper representing an existing file to use
* when writing trace data.
* @param prefix Filename prefix to use when creating ascii trace files
* @param ipv6Name Name of the Ptr<Ipv6> on which you want to enable tracing.
* @param interface The device identifier/index of the device on which to enable
* ascii tracing
* @param explicitFilename Treat the prefix as an explicit filename if true.
*/
void EnableAsciiIpv6Impl (Ptr<OutputStreamWrapper> stream,
std::string prefix,
@@ -633,7 +740,20 @@ private:
bool explicitFilename);
/**
* @internal Avoid code duplication.
* @internal
*
* @brief Enable ascii trace output on the Ipv6 and interface pair specified by a
* global node-id (of a previously created node) and interface. Since there
* can be only one Ipv6 aggregated to a node, the node-id unambiguously
* determines the Ipv6.
*
* @param stream An OutputStreamWrapper representing an existing file to use
* when writing trace data.
* @param prefix Filename prefix to use when creating ascii trace files
* @param ipv6 Ptr<Ipv6> on which you want to enable tracing.
* @param interface The device identifier/index of the device on which to enable
* ascii tracing
* @param explicitFilename Treat the prefix as an explicit filename if true.
*/
void EnableAsciiIpv6Impl (Ptr<OutputStreamWrapper> stream,
std::string prefix,

View File

@@ -110,7 +110,7 @@ public:
void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \brief Request a specified routing protocol <T> from Ipv4RoutingProtocol protocol
* \brief Request a specified routing protocol &lt;T&gt; from Ipv4RoutingProtocol protocol
*
* If protocol is Ipv4ListRouting, then protocol will be searched in the list,
* otherwise a simple DynamicCast will be performed
@@ -122,11 +122,44 @@ public:
static Ptr<T> GetRouting (Ptr<Ipv4RoutingProtocol> protocol);
private:
/**
* \internal
*
* \brief prints the routing tables of a node.
* \param node The node ptr for which we need the routing table to be printed
* \param stream The output stream object to use
*
* This method calls the PrintRoutingTable() method of the
* Ipv6RoutingProtocol stored in the Ipv6 object;
* the output format is routing protocol-specific.
*/
void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \internal
*
* \brief prints the routing tables of a node at regular intervals specified by user.
* \param printInterval the time interval for which the routing table is supposed to be printed.
* \param node The node ptr for which we need the routing table to be printed
* \param stream The output stream object to use
*
* This method calls the PrintRoutingTable() method of the
* Ipv6RoutingProtocol stored in the Ipv6 object, for the selected node
* at the specified interval; the output format is routing protocol-specific.
*/
void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
};
/**
* \brief Request a specified routing protocol &lt;T&gt; from Ipv4RoutingProtocol protocol
*
* If protocol is Ipv4ListRouting, then protocol will be searched in the list,
* otherwise a simple DynamicCast will be performed
*
* \param protocol Smart pointer to Ipv4RoutingProtocol object
* \return a Smart Pointer to the requested protocol (zero if the protocol can't be found)
*/
template<class T>
Ptr<T> Ipv4RoutingHelper::GetRouting (Ptr<Ipv4RoutingProtocol> protocol)
{

View File

@@ -73,6 +73,11 @@ namespace ns3 {
* If this method is called, the addressed returned will include a
* modified EUI-64-format identifier created from the MAC address as
* specified in \RFC{4291}.
*
* BEWARE: the underlying implementation acts as a Singleton.
* In other terms, two different instances of Ipv6AddressHelper will
* pick IPv6 numbers from the same pool. Changing the network in one of them
* will also change the network in the other instances.
*/
class Ipv6AddressHelper
{

View File

@@ -41,7 +41,12 @@ namespace ns3
class Ipv6InterfaceContainer
{
public:
/**
* \brief Container Const Iterator for pairs of Ipv6 smart pointer / Interface Index.
*/
typedef std::vector<std::pair<Ptr<Ipv6>, uint32_t> >::const_iterator Iterator;
/**
* \brief Constructor.
*/
@@ -205,6 +210,10 @@ public:
void SetDefaultRoute (uint32_t i, Ipv6Address routerAddr);
private:
/**
* \internal
* \brief Container for pairs of Ipv6 smart pointer / Interface Index.
*/
typedef std::vector<std::pair<Ptr<Ipv6>, uint32_t> > InterfaceVector;
/**

View File

@@ -86,9 +86,15 @@ private:
* \internal
* \brief Assignment operator declared private and not implemented to disallow
* assignment and prevent the compiler from happily inserting its own.
* \param o object to copy from
* \returns a reference to the new object
*/
Ipv6ListRoutingHelper &operator = (const Ipv6ListRoutingHelper &o);
/**
* \internal
* \brief Container for pairs of Ipv6RoutingHelper pointer / priority.
*/
std::list<std::pair<const Ipv6RoutingHelper *,int16_t> > m_list;
};

View File

@@ -112,7 +112,7 @@ public:
void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \brief Request a specified routing protocol <T> from Ipv6RoutingProtocol protocol
* \brief Request a specified routing protocol &lt;T&gt; from Ipv6RoutingProtocol protocol
*
* If protocol is Ipv6ListRouting, then protocol will be searched in the list,
* otherwise a simple DynamicCast will be performed
@@ -124,10 +124,43 @@ public:
static Ptr<T> GetRouting (Ptr<Ipv6RoutingProtocol> protocol);
private:
/**
* \internal
*
* \brief prints the routing tables of a node.
* \param node The node ptr for which we need the routing table to be printed
* \param stream The output stream object to use
*
* This method calls the PrintRoutingTable() method of the
* Ipv6RoutingProtocol stored in the Ipv6 object;
* the output format is routing protocol-specific.
*/
void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \internal
*
* \brief prints the routing tables of a node at regular intervals specified by user.
* \param printInterval the time interval for which the routing table is supposed to be printed.
* \param node The node ptr for which we need the routing table to be printed
* \param stream The output stream object to use
*
* This method calls the PrintRoutingTable() method of the
* Ipv6RoutingProtocol stored in the Ipv6 object, for the selected node
* at the specified interval; the output format is routing protocol-specific.
*/
void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
};
/**
* \brief Request a specified routing protocol &lt;T&gt; from Ipv6RoutingProtocol protocol
*
* If protocol is Ipv6ListRouting, then protocol will be searched in the list,
* otherwise a simple DynamicCast will be performed
*
* \param protocol Smart pointer to Ipv6RoutingProtocol object
* \return a Smart Pointer to the requested protocol (zero if the protocol can't be found)
*/
template<class T>
Ptr<T> Ipv6RoutingHelper::GetRouting (Ptr<Ipv6RoutingProtocol> protocol)
{

View File

@@ -121,6 +121,8 @@ private:
* \internal
* \brief Assignment operator declared private and not implemented to disallow
* assignment and prevent the compiler from happily inserting its own.
* \param o object to copy from
* \returns a reference to the new object
*/
Ipv6StaticRoutingHelper &operator = (const Ipv6StaticRoutingHelper &o);
};

View File

@@ -24,12 +24,26 @@ public:
static uint16_t GetStaticProtocolNumber (void);
virtual int GetProtocolNumber (void) const;
/**
* \brief Receive method.
* \param p the packet
* \param header the IPv4 header
* \param interface the interface from which the packet is coming
*/
virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
Ipv4Header const &header,
Ptr<Ipv4Interface> incomingInterface);
Ipv4Header const &header,
Ptr<Ipv4Interface> incomingInterface);
/**
* \brief Receive method.
* \param p the packet
* \param header the IPv6 header
* \param interface the interface from which the packet is coming
*/
virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
Ipv6Header const &header,
Ptr<Ipv6Interface> incomingInterface);
Ipv6Header const &header,
Ptr<Ipv6Interface> incomingInterface);
void SendDestUnreachFragNeeded (Ipv4Header header, Ptr<const Packet> orgData, uint16_t nextHopMtu);
void SendTimeExceededTtl (Ipv4Header header, Ptr<const Packet> orgData);

View File

@@ -346,8 +346,7 @@ public:
/**
* \brief Receive method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param header the IPv6 header
* \param interface the interface from which the packet is coming
*/
virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,

View File

@@ -74,6 +74,15 @@ public:
virtual enum RxStatus Receive (Ptr<Packet> p,
Ipv4Header const &header,
Ptr<Ipv4Interface> incomingInterface) = 0;
/**
* \param p packet to forward up
* \param header IPv6 Header information
* \param incomingInterface the Ipv6Interface on which the packet arrived
*
* Called from lower-level layers to send the packet up
* in the stack.
*/
virtual enum RxStatus Receive (Ptr<Packet> p,
Ipv6Header const &header,
Ptr<Ipv6Interface> incomingInterface) = 0;
@@ -96,6 +105,22 @@ public:
uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
Ipv4Address payloadSource, Ipv4Address payloadDestination,
const uint8_t payload[8]);
/**
* \param icmpSource the source address of the icmp message
* \param icmpTtl the ttl of the icmp message
* \param icmpType the 'type' field of the icmp message
* \param icmpCode the 'code' field of the icmp message
* \param icmpInfo extra information dependent on the icmp message
* generated by Icmpv6L4Protocol
* \param payloadSource the source address of the packet which triggered
* the icmp message
* \param payloadDestination the destination address of the packet which
* triggered the icmp message.
* \param payload the first 8 bytes of the udp header of the packet
* which triggered the icmp message.
*/
virtual void ReceiveIcmp (Ipv6Address icmpSource, uint8_t icmpTtl,
uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
Ipv6Address payloadSource, Ipv6Address payloadDestination,
@@ -103,6 +128,7 @@ public:
typedef Callback<void,Ptr<Packet>, Ipv4Address, Ipv4Address, uint8_t, Ptr<Ipv4Route> > DownTargetCallback;
typedef Callback<void,Ptr<Packet>, Ipv6Address, Ipv6Address, uint8_t, Ptr<Ipv6Route> > DownTargetCallback6;
/**
* This method allows a caller to set the current down target callback
* set for this L4 protocol
@@ -110,7 +136,15 @@ public:
* \param cb current Callback for the L4 protocol
*/
virtual void SetDownTarget (DownTargetCallback cb) = 0;
/**
* This method allows a caller to set the current down target callback
* set for this L4 protocol
*
* \param cb current Callback for the L4 protocol
*/
virtual void SetDownTarget6 (DownTargetCallback6 cb) = 0;
/**
* This method allows a caller to get the current down target callback
* set for this L4 protocol, for
@@ -118,6 +152,13 @@ public:
* \return current Callback for the L4 protocol
*/
virtual DownTargetCallback GetDownTarget (void) const = 0;
/**
* This method allows a caller to get the current down target callback
* set for this L4 protocol, for
*
* \return current Callback for the L4 protocol
*/
virtual DownTargetCallback6 GetDownTarget6 (void) const = 0;
};

View File

@@ -50,11 +50,22 @@ class NetDevice;
class Ipv4RoutingProtocol : public Object
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
/// Callback for unicast packets to be forwarded
typedef Callback<void, Ptr<Ipv4Route>, Ptr<const Packet>, const Ipv4Header &> UnicastForwardCallback;
/// Callback for multicast packets to be forwarded
typedef Callback<void, Ptr<Ipv4MulticastRoute>, Ptr<const Packet>, const Ipv4Header &> MulticastForwardCallback;
/// Callback for packets to be locally delivered
typedef Callback<void, Ptr<const Packet>, const Ipv4Header &, uint32_t > LocalDeliverCallback;
/// Callback for routing errors (e.g., no route found)
typedef Callback<void, Ptr<const Packet>, const Ipv4Header &, Socket::SocketErrno > ErrorCallback;
/**

View File

@@ -28,54 +28,163 @@ NS_LOG_COMPONENT_DEFINE ("Ipv6AddressGenerator");
namespace ns3 {
/**
* \internal
* \ingroup address
*
* \brief Implementation class of Ipv6AddressGenerator
* This generator assigns addresses sequentially from a provided
* network address; used in topology code. It also keeps track of all
* addresses assigned to perform duplicate detection.
*
*/
class Ipv6AddressGeneratorImpl
{
public:
Ipv6AddressGeneratorImpl ();
virtual ~Ipv6AddressGeneratorImpl ();
/**
* \internal
* \brief Initialise the base network and interfaceId for the generator
*
* The first call to NextAddress() or GetAddress() will return the
* value passed in.
*
* \param net The network for the base Ipv6Address
* \param prefix The prefix of the base Ipv6Address
* \param interfaceId The base interface ID used for initialization
*/
void Init (const Ipv6Address net, const Ipv6Prefix prefix,
const Ipv6Address interfaceId);
Ipv6Address GetNetwork (const Ipv6Prefix prefix) const;
/**
* \internal
* \brief Get the next network according to the given Ipv6Prefix
*
* This operation is a pre-increment, meaning that the internal state
* is changed before returning the new network address.
*
* This also resets the interface ID to the base interface ID that was
* used for initialization.
*
* \param prefix The Ipv6Prefix used to set the next network
* \returns the IPv6 address of the next network
*/
Ipv6Address NextNetwork (const Ipv6Prefix prefix);
/**
* \internal
* \brief Get the current network of the given Ipv6Prefix
*
* Does not change the internal state; this just peeks at the current
* network
*
* \param prefix The Ipv6Prefix for the current network
* \returns the IPv6 address of the current network
*/
Ipv6Address GetNetwork (const Ipv6Prefix prefix) const;
/**
* \internal
* \brief Set the interfaceId for the given Ipv6Prefix
*
* \param interfaceId The interfaceId to set for the current Ipv6Prefix
* \param prefix The Ipv6Prefix whose address is to be set
*/
void InitAddress (const Ipv6Address interfaceId, const Ipv6Prefix prefix);
/**
* \internal
* \brief Get the Ipv6Address that will be allocated upon NextAddress ()
*
* Does not change the internal state; just is used to peek the next
* address that will be allocated upon NextAddress ()
*
* \param prefix The Ipv6Prefix for the current network
* \returns the IPv6 address
*/
Ipv6Address GetAddress (const Ipv6Prefix prefix) const;
/**
* \internal
* \brief Allocate the next Ipv6Address for the configured network and prefix
*
* This operation is a post-increment, meaning that the first address
* allocated will be the one that was initially configured.
*
* \param prefix The Ipv6Prefix for the current network
* \returns the IPv6 address
*/
Ipv6Address NextAddress (const Ipv6Prefix prefix);
/**
* \internal
* \brief Reset the networks and Ipv6Address to zero
*/
void Reset (void);
/**
* \internal
* \brief Add the Ipv6Address to the list of IPv6 entries
*
* Typically, this is used by external address allocators that want
* to make use of this class's ability to track duplicates. AddAllocated
* is always called internally for any address generated by NextAddress ()
*
* \param addr The Ipv6Address to be added to the list of Ipv6 entries
* \returns true on success
*/
bool AddAllocated (const Ipv6Address addr);
/**
* \internal
* \brief Used to turn off fatal errors and assertions, for testing
*/
void TestMode (void);
private:
static const uint32_t N_BITS = 128;
static const uint32_t MOST_SIGNIFICANT_BIT = 0x80;
private:
static const uint32_t N_BITS = 128; //!< /internal the number of bits in the address
static const uint32_t MOST_SIGNIFICANT_BIT = 0x80; //!< /internal MSB set to 1
/**
* \internal
* \brief Create an index number for the prefix
* \param prefix the prefix to index
* \returns an index
*/
uint32_t PrefixToIndex (Ipv6Prefix prefix) const;
/**
* \internal
* \brief This class holds the state for a given network
*/
class NetworkState
{
public:
uint8_t prefix[16];
uint32_t shift;
uint8_t network[16];
uint8_t addr[16];
uint8_t addrMax[16];
uint8_t prefix[16]; //!< /internal the network prefix
uint32_t shift; //!< /internal a shift
uint8_t network[16]; //!< /internal the network
uint8_t addr[16]; //!< /internal the address
uint8_t addrMax[16]; //!< /internal the maximum address
};
NetworkState m_netTable[N_BITS];
NetworkState m_netTable[N_BITS]; //!< /internal the available networks
/**
* \internal
* \brief This class holds the allocated addresses
*/
class Entry
{
public:
uint8_t addrLow[16];
uint8_t addrHigh[16];
uint8_t addrLow[16]; //!< /internal the lowest allocated address
uint8_t addrHigh[16]; //!< /internal the highest allocated address
};
std::list<Entry> m_entries;
Ipv6Address m_base;
bool m_test;
std::list<Entry> m_entries; //!< /internal contained of allocated addresses
Ipv6Address m_base; //!< /internal base address
bool m_test; //!< /internal test mode (if true)
};
Ipv6AddressGeneratorImpl::Ipv6AddressGeneratorImpl ()

View File

@@ -50,6 +50,12 @@ namespace ns3 {
* The interface ID is often an EUI-64 address derived from the MAC address,
* but can also be a pseudo-random value (\RFC{3041}). This implementation
* does not generate EUI-64-based interface IDs.
*
* BEWARE: this class acts as a Singleton.
* In other terms, two different instances of Ipv6AddressGenerator will
* pick IPv6 numbers from the same pool. Changing the network in one of them
* will also change the network in the other instances.
*
*/
class Ipv6AddressGenerator
{
@@ -68,7 +74,7 @@ public:
const Ipv6Address interfaceId = "::1");
/**
* \brief Get the next network acoording to the given Ipv6Prefix
* \brief Get the next network according to the given Ipv6Prefix
*
* This operation is a pre-increment, meaning that the internal state
* is changed before returning the new network address.
@@ -77,6 +83,7 @@ public:
* used for initialization.
*
* \param prefix The Ipv6Prefix used to set the next network
* \returns the IPv6 address of the next network
*/
static Ipv6Address NextNetwork (const Ipv6Prefix prefix);
@@ -87,6 +94,7 @@ public:
* network
*
* \param prefix The Ipv6Prefix for the current network
* \returns the IPv6 address of the current network
*/
static Ipv6Address GetNetwork (const Ipv6Prefix prefix);
@@ -103,18 +111,20 @@ public:
*
* This operation is a post-increment, meaning that the first address
* allocated will be the one that was initially configured.
* .
*
* \param prefix The Ipv6Prefix for the current network
* \returns the IPv6 address
*/
static Ipv6Address NextAddress (const Ipv6Prefix prefix);
/**
* \brief Get the Ipv6Address that will be allocated upon NextAddress()
* \brief Get the Ipv6Address that will be allocated upon NextAddress ()
*
* Does not change the internal state; just is used to peek the next
* address that will be allocated upon NextAddress ()
*
* \param prefix The Ipv6Prefix for the current network
* \returns the IPv6 address
*/
static Ipv6Address GetAddress (const Ipv6Prefix prefix);
@@ -128,9 +138,10 @@ public:
*
* Typically, this is used by external address allocators that want
* to make use of this class's ability to track duplicates. AddAllocated
* is always called internally for any address generated by NextAddress()
* is always called internally for any address generated by NextAddress ()
*
* \param addr The Ipv6Address to be added to the list of Ipv6 entries
* \returns true on success
*/
static bool AddAllocated (const Ipv6Address addr);

View File

@@ -37,7 +37,14 @@ class Ipv6EndPoint;
class Ipv6EndPointDemux
{
public:
/**
* \brief Container of the IPv6 endpoints.
*/
typedef std::list<Ipv6EndPoint *>EndPoints;
/**
* \brief Iterator to the container of the IPv6 endpoints.
*/
typedef std::list<Ipv6EndPoint *>::iterator EndPointsI;
/**

View File

@@ -149,8 +149,7 @@ public:
/**
* \brief Forward the packet to the upper level.
* \param p the packet
* \param srcAddr source address
* \param dstAddr source address
* \param header the packet header
* \param port source port
*/
void ForwardUp (Ptr<Packet> p, Ipv6Header header, uint16_t port);
@@ -171,8 +170,7 @@ private:
/**
* \brief ForwardUp wrapper.
* \param p packet
* \param saddr source IPv6 address
* \param daddr dest IPv6 address
* \param header the packet header
* \param sport source port
*/
void DoForwardUp (Ptr<Packet> p, Ipv6Header header, uint16_t sport);

View File

@@ -86,6 +86,10 @@ protected:
virtual void DoDispose ();
private:
/**
* \brief Container of the IPv6 Extensions.
*/
typedef std::list<Ptr<Ipv6Extension> > Ipv6ExtensionList_t;
/**

View File

@@ -196,6 +196,7 @@ private:
/**
* \brief Calculate padding.
* \param alignment alignment
* \return the number of pad bytes
*/
uint32_t CalculatePad (Ipv6OptionHeader::Alignment alignment) const;

View File

@@ -381,7 +381,6 @@ private:
* \brief Process the timeout for packet fragments
* \param key representing the packet fragments
* \param ipHeader the IP header of the original packet
* \param iif Input Interface
*/
void HandleFragmentsTimeout (std::pair<Ipv6Address, uint32_t> key, Ipv6Header & ipHeader);
@@ -401,6 +400,9 @@ private:
*/
void CancelTimeout ();
/**
* \brief Container for the packet fragments.
*/
typedef std::map<std::pair<Ipv6Address, uint32_t>, Ptr<Fragments> > MapFragments_t;
/**
@@ -521,6 +523,9 @@ protected:
virtual void DoDispose ();
private:
/**
* \brief Container for the extension routing.
*/
typedef std::list<Ptr<Ipv6ExtensionRouting> > Ipv6ExtensionRoutingList_t;
/**

View File

@@ -179,7 +179,22 @@ private:
*/
Scope_e m_scope;
/**
* \brief Equal to operator.
*
* \param a the first operand
* \param b the first operand
* \returns true if the operands are equal
*/
friend bool operator == (Ipv6InterfaceAddress const& a, Ipv6InterfaceAddress const& b);
/**
* \brief Not equal to operator.
*
* \param a the first operand
* \param b the first operand
* \returns true if the operands are not equal
*/
friend bool operator != (Ipv6InterfaceAddress const& a, Ipv6InterfaceAddress const& b);
/**
@@ -188,6 +203,13 @@ private:
uint32_t m_nsDadUid;
};
/**
* \brief Stream insertion operator.
*
* \param os the reference to the output stream
* \param addr the Ipv6InterfaceAddress
* \returns the reference to the output stream
*/
std::ostream& operator<< (std::ostream& os, const Ipv6InterfaceAddress &addr);
/* follow Ipv4InterfaceAddress way, maybe not inline them */

View File

@@ -257,8 +257,19 @@ protected:
virtual void DoDispose ();
private:
/**
* \brief Container for the Ipv6InterfaceAddresses.
*/
typedef std::list<Ipv6InterfaceAddress> Ipv6InterfaceAddressList;
/**
* \brief Container Iterator for the Ipv6InterfaceAddresses.
*/
typedef std::list<Ipv6InterfaceAddress>::iterator Ipv6InterfaceAddressListI;
/**
* \brief Const Container Itareator for the Ipv6InterfaceAddresses.
*/
typedef std::list<Ipv6InterfaceAddress>::const_iterator Ipv6InterfaceAddressListCI;
/**

View File

@@ -217,6 +217,7 @@ public:
/**
* \brief Get interface index which is on a specified net device.
* \param device net device
* \returns the interface index
*/
int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const;
@@ -224,6 +225,7 @@ public:
* \brief Add an address on interface.
* \param i interface index
* \param address to add
* \returns true if the operation succeeded
*/
bool AddAddress (uint32_t i, Ipv6InterfaceAddress address);
@@ -246,6 +248,7 @@ public:
* \brief Remove an address from an interface.
* \param interfaceIndex interface index
* \param addressIndex address index on the interface
* \returns true if the operation succeeded
*/
bool RemoveAddress (uint32_t interfaceIndex, uint32_t addressIndex);
@@ -255,7 +258,7 @@ public:
* \param address Ipv6Address to be removed from the interface
* \returns true if the operation succeeded
*/
bool RemoveAddress (uint32_t interface, Ipv6Address address);
bool RemoveAddress (uint32_t interfaceIndex, Ipv6Address address);
/**
* \brief Set metric for an interface.
@@ -288,6 +291,7 @@ public:
/**
* \brief Is specified interface up ?
* \param i interface index
* \returns true if the interface is up
*/
bool IsUp (uint32_t i) const;
@@ -306,6 +310,7 @@ public:
/**
* \brief Is interface allows forwarding ?
* \param i interface index
* \returns true if the interface is forwarding
*/
bool IsForwarding (uint32_t i) const;
@@ -380,11 +385,29 @@ private:
friend class Ipv6L3ProtocolTestCase;
friend class Ipv6ExtensionLooseRouting;
/**
* \brief Container of the IPv6 Interfaces.
*/
typedef std::list<Ptr<Ipv6Interface> > Ipv6InterfaceList;
/**
* \brief Container of the IPv6 Raw Sockets.
*/
typedef std::list<Ptr<Ipv6RawSocketImpl> > SocketList;
/**
* \brief Container of the IPv6 L4 instances.
*/
typedef std::list<Ptr<IpL4Protocol> > L4List_t;
/**
* \brief Container of the IPv6 Autoconfigured addresses.
*/
typedef std::list< Ptr<Ipv6AutoconfiguredPrefix> > Ipv6AutoconfiguredPrefixList;
/**
* \brief Iterator of the container of the IPv6 Autoconfigured addresses.
*/
typedef std::list< Ptr<Ipv6AutoconfiguredPrefix> >::iterator Ipv6AutoconfiguredPrefixListI;
/**
@@ -411,6 +434,7 @@ private:
/**
* \brief Copy constructor.
* \param o object to copy
* \returns the copied object
*/
Ipv6L3Protocol &operator = (const Ipv6L3Protocol& o);
@@ -421,6 +445,7 @@ private:
* \param protocol L4 protocol
* \param payloadSize payload size
* \param hopLimit Hop limit
* \param tclass Tclass
* \return newly created IPv6 header
*/
Ipv6Header BuildHeader (Ipv6Address src, Ipv6Address dst, uint8_t protocol,

View File

@@ -118,7 +118,14 @@ protected:
virtual void DoDispose (void);
private:
/**
* \brief Container identifying an IPv6 Routing Protocol entry in the list.
*/
typedef std::pair<int16_t, Ptr<Ipv6RoutingProtocol> > Ipv6RoutingProtocolEntry;
/**
* \brief Container of the IPv6 Routing Protocols.
*/
typedef std::list<Ipv6RoutingProtocolEntry> Ipv6RoutingProtocolList;
/**

View File

@@ -86,6 +86,9 @@ protected:
virtual void DoDispose ();
private:
/**
* \brief Container of the IPv6 Options types.
*/
typedef std::list<Ptr<Ipv6Option> > Ipv6OptionList_t;
/**

View File

@@ -45,22 +45,70 @@ class Ipv6PacketInfoTag : public Tag
{
public:
Ipv6PacketInfoTag ();
// Implemented, but not used in the stack yet
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
/**
* \brief Set the tag's address
*
* \param addr the address
*/
void SetAddress (Ipv6Address addr);
// Implemented, but not used in the stack yet
/**
* \brief Get the tag's address
*
* \returns the address
*/
Ipv6Address GetAddress (void) const;
/**
* \brief Set the tag's receiving interface
*
* \param ifindex the interface index
*/
void SetRecvIf (uint32_t ifindex);
/**
* \brief Get the tag's receiving interface
*
* \returns the interface index
*/
uint32_t GetRecvIf (void) const;
// Implemented, but not used in the stack yet
/**
* \brief Set the tag's Hop Limit
*
* \param ttl the hop limit
*/
void SetHoplimit (uint8_t ttl);
// Implemented, but not used in the stack yet
/**
* \brief Get the tag's Hop Limit
*
* \returns the Hop Limit
*/
uint8_t GetHoplimit (void) const;
// Implemented, but not used in the stack yet
/**
* \brief Set the tag's Traffic Class
*
* \param tclass the Traffic Class
*/
void SetTrafficClass (uint8_t tclass);
// Implemented, but not used in the stack yet
/**
* \brief Get the tag's Traffic Class
*
* \returns the Traffic Class
*/
uint8_t GetTrafficClass (void) const;
static TypeId GetTypeId (void);
// inherited functions, no doc necessary
virtual TypeId GetInstanceTypeId (void) const;
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (TagBuffer i) const;
@@ -83,10 +131,10 @@ private:
* 3. the arriving hop limit, and
* 4. the arriving traffic class value.
*/
Ipv6Address m_addr;
uint8_t m_ifindex;
uint8_t m_hoplimit;
uint8_t m_tclass;
Ipv6Address m_addr; //!< the packet address (src or dst)
uint8_t m_ifindex; //!< the Interface index
uint8_t m_hoplimit; //!< the Hop Limit
uint8_t m_tclass; //!< the Traffic Class
};
} // namespace ns3

View File

@@ -48,7 +48,12 @@ namespace ns3 {
class Ipv6PacketProbe : public Probe
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId ();
Ipv6PacketProbe ();
virtual ~Ipv6PacketProbe ();
@@ -103,7 +108,9 @@ private:
*/
void TraceSink (Ptr<const Packet> packet, Ptr<Ipv6> ipv6, uint32_t interface);
/// Traced Callback: the packet, the Ipv6 object and the interface.
TracedCallback<Ptr<const Packet>, Ptr<Ipv6>, uint32_t> m_output;
/// Traced Callback: the previous packet's size and the actual packet's size.
TracedCallback<uint32_t, uint32_t> m_outputBytes;
/// The traced packet.

View File

@@ -108,7 +108,11 @@ private:
*/
std::map<Ipv6Address, uint32_t> m_pathMtu;
/**
* \brief Container of the IPv6 PMTU data (Ipv6 destination address and expiration event).
*/
typedef std::map<Ipv6Address, EventId> ::iterator pathMtuTimerIter;
/**
* \brief Path MTU Expiration table
*/

View File

@@ -232,26 +232,26 @@ public:
/**
* \brief Set the filter to pass one ICMPv6 type
* \param the ICMPv6 type to pass
* \param type the ICMPv6 type to pass
*/
void Icmpv6FilterSetPass(uint8_t type);
/**
* \brief Set the filter to block one ICMPv6 type
* \param the ICMPv6 type to block
* \param type the ICMPv6 type to block
*/
void Icmpv6FilterSetBlock(uint8_t type);
/**
* \brief Ask the filter about the status of one ICMPv6 type
* \param the ICMPv6 type
* \param type the ICMPv6 type
* \return true if the ICMP type is passing through
*/
bool Icmpv6FilterWillPass(uint8_t type);
/**
* \brief Ask the filter about the status of one ICMPv6 type
* \param the ICMPv6 type
* \param type the ICMPv6 type
* \return true if the ICMP type is being blocked
*/
bool Icmpv6FilterWillBlock(uint8_t type);
@@ -319,7 +319,7 @@ private:
*/
typedef struct
{
uint32_t icmpv6Filt[8];
uint32_t icmpv6Filt[8]; //!< ICMPv6 filter specification
} icmpv6Filter;
/**

View File

@@ -123,6 +123,13 @@ private:
Ptr<NetDevice> m_outputDevice;
};
/**
* \brief Stream insertion operator.
*
* \param os the reference to the output stream
* \param route the Ipv6 route
* \returns the reference to the output stream
*/
std::ostream& operator<< (std::ostream& os, Ipv6Route const& route);
/**
@@ -231,6 +238,13 @@ private:
std::map<uint32_t, uint32_t> m_ttls;
};
/**
* \brief Stream insertion operator.
*
* \param os the reference to the output stream
* \param route the Ipv6 multicast route
* \returns the reference to the output stream
*/
std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoute const& route);
} /* namespace ns3 */

View File

@@ -54,11 +54,22 @@ class NetDevice;
class Ipv6RoutingProtocol : public Object
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
/// Callback for unicast packets to be forwarded
typedef Callback<void, Ptr<const NetDevice>, Ptr<Ipv6Route>, Ptr<const Packet>, const Ipv6Header &> UnicastForwardCallback;
/// Callback for multicast packets to be forwarded
typedef Callback<void, Ptr<const NetDevice>, Ptr<Ipv6MulticastRoute>, Ptr<const Packet>, const Ipv6Header &> MulticastForwardCallback;
/// Callback for packets to be locally delivered
typedef Callback<void, Ptr<const Packet>, const Ipv6Header &, uint32_t > LocalDeliverCallback;
/// Callback for routing errors (e.g., no route found)
typedef Callback<void, Ptr<const Packet>, const Ipv6Header &, Socket::SocketErrno > ErrorCallback;
/**

View File

@@ -260,6 +260,13 @@ private:
};
/**
* \brief Stream insertion operator.
*
* \param os the reference to the output stream
* \param route the Ipv6 routing table entry
* \returns the reference to the output stream
*/
std::ostream& operator<< (std::ostream& os, Ipv6RoutingTableEntry const& route);
/**
@@ -364,6 +371,13 @@ private:
std::vector<uint32_t> m_outputInterfaces;
};
/**
* \brief Stream insertion operator.
*
* \param os the reference to the output stream
* \param route the Ipv6 multicast routing table entry
* \returns the reference to the output stream
*/
std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoutingTableEntry const& route);
} /* namespace ns3 */

View File

@@ -205,6 +205,7 @@ public:
* \param origin IPv6 address of the source
* \param group the multicast group address.
* \param inputInterface the input interface index
* \return true on success
*/
bool RemoveMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface);
@@ -250,12 +251,22 @@ protected:
virtual void DoDispose ();
private:
/// Container for the network routes
typedef std::list<std::pair <Ipv6RoutingTableEntry *, uint32_t> > NetworkRoutes;
/// Const Iterator for container for the network routes
typedef std::list<std::pair <Ipv6RoutingTableEntry *, uint32_t> >::const_iterator NetworkRoutesCI;
/// Iterator for container for the network routes
typedef std::list<std::pair <Ipv6RoutingTableEntry *, uint32_t> >::iterator NetworkRoutesI;
/// Container for the multicast routes
typedef std::list<Ipv6MulticastRoutingTableEntry *> MulticastRoutes;
/// Const Iterator for container for the multicast routes
typedef std::list<Ipv6MulticastRoutingTableEntry *>::const_iterator MulticastRoutesCI;
/// Iterator for container for the multicast routes
typedef std::list<Ipv6MulticastRoutingTableEntry *>::iterator MulticastRoutesI;
/**

View File

@@ -79,6 +79,10 @@ class Ipv6RoutingProtocol;
class Ipv6 : public Object
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
/**

View File

@@ -122,22 +122,55 @@ public:
uint16_t GetUrgentPointer () const;
/**
* \param source the ip source to use in the underlying
* ip packet.
* \param destination the ip destination to use in the
* underlying ip packet.
* \param protocol the protocol number to use in the underlying
* ip packet.
* \brief Initialize the TCP checksum.
*
* If you want to use tcp checksums, you should call this
* method prior to adding the header to a packet.
*
* \param source the IP source to use in the underlying
* IP packet.
* \param destination the IP destination to use in the
* underlying IP packet.
* \param protocol the protocol number to use in the underlying
* IP packet.
*
*/
void InitializeChecksum (Ipv4Address source,
Ipv4Address destination,
uint8_t protocol);
/**
* \brief Initialize the TCP checksum.
*
* If you want to use tcp checksums, you should call this
* method prior to adding the header to a packet.
*
* \param source the IP source to use in the underlying
* IP packet.
* \param destination the IP destination to use in the
* underlying IP packet.
* \param protocol the protocol number to use in the underlying
* IP packet.
*
*/
void InitializeChecksum (Ipv6Address source,
Ipv6Address destination,
uint8_t protocol);
/**
* \brief Initialize the TCP checksum.
*
* If you want to use tcp checksums, you should call this
* method prior to adding the header to a packet.
*
* \param source the IP source to use in the underlying
* IP packet.
* \param destination the IP destination to use in the
* underlying IP packet.
* \param protocol the protocol number to use in the underlying
* IP packet.
*
*/
void InitializeChecksum (Address source,
Address destination,
uint8_t protocol);

View File

@@ -210,42 +210,42 @@ TcpSocketBase::~TcpSocketBase (void)
CancelAllTimers ();
}
/** Associate a node with this TCP socket */
/* Associate a node with this TCP socket */
void
TcpSocketBase::SetNode (Ptr<Node> node)
{
m_node = node;
}
/** Associate the L4 protocol (e.g. mux/demux) with this socket */
/* Associate the L4 protocol (e.g. mux/demux) with this socket */
void
TcpSocketBase::SetTcp (Ptr<TcpL4Protocol> tcp)
{
m_tcp = tcp;
}
/** Set an RTT estimator with this socket */
/* Set an RTT estimator with this socket */
void
TcpSocketBase::SetRtt (Ptr<RttEstimator> rtt)
{
m_rtt = rtt;
}
/** Inherit from Socket class: Returns error code */
/* Inherit from Socket class: Returns error code */
enum Socket::SocketErrno
TcpSocketBase::GetErrno (void) const
{
return m_errno;
}
/** Inherit from Socket class: Returns socket type, NS3_SOCK_STREAM */
/* Inherit from Socket class: Returns socket type, NS3_SOCK_STREAM */
enum Socket::SocketType
TcpSocketBase::GetSocketType (void) const
{
return NS3_SOCK_STREAM;
}
/** Inherit from Socket class: Returns associated node */
/* Inherit from Socket class: Returns associated node */
Ptr<Node>
TcpSocketBase::GetNode (void) const
{
@@ -253,7 +253,7 @@ TcpSocketBase::GetNode (void) const
return m_node;
}
/** Inherit from Socket class: Bind socket to an end-point in TcpL4Protocol */
/* Inherit from Socket class: Bind socket to an end-point in TcpL4Protocol */
int
TcpSocketBase::Bind (void)
{
@@ -282,7 +282,7 @@ TcpSocketBase::Bind6 (void)
return SetupCallback ();
}
/** Inherit from Socket class: Bind socket (with specific address) to an end-point in TcpL4Protocol */
/* Inherit from Socket class: Bind socket (with specific address) to an end-point in TcpL4Protocol */
int
TcpSocketBase::Bind (const Address &address)
{
@@ -352,7 +352,7 @@ TcpSocketBase::Bind (const Address &address)
return SetupCallback ();
}
/** Inherit from Socket class: Initiate connection to a remote address:port */
/* Inherit from Socket class: Initiate connection to a remote address:port */
int
TcpSocketBase::Connect (const Address & address)
{
@@ -424,7 +424,7 @@ TcpSocketBase::Connect (const Address & address)
return DoConnect ();
}
/** Inherit from Socket class: Listen on the endpoint for an incoming connection */
/* Inherit from Socket class: Listen on the endpoint for an incoming connection */
int
TcpSocketBase::Listen (void)
{
@@ -441,7 +441,7 @@ TcpSocketBase::Listen (void)
return 0;
}
/** Inherit from Socket class: Kill this socket and signal the peer (if any) */
/* Inherit from Socket class: Kill this socket and signal the peer (if any) */
int
TcpSocketBase::Close (void)
{
@@ -468,7 +468,7 @@ TcpSocketBase::Close (void)
return DoClose ();
}
/** Inherit from Socket class: Signal a termination of send */
/* Inherit from Socket class: Signal a termination of send */
int
TcpSocketBase::ShutdownSend (void)
{
@@ -502,7 +502,7 @@ TcpSocketBase::ShutdownSend (void)
return 0;
}
/** Inherit from Socket class: Signal a termination of receive */
/* Inherit from Socket class: Signal a termination of receive */
int
TcpSocketBase::ShutdownRecv (void)
{
@@ -511,7 +511,7 @@ TcpSocketBase::ShutdownRecv (void)
return 0;
}
/** Inherit from Socket class: Send a packet. Parameter flags is not used.
/* Inherit from Socket class: Send a packet. Parameter flags is not used.
Packet has no TCP header. Invoked by upper-layer application */
int
TcpSocketBase::Send (Ptr<Packet> p, uint32_t flags)
@@ -546,15 +546,15 @@ TcpSocketBase::Send (Ptr<Packet> p, uint32_t flags)
}
}
/** Inherit from Socket class: In TcpSocketBase, it is same as Send() call */
/* Inherit from Socket class: In TcpSocketBase, it is same as Send() call */
int
TcpSocketBase::SendTo (Ptr<Packet> p, uint32_t flags, const Address &address)
{
return Send (p, flags); // SendTo() and Send() are the same
}
/** Inherit from Socket class: Return data to upper-layer application. Parameter flags
is not used. Data is returned as a packet of size no larger than maxSize */
/* Inherit from Socket class: Return data to upper-layer application. Parameter flags
is not used. Data is returned as a packet of size no larger than maxSize */
Ptr<Packet>
TcpSocketBase::Recv (uint32_t maxSize, uint32_t flags)
{
@@ -581,7 +581,7 @@ TcpSocketBase::Recv (uint32_t maxSize, uint32_t flags)
return outPacket;
}
/** Inherit from Socket class: Recv and return the remote's address */
/* Inherit from Socket class: Recv and return the remote's address */
Ptr<Packet>
TcpSocketBase::RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress)
{
@@ -606,7 +606,7 @@ TcpSocketBase::RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress)
return packet;
}
/** Inherit from Socket class: Get the max number of bytes an app can send */
/* Inherit from Socket class: Get the max number of bytes an app can send */
uint32_t
TcpSocketBase::GetTxAvailable (void) const
{
@@ -614,7 +614,7 @@ TcpSocketBase::GetTxAvailable (void) const
return m_txBuffer.Available ();
}
/** Inherit from Socket class: Get the max number of bytes an app can read */
/* Inherit from Socket class: Get the max number of bytes an app can read */
uint32_t
TcpSocketBase::GetRxAvailable (void) const
{
@@ -622,7 +622,7 @@ TcpSocketBase::GetRxAvailable (void) const
return m_rxBuffer.Available ();
}
/** Inherit from Socket class: Return local address:port */
/* Inherit from Socket class: Return local address:port */
int
TcpSocketBase::GetSockName (Address &address) const
{
@@ -644,7 +644,7 @@ TcpSocketBase::GetSockName (Address &address) const
return 0;
}
/** Inherit from Socket class: Bind this socket to the specified NetDevice */
/* Inherit from Socket class: Bind this socket to the specified NetDevice */
void
TcpSocketBase::BindToNetDevice (Ptr<NetDevice> netdevice)
{
@@ -668,7 +668,7 @@ TcpSocketBase::BindToNetDevice (Ptr<NetDevice> netdevice)
return;
}
/** Clean up after Bind. Set up callback functions in the end-point. */
/* Clean up after Bind. Set up callback functions in the end-point. */
int
TcpSocketBase::SetupCallback (void)
{
@@ -694,7 +694,7 @@ TcpSocketBase::SetupCallback (void)
return 0;
}
/** Perform the real connection tasks: Send SYN if allowed, RST if invalid */
/* Perform the real connection tasks: Send SYN if allowed, RST if invalid */
int
TcpSocketBase::DoConnect (void)
{
@@ -716,7 +716,7 @@ TcpSocketBase::DoConnect (void)
return 0;
}
/** Do the action to close the socket. Usually send a packet with appropriate
/* Do the action to close the socket. Usually send a packet with appropriate
flags depended on the current m_state. */
int
TcpSocketBase::DoClose (void)
@@ -759,7 +759,7 @@ TcpSocketBase::DoClose (void)
return 0;
}
/** Peacefully close the socket by notifying the upper layer and deallocate end point */
/* Peacefully close the socket by notifying the upper layer and deallocate end point */
void
TcpSocketBase::CloseAndNotify (void)
{
@@ -780,7 +780,7 @@ TcpSocketBase::CloseAndNotify (void)
}
/** Tell if a sequence number range is out side the range that my rx buffer can
/* Tell if a sequence number range is out side the range that my rx buffer can
accpet */
bool
TcpSocketBase::OutOfRange (SequenceNumber32 head, SequenceNumber32 tail) const
@@ -799,7 +799,7 @@ TcpSocketBase::OutOfRange (SequenceNumber32 head, SequenceNumber32 tail) const
return (tail < m_rxBuffer.NextRxSequence () || m_rxBuffer.MaxRxSequence () <= head);
}
/** Function called by the L3 protocol when it received a packet to pass on to
/* Function called by the L3 protocol when it received a packet to pass on to
the TCP. This function is registered as the "RxCallback" function in
SetupCallback(), which invoked by Bind(), and CompleteFork() */
void
@@ -841,7 +841,7 @@ TcpSocketBase::ForwardIcmp6 (Ipv6Address icmpSource, uint8_t icmpTtl,
}
}
/** The real function to handle the incoming packet from lower layers. This is
/* The real function to handle the incoming packet from lower layers. This is
wrapped by ForwardUp() so that this function can be overloaded by daughter
classes. */
void
@@ -1035,7 +1035,7 @@ TcpSocketBase::DoForwardUp (Ptr<Packet> packet, Ipv6Header header, uint16_t port
}
}
/** Received a packet upon ESTABLISHED state. This function is mimicking the
/* Received a packet upon ESTABLISHED state. This function is mimicking the
role of tcp_rcv_established() in tcp_input.c in Linux kernel. */
void
TcpSocketBase::ProcessEstablished (Ptr<Packet> packet, const TcpHeader& tcpHeader)
@@ -1081,7 +1081,7 @@ TcpSocketBase::ProcessEstablished (Ptr<Packet> packet, const TcpHeader& tcpHeade
}
}
/** Process the newly received ACK */
/* Process the newly received ACK */
void
TcpSocketBase::ReceivedAck (Ptr<Packet> packet, const TcpHeader& tcpHeader)
{
@@ -1118,7 +1118,7 @@ TcpSocketBase::ReceivedAck (Ptr<Packet> packet, const TcpHeader& tcpHeader)
}
}
/** Received a packet upon LISTEN state. */
/* Received a packet upon LISTEN state. */
void
TcpSocketBase::ProcessListen (Ptr<Packet> packet, const TcpHeader& tcpHeader,
const Address& fromAddress, const Address& toAddress)
@@ -1148,7 +1148,7 @@ TcpSocketBase::ProcessListen (Ptr<Packet> packet, const TcpHeader& tcpHeader,
packet, tcpHeader, fromAddress, toAddress);
}
/** Received a packet upon SYN_SENT */
/* Received a packet upon SYN_SENT */
void
TcpSocketBase::ProcessSynSent (Ptr<Packet> packet, const TcpHeader& tcpHeader)
{
@@ -1206,7 +1206,7 @@ TcpSocketBase::ProcessSynSent (Ptr<Packet> packet, const TcpHeader& tcpHeader)
}
}
/** Received a packet upon SYN_RCVD */
/* Received a packet upon SYN_RCVD */
void
TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader,
const Address& fromAddress, const Address& toAddress)
@@ -1296,7 +1296,7 @@ TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader,
}
}
/** Received a packet upon CLOSE_WAIT, FIN_WAIT_1, or FIN_WAIT_2 states */
/* Received a packet upon CLOSE_WAIT, FIN_WAIT_1, or FIN_WAIT_2 states */
void
TcpSocketBase::ProcessWait (Ptr<Packet> packet, const TcpHeader& tcpHeader)
{
@@ -1367,7 +1367,7 @@ TcpSocketBase::ProcessWait (Ptr<Packet> packet, const TcpHeader& tcpHeader)
}
}
/** Received a packet upon CLOSING */
/* Received a packet upon CLOSING */
void
TcpSocketBase::ProcessClosing (Ptr<Packet> packet, const TcpHeader& tcpHeader)
{
@@ -1399,7 +1399,7 @@ TcpSocketBase::ProcessClosing (Ptr<Packet> packet, const TcpHeader& tcpHeader)
}
}
/** Received a packet upon LAST_ACK */
/* Received a packet upon LAST_ACK */
void
TcpSocketBase::ProcessLastAck (Ptr<Packet> packet, const TcpHeader& tcpHeader)
{
@@ -1435,7 +1435,7 @@ TcpSocketBase::ProcessLastAck (Ptr<Packet> packet, const TcpHeader& tcpHeader)
}
}
/** Peer sent me a FIN. Remember its sequence in rx buffer. */
/* Peer sent me a FIN. Remember its sequence in rx buffer. */
void
TcpSocketBase::PeerClose (Ptr<Packet> p, const TcpHeader& tcpHeader)
{
@@ -1472,7 +1472,7 @@ TcpSocketBase::PeerClose (Ptr<Packet> p, const TcpHeader& tcpHeader)
DoPeerClose (); // Change state, respond with ACK
}
/** Received a in-sequence FIN. Close down this socket. */
/* Received a in-sequence FIN. Close down this socket. */
void
TcpSocketBase::DoPeerClose (void)
{
@@ -1510,7 +1510,7 @@ TcpSocketBase::DoPeerClose (void)
}
}
/** Kill this socket. This is a callback function configured to m_endpoint in
/* Kill this socket. This is a callback function configured to m_endpoint in
SetupCallback(), invoked when the endpoint is destroyed. */
void
TcpSocketBase::Destroy (void)
@@ -1531,7 +1531,7 @@ TcpSocketBase::Destroy (void)
CancelAllTimers ();
}
/** Kill this socket. This is a callback function configured to m_endpoint in
/* Kill this socket. This is a callback function configured to m_endpoint in
SetupCallback(), invoked when the endpoint is destroyed. */
void
TcpSocketBase::Destroy6 (void)
@@ -1552,7 +1552,7 @@ TcpSocketBase::Destroy6 (void)
CancelAllTimers ();
}
/** Send an empty packet with specified TCP flags */
/* Send an empty packet with specified TCP flags */
void
TcpSocketBase::SendEmptyPacket (uint8_t flags)
{
@@ -1667,7 +1667,7 @@ TcpSocketBase::SendEmptyPacket (uint8_t flags)
}
}
/** This function closes the endpoint completely. Called upon RST_TX action. */
/* This function closes the endpoint completely. Called upon RST_TX action. */
void
TcpSocketBase::SendRST (void)
{
@@ -1677,7 +1677,7 @@ TcpSocketBase::SendRST (void)
DeallocateEndPoint ();
}
/** Deallocate the end point and cancel all the timers */
/* Deallocate the end point and cancel all the timers */
void
TcpSocketBase::DeallocateEndPoint (void)
{
@@ -1709,7 +1709,7 @@ TcpSocketBase::DeallocateEndPoint (void)
}
}
/** Configure the endpoint to a local address. Called by Connect() if Bind() didn't specify one. */
/* Configure the endpoint to a local address. Called by Connect() if Bind() didn't specify one. */
int
TcpSocketBase::SetupEndpoint ()
{
@@ -1770,7 +1770,7 @@ TcpSocketBase::SetupEndpoint6 ()
return 0;
}
/** This function is called only if a SYN received in LISTEN state. After
/* This function is called only if a SYN received in LISTEN state. After
TcpSocketBase cloned, allocate a new end point to handle the incoming
connection and send a SYN+ACK to complete the handshake. */
void
@@ -1820,7 +1820,7 @@ TcpSocketBase::ConnectionSucceeded ()
}
}
/** Extract at most maxSize bytes from the TxBuffer at sequence seq, add the
/* Extract at most maxSize bytes from the TxBuffer at sequence seq, add the
TCP header, and send to TcpL4Protocol */
uint32_t
TcpSocketBase::SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool withAck)
@@ -1926,7 +1926,7 @@ TcpSocketBase::SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool with
return sz;
}
/** Send as much pending data as possible according to the Tx window. Note that
/* Send as much pending data as possible according to the Tx window. Note that
* this function did not implement the PSH flag
*/
bool
@@ -2071,7 +2071,7 @@ TcpSocketBase::ReceivedData (Ptr<Packet> p, const TcpHeader& tcpHeader)
}
}
/** Called by ForwardUp() to estimate RTT */
/* Called by ForwardUp() to estimate RTT */
void
TcpSocketBase::EstimateRtt (const TcpHeader& tcpHeader)
{
@@ -2281,7 +2281,7 @@ TcpSocketBase::CancelAllTimers ()
m_timewaitEvent.Cancel ();
}
/** Move TCP to Time_Wait state and schedule a transition to Closed state */
/* Move TCP to Time_Wait state and schedule a transition to Closed state */
void
TcpSocketBase::TimeWait ()
{
@@ -2294,7 +2294,7 @@ TcpSocketBase::TimeWait ()
&TcpSocketBase::CloseAndNotify, this);
}
/** Below are the attribute get/set functions */
/* Below are the attribute get/set functions */
void
TcpSocketBase::SetSndBufSize (uint32_t size)
@@ -2418,13 +2418,13 @@ TcpSocketBase::GetAllowBroadcast (void) const
return false;
}
/** Placeholder function for future extension that reads more from the TCP header */
/* Placeholder function for future extension that reads more from the TCP header */
void
TcpSocketBase::ReadOptions (const TcpHeader&)
{
}
/** Placeholder function for future extension that changes the TCP header */
/* Placeholder function for future extension that changes the TCP header */
void
TcpSocketBase::AddOptions (TcpHeader&)
{

View File

@@ -61,6 +61,11 @@ class TcpHeader;
class TcpSocketBase : public TcpSocket
{
public:
/**
* Get the type ID.
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
/**
* Create an unbound TCP socket
@@ -69,13 +74,30 @@ public:
/**
* Clone a TCP socket, for use upon receiving a connection request in LISTEN state
*
* \param sock the original Tcp Socket
*/
TcpSocketBase (const TcpSocketBase& sock);
virtual ~TcpSocketBase (void);
// Set associated Node, TcpL4Protocol, RttEstimator to this socket
/**
* \brief Set the associated node.
* \param node the node
*/
virtual void SetNode (Ptr<Node> node);
/**
* \brief Set the associated TCP L4 protocol.
* \param tcp the TCP L4 protocol
*/
virtual void SetTcp (Ptr<TcpL4Protocol> tcp);
/**
* \brief Set the associated RTT estimator.
* \param rtt the RTT estimator
*/
virtual void SetRtt (Ptr<RttEstimator> rtt);
// Necessary implementations of null functions from ns3::Socket
@@ -101,6 +123,8 @@ public:
protected:
// Implementing ns3::TcpSocket -- Attribute get/set
// inherited, no need to doc
virtual void SetSndBufSize (uint32_t size);
virtual uint32_t GetSndBufSize (void) const;
virtual void SetRcvBufSize (uint32_t size);
@@ -126,120 +150,454 @@ protected:
virtual bool SetAllowBroadcast (bool allowBroadcast);
virtual bool GetAllowBroadcast (void) const;
// Helper functions: Connection set up
int SetupCallback (void); // Common part of the two Bind(), i.e. set callback and remembering local addr:port
int DoConnect (void); // Sending a SYN packet to make a connection if the state allows
void ConnectionSucceeded (void); // Schedule-friendly wrapper for Socket::NotifyConnectionSucceeded()
int SetupEndpoint (void); // Configure m_endpoint for local addr for given remote addr
int SetupEndpoint6 (void); // Configure m_endpoint6 for local addr for given remote addr
void CompleteFork (Ptr<Packet>, const TcpHeader&, const Address& fromAddress, const Address& toAdress);
/**
* \brief Common part of the two Bind(), i.e. set callback and remembering local addr:port
*
* \returns 0 on success, -1 on failure
*/
int SetupCallback (void);
/**
* \brief Perform the real connection tasks: Send SYN if allowed, RST if invalid
*
* \returns 0 on success
*/
int DoConnect (void);
/**
* \brief Schedule-friendly wrapper for Socket::NotifyConnectionSucceeded()
*/
void ConnectionSucceeded (void);
/**
* \brief Configure the endpoint to a local address. Called by Connect() if Bind() didn't specify one.
*
* \returns 0 on success
*/
int SetupEndpoint (void);
/**
* \brief Configure the endpoint v6 to a local address. Called by Connect() if Bind() didn't specify one.
*
* \returns 0 on success
*/
int SetupEndpoint6 (void);
/**
* \brief Complete a connection by forking the socket
*
* This function is called only if a SYN received in LISTEN state. After
* TcpSocketBase cloned, allocate a new end point to handle the incoming
* connection and send a SYN+ACK to complete the handshake.
*
* \param p the packet triggering the fork
* \param tcpHeader the TCP header of the triggering packet
* \param fromAddress the address of the remote host
* \param toAddress the address the connection is directed to
*/
void CompleteFork (Ptr<Packet> p, const TcpHeader& tcpHeader, const Address& fromAddress, const Address& toAddress);
// Helper functions: Transfer operation
/**
* \brief Called by the L3 protocol when it received a packet to pass on to TCP.
*
* \param packet the incoming packet
* \param header the apcket's IPv4 header
* \param port the incoming port
* \param incomingInterface the incoming interface
*/
void ForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port, Ptr<Ipv4Interface> incomingInterface);
/**
* \brief Called by the L3 protocol when it received a packet to pass on to TCP.
*
* \param packet the incoming packet
* \param header the apcket's IPv6 header
* \param port the incoming port
*/
void ForwardUp6 (Ptr<Packet> packet, Ipv6Header header, uint16_t port);
/**
* \brief Called by TcpSocketBase::ForwardUp().
*
* \param packet the incoming packet
* \param header the apcket's IPv4 header
* \param port the incoming port
* \param incomingInterface the incoming interface
*/
virtual void DoForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port, Ptr<Ipv4Interface> incomingInterface); //Get a pkt from L3
virtual void DoForwardUp (Ptr<Packet> packet, Ipv6Header header, uint16_t port); // Ipv6 version
/**
* \brief Called by TcpSocketBase::ForwardUp6().
*
* \param packet the incoming packet
* \param header the apcket's IPv6 header
* \param port the incoming port
*/
virtual void DoForwardUp (Ptr<Packet> packet, Ipv6Header header, uint16_t port);
/**
* \brief Called by the L3 protocol when it received an ICMP packet to pass on to TCP.
*
* \param icmpSource the ICMP source address
* \param icmpTtl the ICMP Time to Live
* \param icmpType the ICMP Type
* \param icmpCode the ICMP Code
* \param icmpInfo the ICMP Info
*/
void ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo);
void ForwardIcmp6 (Ipv6Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo);
bool SendPendingData (bool withAck = false); // Send as much as the window allows
uint32_t SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool withAck); // Send a data packet
void SendEmptyPacket (uint8_t flags); // Send a empty packet that carries a flag, e.g. ACK
void SendRST (void); // Send reset and tear down this socket
bool OutOfRange (SequenceNumber32 head, SequenceNumber32 tail) const; // Check if a sequence number range is within the rx window
/**
* \brief Called by the L3 protocol when it received an ICMPv6 packet to pass on to TCP.
*
* \param icmpSource the ICMP source address
* \param icmpTtl the ICMP Time to Live
* \param icmpType the ICMP Type
* \param icmpCode the ICMP Code
* \param icmpInfo the ICMP Info
*/
void ForwardIcmp6 (Ipv6Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo);
/**
* \brief Send as much pending data as possible according to the Tx window.
*
* Note that this function did not implement the PSH flag.
*
* \param withAck forces an ACK to be sent
* \returns true if some data have been sent
*/
bool SendPendingData (bool withAck = false);
/**
* \brief Extract at most maxSize bytes from the TxBuffer at sequence seq, add the
* TCP header, and send to TcpL4Protocol
*
* \param seq the sequence number
* \param maxSize the maximum data block to be transmitted (in bytes)
* \param withAck forces an ACK to be sent
* \returns the number of bytes sent
*/
uint32_t SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool withAck);
/**
* \brief Send a empty packet that carries a flag, e.g. ACK
*
* \param flags the packet's flags
*/
void SendEmptyPacket (uint8_t flags);
/**
* \brief Send reset and tear down this socket
*/
void SendRST (void);
/**
* \brief Check if a sequence number range is within the rx window
*
* \param head start of the Sequence window
* \param tail end of the Sequence window
* \returns true if it is in range
*/
bool OutOfRange (SequenceNumber32 head, SequenceNumber32 tail) const;
// Helper functions: Connection close
int DoClose (void); // Close a socket by sending RST, FIN, or FIN+ACK, depend on the current state
void CloseAndNotify (void); // To CLOSED state, notify upper layer, and deallocate end point
void Destroy (void); // Kill this socket by zeroing its attributes
void Destroy6 (void); // Kill this socket by zeroing its attributes
void DeallocateEndPoint (void); // Deallocate m_endPoint
void PeerClose (Ptr<Packet>, const TcpHeader&); // Received a FIN from peer, notify rx buffer
void DoPeerClose (void); // FIN is in sequence, notify app and respond with a FIN
void CancelAllTimers (void); // Cancel all timer when endpoint is deleted
void TimeWait (void); // Move from CLOSING or FIN_WAIT_2 to TIME_WAIT state
/**
* \brief Close a socket by sending RST, FIN, or FIN+ACK, depend on the current state
*
* \returns 0 on success
*/
int DoClose (void);
/**
* \brief Peacefully close the socket by notifying the upper layer and deallocate end point
*/
void CloseAndNotify (void);
/**
* \brief Kill this socket by zeroing its attributes (IPv4)
*
* This is a callback function configured to m_endpoint in
* SetupCallback(), invoked when the endpoint is destroyed.
*/
void Destroy (void);
/**
* \brief Kill this socket by zeroing its attributes (IPv6)
*
* This is a callback function configured to m_endpoint in
* SetupCallback(), invoked when the endpoint is destroyed.
*/
void Destroy6 (void);
/**
* \brief Deallocate m_endPoint
*/
void DeallocateEndPoint (void);
/**
* \brief Received a FIN from peer, notify rx buffer
*
* \param p the packet
* \param tcpHeader the packet's TCP header
*/
void PeerClose (Ptr<Packet> p, const TcpHeader& tcpHeader);
/**
* \brief FIN is in sequence, notify app and respond with a FIN
*/
void DoPeerClose (void);
/**
* \brief Cancel all timer when endpoint is deleted
*/
void CancelAllTimers (void);
/**
* \brief Move from CLOSING or FIN_WAIT_2 to TIME_WAIT state
*/
void TimeWait (void);
// State transition functions
void ProcessEstablished (Ptr<Packet>, const TcpHeader&); // Received a packet upon ESTABLISHED state
void ProcessListen (Ptr<Packet>, const TcpHeader&, const Address&, const Address&); // Process the newly received ACK
void ProcessSynSent (Ptr<Packet>, const TcpHeader&); // Received a packet upon SYN_SENT
void ProcessSynRcvd (Ptr<Packet>, const TcpHeader&, const Address&, const Address&); // Received a packet upon SYN_RCVD
void ProcessWait (Ptr<Packet>, const TcpHeader&); // Received a packet upon CLOSE_WAIT, FIN_WAIT_1, FIN_WAIT_2
void ProcessClosing (Ptr<Packet>, const TcpHeader&); // Received a packet upon CLOSING
void ProcessLastAck (Ptr<Packet>, const TcpHeader&); // Received a packet upon LAST_ACK
/**
* \brief Received a packet upon ESTABLISHED state.
*
* This function is mimicking the role of tcp_rcv_established() in tcp_input.c in Linux kernel.
*
* \param packet the packet
* \param tcpHeader the packet's TCP header
*/
void ProcessEstablished (Ptr<Packet> packet, const TcpHeader& tcpHeader); // Received a packet upon ESTABLISHED state
/**
* \brief Received a packet upon LISTEN state.
*
* \param packet the packet
* \param tcpHeader the packet's TCP header
* \param fromAddress the source address
* \param toAddress the destination address
*/
void ProcessListen (Ptr<Packet> packet, const TcpHeader& tcpHeader,
const Address& fromAddress, const Address& toAddress);
/**
* \brief Received a packet upon SYN_SENT
*
* \param packet the packet
* \param tcpHeader the packet's TCP header
*/
void ProcessSynSent (Ptr<Packet> packet, const TcpHeader& tcpHeader);
/**
* \brief Received a packet upon SYN_RCVD.
*
* \param packet the packet
* \param tcpHeader the packet's TCP header
* \param fromAddress the source address
* \param toAddress the destination address
*/
void ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader,
const Address& fromAddress, const Address& toAddress);
/**
* \brief Received a packet upon CLOSE_WAIT, FIN_WAIT_1, FIN_WAIT_2
*
* \param packet the packet
* \param tcpHeader the packet's TCP header
*/
void ProcessWait (Ptr<Packet> packet, const TcpHeader& tcpHeader);
/**
* \brief Received a packet upon CLOSING
*
* \param packet the packet
* \param tcpHeader the packet's TCP header
*/
void ProcessClosing (Ptr<Packet> packet, const TcpHeader& tcpHeader);
/**
* \brief Received a packet upon LAST_ACK
*
* \param packet the packet
* \param tcpHeader the packet's TCP header
*/
void ProcessLastAck (Ptr<Packet> packet, const TcpHeader& tcpHeader);
// Window management
virtual uint32_t UnAckDataCount (void); // Return count of number of unacked bytes
virtual uint32_t BytesInFlight (void); // Return total bytes in flight
virtual uint32_t Window (void); // Return the max possible number of unacked bytes
virtual uint32_t AvailableWindow (void); // Return unfilled portion of window
virtual uint16_t AdvertisedWindowSize (void); // The amount of Rx window announced to the peer
/**
* \brief Return count of number of unacked bytes
* \returns count of number of unacked bytes
*/
virtual uint32_t UnAckDataCount (void);
/**
* \brief Return total bytes in flight
* \returns total bytes in flight
*/
virtual uint32_t BytesInFlight (void);
/**
* \brief Return the max possible number of unacked bytes
* \returns the max possible number of unacked bytes
*/
virtual uint32_t Window (void);
/**
* \brief Return unfilled portion of window
* \return unfilled portion of window
*/
virtual uint32_t AvailableWindow (void);
/**
* \brief The amount of Rx window announced to the peer
* \returns size of Rx window announced to the peer
*/
virtual uint16_t AdvertisedWindowSize (void);
// Manage data tx/rx
virtual Ptr<TcpSocketBase> Fork (void) = 0; // Call CopyObject<> to clone me
virtual void ReceivedAck (Ptr<Packet>, const TcpHeader&); // Received an ACK packet
virtual void ReceivedData (Ptr<Packet>, const TcpHeader&); // Recv of a data, put into buffer, call L7 to get it if necessary
virtual void EstimateRtt (const TcpHeader&); // RTT accounting
virtual void NewAck (SequenceNumber32 const& seq); // Update buffers w.r.t. ACK
virtual void DupAck (const TcpHeader& t, uint32_t count) = 0; // Received dupack
virtual void ReTxTimeout (void); // Call Retransmit() upon RTO event
virtual void Retransmit (void); // Halving cwnd and call DoRetransmit()
virtual void DelAckTimeout (void); // Action upon delay ACK timeout, i.e. send an ACK
virtual void LastAckTimeout (void); // Timeout at LAST_ACK, close the connection
virtual void PersistTimeout (void); // Send 1 byte probe to get an updated window size
virtual void DoRetransmit (void); // Retransmit the oldest packet
virtual void ReadOptions (const TcpHeader&); // Read option from incoming packets
virtual void AddOptions (TcpHeader&); // Add option to outgoing packets
/**
* \brief Call CopyObject<> to clone me
* \returns a copy of the socket
*/
virtual Ptr<TcpSocketBase> Fork (void) = 0;
/**
* \brief Received an ACK packet
* \param packet the packet
* \param tcpHeader the packet's TCP header
*/
virtual void ReceivedAck (Ptr<Packet> packet, const TcpHeader& tcpHeader);
/**
* \brief Recv of a data, put into buffer, call L7 to get it if necessary
* \param packet the packet
* \param tcpHeader the packet's TCP header
*/
virtual void ReceivedData (Ptr<Packet> packet, const TcpHeader& tcpHeader);
/**
* \brief Take into account the packet for RTT estimation
* \param tcpHeader the packet's TCP header
*/
virtual void EstimateRtt (const TcpHeader& tcpHeader);
/**
* \brief Update buffers w.r.t. ACK
* \param seq the sequence number
*/
virtual void NewAck (SequenceNumber32 const& seq);
/**
* \brief Received dupack (duplicate ACK)
* \param tcpHeader the packet's TCP header
* \param count counter of duplicate ACKs
*/
virtual void DupAck (const TcpHeader& tcpHeader, uint32_t count) = 0;
/**
* \brief Call Retransmit() upon RTO event
*/
virtual void ReTxTimeout (void);
/**
* \brief Halving cwnd and call DoRetransmit()
*/
virtual void Retransmit (void);
/**
* \brief Action upon delay ACK timeout, i.e. send an ACK
*/
virtual void DelAckTimeout (void);
/**
* \brief Timeout at LAST_ACK, close the connection
*/
virtual void LastAckTimeout (void);
/**
* \brief Send 1 byte probe to get an updated window size
*/
virtual void PersistTimeout (void);
/**
* \brief Retransmit the oldest packet
*/
virtual void DoRetransmit (void);
/**
* \brief Read option from incoming packets
* \param tcpHeader the packet's TCP header
*/
virtual void ReadOptions (const TcpHeader& tcpHeader);
/**
* \brief Add option to outgoing packets
* \param tcpHeader the packet's TCP header
*/
virtual void AddOptions (TcpHeader& tcpHeader);
protected:
// Counters and events
EventId m_retxEvent; //< Retransmission event
EventId m_lastAckEvent; //< Last ACK timeout event
EventId m_delAckEvent; //< Delayed ACK timeout event
EventId m_persistEvent; //< Persist event: Send 1 byte to probe for a non-zero Rx window
EventId m_timewaitEvent; //< TIME_WAIT expiration event: Move this socket to CLOSED state
uint32_t m_dupAckCount; //< Dupack counter
uint32_t m_delAckCount; //< Delayed ACK counter
uint32_t m_delAckMaxCount; //< Number of packet to fire an ACK before delay timeout
bool m_noDelay; //< Set to true to disable Nagle's algorithm
uint32_t m_cnCount; //< Count of remaining connection retries
uint32_t m_cnRetries; //< Number of connection retries before giving up
TracedValue<Time> m_rto; //< Retransmit timeout
TracedValue<Time> m_lastRtt; //< Last RTT sample collected
Time m_delAckTimeout; //< Time to delay an ACK
Time m_persistTimeout; //< Time between sending 1-byte probes
Time m_cnTimeout; //< Timeout for connection retry
EventId m_retxEvent; //!< Retransmission event
EventId m_lastAckEvent; //!< Last ACK timeout event
EventId m_delAckEvent; //!< Delayed ACK timeout event
EventId m_persistEvent; //!< Persist event: Send 1 byte to probe for a non-zero Rx window
EventId m_timewaitEvent; //!< TIME_WAIT expiration event: Move this socket to CLOSED state
uint32_t m_dupAckCount; //!< Dupack counter
uint32_t m_delAckCount; //!< Delayed ACK counter
uint32_t m_delAckMaxCount; //!< Number of packet to fire an ACK before delay timeout
bool m_noDelay; //!< Set to true to disable Nagle's algorithm
uint32_t m_cnCount; //!< Count of remaining connection retries
uint32_t m_cnRetries; //!< Number of connection retries before giving up
TracedValue<Time> m_rto; //!< Retransmit timeout
TracedValue<Time> m_lastRtt; //!< Last RTT sample collected
Time m_delAckTimeout; //!< Time to delay an ACK
Time m_persistTimeout; //!< Time between sending 1-byte probes
Time m_cnTimeout; //!< Timeout for connection retry
// Connections to other layers of TCP/IP
Ipv4EndPoint* m_endPoint;
Ipv6EndPoint* m_endPoint6;
Ptr<Node> m_node;
Ptr<TcpL4Protocol> m_tcp;
Callback<void, Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> m_icmpCallback;
Callback<void, Ipv6Address,uint8_t,uint8_t,uint8_t,uint32_t> m_icmpCallback6;
Ipv4EndPoint* m_endPoint; //!< the IPv4 endpoint
Ipv6EndPoint* m_endPoint6; //!< the IPv6 endpoint
Ptr<Node> m_node; //!< the associated node
Ptr<TcpL4Protocol> m_tcp; //!< the associated TCP L4 protocol
Callback<void, Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> m_icmpCallback; //!< ICMP callback
Callback<void, Ipv6Address,uint8_t,uint8_t,uint8_t,uint32_t> m_icmpCallback6; //!< ICMPv6 callback
// Round trip time estimation
Ptr<RttEstimator> m_rtt;
Ptr<RttEstimator> m_rtt; //!< Round trip time estimator
// Rx and Tx buffer management
TracedValue<SequenceNumber32> m_nextTxSequence; //< Next seqnum to be sent (SND.NXT), ReTx pushes it back
TracedValue<SequenceNumber32> m_highTxMark; //< Highest seqno ever sent, regardless of ReTx
TcpRxBuffer m_rxBuffer; //< Rx buffer (reordering buffer)
TcpTxBuffer m_txBuffer; //< Tx buffer
TracedValue<SequenceNumber32> m_nextTxSequence; //!< Next seqnum to be sent (SND.NXT), ReTx pushes it back
TracedValue<SequenceNumber32> m_highTxMark; //!< Highest seqno ever sent, regardless of ReTx
TcpRxBuffer m_rxBuffer; //!< Rx buffer (reordering buffer)
TcpTxBuffer m_txBuffer; //!< Tx buffer
// State-related attributes
TracedValue<TcpStates_t> m_state; //< TCP state
enum SocketErrno m_errno; //< Socket error code
bool m_closeNotified; //< Told app to close socket
bool m_closeOnEmpty; //< Close socket upon tx buffer emptied
bool m_shutdownSend; //< Send no longer allowed
bool m_shutdownRecv; //< Receive no longer allowed
bool m_connected; //< Connection established
double m_msl; //< Max segment lifetime
TracedValue<TcpStates_t> m_state; //!< TCP state
enum SocketErrno m_errno; //!< Socket error code
bool m_closeNotified; //!< Told app to close socket
bool m_closeOnEmpty; //!< Close socket upon tx buffer emptied
bool m_shutdownSend; //!< Send no longer allowed
bool m_shutdownRecv; //!< Receive no longer allowed
bool m_connected; //!< Connection established
double m_msl; //!< Max segment lifetime
// Window management
uint32_t m_segmentSize; //< Segment size
uint16_t m_maxWinSize; //< Maximum window size to advertise
TracedValue<uint32_t> m_rWnd; //< Flow control window at remote side
uint32_t m_segmentSize; //!< Segment size
uint16_t m_maxWinSize; //!< Maximum window size to advertise
TracedValue<uint32_t> m_rWnd; //!< Flow control window at remote side
};
} // namespace ns3

View File

@@ -46,6 +46,10 @@ public:
TcpSocketFactoryImpl ();
virtual ~TcpSocketFactoryImpl ();
/**
* \brief Set the associated TCP L4 protocol.
* \param tcp the TCP L4 protocol
*/
void SetTcp (Ptr<TcpL4Protocol> tcp);
virtual Ptr<Socket> CreateSocket (void);
@@ -53,7 +57,7 @@ public:
protected:
virtual void DoDispose (void);
private:
Ptr<TcpL4Protocol> m_tcp;
Ptr<TcpL4Protocol> m_tcp; //!< the associated TCP L4 protocol
};
} // namespace ns3

View File

@@ -46,6 +46,11 @@ class Socket;
class TcpSocketFactory : public SocketFactory
{
public:
/**
* Get the type ID.
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
};

View File

@@ -35,7 +35,9 @@ namespace ns3 {
class Node;
class Packet;
/* Names of the 11 TCP states */
/**
* \brief Names of the 11 TCP states
*/
typedef enum {
CLOSED, // 0
LISTEN, // 1
@@ -62,37 +64,164 @@ typedef enum {
class TcpSocket : public Socket
{
public:
/**
* Get the type ID.
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
TcpSocket (void);
virtual ~TcpSocket (void);
// Literal names of TCP states for use in log messages */
/**
* \brief Literal names of TCP states for use in log messages
*/
static const char* const TcpStateName[LAST_STATE];
private:
// Indirect the attribute setting and getting through private virtual methods
/**
* \brief Set the send buffer size.
* \param size the buffer size (in bytes)
*/
virtual void SetSndBufSize (uint32_t size) = 0;
/**
* \brief Get the send buffer size.
* \returns the buffer size (in bytes)
*/
virtual uint32_t GetSndBufSize (void) const = 0;
/**
* \brief Set the receive buffer size.
* \param size the buffer size (in bytes)
*/
virtual void SetRcvBufSize (uint32_t size) = 0;
/**
* \brief Get the receive buffer size.
* \returns the buffer size (in bytes)
*/
virtual uint32_t GetRcvBufSize (void) const = 0;
/**
* \brief Set the segment size.
* \param size the segment size (in bytes)
*/
virtual void SetSegSize (uint32_t size) = 0;
/**
* \brief Get the segment size.
* \returns the segment size (in bytes)
*/
virtual uint32_t GetSegSize (void) const = 0;
/**
* \brief Set the Slow Start Threshold.
* \param threshold the Slow Start Threshold (in bytes)
*/
virtual void SetSSThresh (uint32_t threshold) = 0;
/**
* \brief Get the Slow Start Threshold.
* \returns the Slow Start Threshold (in bytes)
*/
virtual uint32_t GetSSThresh (void) const = 0;
virtual void SetInitialCwnd (uint32_t count) = 0;
/**
* \brief Set the initial Congestion Window.
* \param cwnd the initial congestion window (in bytes)
*/
virtual void SetInitialCwnd (uint32_t cwnd) = 0;
/**
* \brief Get the initial Congestion Window.
* \returns the initial congestion window (in bytes)
*/
virtual uint32_t GetInitialCwnd (void) const = 0;
/**
* \brief Set the connection timeout.
* \param timeout the connection timeout
*/
virtual void SetConnTimeout (Time timeout) = 0;
/**
* \brief Get the connection timeout.
* \returns the connection timeout
*/
virtual Time GetConnTimeout (void) const = 0;
/**
* \brief Set the number of connection retries before giving up.
* \param count the number of connection retries
*/
virtual void SetConnCount (uint32_t count) = 0;
/**
* \brief Get the number of connection retries before giving up.
* \returns the number of connection retries
*/
virtual uint32_t GetConnCount (void) const = 0;
/**
* \brief Set the time to delay an ACK.
* \param timeout the time to delay an ACK
*/
virtual void SetDelAckTimeout (Time timeout) = 0;
/**
* \brief Get the time to delay an ACK.
* \returns the time to delay an ACK
*/
virtual Time GetDelAckTimeout (void) const = 0;
/**
* \brief Set the number of packet to fire an ACK before delay timeout.
* \param count the umber of packet to fire an ACK before delay timeout
*/
virtual void SetDelAckMaxCount (uint32_t count) = 0;
/**
* \brief Get the number of packet to fire an ACK before delay timeout.
* \returns the number of packet to fire an ACK before delay timeout
*/
virtual uint32_t GetDelAckMaxCount (void) const = 0;
/**
* \brief Enable/Disable Nagle's algorithm.
* \param noDelay true to DISABLE Nagle's algorithm
*/
virtual void SetTcpNoDelay (bool noDelay) = 0;
/**
* \brief Check if Nagle's algorithm is enabled or not.
* \returns true if Nagle's algorithm is DISABLED
*/
virtual bool GetTcpNoDelay (void) const = 0;
/**
* \brief Set the timout for persistent connection
*
* When the timout expires, send 1-byte data to probe for the window
* size at the receiver when the local knowledge tells that the
* receiver has zero window size
*
* \param timeout the persistent timout
*/
virtual void SetPersistTimeout (Time timeout) = 0;
/**
* \brief Get the timout for persistent connection
*
* When the timout expires, send 1-byte data to probe for the window
* size at the receiver when the local knowledge tells that the
* receiver has zero window size
*
* \returns the persistent timout
*/
virtual Time GetPersistTimeout (void) const = 0;
};

View File

@@ -66,11 +66,19 @@ class Packet;
class Socket : public Object
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
Socket (void);
virtual ~Socket (void);
/**
* \enum SocketErrno
* \brief Enumeration of the possible errors returned by a socket.
*/
enum SocketErrno {
ERROR_NOTERROR,
ERROR_ISCONN,
@@ -89,6 +97,10 @@ public:
SOCKET_ERRNO_LAST
};
/**
* \enum SocketType
* \brief Enumeration of the possible socket types.
*/
enum SocketType {
NS3_SOCK_STREAM,
NS3_SOCK_SEQPACKET,
@@ -253,6 +265,7 @@ public:
/**
* \brief Initiate a connection to a remote host
* \param address Address of remote.
* \returns 0 on success, -1 on error (in which case errno is set).
*/
virtual int Connect (const Address &address) = 0;
@@ -271,6 +284,8 @@ public:
*
* For stream sockets, this returns the available space in bytes
* left in the transmit buffer.
*
* \returns The number of bytes which can be sent in a single Send call.
*/
virtual uint32_t GetTxAvailable (void) const = 0;
@@ -341,6 +356,9 @@ public:
* Return number of bytes which can be returned from one or
* multiple calls to Recv.
* Must be possible to call this method from the Recv callback.
*
* \returns the number of bytes which can be returned from one or
* multiple Recv calls.
*/
virtual uint32_t GetRxAvailable (void) const = 0;
@@ -446,6 +464,8 @@ public:
* second parameter
* \param size the number of bytes to copy from the buffer
* \param flags Socket control flags
* \returns the number of bytes accepted for transmission if no error
* occurs, and -1 otherwise.
*/
int Send (const uint8_t* buf, uint32_t size, uint32_t flags);
@@ -613,7 +633,7 @@ public:
*/
bool IsRecvPktInfo () const;
/*
/**
* \brief Manually set IP Type of Service field
*
* This method corresponds to using setsockopt () IP_TOS of
@@ -626,7 +646,7 @@ public:
*/
void SetIpTos (uint8_t ipTos);
/*
/**
* \brief Query the value of IP Type of Service of this socket
*
* This method corresponds to using getsockopt () IP_TOS of real network
@@ -655,11 +675,11 @@ public:
* This method corresponds to using getsockopt () IP_RECVTOS of real
* network or BSD sockets.
*
* \return Wheter the IP_RECVTOS is set
* \return Whether the IP_RECVTOS is set
*/
bool IsIpRecvTos (void) const;
/*
/**
* \brief Manually set IPv6 Traffic Class field
*
* This method corresponds to using setsockopt () IPV6_TCLASS of
@@ -671,7 +691,7 @@ public:
*/
void SetIpv6Tclass (int ipTclass);
/*
/**
* \brief Query the value of IPv6 Traffic Class field of this socket
*
* This method corresponds to using getsockopt () IPV6_TCLASS of real network
@@ -700,11 +720,11 @@ public:
* This method corresponds to using getsockopt () IPV6_RECVTCLASS of real
* network or BSD sockets.
*
* \return Wheter the IPV6_RECVTCLASS is set
* \return Whether the IPV6_RECVTCLASS is set
*/
bool IsIpv6RecvTclass (void) const;
/*
/**
* \brief Manually set IP Time to Live field
*
* This method corresponds to using setsockopt () IP_TTL of
@@ -714,7 +734,7 @@ public:
*/
virtual void SetIpTtl (uint8_t ipTtl);
/*
/**
* \brief Query the value of IP Time to Live field of this socket
*
* This method corresponds to using getsockopt () IP_TTL of real network
@@ -743,11 +763,11 @@ public:
* This method corresponds to using getsockopt () IP_RECVTTL of real
* network or BSD sockets.
*
* \return Wheter the IP_RECVTTL is set
* \return Whether the IP_RECVTTL is set
*/
bool IsIpRecvTtl (void) const;
/*
/**
* \brief Manually set IPv6 Hop Limit
*
* This method corresponds to using setsockopt () IPV6_HOPLIMIT of
@@ -757,7 +777,7 @@ public:
*/
virtual void SetIpv6HopLimit (uint8_t ipHopLimit);
/*
/**
* \brief Query the value of IP Hop Limit field of this socket
*
* This method corresponds to using getsockopt () IPV6_HOPLIMIT of real network
@@ -786,58 +806,135 @@ public:
* This method corresponds to using getsockopt () IPV6_RECVHOPLIMIT of real
* network or BSD sockets.
*
* \return Wheter the IPV6_RECVHOPLIMIT is set
* \return Whether the IPV6_RECVHOPLIMIT is set
*/
bool IsIpv6RecvHopLimit (void) const;
protected:
/**
* \brief Notify through the callback (if set) that the connection has been
* established.
*/
void NotifyConnectionSucceeded (void);
/**
* \brief Notify through the callback (if set) that the connection has not been
* established due to an error.
*/
void NotifyConnectionFailed (void);
/**
* \brief Notify through the callback (if set) that the connection has been
* closed.
*/
void NotifyNormalClose (void);
/**
* \brief Notify through the callback (if set) that the connection has been
* closed due to an error.
*/
void NotifyErrorClose (void);
/**
* \brief Notify through the callback (if set) that an incoming connection
* is being requested by a remote host.
*
* This function returns true by default (i.e., accept all the incoming connections).
* The callback (if set) might restrict this behaviour by returning zero for a
* connection that should be refused.
*
* \param from the address the connection is incoming from
* \returns true if the connection must be accepted, false otherwise.
*/
bool NotifyConnectionRequest (const Address &from);
/**
* \brief Notify through the callback (if set) that a new connection has been
* created.
*/
void NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from);
/**
* \brief Notify through the callback (if set) that some data have been sent.
*
* \param size number of sent bytes.
*/
void NotifyDataSent (uint32_t size);
/**
* \brief Notify through the callback (if set) that some data have been sent.
*
* \param spaceAvailable the number of bytes available in the transmission buffer.
*/
void NotifySend (uint32_t spaceAvailable);
/**
* \brief Notify through the callback (if set) that some data have been received.
*/
void NotifyDataRecv (void);
// inherited function, no doc necessary
virtual void DoDispose (void);
/**
* \brief Checks if the socket has a specific IPv4 ToS set
*
* \returns true if the socket has a IPv4 ToS set, false otherwise.
*/
bool IsManualIpTos (void) const;
/**
* \brief Checks if the socket has a specific IPv6 Tclass set
*
* \returns true if the socket has a IPv6 Tclass set, false otherwise.
*/
bool IsManualIpv6Tclass (void) const;
/**
* \brief Checks if the socket has a specific IPv4 TTL set
*
* \returns true if the socket has a IPv4 TTL set, false otherwise.
*/
bool IsManualIpTtl (void) const;
/**
* \brief Checks if the socket has a specific IPv6 Hop Limit set
*
* \returns true if the socket has a IPv6 Hop Limit set, false otherwise.
*/
bool IsManualIpv6HopLimit (void) const;
Ptr<NetDevice> m_boundnetdevice;
bool m_recvPktInfo;
Ptr<NetDevice> m_boundnetdevice; //!< the device this socket is bound to (might be null).
bool m_recvPktInfo; //!< if the socket should add packet info tags to the packet forwarded to L4.
private:
Callback<void, Ptr<Socket> > m_connectionSucceeded;
Callback<void, Ptr<Socket> > m_connectionFailed;
Callback<void, Ptr<Socket> > m_normalClose;
Callback<void, Ptr<Socket> > m_errorClose;
Callback<bool, Ptr<Socket>, const Address &> m_connectionRequest;
Callback<void, Ptr<Socket>, const Address&> m_newConnectionCreated;
Callback<void, Ptr<Socket>, uint32_t> m_dataSent;
Callback<void, Ptr<Socket>, uint32_t > m_sendCb;
Callback<void, Ptr<Socket> > m_receivedData;
Callback<void, Ptr<Socket> > m_connectionSucceeded; //!< connection succeeded callback
Callback<void, Ptr<Socket> > m_connectionFailed; //!< connection failed callback
Callback<void, Ptr<Socket> > m_normalClose; //!< connection closed callback
Callback<void, Ptr<Socket> > m_errorClose; //!< connection closed due to errors callback
Callback<bool, Ptr<Socket>, const Address &> m_connectionRequest; //!< connection request callback
Callback<void, Ptr<Socket>, const Address&> m_newConnectionCreated; //!< connection created callback
Callback<void, Ptr<Socket>, uint32_t> m_dataSent; //!< data sent callback
Callback<void, Ptr<Socket>, uint32_t > m_sendCb; //!< packet sent callback
Callback<void, Ptr<Socket> > m_receivedData; //!< data received callback
//IPv4 options
bool m_manualIpTos;
bool m_manualIpTtl;
bool m_ipRecvTos;
bool m_ipRecvTtl;
bool m_manualIpTos; //!< socket has IPv4 TOS set
bool m_manualIpTtl; //!< socket has IPv4 TTL set
bool m_ipRecvTos; //!< socket forwards IPv4 TOS tag to L4
bool m_ipRecvTtl; //!< socket forwards IPv4 TTL tag to L4
uint8_t m_ipTos;
uint8_t m_ipTtl;
uint8_t m_ipTos; //!< the socket IPv4 TOS
uint8_t m_ipTtl; //!< the socket IPv4 TTL
//IPv6 options
bool m_manualIpv6Tclass;
bool m_manualIpv6HopLimit;
bool m_ipv6RecvTclass;
bool m_ipv6RecvHopLimit;
bool m_manualIpv6Tclass; //!< socket has IPv6 Tclass set
bool m_manualIpv6HopLimit; //!< socket has IPv6 Hop Limit set
bool m_ipv6RecvTclass; //!< socket forwards IPv6 Tclass tag to L4
bool m_ipv6RecvHopLimit; //!< socket forwards IPv6 Hop Limit tag to L4
uint8_t m_ipv6Tclass;
uint8_t m_ipv6HopLimit;
uint8_t m_ipv6Tclass; //!< the socket IPv6 Tclass
uint8_t m_ipv6HopLimit; //!< the socket IPv6 Hop Limit
};
/**
@@ -848,18 +945,44 @@ class SocketAddressTag : public Tag
{
public:
SocketAddressTag ();
/**
* \brief Set the tag's address
*
* \param addr the address
*/
void SetAddress (Address addr);
/**
* \brief Get the tag's address
*
* \returns the address
*/
Address GetAddress (void) const;
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
// inherited function, no need to doc.
virtual TypeId GetInstanceTypeId (void) const;
// inherited function, no need to doc.
virtual uint32_t GetSerializedSize (void) const;
// inherited function, no need to doc.
virtual void Serialize (TagBuffer i) const;
// inherited function, no need to doc.
virtual void Deserialize (TagBuffer i);
// inherited function, no need to doc.
virtual void Print (std::ostream &os) const;
private:
Address m_address;
Address m_address; //!< the address carried by the tag
};
/**
@@ -870,18 +993,44 @@ class SocketIpTtlTag : public Tag
{
public:
SocketIpTtlTag ();
/**
* \brief Set the tag's TTL
*
* \param ttl the TTL
*/
void SetTtl (uint8_t ttl);
/**
* \brief Get the tag's TTL
*
* \returns the TTL
*/
uint8_t GetTtl (void) const;
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
// inherited function, no need to doc.
virtual TypeId GetInstanceTypeId (void) const;
// inherited function, no need to doc.
virtual uint32_t GetSerializedSize (void) const;
// inherited function, no need to doc.
virtual void Serialize (TagBuffer i) const;
// inherited function, no need to doc.
virtual void Deserialize (TagBuffer i);
// inherited function, no need to doc.
virtual void Print (std::ostream &os) const;
private:
uint8_t m_ttl;
uint8_t m_ttl; //!< the ttl carried by the tag
};
/**
@@ -892,82 +1041,188 @@ class SocketIpv6HopLimitTag : public Tag
{
public:
SocketIpv6HopLimitTag ();
/**
* \brief Set the tag's Hop Limit
*
* \param hopLimit the Hop Limit
*/
void SetHopLimit (uint8_t hopLimit);
/**
* \brief Get the tag's Hop Limit
*
* \returns the Hop Limit
*/
uint8_t GetHopLimit (void) const;
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
// inherited function, no need to doc.
virtual TypeId GetInstanceTypeId (void) const;
// inherited function, no need to doc.
virtual uint32_t GetSerializedSize (void) const;
// inherited function, no need to doc.
virtual void Serialize (TagBuffer i) const;
// inherited function, no need to doc.
virtual void Deserialize (TagBuffer i);
// inherited function, no need to doc.
virtual void Print (std::ostream &os) const;
private:
uint8_t m_hopLimit;
uint8_t m_hopLimit; //!< the Hop Limit carried by the tag
};
/**
* \brief indicated whether packets should be sent out with
* the DF flag set.
* \brief indicates whether packets should be sent out with
* the DF (Don't Fragment) flag set.
*/
class SocketSetDontFragmentTag : public Tag
{
public:
SocketSetDontFragmentTag ();
/**
* \brief Enables the DF (Don't Fragment) flag
*/
void Enable (void);
/**
* \brief Disables the DF (Don't Fragment) flag
*/
void Disable (void);
/**
* \brief Checks if the DF (Don't Fragment) flag is set
*
* \returns true if DF is set.
*/
bool IsEnabled (void) const;
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
// inherited function, no need to doc.
virtual TypeId GetInstanceTypeId (void) const;
// inherited function, no need to doc.
virtual uint32_t GetSerializedSize (void) const;
// inherited function, no need to doc.
virtual void Serialize (TagBuffer i) const;
// inherited function, no need to doc.
virtual void Deserialize (TagBuffer i);
// inherited function, no need to doc.
virtual void Print (std::ostream &os) const;
private:
bool m_dontFragment;
bool m_dontFragment; //!< DF bit value for outgoing packets.
};
/*
* \brief indicated whether the socket has IP_TOS set.
/**
* \brief indicates whether the socket has IP_TOS set.
* This tag is for IPv4 socket.
*/
class SocketIpTosTag : public Tag
{
public:
SocketIpTosTag ();
/**
* \brief Set the tag's TOS
*
* \param tos the TOS
*/
void SetTos (uint8_t tos);
/**
* \brief Get the tag's TOS
*
* \returns the TOS
*/
uint8_t GetTos (void) const;
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
// inherited function, no need to doc.
virtual TypeId GetInstanceTypeId (void) const;
// inherited function, no need to doc.
virtual uint32_t GetSerializedSize (void) const;
// inherited function, no need to doc.
virtual void Serialize (TagBuffer i) const;
// inherited function, no need to doc.
virtual void Deserialize (TagBuffer i);
// inherited function, no need to doc.
virtual void Print (std::ostream &os) const;
private:
uint8_t m_ipTos;
uint8_t m_ipTos; //!< the TOS carried by the tag
};
/*
* \brief indicated whether the socket has IPV6_TCLASS set.
/**
* \brief indicates whether the socket has IPV6_TCLASS set.
* This tag is for IPv6 socket.
*/
class SocketIpv6TclassTag : public Tag
{
public:
SocketIpv6TclassTag ();
/**
* \brief Set the tag's Tclass
*
* \param tclass the Tclass
*/
void SetTclass (uint8_t tclass);
/**
* \brief Get the tag's Tclass
*
* \returns the Tclass
*/
uint8_t GetTclass (void) const;
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
// inherited function, no need to doc.
virtual TypeId GetInstanceTypeId (void) const;
// inherited function, no need to doc.
virtual uint32_t GetSerializedSize (void) const;
// inherited function, no need to doc.
virtual void Serialize (TagBuffer i) const;
// inherited function, no need to doc.
virtual void Deserialize (TagBuffer i);
// inherited function, no need to doc.
virtual void Print (std::ostream &os) const;
private:
uint8_t m_ipv6Tclass;
uint8_t m_ipv6Tclass; //!< the Tclass carried by the tag
};
} // namespace ns3

View File

@@ -30,18 +30,90 @@
namespace ns3 {
/**
* \brief Write an Ipv4Address to a Buffer
* \param i a reference to the buffer to write to
* \param ad the Ipv4Address
*/
void WriteTo (Buffer::Iterator &i, Ipv4Address ad);
/**
* \brief Write an Ipv4Address to a Buffer
* \param i a reference to the buffer to write to
* \param ad the Ipv6Address
*/
void WriteTo (Buffer::Iterator &i, Ipv6Address ad);
/**
* \brief Write an Address to a Buffer
* \param i a reference to the buffer to write to
* \param ad the Address
*/
void WriteTo (Buffer::Iterator &i, const Address &ad);
/**
* \brief Write an Mac64Address to a Buffer
* \param i a reference to the buffer to write to
* \param ad the Mac64Address
*/
void WriteTo (Buffer::Iterator &i, Mac64Address ad);
/**
* \brief Write an Mac48Address to a Buffer
* \param i a reference to the buffer to write to
* \param ad the Mac48Address
*/
void WriteTo (Buffer::Iterator &i, Mac48Address ad);
/**
* \brief Write an Mac16Address to a Buffer
* \param i a reference to the buffer to write to
* \param ad the Mac16Address
*/
void WriteTo (Buffer::Iterator &i, Mac16Address ad);
/**
* \brief Read an Ipv4Address from a Buffer
* \param i a reference to the buffer to read from
* \param ad a reference to the Ipv4Address to be read
*/
void ReadFrom (Buffer::Iterator &i, Ipv4Address &ad);
/**
* \brief Read an Ipv6Address from a Buffer
* \param i a reference to the buffer to read from
* \param ad a reference to the Ipv6Address to be read
*/
void ReadFrom (Buffer::Iterator &i, Ipv6Address &ad);
/**
* \brief Read an Address from a Buffer
* \param i a reference to the buffer to read from
* \param ad a reference to the Address to be read
* \param len the length of the Address
*/
void ReadFrom (Buffer::Iterator &i, Address &ad, uint32_t len);
/**
* \brief Read a Mac64Address from a Buffer
* \param i a reference to the buffer to read from
* \param ad a reference to the Mac64Address to be read
*/
void ReadFrom (Buffer::Iterator &i, Mac64Address &ad);
/**
* \brief Read a Mac48Address from a Buffer
* \param i a reference to the buffer to read from
* \param ad a reference to the Mac48Address to be read
*/
void ReadFrom (Buffer::Iterator &i, Mac48Address &ad);
/**
* \brief Read a Mac16Address from a Buffer
* \param i a reference to the buffer to read from
* \param ad a reference to the Mac16Address to be read
*/
void ReadFrom (Buffer::Iterator &i, Mac16Address &ad);
namespace addressUtils {

View File

@@ -115,7 +115,12 @@ static uint32_t lookuphash (unsigned char* k, uint32_t length, uint32_t level)
/**
* \brief Convert an IPv6 C-string into a 128-bit representation.
*
* \param address pointer to the char buffer with the address ascii representation
* \param addr the buffer to store the IPv6 address
*
* \return true if success, false otherwise (bad format, ...)
*
* \note This function is strongly inspired by inet_pton6() from Paul Vixie.
* \todo Handle IPv6 address with decimal value for last four bytes.
*/
@@ -915,16 +920,6 @@ std::istream& operator >> (std::istream& is, Ipv6Prefix& prefix)
return is;
}
bool operator == (Ipv6Prefix const &a, Ipv6Prefix const &b)
{
return a.IsEqual (b);
}
bool operator != (Ipv6Prefix const &a, Ipv6Prefix const &b)
{
return !a.IsEqual (b);
}
size_t Ipv6AddressHash::operator () (Ipv6Address const &x) const
{
uint8_t buf[16];

View File

@@ -350,8 +350,31 @@ private:
*/
uint8_t m_address[16];
/**
* \brief Equal to operator.
*
* \param a the first operand
* \param b the first operand
* \returns true if the operands are equal
*/
friend bool operator == (Ipv6Address const &a, Ipv6Address const &b);
/**
* \brief Not equal to operator.
*
* \param a the first operand
* \param b the first operand
* \returns true if the operands are not equal
*/
friend bool operator != (Ipv6Address const &a, Ipv6Address const &b);
/**
* \brief Less than to operator.
*
* \param a the first operand
* \param b the first operand
* \returns true if the first operand is less than the second
*/
friend bool operator < (Ipv6Address const &a, Ipv6Address const &b);
};
@@ -463,6 +486,24 @@ private:
* \brief The prefix representation.
*/
uint8_t m_prefix[16];
/**
* \brief Equal to operator.
*
* \param a the first operand
* \param b the first operand
* \returns true if the operands are equal
*/
friend bool operator == (Ipv6Prefix const &a, Ipv6Prefix const &b);
/**
* \brief Not equal to operator.
*
* \param a the first operand
* \param b the first operand
* \returns true if the operands are not equal
*/
friend bool operator != (Ipv6Prefix const &a, Ipv6Prefix const &b);
};
/**
@@ -477,9 +518,40 @@ ATTRIBUTE_HELPER_HEADER (Ipv6Address);
*/
ATTRIBUTE_HELPER_HEADER (Ipv6Prefix);
std::ostream& operator << (std::ostream& os, Ipv6Address const& address);
std::ostream& operator<< (std::ostream& os, Ipv6Prefix const& prefix);
/**
* \brief Stream insertion operator.
*
* \param os the reference to the output stream
* \param address the Ipv6Address
* \returns the reference to the output stream
*/
std::ostream & operator << (std::ostream& os, Ipv6Address const& address);
/**
* \brief Stream insertion operator.
*
* \param os the reference to the output stream
* \param prefix the Ipv6Prefix
* \returns the reference to the output stream
*/
std::ostream & operator << (std::ostream& os, Ipv6Prefix const& prefix);
/**
* \brief Stream extraction operator.
*
* \param is the reference to the input stream
* \param address the Ipv6Address
* \returns the reference to the input stream
*/
std::istream & operator >> (std::istream &is, Ipv6Address &address);
/**
* \brief Stream extraction operator.
*
* \param is the reference to the input stream
* \param prefix the Ipv6Preofix
* \returns the reference to the input stream
*/
std::istream & operator >> (std::istream &is, Ipv6Prefix &prefix);
inline bool operator == (const Ipv6Address& a, const Ipv6Address& b)
@@ -497,6 +569,16 @@ inline bool operator < (const Ipv6Address& a, const Ipv6Address& b)
return (std::memcmp (a.m_address, b.m_address, 16) < 0);
}
inline bool operator == (const Ipv6Prefix& a, const Ipv6Prefix& b)
{
return (!std::memcmp (a.m_prefix, b.m_prefix, 16));
}
inline bool operator != (const Ipv6Prefix& a, const Ipv6Prefix& b)
{
return std::memcmp (a.m_prefix, b.m_prefix, 16);
}
/**
* \class Ipv6AddressHash
* \brief Hash function class for IPv6 addresses.
@@ -507,13 +589,11 @@ public:
/**
* \brief Unary operator to hash IPv6 address.
* \param x IPv6 address to hash
* \returns the hash of the address
*/
size_t operator () (Ipv6Address const &x) const;
};
bool operator == (Ipv6Prefix const &a, Ipv6Prefix const &b);
bool operator != (Ipv6Prefix const &a, Ipv6Prefix const &b);
} /* namespace ns3 */
#endif /* IPV6_ADDRESS_H */

View File

@@ -32,7 +32,7 @@ NS_LOG_COMPONENT_DEFINE ("TopologyReaderHelper");
TopologyReaderHelper::TopologyReaderHelper ()
{
m_inFile = 0;
m_inputModel = 0;
}
void
@@ -51,7 +51,7 @@ TopologyReaderHelper::SetFileType (const std::string fileType)
Ptr<TopologyReader>
TopologyReaderHelper::GetTopologyReader ()
{
if (!m_inFile)
if (!m_inputModel)
{
NS_ASSERT_MSG (!m_fileType.empty (), "Missing File Type");
NS_ASSERT_MSG (!m_fileName.empty (), "Missing File Name");
@@ -59,26 +59,26 @@ TopologyReaderHelper::GetTopologyReader ()
if (m_fileType == "Orbis")
{
NS_LOG_INFO ("Creating Orbis formatted data input.");
m_inFile = CreateObject<OrbisTopologyReader> ();
m_inputModel = CreateObject<OrbisTopologyReader> ();
}
else if (m_fileType == "Inet")
{
NS_LOG_INFO ("Creating Inet formatted data input.");
m_inFile = CreateObject<InetTopologyReader> ();
m_inputModel = CreateObject<InetTopologyReader> ();
}
else if (m_fileType == "Rocketfuel")
{
NS_LOG_INFO ("Creating Rocketfuel formatted data input.");
m_inFile = CreateObject<RocketfuelTopologyReader> ();
m_inputModel = CreateObject<RocketfuelTopologyReader> ();
}
else
{
NS_ASSERT_MSG (false, "Wrong (unknown) File Type");
}
m_inFile->SetFileName (m_fileName);
m_inputModel->SetFileName (m_fileName);
}
return m_inFile;
return m_inputModel;
}

View File

@@ -56,9 +56,9 @@ public:
Ptr<TopologyReader> GetTopologyReader ();
private:
Ptr<TopologyReader> m_inFile;
std::string m_fileName;
std::string m_fileType;
Ptr<TopologyReader> m_inputModel; //!< Smart pointer to the actual topology model
std::string m_fileName; //!< Name of the input file
std::string m_fileType; //!< Type of the input file (e.g., "Inet", "Orbis", etc.).
};
} // namespace ns3

View File

@@ -47,6 +47,10 @@ namespace ns3 {
class InetTopologyReader : public TopologyReader
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
InetTopologyReader ();
@@ -66,10 +70,6 @@ public:
*/
virtual NodeContainer Read (void);
private:
InetTopologyReader (const InetTopologyReader&);
InetTopologyReader& operator= (const InetTopologyReader&);
// end class InetTopologyReader
};

View File

@@ -44,6 +44,10 @@ namespace ns3 {
class OrbisTopologyReader : public TopologyReader
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
OrbisTopologyReader ();
@@ -61,10 +65,6 @@ public:
*/
virtual NodeContainer Read (void);
private:
OrbisTopologyReader (const OrbisTopologyReader&);
OrbisTopologyReader& operator= (const OrbisTopologyReader&);
// end class OrbisTopologyReader
};

View File

@@ -44,6 +44,8 @@ TypeId RocketfuelTopologyReader::GetTypeId (void)
RocketfuelTopologyReader::RocketfuelTopologyReader ()
{
m_linksNumber = 0;
m_nodesNumber = 0;
NS_LOG_FUNCTION (this);
}
@@ -54,6 +56,7 @@ RocketfuelTopologyReader::~RocketfuelTopologyReader ()
/* uid @loc [+] [bb] (num_neigh) [&ext] -> <nuid-1> <nuid-2> ... {-euid} ... =name[!] rn */
#define REGMATCH_MAX 16
#define START "^"
@@ -73,22 +76,6 @@ RocketfuelTopologyReader::~RocketfuelTopologyReader ()
#define ROCKETFUEL_WEIGHTS_LINE \
START "([^ \t]+)" SPACE "([^ \t]+)" SPACE "([0-9.]+)" MAYSPACE END
int linksNumber = 0;
int nodesNumber = 0;
std::map<std::string, Ptr<Node> > nodeMap;
static inline void
PrintNodeInfo (std::string & uid, std::string & loc, bool dns, bool bb,
std::vector <std::string>::size_type neighListSize,
std::string & name, int radius)
{
/* uid @loc [+] [bb] (num_neigh) [&ext] -> <nuid-1> <nuid-2> ... {-euid} ... =name[!] rn */
NS_LOG_INFO ("Load Node[" << uid << "]: location: " << loc << " dns: " << dns
<< " bb: " << bb << " neighbors: " << neighListSize
<< "(" << "%d" << ") externals: \"%s\"(%d) "
<< "name: " << name << " radius: " << radius);
}
NodeContainer
RocketfuelTopologyReader::GenerateFromMapsFile (int argc, char *argv[])
{
@@ -148,7 +135,7 @@ RocketfuelTopologyReader::GenerateFromMapsFile (int argc, char *argv[])
/* externs */
if (argv[7])
{
// euid = argv[7];
// euid = argv[7];
}
/* name */
@@ -163,17 +150,21 @@ RocketfuelTopologyReader::GenerateFromMapsFile (int argc, char *argv[])
return nodes;
}
PrintNodeInfo (uid, loc, dns, bb, neigh_list.size (), name, radius);
/* uid @loc [+] [bb] (num_neigh) [&ext] -> <nuid-1> <nuid-2> ... {-euid} ... =name[!] rn */
NS_LOG_INFO ("Load Node[" << uid << "]: location: " << loc << " dns: " << dns
<< " bb: " << bb << " neighbors: " << int(neigh_list.size ())
<< "(" << "%d" << ") externals: \"%s\"(%d) "
<< "name: " << name << " radius: " << radius);
// Create node and link
if (!uid.empty ())
{
if (nodeMap[uid] == 0)
if (m_nodeMap[uid] == 0)
{
Ptr<Node> tmpNode = CreateObject<Node> ();
nodeMap[uid] = tmpNode;
m_nodeMap[uid] = tmpNode;
nodes.Add (tmpNode);
nodesNumber++;
m_nodesNumber++;
}
for (uint32_t i = 0; i < neigh_list.size (); ++i)
@@ -185,19 +176,22 @@ RocketfuelTopologyReader::GenerateFromMapsFile (int argc, char *argv[])
return nodes;
}
if (nodeMap[nuid] == 0)
if (m_nodeMap[nuid] == 0)
{
Ptr<Node> tmpNode = CreateObject<Node> ();
nodeMap[nuid] = tmpNode;
m_nodeMap[nuid] = tmpNode;
nodes.Add (tmpNode);
nodesNumber++;
m_nodesNumber++;
}
NS_LOG_INFO (linksNumber << ":" << nodesNumber << " From: " << uid << " to: " << nuid);
Link link (nodeMap[uid], uid, nodeMap[nuid], nuid);
NS_LOG_INFO (m_linksNumber << ":" << m_nodesNumber << " From: " << uid << " to: " << nuid);
Link link (m_nodeMap[uid], uid, m_nodeMap[nuid], nuid);
AddLink (link);
linksNumber++;
m_linksNumber++;
}
}
NS_LOG_INFO ("Rocketfuel topology created with " << m_nodesNumber << " nodes and " << m_linksNumber << " links");
return nodes;
}
@@ -223,28 +217,28 @@ RocketfuelTopologyReader::GenerateFromWeightsFile (int argc, char *argv[])
// Create node and link
if (!sname.empty () && !tname.empty ())
{
if (nodeMap[sname] == 0)
if (m_nodeMap[sname] == 0)
{
Ptr<Node> tmpNode = CreateObject<Node> ();
nodeMap[sname] = tmpNode;
m_nodeMap[sname] = tmpNode;
nodes.Add (tmpNode);
nodesNumber++;
m_nodesNumber++;
}
if (nodeMap[tname] == 0)
if (m_nodeMap[tname] == 0)
{
Ptr<Node> tmpNode = CreateObject<Node> ();
nodeMap[tname] = tmpNode;
m_nodeMap[tname] = tmpNode;
nodes.Add (tmpNode);
nodesNumber++;
m_nodesNumber++;
}
NS_LOG_INFO (linksNumber << ":" << nodesNumber << " From: " << sname << " to: " << tname);
NS_LOG_INFO (m_linksNumber << ":" << m_nodesNumber << " From: " << sname << " to: " << tname);
TopologyReader::ConstLinksIterator iter;
bool found = false;
for (iter = LinksBegin (); iter != LinksEnd (); iter++)
{
if ((iter->GetFromNode () == nodeMap[tname])
&& (iter->GetToNode () == nodeMap[sname]))
if ((iter->GetFromNode () == m_nodeMap[tname])
&& (iter->GetToNode () == m_nodeMap[sname]))
{
found = true;
break;
@@ -253,11 +247,14 @@ RocketfuelTopologyReader::GenerateFromWeightsFile (int argc, char *argv[])
if (!found)
{
Link link (nodeMap[sname], sname, nodeMap[tname], tname);
Link link (m_nodeMap[sname], sname, m_nodeMap[tname], tname);
AddLink (link);
linksNumber++;
m_linksNumber++;
}
}
NS_LOG_INFO ("Rocketfuel topology created with " << m_nodesNumber << " nodes and " << m_linksNumber << " links");
return nodes;
}
@@ -423,7 +420,6 @@ RocketfuelTopologyReader::Read (void)
topgen.close ();
NS_LOG_INFO ("Rocketfuel topology created with " << nodesNumber << " nodes and " << linksNumber << " links");
return nodes;
}

View File

@@ -43,6 +43,10 @@ namespace ns3 {
class RocketfuelTopologyReader : public TopologyReader
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
RocketfuelTopologyReader ();
@@ -61,23 +65,52 @@ public:
virtual NodeContainer Read (void);
private:
RocketfuelTopologyReader (const RocketfuelTopologyReader&);
RocketfuelTopologyReader& operator= (const RocketfuelTopologyReader&);
// Parser for the *.cch file available at:
// http://www.cs.washington.edu/research/networking/rocketfuel/maps/rocketfuel_maps_cch.tar.gz
/**
* \brief Topology read function from a file containing the nodes map.
*
* Parser for the *.cch file available at:
* http://www.cs.washington.edu/research/networking/rocketfuel/maps/rocketfuel_maps_cch.tar.gz
*
* \param argc argument counter
* \param argv argument vector
* \return the container of the nodes created (or empty container if there was an error)
*/
NodeContainer GenerateFromMapsFile (int argc, char *argv[]);
// Parser for the weights.* file available at:
// http://www.cs.washington.edu/research/networking/rocketfuel/maps/weights-dist.tar.gz
/**
* \brief Topology read function from a file containing the nodes weights.
*
* Parser for the weights.* file available at:
* http://www.cs.washington.edu/research/networking/rocketfuel/maps/weights-dist.tar.gz
*
* \param argc argument counter
* \param argv argument vector
* \return the container of the nodes created (or empty container if there was an error)
*/
NodeContainer GenerateFromWeightsFile (int argc, char *argv[]);
/**
* \brief Enum of the possible file types.
*/
enum RF_FileType
{
RF_MAPS,
RF_WEIGHTS,
RF_UNKNOWN
};
/**
* \brief Classifies the file type according to its content.
*
* \return the file type (RF_MAPS, RF_WEIGHTS, or RF_UNKNOWN)
*/
enum RF_FileType GetFileType (const char *);
int m_linksNumber; //!< number of links
int m_nodesNumber; //!< number of nodes
std::map<std::string, Ptr<Node> > m_nodeMap; //!< map of the nodes (name, node)
// end class RocketfuelTopologyReader
};

View File

@@ -54,9 +54,9 @@ public:
class Link
{
public:
/**
* \brief Constant iterator to scan the map of link attributes.
*/
/**
* \brief Constant iterator to scan the map of link attributes.
*/
typedef std::map<std::string, std::string>::const_iterator ConstAttributesIterator;
/**
@@ -123,11 +123,11 @@ public:
private:
Link ();
std::string m_fromName;
Ptr< Node > m_fromPtr;
std::string m_toName;
Ptr< Node > m_toPtr;
std::map<std::string, std::string> m_linkAttr;
std::string m_fromName; //!< Name of the node the links originates from
Ptr< Node > m_fromPtr; //!< The node the links originates from
std::string m_toName; //!< Name of the node the links is directed to
Ptr< Node > m_toPtr; //!< The node the links is directed to
std::map<std::string, std::string> m_linkAttr; ///< Container of the link attributes (if any)
};
/**
@@ -135,6 +135,10 @@ private:
*/
typedef std::list< Link >::const_iterator ConstLinksIterator;
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
TopologyReader ();
@@ -196,10 +200,15 @@ private:
void AddLink (Link link);
private:
TopologyReader (const TopologyReader&);
TopologyReader& operator= (const TopologyReader&);
/**
* the name of the input file
*/
std::string m_fileName;
/**
* the container of the links between the nodes
*/
std::list<Link> m_linksList;
// end class TopologyReader