--- a/src/ltp-protocol/examples/ltp-protocol-example.cc Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/examples/ltp-protocol-example.cc Mon Aug 11 01:28:34 2014 +0200
@@ -123,16 +123,6 @@
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
- std::list<uint32_t> sampleList;
- // Lose first two SYNs
- sampleList.push_back (0);
- // sampleList.push_back (4);
- // This time, we'll explicitly create the error model we want
- Ptr<ReceiveListErrorModel> pem = CreateObject<ReceiveListErrorModel> ();
- pem->SetList (sampleList);
-
- devices.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (pem));
-
// Install the internet stack on the nodes
InternetStackHelper internet;
internet.Install (nodes);
@@ -153,7 +143,7 @@
ltpHelper.SetAttributes("CheckPointRtxLimit", UintegerValue(20),
"ReportSegmentRtxLimit", UintegerValue(20),
"RetransCyclelimit", UintegerValue(20));
- ltpHelper.SetRoutingProtocol (routing);
+ ltpHelper.SetLtpIpResolutionTable (routing);
ltpHelper.SetBaseLtpEngineId (0);
ltpHelper.SetStartTransmissionTime(Seconds(1));
ltpHelper.InstallAndLink (nodes);
--- a/src/ltp-protocol/helper/ltp-protocol-helper.cc Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/helper/ltp-protocol-helper.cc Mon Aug 11 01:28:34 2014 +0200
@@ -27,41 +27,45 @@
#include "ns3/ipv4.h"
#include "ns3/ipv6.h"
#include "ns3/enum.h"
+#include <ns3/log.h>
+
+NS_LOG_COMPONENT_DEFINE ("LtpHelper");
namespace ns3 {
namespace ltp {
LtpProtocolHelper::LtpProtocolHelper ()
- : m_ltpid (0),
+ : m_startTime (Seconds (0)),
+ m_ltpid (0),
m_routingProtocol (0)
{
- // Default UDP
- m_claFactory.SetTypeId (LtpUdpConvergenceLayerAdapter::GetTypeId ());
+ NS_LOG_FUNCTION (this);
+ m_claFactory.SetTypeId (LtpUdpConvergenceLayerAdapter::GetTypeId ()); // Default UDP
m_ltpFactory.SetTypeId (LtpProtocol::GetTypeId ());
}
void
-LtpProtocolHelper::SetAttributes ( std::string n1, const AttributeValue &v1,
- std::string n2, const AttributeValue &v2,
- std::string n3, const AttributeValue &v3,
- std::string n4, const AttributeValue &v4,
- std::string n5, const AttributeValue &v5,
- std::string n6, const AttributeValue &v6,
- std::string n7, const AttributeValue &v7,
- std::string n8, const AttributeValue &v8,
- std::string n9, const AttributeValue &v9)
+LtpProtocolHelper::SetAttributes (std::string n1, const AttributeValue &v1,
+ std::string n2, const AttributeValue &v2,
+ std::string n3, const AttributeValue &v3,
+ std::string n4, const AttributeValue &v4,
+ std::string n5, const AttributeValue &v5,
+ std::string n6, const AttributeValue &v6,
+ std::string n7, const AttributeValue &v7,
+ std::string n8, const AttributeValue &v8,
+ std::string n9, const AttributeValue &v9)
{
- m_ltpFactory.Set (n1, v1);
- m_ltpFactory.Set (n2, v2);
- m_ltpFactory.Set (n3, v3);
- m_ltpFactory.Set (n4, v4);
- m_ltpFactory.Set (n5, v5);
- m_ltpFactory.Set (n6, v6);
- m_ltpFactory.Set (n7, v7);
- m_ltpFactory.Set (n8, v8);
- m_ltpFactory.Set (n9, v9);
+ m_ltpFactory.Set (n1, v1);
+ m_ltpFactory.Set (n2, v2);
+ m_ltpFactory.Set (n3, v3);
+ m_ltpFactory.Set (n4, v4);
+ m_ltpFactory.Set (n5, v5);
+ m_ltpFactory.Set (n6, v6);
+ m_ltpFactory.Set (n7, v7);
+ m_ltpFactory.Set (n8, v8);
+ m_ltpFactory.Set (n9, v9);
}
@@ -91,42 +95,49 @@
void
-LtpProtocolHelper::InstallAndLink(NodeContainer c)
+LtpProtocolHelper::InstallAndLink (NodeContainer c)
{
- uint64_t base_addr = m_ltpid;
+ NS_LOG_FUNCTION (this);
+
+ uint64_t base_addr = m_ltpid;
uint32_t numNode = 0;
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
- {
- if (++numNode < c.GetN())
- m_claFactory.Set("RemotePeer", UintegerValue (m_ltpid+1));
+ {
+ if (++numNode < c.GetN ())
+ {
+ m_claFactory.Set ("RemotePeer", UintegerValue (m_ltpid + 1));
+ }
else
- m_claFactory.Set("RemotePeer", UintegerValue (base_addr));
-
- InstallAndLink (*i);
+ {
+ m_claFactory.Set ("RemotePeer", UintegerValue (base_addr));
+ }
+
+ InstallAndLink (*i);
}
-
+
}
-void
-LtpProtocolHelper::InstallAndLink(Ptr<Node> n)
+void
+LtpProtocolHelper::InstallAndLink (Ptr<Node> n)
{
+ NS_LOG_FUNCTION (this);
Ptr<LtpConvergenceLayerAdapter> link = m_claFactory.Create ()->GetObject<LtpConvergenceLayerAdapter> ();
if (link == 0)
{
NS_FATAL_ERROR ("The requested cla does not exist: \"" <<
m_claFactory.GetTypeId ().GetName () << "\"");
}
-
- Install(n);
+
+ Install (n);
Ptr<LtpProtocol> ltpProtocol = n->GetObject<LtpProtocol> ();
-
+
link->SetProtocol (ltpProtocol);
- ltpProtocol->AddDatalink (link);
- ltpProtocol->SetRoutingProtocol (m_routingProtocol);
+ ltpProtocol->AddDatalink (link);
+ ltpProtocol->SetIpResolutionTable (m_routingProtocol);
link->EnableReceive (ltpProtocol->GetLocalEngineId ());
-
- ltpProtocol->SetLinkStateCues(link);
-
+
+ ltpProtocol->SetLinkStateCues (link);
+
EnumValue mode = 0;
m_routingProtocol->GetAttribute ("Addressing",mode);
@@ -144,90 +155,102 @@
m_routingProtocol->AddBinding (m_ltpid++,ipv6->GetAddress (1,0).GetAddress (),port.Get ());
}
- link->SetLinkUpCallback ( MakeCallback (&LtpProtocol::Send,ltpProtocol));
+ link->SetLinkUpCallback ( MakeCallback (&LtpProtocol::Send,ltpProtocol));
Simulator::Schedule (m_startTime, &LtpUdpConvergenceLayerAdapter::SetLinkUp, link);
- m_claStorage.push_back (link);
-
-
}
void
LtpProtocolHelper::Install (Ptr<Node> node)
{
+ NS_LOG_FUNCTION (this);
if (node->GetObject<LtpProtocol> () != 0)
{
NS_FATAL_ERROR ("LtpProtocolHelper::Install (): Aggregating "
"an LtpProtocol to a node with an existing Ltp object");
return;
}
-
+
Ptr<LtpProtocol> ltpProtocol = m_ltpFactory.Create ()->GetObject<LtpProtocol> ();
- ltpProtocol->SetAttribute ("LocalEngineId", UintegerValue (m_ltpid));
+ ltpProtocol->SetAttribute ("LocalEngineId", UintegerValue (m_ltpid));
ltpProtocol->SetNode (node);
-
+
- if(m_routingProtocol == 0)
- NS_FATAL_ERROR ("LtpProtocolHelper::Install (): "
- "Routing protocol is not set");
-
+ if (m_routingProtocol == 0)
+ {
+ NS_FATAL_ERROR ("LtpProtocolHelper::Install (): "
+ "Routing protocol is not set");
+ }
+
node->AggregateObject (ltpProtocol);
}
void
LtpProtocolHelper::Install (NodeContainer c)
-{
- uint64_t base_addr = m_ltpid;
+{
+ NS_LOG_FUNCTION (this);
+ uint64_t base_addr = m_ltpid;
uint32_t numNode = 0;
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
- {
- if (++numNode < c.GetN())
- m_claFactory.Set("RemotePeer", UintegerValue (m_ltpid+1));
+ {
+ if (++numNode < c.GetN ())
+ {
+ m_claFactory.Set ("RemotePeer", UintegerValue (m_ltpid + 1));
+ }
else
- m_claFactory.Set("RemotePeer", UintegerValue (base_addr));
-
- Install (*i);
+ {
+ m_claFactory.Set ("RemotePeer", UintegerValue (base_addr));
+ }
+
+ Install (*i);
}
}
void
LtpProtocolHelper::Install (std::string nodeName)
{
+ NS_LOG_FUNCTION (this);
Ptr<Node> node = Names::Find<Node> (nodeName);
Install (node);
}
void LtpProtocolHelper::SetBaseLtpEngineId (uint64_t id)
{
+ NS_LOG_FUNCTION (this << id);
m_ltpid = id;
}
void SetLtpEngineId (Ptr<Node> node, uint64_t id)
{
+ NS_LOG_FUNCTION (this << node << id);
Ptr<LtpProtocol> ltpProtocol = node->GetObject<LtpProtocol> ();
ltpProtocol->SetAttribute ("LocalEngineId", UintegerValue (id));
}
-void LtpProtocolHelper::SetRoutingProtocol (Ptr<LtpIpResolutionTable> rprot)
+void LtpProtocolHelper::SetLtpIpResolutionTable (Ptr<LtpIpResolutionTable> rprot)
{
+ NS_LOG_FUNCTION (this << rprot);
m_routingProtocol = rprot;
}
bool LtpProtocolHelper::AddBinding (uint64_t dstLtpEngineId, Ipv4Address dstAddr, uint16_t port)
{
+ NS_LOG_FUNCTION (this << dstLtpEngineId << dstAddr << port);
return m_routingProtocol->AddBinding (dstLtpEngineId,dstAddr,port);
}
bool LtpProtocolHelper::AddBinding (uint64_t dstLtpEngineId, Ipv4Address dstAddr)
{
+ NS_LOG_FUNCTION (this << dstLtpEngineId << dstAddr);
return AddBinding (dstLtpEngineId,dstAddr,0);
}
void LtpProtocolHelper::SetStartTransmissionTime (Time start)
{
+ NS_LOG_FUNCTION (this << start);
m_startTime = start;
}
--- a/src/ltp-protocol/helper/ltp-protocol-helper.h Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/helper/ltp-protocol-helper.h Mon Aug 11 01:28:34 2014 +0200
@@ -34,29 +34,59 @@
namespace ns3 {
namespace ltp {
-
+/**
+ * \ingroup dtn
+ *
+ * \brief helps to manage and create Ltp Protocol objects
+ *
+ * This class can help to create Ltp Protocol Objects
+ * and to configure their attributes during creation, it can
+ * also create links between the nodes.
+ *
+ */
class LtpProtocolHelper
{
public:
+ /**
+ * \brief Create a LrWpan helper in an empty state.
+ */
LtpProtocolHelper ();
+ /**
+ * \brief Installs LTP protocol instances in each node of the provided container.
+ * \param c a set of nodes
+ */
void Install (NodeContainer c);
- void InstallAndLink(NodeContainer c);
-
- /* Create point to point links with the next node of the node container,
- and link the last one to the first */
- void Install (Ptr<Node> node);
- void InstallAndLink(Ptr<Node> node);
- void Install (std::string nodeName);
-
+ /* \brief Install LTP protocol instances in each nodes, and for each individual node
+ * it creates a point to point links with the next node the container, the last one
+ * is linked to the first
+ * \param c a set of nodes
+ */
+ void InstallAndLink (NodeContainer c);
+ /*
+ * \brief Set base ltp engine id will be incremented sequentially with each installed node.
+ * \param id
+ */
void SetBaseLtpEngineId (uint64_t id);
+ /*
+ * \brief Set specific ltp engine id to a given node.
+ * \param node pointer to node.
+ * \param id ltp engine id.
+ */
void SetLtpEngineId (Ptr<Node> node, uint64_t id);
- void SetRoutingProtocol (Ptr<LtpIpResolutionTable> rt);
+ /*
+ * \brief Set base LtpIpResolutionTable that will be used in installed ltp protocol instances.
+ * \param rt pointer to resolution talbe.
+ */
+ void SetLtpIpResolutionTable (Ptr<LtpIpResolutionTable> rt);
+ /*
+ * \brief Set type and attributes of Convergence Layer.
+ */
void SetConvergenceLayerAdapter (std::string type,
std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
@@ -67,35 +97,50 @@
std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (),
std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ());
-
+ /*
+ * \brief Set attributes of LTP protocol instances.
+ */
void SetAttributes ( std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
- std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
- std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
- std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
- std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
- std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
- std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
- std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (),
- std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ());
+ std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
+ std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
+ std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
+ std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
+ std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
+ std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
+ std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (),
+ std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ());
+ /*
+ * \brief Add bindings between ltp engine id and ip address.
+ */
bool AddBinding (uint64_t dstLtpEngineId, Ipv4Address dstAddr);
+
+ /*
+ * \brief Add bindings between ltp engine id and ip address.
+ */
bool AddBinding (uint64_t dstLtpEngineId, Ipv4Address dstAddr, uint16_t port);
- /* Find a better way to do this */
+ /*
+ * \brief Set the activation time of installed ltp protocols.
+ * */
void SetStartTransmissionTime (Time t);
+
private:
+
+ void Install (Ptr<Node> node);
+ void InstallAndLink (Ptr<Node> node);
+ void Install (std::string nodeName);
+
Time m_startTime;
- ObjectFactory m_claFactory; //!< Object factory.
- ObjectFactory m_ltpFactory;
+ ObjectFactory m_claFactory; //!< Cla Object factory.
+ ObjectFactory m_ltpFactory; //!< LTP Object factory.
- uint64_t m_ltpid;
+ uint64_t m_ltpid; //!< Base ltp id.
- Ptr<LtpIpResolutionTable> m_routingProtocol;
-
- std::deque<Ptr<LtpConvergenceLayerAdapter> > m_claStorage;
+ Ptr<LtpIpResolutionTable> m_routingProtocol; //!< Ltp to Ip resolution table.
};
--- a/src/ltp-protocol/model/ltp-convergence-layer-adapter.cc Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-convergence-layer-adapter.cc Mon Aug 11 01:28:34 2014 +0200
@@ -43,8 +43,10 @@
}
-LtpConvergenceLayerAdapter::LtpConvergenceLayerAdapter ():
- m_linkState(false)
+LtpConvergenceLayerAdapter::LtpConvergenceLayerAdapter ()
+ : m_linkState (false),
+ m_peerLtpEngineId (0),
+ m_activeSessionId (SessionId ())
{
NS_LOG_FUNCTION (this);
}
@@ -62,7 +64,7 @@
}
void
-LtpConvergenceLayerAdapter::SetLinkDownCallback (Callback<void> cb)
+LtpConvergenceLayerAdapter::SetLinkDownCallback (Callback<void, Ptr<LtpConvergenceLayerAdapter> > cb)
{
NS_LOG_FUNCTION (this << &cb);
m_linkDown = cb;
@@ -78,7 +80,7 @@
void
LtpConvergenceLayerAdapter::SetReportSentCallback (Callback<void, SessionId,RedSegmentInfo> cb)
{
- NS_LOG_FUNCTION (this << &cb);
+ NS_LOG_FUNCTION (this << &cb);
m_reportSent = cb;
}
@@ -90,7 +92,7 @@
}
void
-LtpConvergenceLayerAdapter::SetCancellationCallback (Callback<void> cb)
+LtpConvergenceLayerAdapter::SetCancellationCallback (Callback<void, SessionId> cb)
{
NS_LOG_FUNCTION (this << &cb);
m_cancelSent = cb;
@@ -102,7 +104,6 @@
if (!m_linkState)
{
-
m_linkState = true;
m_linkUp (this);
}
@@ -114,7 +115,7 @@
if (m_linkState)
{
m_linkState = false;
- m_linkDown ();
+ m_linkDown (this);
}
}
--- a/src/ltp-protocol/model/ltp-convergence-layer-adapter.h Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-convergence-layer-adapter.h Mon Aug 11 01:28:34 2014 +0200
@@ -35,6 +35,8 @@
class SessionId;
/**
+ * \ingroup dtn
+ *
* \brief Convergence Layer Adapter abstract base class
*
* Abstract base class for CLAs used in the LTP protocol
@@ -57,7 +59,6 @@
/*
* Send packet using the underlying layer.
* \param p packet to send.
- * \param dstLtpEngineId destination ltp engine.
* \return 0 if operation failed, size of sent data otherwise.
*/
virtual uint32_t Send (Ptr<Packet> p) = 0;
@@ -67,7 +68,6 @@
* destination Engine ID.
* \return 0 if operation failed (e.g. binding is not there);
* otherwise, return the MTU in bytes.
- * \param dstLtpEngineId the destination Engine ID
*/
virtual uint16_t GetMtu () const = 0;
@@ -79,6 +79,34 @@
*/
virtual bool EnableReceive (const uint64_t &localLtpEngineId) = 0;
+ /* Getter functions */
+
+ /**
+ * Get LTP protocol associated to this CLA
+ *
+ * \return pointer to LtpProtocol instance
+ */
+ virtual Ptr<LtpProtocol> GetProtocol () const = 0;
+
+ /*
+ * \brief Get routing protocol instance
+ *
+ * \return pointer to routing protocol.
+ */
+ virtual Ptr<LtpIpResolutionTable> GetRoutingProtocol () const = 0;
+
+ /*
+ * \brief Get Ltp engine of remote engine to which this channel is linked
+ */
+ uint64_t GetRemoteEngineId () const;
+
+ /*
+ * \brief Get active session id that is using this channel.
+ */
+ SessionId GetSessionId () const;
+
+ /* Setter functions */
+
/**
* Assign LTP protocol to CLA.
*
@@ -86,13 +114,6 @@
*/
virtual void SetProtocol (Ptr<LtpProtocol> prot) = 0;
- /**
- * Get LTP protocol associated to this CLA
- *
- * \return prot pointer to LtpProtocol instance
- */
- virtual Ptr<LtpProtocol> GetProtocol () const = 0;
-
/*
* Assign Routing protocol for resolution of LTP engine IDs
* to IP addresses.
@@ -102,48 +123,59 @@
virtual void SetRoutingProtocol (Ptr<LtpIpResolutionTable> prot) = 0;
/*
- * Get routing protocol instance
- *
- * \return pointer to routing protocol.
+ * \brief Set ltp engine of remote engine to which this channel is linked.
+ * \param id remote ltp engine id.
*/
- virtual Ptr<LtpIpResolutionTable> GetRoutingProtocol () const = 0;
+ void SetRemoteEngineId (uint64_t id);
- void SetLinkUp ();
- void SetLinkDown ();
-
-
- uint64_t GetRemoteEngineId () const;
- void SetRemoteEngineId (uint64_t);
-
- SessionId GetSessionId () const;
+ /*
+ * \brief Set active session id that is using this channel.
+ * \param id Ltp session id.
+ */
void SetSessionId (SessionId id );
+ /*
+ * \brief switches link status to "up" and notifies upper layer, if already up it does nothing.
+ */
+ void SetLinkUp (void);
- /* Link State Cues */
- /* Defined in : 5. Requirements from the Operating Environment */
+ /*
+ * \brief switches link status to "down" and notifies upper layer, if already down it does nothing.
+ */
+ void SetLinkDown (void);
+
+
+ /* Setters for Callbacks :
+ * each callback represents a link state cue as defined in Section 5 of RFC 5327
+ */
void SetLinkUpCallback ( Callback<void, Ptr<LtpConvergenceLayerAdapter> >);
- void SetLinkDownCallback ( Callback<void>);
-
+ void SetLinkDownCallback ( Callback<void, Ptr<LtpConvergenceLayerAdapter> >);
+
void SetCheckPointSentCallback ( Callback<void, SessionId,RedSegmentInfo>);
void SetReportSentCallback ( Callback<void, SessionId,RedSegmentInfo>);
- void SetEndOfBlockSentCallback( Callback<void, SessionId>);
- void SetCancellationCallback ( Callback<void>);
+ void SetEndOfBlockSentCallback ( Callback<void, SessionId>);
+ void SetCancellationCallback ( Callback<void, SessionId>);
protected:
- uint64_t m_peerLtpEngineId;
- SessionId m_activeSessionId;
+
+ bool m_linkState; //!< Defines Link state: up/down.
- bool m_linkState;
+ uint64_t m_peerLtpEngineId; //!< Remote Ltp engine to which this cla is linked.
+ SessionId m_activeSessionId; //!< Ltp session id that is using this channel.
+
+ /* Link status callbacks */
- Callback<void, Ptr<LtpConvergenceLayerAdapter> > m_linkUp;
- Callback<void> m_linkDown;
- Callback<void, SessionId,RedSegmentInfo> m_checkpointSent;
- // Callback<void, typename FN ,const Time ,TimerCode> m_checkpointSent;
- Callback<void, SessionId,RedSegmentInfo> m_reportSent;
- Callback<void, SessionId> m_endOfBlockSent;
- Callback<void> m_cancelSent;
+ Callback<void, Ptr<LtpConvergenceLayerAdapter> > m_linkUp; //!< Callback used to notify link ready status.
+ Callback<void, Ptr<LtpConvergenceLayerAdapter> > m_linkDown; //!< Callback used to notify link down status.
+
+ /* Segment transmission callbacks */
+
+ Callback<void, SessionId,RedSegmentInfo> m_checkpointSent; //!< Notify transmission of a checkpoint segment
+ Callback<void, SessionId,RedSegmentInfo> m_reportSent; //!< Callback used to notify that Report has been transmitted
+ Callback<void, SessionId> m_endOfBlockSent; //!< Callback used to notify that the EOB segment has been transmitted
+ Callback<void, SessionId> m_cancelSent; //!< Callback used to notify that a Cancelation segment has been transmitted
};
--- a/src/ltp-protocol/model/ltp-header.cc Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-header.cc Mon Aug 11 01:28:34 2014 +0200
@@ -140,9 +140,6 @@
{
m_extensions[j].Serialize (i);
}
-
-
-
}
uint32_t
LtpHeader::Deserialize (Buffer::Iterator start)
@@ -1236,8 +1233,12 @@
return offset < o.offset;
}
-
-
+std::ostream&
+operator << (std::ostream& os, const SessionId& id)
+{
+ os << id.GetSessionNumber () << " " << id.GetSessionOriginator ();
+ return os;
+}
} // namespace ltp
} // namespace ns3
--- a/src/ltp-protocol/model/ltp-header.h Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-header.h Mon Aug 11 01:28:34 2014 +0200
@@ -71,6 +71,8 @@
};
/**
+ * \ingroup dtn
+ *
* \brief Session ID Class for LTP Segment headers:
* A session Id uniquely identifies, among all transmissions, the session
* to which a segment pertains.
@@ -85,31 +87,31 @@
~SessionId ();
/**
* \brief Construct a session ID from specified parameters.
- * \param Session Originator
- * \param Session Number
+ * \param originator Session Originator
+ * \param value Session Number
*/
- SessionId (uint64_t,uint64_t);
+ SessionId (uint64_t originator,uint64_t value);
/**
* \returns the session originator of this session ID.
*/
uint64_t GetSessionOriginator () const;
/**
+ * \brief get session number
* \returns the session number of this session ID
*/
uint64_t GetSessionNumber () const;
/**
- * \param session originator.
+ * \brief set session originator.
+ * \param originator session originator.
*/
- void SetSessionOriginator (uint64_t);
+ void SetSessionOriginator (uint64_t originator);
/**
- * \param session number.
+ * \brief set session number.
+ * \param value session number.
*/
- void SetSessionNumber (uint64_t);
-
- uint64_t m_sessionOriginator; //!< The Ltp Engine ID of the sender (SDNV encoded)
- uint64_t m_sessionNumber; //!< Random number generated by the sender. (SDNV encoded)
+ void SetSessionNumber (uint64_t value);
bool operator == (SessionId const &o) const;
bool operator < (SessionId const &o) const;
@@ -121,7 +123,15 @@
static const uint32_t MIN_SESSION_NUMBER = 1;
static const uint32_t MAX_SESSION_NUMBER = 4294967295U;
+private:
+
+ uint64_t m_sessionOriginator; //!< The Ltp Engine ID of the sender (SDNV encoded)
+ uint64_t m_sessionNumber; //!< Random number generated by the sender. (SDNV encoded)
+
};
+
+std::ostream& operator << (std::ostream& os, const SessionId& pvf);
+
/**
* \brief Class for LTP Extensions as defined in RFC 5327.
* This class defines the main structure of an LTP extension.
@@ -157,12 +167,12 @@
uint64_t GetExtensionLength () const;
/**
- * \param Extension tag code.
+ * \param type Extension tag code.
*/
void SetExtensionType (ExtensionType type);
/**
* \brief Adds new data to the extension data and increases the length counter.
- * \param new byte of data
+ * \param data new byte of data
*/
void AddExtensionData (uint8_t data);
/**
@@ -180,6 +190,8 @@
};
/**
+ * \ingroup dtn
+ *
* \brief LTP Segment Header: Defined in RFC-5326 section 3.1
\verbatim
@@ -210,6 +222,8 @@
LtpHeader ();
/**
* \brief Construct a LTP segment from given parameters
+ * \param segmentType Type of segment.
+ * \param sId Session Id.
*/
LtpHeader (SegmentType segmentType, SessionId sId);
~LtpHeader ();
@@ -227,27 +241,27 @@
/* Setter Methods */
/**
- * \param Protocol version.
+ * \param version Protocol version.
*/
void SetVersion (uint8_t version);
/**
- * \param Segmentype enum value.
+ * \param segmentType Segmentype enum value.
*/
void SetSegmentType (SegmentType segmentType);
/**
- * \param Number of header extensions.
+ * \param count Number of header extensions.
*/
void SetHeaderExtensionCount (uint8_t count);
/**
- * \param Number of trailer extensions.
+ * \param count Number of trailer extensions.
*/
void SetTrailerExtensionCount (uint8_t count);
/**
- * \param SessionId object.
+ * \param id SessionId object.
*/
void SetSessionId (SessionId id);
/**
- * \param Extension object.
+ * \param extension Extension object.
*/
void AddExtension (LtpExtension extension);
@@ -275,15 +289,33 @@
SessionId GetSessionId () const;
/**
* \return Extesion object
- * \param Requested index
+ * \param index Requested index
*/
LtpExtension GetExtension (uint32_t index) const;
- bool operator == (LtpHeader const &o) const;
+ /* Static packet type checkers */
- static bool IsDataSegment(SegmentType);
- static bool IsRedDataSegment(SegmentType);
- static bool IsGreenDataSegment(SegmentType);
+ /*
+ * \brief Check if this type corresponds to a data segment
+ * \param type segment type.
+ * \return true if data segment, false otherwise.
+ */
+ static bool IsDataSegment (SegmentType type);
+ /*
+ * \brief Check if this type corresponds to a red data segment
+ * \param type segment type.
+ * \return true if data segment, false otherwise.
+ */
+ static bool IsRedDataSegment (SegmentType type);
+
+ /*
+ * \brief Check if this type corresponds to a red data segment
+ * \param type segment type.
+ * \return true if data segment, false otherwise.
+ */
+ static bool IsGreenDataSegment (SegmentType type);
+
+ bool operator == (LtpHeader const &o) const;
private:
// Control byte
@@ -299,11 +331,11 @@
std::vector<LtpExtension> m_extensions; //!< Extensions in TLV format (from 0 to 15)
-
-
};
/**
+ * \ingroup dtn
+ *
* \brief Class for LTP Trailer as defined in RFC-5326 section 3.3
*/
class LtpTrailer : public Trailer
@@ -341,6 +373,8 @@
/**
+ * \ingroup dtn
+ *
* \brief Generic Header for LTP data content as defined in RFC-5326 section 3.2
*/
class LtpContentHeader : public Header
@@ -348,11 +382,11 @@
public:
class ReceptionClaim
{
- public:
- uint64_t offset;
- uint64_t length;
+public:
+ uint64_t offset;
+ uint64_t length;
- bool operator < (ReceptionClaim const &o) const;
+ bool operator < (ReceptionClaim const &o) const;
};
LtpContentHeader ();
@@ -373,40 +407,40 @@
*/
void SetSegmentType (SegmentType segmentType);
/**
- * \param Client service id.
+ * \param id Client service id.
*/
void SetClientServiceId (uint64_t id);
/**
- * \param value for offset.
+ * \param val value for offset.
*/
void SetOffset (uint64_t val);
/**
- * \param value for length parameter.
+ * \param val value for length parameter.
*/
void SetLength (uint64_t val);
/**
- * \param value for checkpoint serial number
+ * \param num value for checkpoint serial number
*/
void SetCpSerialNumber (uint64_t num);
/**
- * \param value for report serial number
+ * \param num value for report serial number
*/
void SetRpSerialNumber (uint64_t num);
/**
- * \param value for upper bound of report segment
+ * \param bound value for upper bound of report segment
*/
void SetUpperBound (uint64_t bound);
/**
- * \param value for lower bound of report segment
+ * \param bound value for lower bound of report segment
*/
void SetLowerBound (uint64_t bound);
/**
- * \param Enum value for reason of cancellation
+ * \param code Enum value for reason of cancellation
*/
void SetCxReason (CxReasonCode code);
/**
* \brief Adds new reception claim and updates de reception claim counter.
- * \param Reception Claim object
+ * \param claim Reception Claim object
*/
void AddReceptionClaim (ReceptionClaim claim);
--- a/src/ltp-protocol/model/ltp-ip-resolution-table.cc Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-ip-resolution-table.cc Mon Aug 11 01:28:34 2014 +0200
@@ -175,7 +175,7 @@
Address LtpIpResolutionTable::GetRoute (uint64_t LtpEngineId)
{
NS_LOG_FUNCTION (this << LtpEngineId);
-
+
if (m_addressMode == Ipv4)
{
return GetIpv4Route (LtpEngineId);
--- a/src/ltp-protocol/model/ltp-ip-resolution-table.h Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-ip-resolution-table.h Mon Aug 11 01:28:34 2014 +0200
@@ -32,7 +32,10 @@
class LtpProtocol;
-/* Define the type of address used for mapping with Ltp Engine Ids */
+/* \enum AddressMode
+ * \brief Defines the type of address that will be used
+ * for the mapping of ltp engine ids.
+ * */
enum AddressMode
{
Ipv4 = 0,
@@ -40,6 +43,8 @@
};
/**
+ * \ingroup dtn
+ *
* \brief This class contains mappings between LTP Engine IDs and IP addresses
* It provides a public API for managing bindings and perform conversions.
*/
@@ -65,6 +70,7 @@
/*
* \brief Add Binding between Ipv4 Address and LTP Engine.
* \param LtpEngineId LTP engine Id.
+ * \param Addr Ipv4 Address
* \return true if binding added successfully, false if there is
* already an existing entry.
*/
@@ -73,6 +79,8 @@
/*
* \brief Add Binding between Ipv4 Address with port and LTP Engine.
* \param LtpEngineId LTP engine Id.
+ * \param Addr Ipv4 Address,
+ * \param port Port number.
* \return true if binding added successfully, false if there is
* already an existing entry.
*/
@@ -81,6 +89,7 @@
/*
* \brief Add Binding between Ipv6 Address and LTP Engine.
* \param LtpEngineId LTP engine Id.
+ * \param Addr Ipv6 Address.
* \return true if binding added successfully, false if there is
* already an existing entry.
*/
@@ -89,14 +98,16 @@
/*
* \brief Add Binding between Ipv6 Address with port and LTP Engine.
* \param LtpEngineId LTP engine Id.
+ * \param Addr Ipv6 Address.
+ * \param port Port number.
* \return true if binding added successfully, false if there is
* already an existing entry.
*/
bool AddBinding (uint64_t LtpEngineId, Ipv6Address Addr, uint16_t port);
/* \brief Remove bindings;
- * \param LtpEngineId LTP engine id
- * \param Addr Ipv4 Addr
+ * \param LtpEngineId LTP engine id.
+ * \param Addr Ipv4 Addr.
* \return true if the class instance found a match and was able to delete it */
bool RemoveBinding (uint64_t LtpEngineId, Ipv4Address Addr);
@@ -165,10 +176,11 @@
private:
+
std::map <uint64_t, InetSocketAddress> m_ltpToIpv4Addr; //!< LTP Engine - Ipv4 Addr Mappings
- std::map <uint64_t, Inet6SocketAddress> m_ltpToIpv6Addr; //!< LTP Engine - Ipv6 Addr Mappings
+ std::map <uint64_t, Inet6SocketAddress> m_ltpToIpv6Addr; //!< LTP Engine - Ipv6 Addr Mappings
- AddressMode m_addressMode; //!< Flag used to select address format.
+ AddressMode m_addressMode; //!< Flag used to select address format.
};
} // namespace ltp
--- a/src/ltp-protocol/model/ltp-protocol.cc Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-protocol.cc Mon Aug 11 01:28:34 2014 +0200
@@ -33,6 +33,19 @@
namespace ltp {
+
+ClientServiceStatus::ClientServiceStatus ()
+ : m_activeSessions (),
+ m_reportStatus ()
+{
+ NS_LOG_FUNCTION (this);
+}
+
+ClientServiceStatus::~ClientServiceStatus ()
+{
+ NS_LOG_FUNCTION (this);
+}
+
TypeId
ClientServiceStatus::GetTypeId (void)
{
@@ -47,13 +60,6 @@
return tid;
}
-ClientServiceStatus::ClientServiceStatus ()
-{
-}
-
-ClientServiceStatus::~ClientServiceStatus ()
-{
-}
void ClientServiceStatus::ReportStatus (SessionId id,
StatusNotificationCode code,
@@ -72,7 +78,6 @@
{
NS_LOG_FUNCTION (this);
m_activeSessions.insert (m_activeSessions.begin (), id);
-
}
void ClientServiceStatus::ClearSessions ()
@@ -94,8 +99,19 @@
}
LtpProtocol::LtpProtocol ()
- : m_cpRtxLimit (0),
- m_version (0)
+ : m_activeSessions (),
+ m_activeClients (),
+ m_clas (),
+ m_localEngineId (0),
+ m_cpRtxLimit (0),
+ m_rpRtxLimit (0),
+ m_rxProblemLimit (0),
+ m_cxRtxLimit (0),
+ m_rtxCycleLimit (0),
+ m_version (0),
+ m_localDelays (Seconds (0)),
+ m_onewayLightTime (Seconds (0)),
+ m_localOperatingSchedule ()
{
NS_LOG_FUNCTION (this);
m_uniformRandomVariable = CreateObject<UniformRandomVariable> ();
@@ -107,7 +123,6 @@
}
-
TypeId
LtpProtocol::GetTypeId (void)
{
@@ -124,23 +139,23 @@
MakeUintegerAccessor (&LtpProtocol::m_localEngineId),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("CheckPointRtxLimit", "Maximum number of checkpoints retransmissions allowed",
- UintegerValue (0),
+ UintegerValue (20),
MakeUintegerAccessor (&LtpProtocol::m_cpRtxLimit),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("ReportSegmentRtxLimit", "Maximum number of report segment retransmissions allowed",
- UintegerValue (0),
+ UintegerValue (20),
MakeUintegerAccessor (&LtpProtocol::m_rpRtxLimit),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("ReceptionProblemLimit", "Maximum number of reception failures allowed",
- UintegerValue (0),
+ UintegerValue (20),
MakeUintegerAccessor (&LtpProtocol::m_rxProblemLimit),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("CancelationRtxLimit", "Maximum number of cancelation request retransmissions allowed",
- UintegerValue (0),
+ UintegerValue (20),
MakeUintegerAccessor (&LtpProtocol::m_cxRtxLimit),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("RetransCyclelimit", "Maximum number of cancelation cycle retransmissions allowed",
- UintegerValue (0),
+ UintegerValue (20),
MakeUintegerAccessor (&LtpProtocol::m_rtxCycleLimit),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("LocalProcessingDelays", "Queue Processing Times (for use in timers)",
@@ -224,11 +239,10 @@
uint32_t LtpProtocol::StartTransmission ( uint64_t sourceId, uint64_t dstClientService,uint64_t dstLtpEngine, std::vector<uint8_t> data, uint64_t rdSize )
{
- NS_LOG_FUNCTION (this << dstClientService << " " << dstLtpEngine << rdSize );
+ NS_LOG_FUNCTION (this << dstClientService << dstLtpEngine << rdSize );
Ptr<SenderSessionStateRecord> ssr = CreateObject<SenderSessionStateRecord> (m_localEngineId, sourceId, dstClientService, dstLtpEngine,m_uniformRandomVariable);
-
SessionId id = ssr->GetSessionId ();
/* Report Session Start to Client Service Instance */
@@ -267,7 +281,7 @@
void LtpProtocol::CancelSession (SessionId id)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION (this << id);
SessionStateRecords::iterator it = m_activeSessions.find (id);
it->second->Cancel (LOCAL_CANCEL,USR_CNCLD);
@@ -279,7 +293,7 @@
void LtpProtocol::SignifyRedPartReception (SessionId id)
{
- NS_LOG_FUNCTION (this << id.GetSessionNumber () << id.GetSessionOriginator ());
+ NS_LOG_FUNCTION (this << id);
SessionStateRecords::iterator it = m_activeSessions.find (id);
if (it != m_activeSessions.end ())
@@ -299,7 +313,7 @@
LtpHeader header;
LtpContentHeader contentHeader;
- while (p = ssr->RemoveRedDataSegment ())
+ while ((p = ssr->RemoveRedDataSegment ()))
{
p->RemoveHeader (header);
contentHeader.SetSegmentType (header.GetSegmentType ());
@@ -328,12 +342,10 @@
void LtpProtocol::SignifyGreenPartSegmentArrival (SessionId id)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION (this << id);
SessionStateRecords::iterator it = m_activeSessions.find (id);
- //it->second->SetRedPartFinished ();
-
ClientServiceInstances::iterator itCls = m_activeClients.find (it->second->GetLocalClientServiceId ());
if (it->second->GetInstanceTypeId () == ReceiverSessionStateRecord::GetTypeId ())
@@ -346,7 +358,7 @@
uint32_t offset = 0;
uint64_t remoteLtp = it->second->GetPeerLtpEngineId ();
- if (p = ssr->RemoveGreenDataSegment ())
+ if ((p = ssr->RemoveGreenDataSegment ()))
{
LtpHeader header;
LtpContentHeader contentHeader;
@@ -377,7 +389,6 @@
}
-
itCls->second->ReportStatus (id,GP_SEGMENT_RCV, packetData, packetData.size (), EOB, remoteLtp, offset);
}
@@ -387,8 +398,7 @@
void LtpProtocol::CloseSession (SessionId id)
{
- NS_LOG_FUNCTION (this << id.GetSessionNumber () << id.GetSessionOriginator ());
-
+ NS_LOG_FUNCTION (this << id);
SessionStateRecords::iterator it = m_activeSessions.find (id);
@@ -397,7 +407,6 @@
Ptr<SessionStateRecord> ssr = it->second;
ssr->SetBlockFinished ();
-
if (it->second->GetNPackets ())
{
// Buffer is not empty , schedule again to allow the transmission of buffered segments and exit
@@ -408,20 +417,18 @@
ssr->CancelTimer (CHECKPOINT);
ssr->CancelTimer (REPORT);
-
ClientServiceInstances::iterator itCls = m_activeClients.find (ssr->GetLocalClientServiceId ());
itCls->second->ReportStatus (id, SESSION_END);
/* This should be done later, send a CX request first*/
m_activeSessions.erase (it);
-
}
}
-void LtpProtocol::CheckPointTx (SessionId id, RedSegmentInfo info)
+void LtpProtocol::SetCheckPointTransmissionTimer (SessionId id, RedSegmentInfo info)
{
- NS_LOG_FUNCTION (this << id.GetSessionNumber () << id.GetSessionOriginator ());
+ NS_LOG_FUNCTION (this << id);
SessionStateRecords::iterator it = m_activeSessions.find (id);
@@ -429,7 +436,6 @@
if (it != m_activeSessions.end ())
{
-
// Round trip = time to reach peer * 2 ( one way and back ) + processing times at both sides + margin
double rtt = m_onewayLightTime.GetSeconds () * 2 + m_localDelays.GetSeconds () * 2 + 1.0;
@@ -439,9 +445,9 @@
}
}
-void LtpProtocol::ReportTx (SessionId id, RedSegmentInfo info)
+void LtpProtocol::SetReportReTransmissionTimer (SessionId id, RedSegmentInfo info)
{
- NS_LOG_FUNCTION (this << id.GetSessionNumber () << id.GetSessionOriginator ());
+ NS_LOG_FUNCTION (this << id);
SessionStateRecords::iterator it = m_activeSessions.find (id);
Ptr<SessionStateRecord> ssr = 0;
@@ -458,14 +464,10 @@
}
-
-
-
/* Should be called on signal from the LinkStateCue: linkUp */
void LtpProtocol::Send (Ptr<LtpConvergenceLayerAdapter> cla)
{
NS_LOG_FUNCTION (this);
- // LTP send logic goes here
SessionId id = cla->GetSessionId ();
SessionStateRecords::iterator it = m_activeSessions.find (id);
@@ -477,17 +479,9 @@
if (packet)
{
cla->Send (packet);
- // Time sendTime = Seconds (1);
Simulator::Schedule (m_localDelays, &LtpProtocol::Send, this, cla);
}
-
- /*while (packet)
- {
- cla->Send (packet);
- packet = it->second->Dequeue () ;
-
- }*/
}
}
/* Should be called from lower layer */
@@ -524,7 +518,6 @@
{
// Service Client does not exist
// Send CX Segment.
- CxState ();
return;
}
@@ -534,16 +527,15 @@
itSessions->first,
m_uniformRandomVariable);
- // Set Timer functions for to newly created Receiver SSR
-
-
+ /* Add to active sessions */
std::pair<SessionId,Ptr<SessionStateRecord> > entry;
entry = std::make_pair (id, DynamicCast< SessionStateRecord > (srecv) );
m_activeSessions.insert (m_activeSessions.begin (),entry);
+
}
else
{
- /* Check If we are on the receiver or the sender side */
+ /* Check if we are on the receiver or the sender side */
if (itSessions->second->GetInstanceTypeId () == SenderSessionStateRecord::GetTypeId ())
{
ssend = DynamicCast<SenderSessionStateRecord> (itSessions->second);
@@ -554,10 +546,9 @@
}
}
- // Delay should be a configurable member var.
+
std::stringstream ss;
RedSegmentInfo retrans_info;
-
ss << "LtpEngine: " << m_localEngineId << " ";
/* If data segment*/
@@ -568,12 +559,9 @@
ss << " Miss-colored part received : " << header;
NS_LOG_DEBUG (ss.str ());
//Send CX Segment.
- CxState ();
}
else
{
-
-
if (LtpHeader::IsRedDataSegment (type))
{
srecv->StoreRedDataSegment (p);
@@ -581,7 +569,6 @@
claim.offset = contentHeader.GetOffset ();
claim.length = contentHeader.GetLength ();
uint32_t upperBound = claim.offset + claim.length;
- NS_LOG_DEBUG ("Claim Offset: " << claim.offset << " Length:" << claim.length << " UpperBound:" << upperBound);
srecv->SetHighBound (upperBound);
srecv->InsertClaim (srecv->GetRpCurrentSerialNumber (), srecv->GetLowBound (),srecv->GetHighBound (),claim);
}
@@ -599,7 +586,6 @@
case LTPTYPE_RD_CP:
ss << "Received Red data segment and Checkpoint : " << header << contentHeader;
NS_LOG_DEBUG (ss.str ());
- // srecv->SetCpStartSerialNumber(contentHeader.GetCpSerialNumber());
ReportSegmentTransmission (id, contentHeader.GetCpSerialNumber ());
break;
case LTPTYPE_RD_CP_EORP:
@@ -707,7 +693,7 @@
void LtpProtocol::ReportSegmentTransmission (SessionId id, uint64_t cpSerialNum)
{
- NS_LOG_FUNCTION (this << id.GetSessionNumber () << id.GetSessionOriginator ());
+ NS_LOG_FUNCTION (this << id << cpSerialNum);
SessionStateRecords::iterator it = m_activeSessions.find (id);
@@ -725,9 +711,9 @@
header.SetSessionId (id);
uint32_t RpSerial = it->second->GetRpCurrentSerialNumber ();
- uint32_t CpSerial = cpSerialNum; //it->second->GetCpCurrentSerialNumber (); // Is Keeping track of last CP received needed
- uint32_t upperBound = srecv->GetHighBound (); //GetClaimsUpperBound (RpSerial);
- uint32_t lowerBound = srecv->GetLowBound (); //GetClaimsLowerBound (RpSerial);
+ uint32_t CpSerial = cpSerialNum;
+ uint32_t upperBound = srecv->GetHighBound ();
+ uint32_t lowerBound = srecv->GetLowBound ();
contentHeader.SetSegmentType (LTPTYPE_RS);
@@ -749,27 +735,18 @@
srecv->StoreClaims (contentHeader);
srecv->Enqueue (p);
- //cla->Send(p);
- /* rfc5325 includes some computations of time required for sending (check) */
-
- // Simulator::ScheduleNow (&LtpProtocol::Send, this, cla); // TODO
Simulator::Schedule (m_localDelays, &LtpProtocol::Send, this, cla);
}
void
LtpProtocol::ReportSegmentAckTransmission (SessionId id, uint64_t rpSerialNum, Ptr<LtpConvergenceLayerAdapter>cla )
{
- NS_LOG_FUNCTION (this << id.GetSessionNumber () << id.GetSessionOriginator ());
+ NS_LOG_FUNCTION (this << id << rpSerialNum << cla);
SessionStateRecords::iterator it = m_activeSessions.find (id);
Ptr<SenderSessionStateRecord> ssr = DynamicCast<SenderSessionStateRecord> (it->second);
-// ConvergenceLayerAdapters::iterator itCla = m_clas.find (ssr->GetPeerLtpEngineId());
-
-// Ptr<LtpConvergenceLayerAdapter> cla = itCla->second;
-
-
Ptr<Packet> p = Create<Packet> ();
LtpHeader header;
LtpContentHeader contentHeader;
@@ -779,15 +756,13 @@
header.SetSessionId (id);
contentHeader.SetSegmentType (LTPTYPE_RAS);
- contentHeader.SetRpSerialNumber (rpSerialNum); //( it->second->GetRpCurrentSerialNumber ());
+ contentHeader.SetRpSerialNumber (rpSerialNum);
p->AddHeader (contentHeader);
p->AddHeader (header);
if (ssr)
{
- //cla->Send(p);
ssr->Enqueue (p);
- // Simulator::ScheduleNow (&LtpProtocol::Send, this, cla);
Simulator::Schedule (m_localDelays, &LtpProtocol::Send, this, cla);
}
else
@@ -801,7 +776,7 @@
void
LtpProtocol::CheckRedPartReceived (SessionId id)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION (this << id);
SessionStateRecords::iterator it = m_activeSessions.find (id);
Ptr<ReceiverSessionStateRecord> ssr = DynamicCast<ReceiverSessionStateRecord> (it->second);
@@ -817,7 +792,7 @@
void LtpProtocol::RetransmitSegment (SessionId id, RedSegmentInfo info)
{
- NS_LOG_FUNCTION (this << id.GetSessionNumber () << id.GetSessionOriginator ());
+ NS_LOG_FUNCTION (this << id);
SessionStateRecords::iterator it = m_activeSessions.find (id);
Ptr<SenderSessionStateRecord> ssr = DynamicCast<SenderSessionStateRecord> (it->second);
@@ -834,37 +809,25 @@
Simulator::Schedule (m_localDelays, &LtpProtocol::Send, this, cla);
}
-
-
-
-/*
- // Case in Which RP is lost -- callled from timer expiration -- retransmit the whole thing
- if (info.claims.size () == 0)
- {
- ssr->GetBlockData(info.low_bound, info.high_bound - info.low_bound);
- }
- // Case in which RP only contains partial claims -- retransmit part of the data
- else
- {
-
- }
- // Case in which everything has been properly claimed
- */
}
void LtpProtocol::RetransmitReport (SessionId id, RedSegmentInfo info)
{
- NS_LOG_FUNCTION (this << id.GetSessionNumber () << id.GetSessionOriginator ());
+ NS_LOG_FUNCTION (this << id);
SessionStateRecords::iterator it = m_activeSessions.find (id);
- Ptr<SessionStateRecord> srecv = it->second;
- ReportSegmentTransmission (id,info.CpserialNum);
+ Ptr<ReceiverSessionStateRecord> srecv = DynamicCast<ReceiverSessionStateRecord> (it->second);
+
+ if (m_rpRtxLimit > srecv->GetRpRtxNumber ())
+ {
+ ReportSegmentTransmission (id,info.CpserialNum);
+ }
}
void LtpProtocol::RetransmitCheckpoint (SessionId id, RedSegmentInfo info)
{
- NS_LOG_FUNCTION (this << id.GetSessionNumber () << id.GetSessionOriginator ());
+ NS_LOG_FUNCTION (this << id);
SessionStateRecords::iterator it = m_activeSessions.find (id);
}
@@ -884,14 +847,14 @@
void LtpProtocol::SetNode (Ptr<Node> node)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION (this << node);
m_node = node;
}
-void LtpProtocol::SetRoutingProtocol (Ptr<LtpIpResolutionTable> rprot)
+void LtpProtocol::SetIpResolutionTable (Ptr<LtpIpResolutionTable> rprot)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION (this << rprot);
ConvergenceLayerAdapters::iterator it;
@@ -903,7 +866,7 @@
bool LtpProtocol::AddDatalink (Ptr<LtpConvergenceLayerAdapter> link)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION (this << link);
std::pair<uint64_t,Ptr<LtpConvergenceLayerAdapter> > entry;
entry = std::make_pair (link->GetRemoteEngineId (), link);
@@ -916,7 +879,7 @@
Ptr<LtpConvergenceLayerAdapter> LtpProtocol::GetDatalink (uint64_t engineId)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION (this << engineId);
ConvergenceLayerAdapters::iterator it = m_clas.find (engineId);
if (it != m_clas.end ())
{
@@ -930,18 +893,18 @@
void
LtpProtocol::SetLinkStateCues (Ptr<LtpConvergenceLayerAdapter> link)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION (this << link);
- link->SetCheckPointSentCallback ( MakeCallback (&LtpProtocol::CheckPointTx, this));
- link->SetReportSentCallback ( MakeCallback (&LtpProtocol::ReportTx, this));
- link->SetEndOfBlockSentCallback ( MakeCallback (&LtpProtocol::SetEndOfBlockTx, this));
+ link->SetCheckPointSentCallback ( MakeCallback (&LtpProtocol::SetCheckPointTransmissionTimer, this));
+ link->SetReportSentCallback ( MakeCallback (&LtpProtocol::SetReportReTransmissionTimer, this));
+ link->SetEndOfBlockSentCallback ( MakeCallback (&LtpProtocol::SetEndOfBlockTransmission, this));
}
void
LtpProtocol::EncapsulateBlockData (uint64_t dstClientService, Ptr<SessionStateRecord> ssr, std::vector<uint8_t> data, uint64_t rdSize, bool rtx)
{
- NS_LOG_FUNCTION (this << rdSize);
+ NS_LOG_FUNCTION (this << dstClientService << ssr << rdSize << rtx);
SessionId id = ssr->GetSessionId ();
@@ -1063,9 +1026,9 @@
}
void
-LtpProtocol::SetEndOfBlockTx (SessionId id)
+LtpProtocol::SetEndOfBlockTransmission (SessionId id)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION (this << id);
SessionStateRecords::iterator it = m_activeSessions.find (id);
--- a/src/ltp-protocol/model/ltp-protocol.h Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-protocol.h Mon Aug 11 01:28:34 2014 +0200
@@ -32,7 +32,11 @@
class LtpUdpConvergenceLayerAdapter;
-/* 7. Notices to Client Service */
+/*
+ * \enum StatusNotificationCode
+ * \brief Notices to client service
+ * Defined in RFC-5326 Sections 7.1-7.7.
+ */
enum StatusNotificationCode
{
SESSION_START = 0,
@@ -41,70 +45,120 @@
TX_COMPLETED = 3,
TX_SESSION_CANCEL = 4,
RX_SESSION_CANCEL = 5,
- SESSION_END = 6
+ SESSION_END = 6
};
-/*RFC 5325 */
-class LtpDelays : public Object
-{
-
- Time m_processigTime; // Protocol processing time
- Time m_queueinDelay;
- // Outbound queuing delay:
- // Radiation time:
- // One way light time:
- // Inbound queuing delay:
-};
-
+/**
+ * \ingroup dtn
+ *
+ * \brief Class representing active client service instances
+ * registered within the LTP protocol.
+ *
+ * This class is used to keep track of active sessions
+ * that are being used by each client service instance. It contains methods
+ * to report the changes on session status that may happen during
+ * a transmission session.
+ */
class ClientServiceStatus : public Object
{
public:
+ /* Default constructor */
ClientServiceStatus ();
+
+ /* Destructor */
~ClientServiceStatus ();
static TypeId GetTypeId (void);
- /* RFC-5326 Section 7.1-7.7 */
- void ReportStatus (SessionId,
- StatusNotificationCode,
- std::vector<uint8_t> data,
- uint32_t dataLength,
- bool endFlag,
- uint64_t srcLtpEngine,
- uint32_t offset
- );
-
- void ReportCancelStatus(SessionId, CxReasonCode);
-
+ /*
+ * \brief This function reports changes in session state to a client service instance.
+ *
+ * Different notification codes require different parameters,
+ * as such the Session Id and the Code are mandatory.
+ * the other parameters have been assigned default values. Those
+ * parameters should only be provided if specifically needed by the type of notification.
+ *
+ * \param id Session Id.
+ * \param code StatusNotificationCode
+ * \param data Data to deliver to the client service instance. (used by RED_PART_RCV & GP_SEGMENT_RCV)
+ * \param dataLength Length of the delivered data. (used by RED_PART_RCV & GP_SEGMENT_RCV)
+ * \param srLtpEngine Source Ltp Engine id. (used by RED_PART_RCV and GP_SEGMENT_RCV)
+ * \param offset Offset within the block of the delivered data (used by GP_SEGMENT_RCV)
+ *
+ * */
+ void ReportStatus (SessionId id,
+ StatusNotificationCode code,
+ std::vector<uint8_t> data,
+ uint32_t dataLength,
+ bool endFlag,
+ uint64_t srcLtpEngine,
+ uint32_t offset
+ );
+
+ /*
+ * \brief This function reports session cancelation to a client service instance.
+ * \param id Session Id.
+ * \param code StatusNotificationCode
+ * \param cx Cancelation reason code
+ **/
+ void ReportCancelStatus (SessionId id,
+ StatusNotificationCode code,
+ CxReasonCode cx);
+
+ /*
+ * \brief Add and active session id to this client service instance.
+ * \param id session id.
+ */
void AddSession (SessionId id);
+ /*
+ * \brief Remove all active sessions
+ */
void ClearSessions ();
- uint32_t GetNSessions() const;
- SessionId GetSession(uint32_t index);
-
+ /*
+ * \brief Get number of active sessions.
+ * \return number of sessions.
+ */
+ uint32_t GetNSessions () const;
+ /*
+ * \brief Get session id for the given index.
+ * \param index
+ * \return Session id.
+ */
+ SessionId GetSession (uint32_t index);
private:
-
-
std::vector<SessionId> m_activeSessions; //!< Client Service Instance Active Sesssions
- TracedCallback<SessionId,StatusNotificationCode,std::vector<uint8_t>,uint32_t, bool,uint64_t ,uint32_t > m_reportStatus; //!< Callback used to report event to the client service instances
+ TracedCallback<SessionId,
+ StatusNotificationCode,
+ std::vector<uint8_t>,
+ uint32_t,
+ bool,
+ uint64_t,
+ uint32_t >
+ m_reportStatus; //!< Callback used to report events to the client service instances
};
-/* \brief Ltp protocol core class. This class contains:
- * - Interface functions with the upper and lower layers.
- * - Session state records management functions.
- * - Main send and receive methods.
+/*
+ * \ingroup dtn
+ *
+ * \brief Ltp protocol core class. Contains the protocol logic and the
+ * sender and receiver state machines.
+ *
+ * This class is a container for:
+ * - Active session state records,
+ * - Available convergence layer adapters.
+ * - Registered client service instances.
+ * Main function tasks:
+ * - Interface functions with the upper and lower layers.
+ * - Session state record management functions.
+ * - Protocol logic defining the state machines for both sender a receiver.
+ *
* */
class LtpProtocol : public Object
{
public:
- struct ActivationInterval
- {
- Time start;
- Time stop;
- };
-
/**
* \brief Default Constructor
*/
@@ -146,27 +200,46 @@
*/
uint32_t StartTransmission ( uint64_t sourceClientService, uint64_t dstClientService,uint64_t dstLtpEngine, std::vector<uint8_t> data, uint64_t rdSize );
-
- uint32_t StartTransmission ( uint64_t sourceClientService, uint64_t dstClientService,uint64_t dstLtpEngine, Ptr<Packet> p, uint64_t rdSize );
-
-
/*
* \brief Requests the cancellation of a session.
* As defined in RFC-5326 Section 4.2.
* \param id Session Id of the session to cancel.
*/
void CancelSession (SessionId id);
-
- void CloseSession(SessionId id);
-
- void SignifyRedPartReception(SessionId id);
- void SignifyGreenPartSegmentArrival(SessionId id);
-
-
- /* Protocol Interaction */
+
+ /*
+ * \brief Closes a session and frees resources.
+ * \param id Session Id of the session to close.
+ */
+ void CloseSession (SessionId id);
+
+ /*
+ * \brief Signals the reception of the full red part.
+ * \param id Session id.
+ */
+ void SignifyRedPartReception (SessionId id);
- void Send (Ptr<LtpConvergenceLayerAdapter>);
- void Receive (Ptr<Packet> packet, Ptr<LtpConvergenceLayerAdapter>);
+ /*
+ * \brief Signals the reception of a green segment.
+ * \param id Session id.
+ */
+ void SignifyGreenPartSegmentArrival (SessionId id);
+
+
+ /* Engines Interaction */
+
+ /*
+ * \brief Send buffered data
+ * \param cla Ltp Convergence layer adapter linked to the remote ltp engine.
+ */
+ void Send (Ptr<LtpConvergenceLayerAdapter> cla);
+
+ /*
+ * \brief Receive packet from lower layer.
+ * \param packet received packet.
+ * \param cla Ltp Convergence layer adapter which received the packet.
+ */
+ void Receive (Ptr<Packet> packet, Ptr<LtpConvergenceLayerAdapter> cla);
/* Getters Methods */
@@ -196,11 +269,15 @@
uint32_t GetRetransCycleLimit () const;
/**
* Get node of this ltp protocol instance
- *
- * \return node
+ * \return pointer to node
*/
Ptr<Node> GetNode () const;
-
+ /**
+ * Get Convergence layer adapter linked to a given remote engine id
+ * \param engineId Ltp engine id.
+ * \return pointer to convergence layer adapter.
+ */
+ Ptr<LtpConvergenceLayerAdapter> GetDatalink (uint64_t engineId);
/**
* \brief Check whether the LTP engine is active for the given time or not
* \param Time to test for
@@ -208,49 +285,128 @@
*/
bool IsActive (Time t);
- void SetNode(Ptr<Node>);
-
- bool AddDatalink(Ptr<LtpConvergenceLayerAdapter>);
- Ptr<LtpConvergenceLayerAdapter> GetDatalink(uint64_t engineId);
+ /* Setter functions */
+
+ /**
+ * Set node of this ltp protocol instance
+ * \param node
+ */
+ void SetNode (Ptr<Node> node);
- void SetRoutingProtocol (Ptr<LtpIpResolutionTable> rprot);
-
- void SetLinkStateCues(Ptr<LtpConvergenceLayerAdapter> link);
-
+ /**
+ * Set Ip resolution table for this ltp protocol instance, allows conversion
+ * between ltp engine ids and ip addresses.
+ * \param rprot Ltp Ip resolution table.
+ */
+ void SetIpResolutionTable (Ptr<LtpIpResolutionTable> rprot);
+
+ /**
+ * Enable link state cue notifications from the given ltp convergence layer adapter.
+ * \param link pointer to the ltp convergence layer adapter.
+ */
+ void SetLinkStateCues (Ptr<LtpConvergenceLayerAdapter> link);
+
+ /*
+ * Stores a new convergence layer adapter.
+ * \param cla pointer to convergence layer adapter.
+ */
+ bool AddDatalink (Ptr<LtpConvergenceLayerAdapter> cla);
+
private:
+/*
+ * \brief Given a destination and a block of data, splits the block
+ * into N segments of mtu size and enqeueues them for transmission
+ * into the outbound transmission queue of the provided session state record.
+ * \param dstClientService Destination client service id.
+ * \param ssr session state record into which enqueue segments.
+ * \param data Block of client service data to transmit
+ * \param rdSize Size of red part (data that needs to be sent in a reliable manner).
+ * \param rtx called for a retransmission ( this flags is used internally).
+ */
+ void EncapsulateBlockData (uint64_t dstClientService, Ptr<SessionStateRecord> ssr, std::vector<uint8_t> data, uint64_t rdSize, bool rtx = false);
- void CheckRedPartReceived(SessionId id);
+ /*
+ * \brief Generate and enqueue a Report segment in response to a CP.
+ * \param id Session Id.
+ * \param cpSerialNum Checkpoint serial number to which this RP responds.
+ */
+ void ReportSegmentTransmission (SessionId id, uint64_t cpSerialNum);
- void EncapsulateBlockData(uint64_t dstClientService, Ptr<SessionStateRecord> ssr, std::vector<uint8_t> data, uint64_t rdSize, bool rtx = false);
+ /*
+ * \brief Generate and enqueue a Report ACK segment in response to a RP.
+ *
+ * Note: Reports may be received even when the session has already been closed,
+ * A third parameter (reference to the CLA that received the report) is provided to
+ * handle these cases.
+ *
+ * \param id Session Id.
+ * \param cpSerialNum Report serial number to which this RA responds.
+ * \param cla pointer to convergence layer adapter that received the report.
+ */
+ void ReportSegmentAckTransmission (SessionId id, uint64_t rpSerialNum, Ptr<LtpConvergenceLayerAdapter>);
+ /* Retransmission Functions */
+
+ /* \brief Retransmit lost data segments
+ * \param id session id.
+ * \param info RedSegment info, contains serial number for checkpoints and the
+ * bounds of the lost data.
+ */
+ void RetransmitSegment (SessionId id, RedSegmentInfo info);
- void RxState(int32_t) {}
- void CxState() {}
- void ReportSegmentTransmission(SessionId id, uint64_t cpSerialNum);
- void ReportSegmentAckTransmission(SessionId id, uint64_t rpSerialNum, Ptr<LtpConvergenceLayerAdapter>);
-
- void CheckPointTx(SessionId id, RedSegmentInfo info);
- void ReportTx(SessionId id, RedSegmentInfo info);
-
- void RetransmitSegment(SessionId id, RedSegmentInfo info);
- void RetransmitReport(SessionId id, RedSegmentInfo info);
- void RetransmitCheckpoint(SessionId id, RedSegmentInfo info);
+ /* \brief Retransmit lost report segment
+ * \param id session id.
+ * \param info RedSegmentInfo contains data of the lost report.
+ */
+ void RetransmitReport (SessionId id, RedSegmentInfo info);
+
+ /* \brief Retransmit lost checkpoint segment
+ * \param id session id.
+ * \param info RedSegmentInfo contains data of the lost checkpoint.
+ */
+ void RetransmitCheckpoint (SessionId id, RedSegmentInfo info);
+
+ /*
+ * \brief Starts the checkpoint retransmission timer.
+ * \param id session id.
+ * \param info RedSegmentInfo information about the transmitted checkpoint to be used in
+ * case of segment loss.
+ */
+ void SetCheckPointTransmissionTimer (SessionId id, RedSegmentInfo info);
- void SetEndOfBlockTx(SessionId id);
+ /*
+ * \brief Starts the report retransmission timer.
+ * \param id session id.
+ * \param info RedSegmentInfo information about the transmitted report to be used in
+ * case of segment loss.
+ */
+ void SetReportReTransmissionTimer (SessionId id, RedSegmentInfo info);
- Ptr<Node> m_node; // LTP node
+/*
+ * \brief Signals the end of transmission, closes the session if certain conditions are meet.
+ * \param id session id.
+ */
+ void SetEndOfBlockTransmission (SessionId id);
+
+ /*
+ * \brief Check received data segments, if all red data received signals end of red part.
+ * \param id session id.
+ */
+ void CheckRedPartReceived (SessionId id);
+
+ Ptr<Node> m_node; // Node in which this ltp engine is running
typedef std::map<SessionId,Ptr<SessionStateRecord> > SessionStateRecords;
typedef std::map<uint64_t, Ptr<ClientServiceStatus> > ClientServiceInstances;
typedef std::map<uint64_t, Ptr<LtpConvergenceLayerAdapter> > ConvergenceLayerAdapters;
-
+
- // LtpEngineConfigParameters m_confParams; //!< Protocol configuration parameters
+ // LtpEngineConfigParameters m_confParams; //!< Protocol configuration parameters
SessionStateRecords m_activeSessions; //!< Active sessions.
ClientServiceInstances m_activeClients; //!< Active client service instances.
- ConvergenceLayerAdapters m_clas; //!< Mapping LtpEngineId with corresponding point-to-point link.
+ ConvergenceLayerAdapters m_clas; //!< Mapping LtpEngineId with corresponding point-to-point link.
Ptr<UniformRandomVariable> m_uniformRandomVariable; ///< Provides uniform random variables.
@@ -267,10 +423,24 @@
uint8_t m_version; //!< Protocol version
- Time m_localDelays; //!< Queue Processing Times (for use in timers)
- Time m_onewayLightTime;
+ /* This is a simplification of the times presented in RFC 5325- Section 3.1.3: Timers.
+ *
+ * m_localDelays represents the sum of :
+ * - outbound/inbound queue delays.
+ * - protocol processing time.
+ * - radiation time.
+ *
+ */
+ Time m_localDelays; //!< Local Processing Times (for use in timers)
+ Time m_onewayLightTime; //!< On way light time: time required to reach the remote ltp engine (for use in timers)
- std::queue<ActivationInterval> m_localOperatingSchedule; //!< Time Intervals that the local LTP engine expects to be operating
+ /* Simple data structure to define time intervals */
+ struct ActivationInterval
+ {
+ Time start;
+ Time stop;
+ };
+ std::queue<ActivationInterval> m_localOperatingSchedule; //!< Time intervals that the local LTP engine expects to be operating
};
--- a/src/ltp-protocol/model/ltp-queue-set.h Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-queue-set.h Mon Aug 11 01:28:34 2014 +0200
@@ -32,6 +32,8 @@
namespace ltp {
/**
+ * \ingroup dtn
+ *
* \brief Queue set class containing the two queues for outbound traffic.
* Represents the dual queue structure and priority en/de-queueing policy described in
* RFC 5325 - 3.1.2 Deferred Transmission.
--- a/src/ltp-protocol/model/ltp-session-state-record-impl.h Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-session-state-record-impl.h Mon Aug 11 01:28:34 2014 +0200
@@ -23,8 +23,8 @@
namespace ns3 {
namespace ltp {
-
-
+
+
template <typename FN>
void SessionStateRecord::SetTimerFunction (FN fn,const Time delay,TimerCode type)
{
@@ -33,17 +33,14 @@
case CHECKPOINT:
m_CpTimer.SetFunction (fn);
m_CpTimer.SetDelay (delay);
- // m_CpTimer.Schedule ();
break;
case REPORT:
m_RsTimer.SetFunction (fn);
m_RsTimer.SetDelay (delay);
- // m_RsTimer.Schedule ();
break;
case CANCEL:
m_CxTimer.SetFunction (fn);
m_CxTimer.SetDelay (delay);
- // m_CxTimer.Schedule ();
break;
default:
break;
@@ -58,17 +55,14 @@
case CHECKPOINT:
m_CpTimer.SetFunction (memPtr,objPtr);
m_CpTimer.SetDelay (delay);
- // m_CpTimer.Schedule ();
break;
case REPORT:
m_RsTimer.SetFunction (memPtr,objPtr);
m_RsTimer.SetDelay (delay);
- // m_RsTimer.Schedule ();
break;
case CANCEL:
m_CxTimer.SetFunction (memPtr,objPtr);
m_CxTimer.SetDelay (delay);
- // m_CxTimer.Schedule ();
break;
default:
break;
@@ -82,22 +76,18 @@
{
case CHECKPOINT:
m_CpTimer.SetFunction (memPtr,objPtr);
- m_CpTimer.SetArguments(param);
+ m_CpTimer.SetArguments (param);
m_CpTimer.SetDelay (delay);
- // m_CpTimer.Schedule ();
break;
case REPORT:
m_RsTimer.SetFunction (memPtr,objPtr);
- m_RsTimer.SetArguments(param);
+ m_RsTimer.SetArguments (param);
m_RsTimer.SetDelay (delay);
- // m_RsTimer.Schedule ();
break;
case CANCEL:
m_CxTimer.SetFunction (memPtr,objPtr);
- m_CxTimer.SetArguments(param);
+ m_CxTimer.SetArguments (param);
m_CxTimer.SetDelay (delay);
-
- // m_CxTimer.Schedule ();
break;
default:
break;
@@ -112,28 +102,23 @@
case CHECKPOINT:
m_CpTimer.SetFunction (memPtr,objPtr);
m_CpTimer.SetDelay (delay);
- m_CpTimer.SetArguments(param,param2);
- // m_CpTimer.Schedule ();
+ m_CpTimer.SetArguments (param,param2);
break;
case REPORT:
m_RsTimer.SetFunction (memPtr,objPtr);
m_RsTimer.SetDelay (delay);
- m_RsTimer.SetArguments(param,param2);
- // m_RsTimer.Schedule ();
+ m_RsTimer.SetArguments (param,param2);
break;
case CANCEL:
m_CxTimer.SetFunction (memPtr,objPtr);
m_CxTimer.SetDelay (delay);
- m_CxTimer.SetArguments(param,param2);
- // m_CxTimer.Schedule ();
+ m_CxTimer.SetArguments (param,param2);
break;
default:
break;
}
}
-
-
} // namespace ltp
} // namespace ns3
--- a/src/ltp-protocol/model/ltp-session-state-record.cc Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-session-state-record.cc Mon Aug 11 01:28:34 2014 +0200
@@ -30,18 +30,24 @@
SessionStateRecord::SessionStateRecord ()
: m_sessionId (),
m_txQueue (),
- m_peerLtpEngine (),
+ m_localLtpEngine (0),
+ m_peerLtpEngine (0),
+ m_localClientService (0),
m_CpTimer (Timer::CANCEL_ON_DESTROY),
m_RsTimer (Timer::CANCEL_ON_DESTROY),
m_CxTimer (Timer::CANCEL_ON_DESTROY),
+ m_firstCpSerialNumber (0),
+ m_currentCpSerialNumber (0),
+ m_firstRpSerialNumber (0),
+ m_currentRpSerialNumber (0),
m_rcvSegments (),
m_redpartSucces (false),
m_blockSuccess (false),
- m_fullRedData(false),
- m_fullGreenData(false),
- m_redPartLength(0),
- m_lowBound(0),
- m_highBound(0),
+ m_fullRedData (false),
+ m_fullGreenData (false),
+ m_redPartLength (0),
+ m_lowBound (0),
+ m_highBound (0),
m_rTxCnt (0),
m_canceled (NOT_CANCELED),
m_canceledReason (RESERVED),
@@ -56,20 +62,24 @@
uint64_t peerLtpEngineId)
: m_sessionId (),
m_txQueue (),
- m_localLtpEngine(localLtpEngineId),
+ m_localLtpEngine (localLtpEngineId),
m_peerLtpEngine (peerLtpEngineId),
m_localClientService (localClientServiceId),
m_CpTimer (Timer::CANCEL_ON_DESTROY),
m_RsTimer (Timer::CANCEL_ON_DESTROY),
m_CxTimer (Timer::CANCEL_ON_DESTROY),
+ m_firstCpSerialNumber (0),
+ m_currentCpSerialNumber (0),
+ m_firstRpSerialNumber (0),
+ m_currentRpSerialNumber (0),
m_rcvSegments (),
m_redpartSucces (false),
m_blockSuccess (false),
- m_fullRedData(false),
- m_fullGreenData(false),
- m_redPartLength(0),
- m_lowBound(0),
- m_highBound(0),
+ m_fullRedData (false),
+ m_fullGreenData (false),
+ m_redPartLength (0),
+ m_lowBound (0),
+ m_highBound (0),
m_rTxCnt (0),
m_canceled (NOT_CANCELED),
m_canceledReason (RESERVED),
@@ -83,7 +93,8 @@
SenderSessionStateRecord::SenderSessionStateRecord ()
: SessionStateRecord (),
m_destinationClientServiceId (0),
- m_cpTxCnt(0),
+ m_txData (),
+ m_cpTxCnt (0),
m_redpartAckSuccess (false)
{
NS_LOG_FUNCTION (this);
@@ -96,7 +107,8 @@
Ptr<UniformRandomVariable> number)
: SessionStateRecord (localLtpEngineId,localClientServiceId,destinationLtpEngine),
m_destinationClientServiceId (destinationClientService),
- m_cpTxCnt(0),
+ m_txData (),
+ m_cpTxCnt (0),
m_redpartAckSuccess (false)
{
NS_LOG_FUNCTION (this);
@@ -106,21 +118,26 @@
m_firstCpSerialNumber = number->GetInteger (MIN_INITIAL_SERIAL_NUMBER,MAX_INITIAL_SERIAL_NUMBER);
m_currentCpSerialNumber = m_firstCpSerialNumber;
m_firstRpSerialNumber = 0;
- m_currentRpSerialNumber = 0;
+ m_currentRpSerialNumber = 0;
}
ReceiverSessionStateRecord::ReceiverSessionStateRecord ()
: SessionStateRecord (),
- m_rcvCheckpoints ()
+ m_rpTxCnt (0),
+ m_rxRedBuffer (),
+ m_rxGreendBuffer ()
{
NS_LOG_FUNCTION (this);
}
ReceiverSessionStateRecord::ReceiverSessionStateRecord (uint64_t localLtpEngineId,
- uint64_t localClientServiceId,
- SessionId id,
- Ptr<UniformRandomVariable> number )
+ uint64_t localClientServiceId,
+ SessionId id,
+ Ptr<UniformRandomVariable> number )
: SessionStateRecord (localLtpEngineId,localClientServiceId,id.GetSessionOriginator ()),
- m_rcvCheckpoints ()
+ m_rpTxCnt (0),
+ m_rxRedBuffer (),
+ m_rxGreendBuffer ()
+
{
NS_LOG_FUNCTION (this);
@@ -213,14 +230,14 @@
{
case CHECKPOINT:
m_CpTimer.Cancel ();
- m_CpTimer.Schedule ();
+ m_CpTimer.Schedule ();
break;
case REPORT:
m_RsTimer.Cancel ();
m_RsTimer.Schedule ();
break;
case CANCEL:
- m_CxTimer.Cancel ();
+ m_CxTimer.Cancel ();
m_CxTimer.Schedule ();
break;
default:
@@ -228,13 +245,11 @@
}
}
-
-
void
SessionStateRecord::CancelTimer (TimerCode type)
{
NS_LOG_FUNCTION (this << type);
-
+
switch (type)
{
case CHECKPOINT:
@@ -252,8 +267,6 @@
}
}
-
-
void
SessionStateRecord::SuspendTimer (TimerCode type)
{
@@ -321,7 +334,6 @@
return m_currentRpSerialNumber;
}
-
uint64_t
SessionStateRecord::GetPeerLtpEngineId () const
{
@@ -369,36 +381,6 @@
NS_LOG_FUNCTION (this);
return m_txQueue.GetNPackets ();
}
-uint64_t
-SenderSessionStateRecord::GetDestination () const
-{
- NS_LOG_FUNCTION (this);
- return m_destinationClientServiceId;
-}
-
-void
-SenderSessionStateRecord::CopyBlockData(std::vector<uint8_t> data)
-{
- NS_LOG_FUNCTION (this);
- m_txData = data;
-}
-
-std::vector<uint8_t>
-SenderSessionStateRecord::GetBlockData (uint32_t offset, uint32_t length)
-{
- NS_LOG_FUNCTION (this);
- std::vector<uint8_t> ret;
- std::copy ( m_txData.begin()+offset, m_txData.begin()+offset+length, ret.begin() );
- return ret;
-}
-
-std::vector<uint8_t>
-SenderSessionStateRecord::GetBlockData ()
-{
- NS_LOG_FUNCTION (this);
- return m_txData;
-}
-
bool
SessionStateRecord::IsRedPartFinished () const
{
@@ -414,20 +396,6 @@
}
bool
-SenderSessionStateRecord::IsRedPartAck () const
-{
- NS_LOG_FUNCTION (this);
- return m_redpartAckSuccess;
-}
-
-void
-SenderSessionStateRecord::SetRedPartAck ()
-{
- NS_LOG_FUNCTION (this);
- m_redpartAckSuccess = true;
-}
-
-bool
SessionStateRecord::IsBlockFinished () const
{
NS_LOG_FUNCTION (this);
@@ -455,20 +423,6 @@
m_rTxCnt++;
}
-uint64_t
-SenderSessionStateRecord::GetCpRtxNumber () const
-{
- NS_LOG_FUNCTION (this);
- return m_cpTxCnt;
-}
-
-void
-SenderSessionStateRecord::IncrementCpRtxNumber ()
-{
- NS_LOG_FUNCTION (this);
- m_cpTxCnt++;
-}
-
bool
SessionStateRecord::IsCanceled () const
{
@@ -494,24 +448,26 @@
void
SessionStateRecord::SetCpStartSerialNumber ( uint64_t serialNum)
{
- NS_LOG_FUNCTION (this);
- if (m_firstCpSerialNumber == 0)
- {
-
- m_firstCpSerialNumber = serialNum;
-
- if (m_currentCpSerialNumber == 0)
-
- m_currentCpSerialNumber = serialNum;
- }
+ NS_LOG_FUNCTION (this << serialNum);
+ if (m_firstCpSerialNumber == 0)
+ {
+ m_firstCpSerialNumber = serialNum;
+
+ if (m_currentCpSerialNumber == 0)
+ {
+ m_currentCpSerialNumber = serialNum;
+ }
+ }
}
void
SessionStateRecord::SetRpStartSerialNumber ( uint64_t serialNum)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION (this << serialNum);
if (m_firstCpSerialNumber == 0)
- m_firstRpSerialNumber = serialNum;
+ {
+ m_firstRpSerialNumber = serialNum;
+ }
}
@@ -536,191 +492,132 @@
}
bool
-SessionStateRecord::InsertClaim (uint32_t serialNum,uint32_t low , uint32_t high, LtpContentHeader::ReceptionClaim claim)
+SessionStateRecord::InsertClaim (uint32_t serialNum,uint32_t low, uint32_t high, LtpContentHeader::ReceptionClaim claim)
{
NS_LOG_FUNCTION (this << claim.offset << claim.length);
- std::map< uint64_t, RedSegmentInfo >::iterator it = m_rcvSegments.find(serialNum);
+ std::map< uint64_t, RedSegmentInfo >::iterator it = m_rcvSegments.find (serialNum);
bool ret = false;
- if (it == m_rcvSegments.end())
- {
- RedSegmentInfo info;
- info.low_bound = 0;
- info.high_bound = 0;
- info.claims.insert(claim);
+ if (it == m_rcvSegments.end ())
+ {
+ RedSegmentInfo info;
+ info.low_bound = 0;
+ info.high_bound = 0;
+ info.claims.insert (claim);
- std::pair<uint64_t, RedSegmentInfo > entry;
+ std::pair<uint64_t, RedSegmentInfo > entry;
- entry = std::make_pair (serialNum,info);
- ret = m_rcvSegments.insert (entry).second;
-
-
- } else
- {
- it->second.low_bound = low;
- it->second.high_bound = high;
- ret = it->second.claims.insert(claim).second;
- }
-
-
+ entry = std::make_pair (serialNum,info);
+ ret = m_rcvSegments.insert (entry).second;
+ }
+ else
+ {
+ it->second.low_bound = low;
+ it->second.high_bound = high;
+ ret = it->second.claims.insert (claim).second;
+ }
return ret;
}
uint32_t
-SessionStateRecord::GetNClaims(uint32_t serialNum) const
+SessionStateRecord::GetNClaims (uint32_t serialNum) const
{
- NS_LOG_FUNCTION (this << serialNum);
+ NS_LOG_FUNCTION (this << serialNum);
- std::map< uint64_t, RedSegmentInfo >::const_iterator it =
- m_rcvSegments.find(serialNum);
+ std::map< uint64_t, RedSegmentInfo >::const_iterator it =
+ m_rcvSegments.find (serialNum);
- if (it != m_rcvSegments.end())
- {
- return it->second.claims.size();
- }
+ if (it != m_rcvSegments.end ())
+ {
+ return it->second.claims.size ();
+ }
- return 0;
+ return 0;
}
- uint32_t
- SessionStateRecord::GetClaimsUpperBound(uint32_t serialNum)
- {
- NS_LOG_FUNCTION (this << serialNum);
+uint32_t
+SessionStateRecord::GetClaimsUpperBound (uint32_t serialNum)
+{
+ NS_LOG_FUNCTION (this << serialNum);
- std::map< uint64_t, RedSegmentInfo >::const_iterator it =
- m_rcvSegments.find(serialNum);
+ std::map< uint64_t, RedSegmentInfo >::const_iterator it =
+ m_rcvSegments.find (serialNum);
- uint32_t upper = 0;
+ uint32_t upper = 0;
- if (it != m_rcvSegments.end())
- {
- upper = it->second.high_bound;
- }
- return upper;
- }
+ if (it != m_rcvSegments.end ())
+ {
+ upper = it->second.high_bound;
+ }
+ return upper;
+}
uint32_t
-SessionStateRecord::GetClaimsLowerBound(uint32_t serialNum)
+SessionStateRecord::GetClaimsLowerBound (uint32_t serialNum)
{
- NS_LOG_FUNCTION (this << serialNum);
+ NS_LOG_FUNCTION (this << serialNum);
- uint32_t lower = 0;
+ uint32_t lower = 0;
- std::map< uint64_t, RedSegmentInfo >::const_iterator it =
- m_rcvSegments.find(serialNum);
+ std::map< uint64_t, RedSegmentInfo >::const_iterator it =
+ m_rcvSegments.find (serialNum);
- if (it != m_rcvSegments.end())
- {
- lower = it->second.high_bound;
- }
- return lower;
+ if (it != m_rcvSegments.end ())
+ {
+ lower = it->second.high_bound;
+ }
+ return lower;
}
std::set<LtpContentHeader::ReceptionClaim>
-SessionStateRecord::GetClaims(uint64_t reportSerialNumber)
+SessionStateRecord::GetClaims (uint64_t reportSerialNumber)
{
- NS_LOG_FUNCTION (this << reportSerialNumber);
+ NS_LOG_FUNCTION (this << reportSerialNumber);
- std::map< uint64_t, RedSegmentInfo >::const_iterator it =
- m_rcvSegments.find(reportSerialNumber);
+ std::map< uint64_t, RedSegmentInfo >::const_iterator it =
+ m_rcvSegments.find (reportSerialNumber);
- if (it != m_rcvSegments.end()) {
+ if (it != m_rcvSegments.end ())
+ {
- return it->second.claims;
- }
- else
- {
+ return it->second.claims;
+ }
+ else
+ {
- return std::set<LtpContentHeader::ReceptionClaim>();
- }
+ return std::set<LtpContentHeader::ReceptionClaim> ();
+ }
}
bool
-ReceiverSessionStateRecord::InsertCheckpoint ()
+SessionStateRecord::StoreClaims (LtpContentHeader reportHeader)
{
NS_LOG_FUNCTION (this);
- return m_rcvCheckpoints.insert (m_currentCpSerialNumber).second;
-}
-void
-ReceiverSessionStateRecord::StoreRedDataSegment(Ptr<Packet> p)
-{
- NS_LOG_FUNCTION (this);
- /* TODO: Some sort of ordering of data packets based on offset should be implemented */
- /* Check for duplicates*/
-
- LtpHeader header;
- LtpContentHeader contentHeader;
-
-
- Ptr<Packet> packet = p->Copy();
-
- packet->RemoveHeader(header);
- contentHeader.SetSegmentType(header.GetSegmentType());
- packet->RemoveHeader(contentHeader);
-
- std::pair<uint32_t, Ptr<Packet> > entry;
- entry = std::make_pair (contentHeader.GetOffset(),p);
-
- m_rxRedBuffer.insert(entry);
-}
+ bool ret = false;
-Ptr<Packet>
-ReceiverSessionStateRecord::RemoveRedDataSegment()
-{
- NS_LOG_FUNCTION (this);
- Ptr<Packet> p = 0;
- if (m_rxRedBuffer.size() > 0)
- {
- std::map<uint32_t, Ptr<Packet> >::iterator it = m_rxRedBuffer.begin();
- p = it->second;
- m_rxRedBuffer.erase(it);
- }
- return p;
-}
-
-void
-ReceiverSessionStateRecord::StoreGreenDataSegment(Ptr<Packet> p)
-{
- NS_LOG_FUNCTION (this);
- m_rxGreendBuffer.push(p);
-}
+ for (uint32_t i = 0; i < reportHeader.GetRxClaimCnt (); i++)
+ {
+ ret = InsertClaim (reportHeader.GetRpSerialNumber (),
+ reportHeader.GetLowerBound (),
+ reportHeader.GetUpperBound (),
+ reportHeader.GetReceptionClaim (i));
-Ptr<Packet>
-ReceiverSessionStateRecord::RemoveGreenDataSegment()
-{
- NS_LOG_FUNCTION (this);
- Ptr<Packet> p = 0;
- if (m_rxGreendBuffer.size() > 0)
- {
- p = m_rxGreendBuffer.front();
- m_rxGreendBuffer.pop();
- }
- return p;
-}
+ if (!ret)
+ {
+ break;
+ }
+ }
-void
-SessionStateRecord::StoreClaims(LtpContentHeader reportHeader)
-{
- NS_LOG_FUNCTION (this);
-
- for (uint32_t i = 0; i < reportHeader.GetRxClaimCnt(); i++)
- {
- InsertClaim(reportHeader.GetRpSerialNumber(),
- reportHeader.GetLowerBound(),
- reportHeader.GetUpperBound(),
- reportHeader.GetReceptionClaim(i));
- }
+ return ret;
}
-
-
RedSegmentInfo
SessionStateRecord::FindMissingClaims (uint32_t serialNum)
{
@@ -728,97 +625,228 @@
uint32_t last_upper = 0;
- std::set<LtpContentHeader::ReceptionClaim> report_claims = GetClaims(serialNum);
+ std::set<LtpContentHeader::ReceptionClaim> report_claims = GetClaims (serialNum);
RedSegmentInfo missing_claims;
- missing_claims.high_bound = GetRedPartLength();
+ missing_claims.high_bound = GetRedPartLength ();
missing_claims.low_bound = 0;
- for (std::set<LtpContentHeader::ReceptionClaim>::iterator it=report_claims.begin(); it!=report_claims.end(); ++it)
- {
- /* Assume reception claims are ordered */
-
- LtpContentHeader::ReceptionClaim claim = *it;
+ for (std::set<LtpContentHeader::ReceptionClaim>::iterator it = report_claims.begin (); it != report_claims.end (); ++it)
+ {
+ /* Assumes that reception claims are ordered */
+ LtpContentHeader::ReceptionClaim claim = *it;
- if (last_upper != claim.offset)
- {
- LtpContentHeader::ReceptionClaim missing;
- missing.offset = last_upper;
- missing.length = claim.offset - last_upper;
+ if (last_upper != claim.offset)
+ {
+ LtpContentHeader::ReceptionClaim missing;
+ missing.offset = last_upper;
+ missing.length = claim.offset - last_upper;
- missing_claims.claims.insert (missing);
- }
+ missing_claims.claims.insert (missing);
+ }
- last_upper = claim.offset + claim.length;
- }
+ last_upper = claim.offset + claim.length;
+ }
return missing_claims;
}
void
-SessionStateRecord::SetRedPartLength(uint32_t len)
+SessionStateRecord::SetRedPartLength (uint32_t len)
{
- NS_LOG_FUNCTION (this << len);
- m_redPartLength = len;
+ NS_LOG_FUNCTION (this << len);
+ m_redPartLength = len;
+}
+
+uint32_t
+SessionStateRecord::GetRedPartLength () const
+{
+ NS_LOG_FUNCTION (this);
+ return m_redPartLength;
}
-uint32_t
-SessionStateRecord::GetRedPartLength() const
+
+void
+SessionStateRecord::SetFullRed ()
{
- NS_LOG_FUNCTION (this);
- return m_redPartLength;
+ NS_LOG_FUNCTION (this);
+ m_fullRedData = true;
+}
+bool
+SessionStateRecord::IsFullRed () const
+{
+ NS_LOG_FUNCTION (this);
+ return m_fullRedData;
}
void
-SessionStateRecord::SetLowBound(uint32_t len)
+SessionStateRecord::SetFullGreen ()
+{
+ NS_LOG_FUNCTION (this);
+ m_fullGreenData = true;
+}
+
+bool
+SessionStateRecord::IsFullGreen () const
{
- NS_LOG_FUNCTION (this << len);
- m_lowBound = len;
+ NS_LOG_FUNCTION (this);
+ return m_fullGreenData;
+}
+
+uint64_t
+SenderSessionStateRecord::GetDestination () const
+{
+ NS_LOG_FUNCTION (this);
+ return m_destinationClientServiceId;
+}
+
+void
+SenderSessionStateRecord::CopyBlockData (std::vector<uint8_t> data)
+{
+ NS_LOG_FUNCTION (this << data.size ());
+ m_txData = data;
}
-uint32_t
-SessionStateRecord::GetLowBound() const
+
+std::vector<uint8_t>
+SenderSessionStateRecord::GetBlockData (uint32_t offset, uint32_t length)
+{
+ NS_LOG_FUNCTION (this << offset << length);
+ std::vector<uint8_t> ret;
+ std::copy ( m_txData.begin () + offset, m_txData.begin () + offset + length, ret.begin () );
+ return ret;
+}
+
+std::vector<uint8_t>
+SenderSessionStateRecord::GetBlockData ()
{
- NS_LOG_FUNCTION (this);
- return m_lowBound;
+ NS_LOG_FUNCTION (this);
+ return m_txData;
+}
+
+bool
+SenderSessionStateRecord::IsRedPartAck () const
+{
+ NS_LOG_FUNCTION (this);
+ return m_redpartAckSuccess;
+}
+
+void
+SenderSessionStateRecord::SetRedPartAck ()
+{
+ NS_LOG_FUNCTION (this);
+ m_redpartAckSuccess = true;
+}
+
+uint64_t
+SenderSessionStateRecord::GetCpRtxNumber () const
+{
+ NS_LOG_FUNCTION (this);
+ return m_cpTxCnt;
}
void
-SessionStateRecord::SetHighBound(uint32_t len)
+SenderSessionStateRecord::IncrementCpRtxNumber ()
{
- NS_LOG_FUNCTION (this << len);
- if(len > m_highBound)
- m_highBound = len;
-}
-uint32_t
-SessionStateRecord::GetHighBound() const
-{
- NS_LOG_FUNCTION (this);
- return m_highBound;
+ NS_LOG_FUNCTION (this);
+ m_cpTxCnt++;
}
-void
-SessionStateRecord::SetFullRed()
+
+uint64_t
+ReceiverSessionStateRecord::GetRpRtxNumber () const
{
- NS_LOG_FUNCTION (this);
- m_fullRedData = true;
+ NS_LOG_FUNCTION (this);
+ return m_rpTxCnt;
}
-bool
-SessionStateRecord::IsFullRed() const
+
+void
+ReceiverSessionStateRecord::IncrementRpRtxNumber ()
{
- NS_LOG_FUNCTION (this);
- return m_fullRedData;
+ NS_LOG_FUNCTION (this);
+ m_rpTxCnt++;
}
void
-SessionStateRecord::SetFullGreen()
+ReceiverSessionStateRecord::StoreRedDataSegment (Ptr<Packet> p)
{
- NS_LOG_FUNCTION (this);
- m_fullGreenData = true;
+ NS_LOG_FUNCTION (this << p);
+
+ LtpHeader header;
+ LtpContentHeader contentHeader;
+
+ Ptr<Packet> packet = p->Copy ();
+
+ packet->RemoveHeader (header);
+ contentHeader.SetSegmentType (header.GetSegmentType ());
+ packet->RemoveHeader (contentHeader);
+
+ std::pair<uint32_t, Ptr<Packet> > entry;
+ entry = std::make_pair (contentHeader.GetOffset (),p);
+
+ m_rxRedBuffer.insert (entry);
+}
+
+Ptr<Packet>
+ReceiverSessionStateRecord::RemoveRedDataSegment ()
+{
+ NS_LOG_FUNCTION (this);
+ Ptr<Packet> p = 0;
+ if (m_rxRedBuffer.size () > 0)
+ {
+ std::map<uint32_t, Ptr<Packet> >::iterator it = m_rxRedBuffer.begin ();
+ p = it->second;
+ m_rxRedBuffer.erase (it);
+ }
+ return p;
+}
+
+void
+ReceiverSessionStateRecord::StoreGreenDataSegment (Ptr<Packet> p)
+{
+ NS_LOG_FUNCTION (this << p);
+ m_rxGreendBuffer.push (p);
}
-bool
-SessionStateRecord::IsFullGreen() const
+
+Ptr<Packet>
+ReceiverSessionStateRecord::RemoveGreenDataSegment ()
+{
+ NS_LOG_FUNCTION (this);
+ Ptr<Packet> p = 0;
+ if (m_rxGreendBuffer.size () > 0)
+ {
+ p = m_rxGreendBuffer.front ();
+ m_rxGreendBuffer.pop ();
+ }
+ return p;
+}
+
+void
+ReceiverSessionStateRecord::SetLowBound (uint32_t len)
{
- NS_LOG_FUNCTION (this);
- return m_fullGreenData;
+ NS_LOG_FUNCTION (this << len);
+ m_lowBound = len;
+}
+uint32_t
+ReceiverSessionStateRecord::GetLowBound () const
+{
+ NS_LOG_FUNCTION (this);
+ return m_lowBound;
}
+void
+ReceiverSessionStateRecord::SetHighBound (uint32_t len)
+{
+ NS_LOG_FUNCTION (this << len);
+ if (len > m_highBound)
+ {
+ m_highBound = len;
+ }
+}
+uint32_t
+ReceiverSessionStateRecord::GetHighBound () const
+{
+ NS_LOG_FUNCTION (this);
+ return m_highBound;
+}
+
+
} // namespace ltp
} // namespace ns3
--- a/src/ltp-protocol/model/ltp-session-state-record.h Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-session-state-record.h Mon Aug 11 01:28:34 2014 +0200
@@ -55,16 +55,22 @@
LOCAL_CANCEL = 2, //!< Remote LTP engine canceled the session
};
+/*
+ * \brief struct that stores specific values from report or checkpoint
+ * segments, used for retransmission.
+ */
struct RedSegmentInfo
{
- uint32_t CpserialNum;
- uint32_t RpserialNum;
- uint32_t low_bound;
- uint32_t high_bound;
- std::set<LtpContentHeader::ReceptionClaim> claims;
+ uint32_t CpserialNum;
+ uint32_t RpserialNum;
+ uint32_t low_bound;
+ uint32_t high_bound;
+ std::set<LtpContentHeader::ReceptionClaim> claims;
};
/**
+ * \ingroup dtn
+ *
* \brief Abstract class to keep track of LTP session state, contains shared
* flags, counters, timers and lists used in both sender and receiver sessions
*/
@@ -78,6 +84,9 @@
SessionStateRecord ();
/**
* \brief Parametized Constructor Session State Record segment
+ * \param localLtpEngineId local ltp Engine id.
+ * \param localClientServiceId local client service id.
+ * \param peerLtpEngineId remote ltp engine id.
*/
SessionStateRecord (uint64_t localLtpEngineId,
uint64_t localClientServiceId,
@@ -95,9 +104,9 @@
/**
* \brief Start the timer based on specified parameters
- * \param Function to call on timer expiration.
- * \param Time to wait.
- * \param Type of timer to start
+ * \param fn Function to call on timer expiration.
+ * \param delay Time to wait.
+ * \param type Type of timer to schedule.
*/
template <typename FN>
void SetTimerFunction (FN fn,const Time delay,TimerCode type);
@@ -110,29 +119,29 @@
template <typename MEM_PTR, typename OBJ_PTR, typename T1, typename T2>
void SetTimerFunction (MEM_PTR memPtr, OBJ_PTR objPtr, T1 param,T2 param2, const Time delay, TimerCode type);
-
+
/**
- * \brief Start timer
- * \param Code of timer to suspend
+ * \brief Start timer specified by parameter, if already running, it is stopped and restarted.
+ * \param type Code of timer to start.
*/
- void StartTimer(TimerCode type);
-
+ void StartTimer (TimerCode type);
+
/**
* \brief Cancel timer
- * \param Code of timer to suspend
+ * \param type Code of timer to cancel.
*/
-
- void CancelTimer(TimerCode type);
-
+
+ void CancelTimer (TimerCode type);
+
/**
* \brief Suspend timer
- * \param Code of timer to suspend
+ * \param type Code of timer to suspend.
*/
void SuspendTimer (TimerCode type);
/*
* \brief Resume timer.
- * \param Code of timer to resume
+ * \param type Code of timer to resume.
*/
void ResumeTimer (TimerCode type);
@@ -140,7 +149,7 @@
/*
* \brief Enqueue a packet for transmission
- * \param Packet to Enqueue.
+ * \param p Packet to Enqueue.
*/
bool Enqueue (Ptr<Packet> p);
@@ -160,25 +169,55 @@
* \brief Insert a reception claim. Should be called upon reception of a data
* segment if used by the receiver, or upon reception of a report segment if
* used by the sender.
+ * \param serialNum Serial Number Identifier to locate claims.
+ * \param low Lower Bound of stored claims.
+ * \param high Higher bound of store claims.
* \param claim Reception claim including offset and length of the data.
- * \param serialNumber Identifier to locate claims.
*/
- bool InsertClaim (uint32_t serialNum,uint32_t low , uint32_t high, LtpContentHeader::ReceptionClaim claim);
+ bool InsertClaim (uint32_t serialNum,uint32_t low, uint32_t high, LtpContentHeader::ReceptionClaim claim);
- uint32_t GetNClaims(uint32_t serialNum) const;
+ /*
+ * \brief Store claims for a given serial number.
+ * \param reportHeader packet corresponding to a report (contains claims, bounds and serial number).
+ */
+ bool StoreClaims (LtpContentHeader reportHeader);
+
+ /*
+ * \brief Get the number of claims stored for a given serial number.
+ * \param serialNum Serial Number Identifier to locate claims.
+ * \return Number of claims
+ */
+ uint32_t GetNClaims (uint32_t serialNum) const;
- uint32_t GetClaimsUpperBound(uint32_t serialNum);
+ /*
+ * \brief Get the claims upper bound for a given serial number.
+ * \param serialNum Serial Number Identifier to locate claims.
+ * \return upper bound
+ */
+ uint32_t GetClaimsUpperBound (uint32_t serialNum);
- uint32_t GetClaimsLowerBound(uint32_t serialNum);
+ /*
+ * \brief Get the claims lower bound for a given serial number.
+ * \param serialNum Serial Number Identifier to locate claims.
+ * \return lower bound
+ */
+ uint32_t GetClaimsLowerBound (uint32_t serialNum);
- std::set<LtpContentHeader::ReceptionClaim> GetClaims(uint64_t reportSerialNumber);
+ /*
+ * \brief Get list of claims stored for a given serial number.
+ * \param serialNum Serial Number Identifier to locate claims.
+ * \return list of claims.
+ */
+ std::set<LtpContentHeader::ReceptionClaim> GetClaims (uint64_t reportSerialNumber);
- void StoreClaims(LtpContentHeader reportHeader);
-
- RedSegmentInfo FindMissingClaims(uint32_t serialNum);
+ /*
+ * \brief Find missing claims between the upper and lower bound of a given serial number.
+ * \param serialNum Serial Number Identifier to locate claims.
+ * \return report information about missing claims.
+ */
+ RedSegmentInfo FindMissingClaims (uint32_t serialNum);
/* Setter Methods */
-
/*
* \brief Increment current Checkpoint serial number.
@@ -205,15 +244,38 @@
* \brief Signal the successful transmission of the full block of data.
*/
void SetBlockFinished ();
-
- void SetCpStartSerialNumber (uint64_t serialNum);
- void SetRpStartSerialNumber (uint64_t serialNum);
+
+ /*
+ * \brief Signal that the block only contained red data.
+ */
+ void SetFullRed ();
+ /*
+ * \brief Signal that the block only contained green data.
+ */
+ void SetFullGreen ();
+ /*
+ * \brief Set length of the red part of the block.
+ * \param len Length of red data.
+ */
+ void SetRedPartLength (uint32_t len);
/*
+ * \brief Set starting checkpoint serial number.
+ * \return serialNum before increase.
+ */
+ void SetCpStartSerialNumber (uint64_t serialNum);
+
+ /*
+ * \brief Set starting report serial number.
+ * \return serialNum before increase.
+ */
+ void SetRpStartSerialNumber (uint64_t serialNum);
+
+ /*
* \brief Cancel Transmission Session
- * \param Indicates which peer requested the cancellation.
- * \param Indicates the reason for cancellation.
+ * \param s Indicates which peer requested the cancellation.
+ * \param r Indicates the reason for cancellation.
*/
void Cancel (CancellationState s,CxReasonCode r);
@@ -270,12 +332,14 @@
* \return true if session is suspended, false if active.
*/
bool IsSuspended () const;
-
- void SetFullRed();
- bool IsFullRed() const;
-
- void SetFullGreen();
- bool IsFullGreen() const;
+ /*
+ * \return true if the block only contains red data, false if active.
+ */
+ bool IsFullRed () const;
+ /*
+ * \return true if the block only contains green data, false if active.
+ */
+ bool IsFullGreen () const;
/*
* \return Reason for cancellation.
@@ -292,14 +356,11 @@
*/
uint64_t GetRTxNumber () const;
- void SetRedPartLength(uint32_t len);
- uint32_t GetRedPartLength() const;
+ /**
+ * \return Length of the red part of the data block.
+ */
+ uint32_t GetRedPartLength () const;
- void SetLowBound(uint32_t len);
- uint32_t GetLowBound() const;
-
- void SetHighBound(uint32_t len);
- uint32_t GetHighBound() const;
/* Constants */
/*
@@ -320,13 +381,12 @@
protected:
- // LtpEngineConfigParameters m_config; //!< LTP Engine Configuration Parameters.
SessionId m_sessionId; //!< Session Identifier
LtpQueueSet m_txQueue; //!< Outgoing Packet Queue
- uint64_t m_localLtpEngine; //!< Id of the local Ltp Engine
- uint64_t m_peerLtpEngine; //!< Id of the peer Ltp Engine
- uint64_t m_localClientService; //!< Local Client Service Id
+ uint64_t m_localLtpEngine; //!< Id of the local Ltp Engine
+ uint64_t m_peerLtpEngine; //!< Id of the peer Ltp Engine
+ uint64_t m_localClientService; //!< Local Client Service Id
/* Timers */
@@ -334,10 +394,6 @@
Timer m_RsTimer; //!< Report timer.
Timer m_CxTimer; //!< Cancel timer.
- bool m_CpExpired; //!< Flag to signal Checkpoint timer expiration.
- bool m_RsExpired; //!< Flag to signal Report timer expiration.
- bool m_CxExpired; //!< Flag to signal Cancel timer expiration.
-
/* Checkpoints*/
uint64_t m_firstCpSerialNumber; //!< First checkpoint serial number chosen(sender)/received (received)
uint64_t m_currentCpSerialNumber; //!< Next checkpoint serial number (sender) / Last checkpoint number received (receiver)
@@ -352,26 +408,28 @@
bool m_redpartSucces; //!< Red part Transmitted/Received successfully
bool m_blockSuccess; //!< Full block Transmitted/Received successfully
- bool m_fullRedData; //!< True if the block only contains red data
- bool m_fullGreenData; //!< True if the block only contains green data
+ bool m_fullRedData; //!< True if the block only contains red data
+ bool m_fullGreenData; //!< True if the block only contains green data
- uint32_t m_redPartLength; //!< Length of the red part
- uint32_t m_lowBound; //!< Smallest non acknowledged offset
- uint32_t m_highBound; //!< Biggest non acknowledged offset
+ uint32_t m_redPartLength; //!< Length of the red part
+ uint32_t m_lowBound; //!< Smallest non acknowledged offset
+ uint32_t m_highBound; //!< Biggest non acknowledged offset
/* Retransmission */
uint64_t m_rTxCnt; //!< Count Number of Retransmissions.
/* Session state */
- CancellationState m_canceled; //!< Session Canceled
- CxReasonCode m_canceledReason; //!< Reason of Cancellation
- bool m_suspended; //!< Session Suspended
+ CancellationState m_canceled; //!< Session Canceled
+ CxReasonCode m_canceledReason; //!< Reason of Cancellation
+ bool m_suspended; //!< Session Suspended
};
/**
+ * \ingroup dtn
+ *
* \brief The Sender Session State Record class to
* store sender specific variables and methods.
*/
@@ -400,48 +458,59 @@
static TypeId GetTypeId (void);
virtual TypeId GetInstanceTypeId (void) const;
- /**
+ /*
* \return Destination Client Service Instance
*/
uint64_t GetDestination () const;
-
- void CopyBlockData(std::vector<uint8_t> data);
- std::vector<uint8_t> GetBlockData (uint32_t offset, uint32_t length);
- std::vector<uint8_t> GetBlockData ();
-
+ /*
+ * \return Number of checkpoint retransmissions during this session.
+ */
+ uint64_t GetCpRtxNumber () const;
/*
* \return true if Red part acknowledged successfully, false otherwise
*/
bool IsRedPartAck () const;
+ /*
+ * \brief Get the block of data to be transmitted
+ * \return block data to be transmited.
+ */
+ std::vector<uint8_t> GetBlockData ();
+ /*
+ * \brief Get the block of data to be transmitted within the bounds specified
+ * by offset and length.
+ * \param offset starting index of the data.
+ * \param length length of the data.
+ * \return block data to be transmited.
+ */
+ std::vector<uint8_t> GetBlockData (uint32_t offset, uint32_t length);
/*
+ * \brief Store a copy of the block data to be transmitted (
+ * it may be required for retransmissions)
+ * \param data vector containing the data.
+ */
+ void CopyBlockData (std::vector<uint8_t> data);
+ /*
* \brief Signal the successful acknowledgment of the red part data.
*/
void SetRedPartAck ();
-
-
/*
* \brief Increment Checkpoint retransmission counter.
*/
void IncrementCpRtxNumber ();
- /**
- * \return Number of retransmissions.
- */
- uint64_t GetCpRtxNumber () const;
-
private:
uint64_t m_destinationClientServiceId; //!< Destination Client Service instance
-
- std::vector<uint8_t> m_txData; //!< Block Data to transmit
+ std::vector<uint8_t> m_txData; //!< Block Data to transmit
- uint64_t m_cpTxCnt; //!< Count Number of retransmitted checkpoints
+ uint64_t m_cpTxCnt; //!< Count Number of retransmitted checkpoints
-
- bool m_redpartAckSuccess; //!< Red part Acknowledged successfully
+ bool m_redpartAckSuccess; //!< Red part Acknowledged successfully
};
/**
+ * \ingroup dtn
+ *
* \brief The Receiver Session State Record class to store
* receiver specific variables and methods.
*/
@@ -458,9 +527,9 @@
* \param Config parameters.
*/
ReceiverSessionStateRecord (uint64_t localLtpEngineId,
- uint64_t localClientServiceId,
- SessionId session,
- Ptr<UniformRandomVariable> number );
+ uint64_t localClientServiceId,
+ SessionId session,
+ Ptr<UniformRandomVariable> number );
/**
* \brief Default Destructor
*/
@@ -468,28 +537,73 @@
static TypeId GetTypeId (void);
virtual TypeId GetInstanceTypeId (void) const;
-
- void StoreRedDataSegment(Ptr<Packet>);
- Ptr<Packet> RemoveRedDataSegment();
+
+
+ /* Data Storage */
- void StoreGreenDataSegment(Ptr<Packet>);
- Ptr<Packet> RemoveGreenDataSegment();
+ /*
+ * \brief Store a received red data segment in the inbound traffic queue.
+ * \param p received packet.
+ */
+ void StoreRedDataSegment (Ptr<Packet> p);
+ /*
+ * \brief Store a received green data segment in the inbound traffic queue.
+ * \param p received packet.
+ */
+ void StoreGreenDataSegment (Ptr<Packet> p);
+ /*
+ * \brief remove a received red data segment from the inbound traffic queue.
+ * \return p received packet.
+ */
+ Ptr<Packet> RemoveRedDataSegment ();
+ /*
+ * \brief remove a received green data segment from the inbound traffic queue.
+ * \return p received packet.
+ */
+ Ptr<Packet> RemoveGreenDataSegment ();
+
+ /* Setter functions */
/*
- * \brief Insert the current checkpoint number to the list
+ * \brief Set lower bound of received data
+ * \param offset Lower bound.
+ */
+ void SetLowBound (uint32_t offset);
+
+ /*
+ * \brief Set higher bound of received data
+ * \param offset higher bound.
+ */
+ void SetHighBound (uint32_t offset);
+ /*
+ * \brief Increment Checkpoint retransmission counter.
*/
- bool InsertCheckpoint (void);
+ void IncrementRpRtxNumber ();
+
+
+ /* Getter functions */
+
+ /*
+ * \brief Get lower bound of received data
+ * \return Lower bound.
+ */
+ uint32_t GetLowBound () const;
+ /*
+ * \brief Get higher bound of received data
+ * \return High bound.
+ */
+ uint32_t GetHighBound () const;
+ /*
+ * \return Number of checkpoint retransmissions during this session.
+ */
+ uint64_t GetRpRtxNumber () const;
private:
- std::set<uint64_t> m_rcvCheckpoints; //!< Track Received Checkpoints
- std::set<LtpContentHeader::ReceptionClaim> m_receivedSegments;
+ uint64_t m_rpTxCnt; //!< Count Number of retransmitted reports.
- std::map<uint32_t, Ptr<Packet> > m_rxRedBuffer; // Storage for received red segments
- //std::set<Ptr<Packet> > m_rxRedBuffer; // Storage for received red segments
- std::queue<Ptr<Packet> > m_rxGreendBuffer; // Storage for received green segments
-
-
+ std::map<uint32_t, Ptr<Packet> > m_rxRedBuffer; //!< Storage for received red segments
+ std::queue<Ptr<Packet> > m_rxGreendBuffer; //!< Storage for received green segments
};
} // namespace ltp
--- a/src/ltp-protocol/model/ltp-udp-convergence-layer-adapter.cc Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-udp-convergence-layer-adapter.cc Mon Aug 11 01:28:34 2014 +0200
@@ -33,17 +33,22 @@
LtpUdpConvergenceLayerAdapter::LtpUdpConvergenceLayerAdapter ()
+ : m_serverPort (0),
+ m_keepAliveValue (0),
+ m_rcvSocket (0),
+ m_rcvSocket6 (0),
+ m_l4SendSockets (),
+ m_ltp (0),
+ m_ltpRouting (0)
{
NS_LOG_FUNCTION (this);
-
+
m_linkUp = MakeNullCallback< void, Ptr<LtpConvergenceLayerAdapter> > ();
- m_linkDown = MakeNullCallback< void > ();
- m_checkpointSent = MakeNullCallback< void , SessionId , RedSegmentInfo> ();
-
- //m_checkpointSent = MakeNullCallback< void , typename FN, const Time, TimerCode > ();
- m_reportSent = MakeNullCallback< void , SessionId , RedSegmentInfo> ();
- m_cancelSent = MakeNullCallback< void > ();
- m_endOfBlockSent = MakeNullCallback< void , SessionId> ();
+ m_linkDown = MakeNullCallback< void, Ptr<LtpConvergenceLayerAdapter> > ();
+ m_checkpointSent = MakeNullCallback< void, SessionId, RedSegmentInfo> ();
+ m_reportSent = MakeNullCallback< void, SessionId, RedSegmentInfo> ();
+ m_cancelSent = MakeNullCallback< void, SessionId > ();
+ m_endOfBlockSent = MakeNullCallback< void, SessionId> ();
}
@@ -58,7 +63,6 @@
TypeId tid;
tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
-
if (m_ltp)
{
m_rcvSocket = Socket::CreateSocket (m_ltp->GetNode (), tid);
@@ -78,9 +82,6 @@
NS_LOG_DEBUG ("Protocol instance is not assigned");
return false;
}
-
-
-
}
TypeId
@@ -131,58 +132,64 @@
NS_LOG_DEBUG ("LtpUdpConvergenceLayerAdapter:: Reuse socket");
socket = it_sock->second;
}
-
+
uint32_t bytes = socket->Send (p);
-
+
LtpHeader header;
LtpContentHeader contentHeader;
-
+
Ptr<Packet> packet = p->Copy ();
- packet->RemoveHeader(header);
+ packet->RemoveHeader (header);
contentHeader.SetSegmentType (header.GetSegmentType ());
- packet->RemoveHeader(contentHeader);
+ packet->RemoveHeader (contentHeader);
RedSegmentInfo info;
-
- switch(header.GetSegmentType())
- {
- case LTPTYPE_RD_CP_EORP_EOB:
- if (!m_endOfBlockSent.IsNull())
- m_endOfBlockSent(m_activeSessionId);
+
+ switch (header.GetSegmentType ())
+ {
+ case LTPTYPE_RD_CP_EORP_EOB:
+ if (!m_endOfBlockSent.IsNull ())
+ {
+ m_endOfBlockSent (m_activeSessionId);
+ }
case LTPTYPE_RD_CP_EORP:
- case LTPTYPE_RD_CP:
- if (!m_checkpointSent.IsNull ()) {
+ case LTPTYPE_RD_CP:
+ if (!m_checkpointSent.IsNull ())
+ {
- info.CpserialNum = contentHeader.GetCpSerialNumber();
- info.RpserialNum = contentHeader.GetRpSerialNumber();
- info.high_bound = contentHeader.GetUpperBound();
- info.low_bound = contentHeader.GetLowerBound();
+ info.CpserialNum = contentHeader.GetCpSerialNumber ();
+ info.RpserialNum = contentHeader.GetRpSerialNumber ();
+ info.high_bound = contentHeader.GetUpperBound ();
+ info.low_bound = contentHeader.GetLowerBound ();
- m_checkpointSent(m_activeSessionId, info); // Link State Cue CP Tx start timer
- }
+ m_checkpointSent (m_activeSessionId, info); // Link State Cue CP Tx start timer
+ }
break;
case LTPTYPE_GD_EOB:
- m_endOfBlockSent(m_activeSessionId);
- break;
- case LTPTYPE_RS:
- if (!m_reportSent.IsNull ()) {
- info.CpserialNum = contentHeader.GetCpSerialNumber();
- info.RpserialNum = contentHeader.GetRpSerialNumber();
- info.high_bound = contentHeader.GetUpperBound();
- info.low_bound = contentHeader.GetLowerBound();
+ m_endOfBlockSent (m_activeSessionId);
+ break;
+ case LTPTYPE_RS:
+ if (!m_reportSent.IsNull ())
+ {
+ info.CpserialNum = contentHeader.GetCpSerialNumber ();
+ info.RpserialNum = contentHeader.GetRpSerialNumber ();
+ info.high_bound = contentHeader.GetUpperBound ();
+ info.low_bound = contentHeader.GetLowerBound ();
- m_reportSent(m_activeSessionId,info); // Link State Cue RS Tx start timer
- }
+ m_reportSent (m_activeSessionId,info); // Link State Cue RS Tx start timer
+ }
break;
case LTPTYPE_CS:
- if (!m_cancelSent.IsNull ())
- m_cancelSent(); // Link State Cue CX Tx start timers
+ if (!m_cancelSent.IsNull ())
+ {
+ m_cancelSent (m_activeSessionId); // Link State Cue CX Tx start timers
+ }
break;
default:
break;
- }
-
+ }
+
return bytes;
}
@@ -197,23 +204,23 @@
while ((packet = socket->RecvFrom (peer)))
{
- TimeValue time;
- m_ltp->GetAttribute("OneWayLightTime", time);
- Simulator::Schedule (time.Get(), &LtpProtocol::Receive, m_ltp, packet, this);
- //m_ltp->Receive (packet, this);
+ TimeValue time;
+ m_ltp->GetAttribute ("OneWayLightTime", time);
+ Simulator::Schedule (time.Get (), &LtpProtocol::Receive, m_ltp, packet, this);
+
}
}
uint16_t LtpUdpConvergenceLayerAdapter::GetMtu () const
{
-
+ NS_LOG_FUNCTION (this);
+
Address addr = m_ltpRouting->GetRoute (m_peerLtpEngineId);
Ptr<Socket> socket = Socket::CreateSocket (m_ltp->GetNode (), UdpSocketFactory::GetTypeId ());
socket->Bind ();
socket->Connect (addr);
-
Ipv4Header iph;
UdpHeader udph;
--- a/src/ltp-protocol/model/ltp-udp-convergence-layer-adapter.h Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/model/ltp-udp-convergence-layer-adapter.h Mon Aug 11 01:28:34 2014 +0200
@@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors: Tom Henderson (tomhend@u.washington.edu)
- * Rubén Martínez <rmartinez@deic.uab.cat>
+ * Rubén Martínez <rmartinez@deic.uab.cat>
*/
@@ -86,21 +86,18 @@
/* public API related to the interface with LTP */
+ /*
+ * Send packet using the underlying layer.
+ * \param p packet to send.
+ * \return 0 if operation failed, size of sent data otherwise.
+ */
virtual uint32_t Send (Ptr<Packet> p);
- /* similar to receive sockets */
- // void SetRecvCallback (Callback<void>, Ptr<LtpUdpConvergenceLayerAdapter> );
-
- /* returns 0 if there are no available datagrams to deliver */
- // Ptr<Packet> Recv (void);
-
+ /* \brief Receive a data packet from the lower layer.
+ * \return 0 if there are no available datagrams to deliver
+ */
void DataRecv (Ptr<Socket> socket);
-
- /* TBD: something to implement cues and link-state notifications */
- /* these can probably be deferred until later */
-
-
/* public API to get the MTU */
/**
@@ -110,7 +107,7 @@
* connected UDP socket to the destination IP address and
* checking it for its MTU.
*
- * \return 0 if operation failed (e.g. binding is not there); otherwise, return the MTU in bytes. *
+ * \return 0 if operation failed (e.g. binding is not there); otherwise, return the MTU in bytes. *
*/
virtual uint16_t GetMtu () const;
@@ -132,7 +129,7 @@
/**
* Get LTP protocol associated to this CLA
*
- * \return prot pointer to LtpProtocol instance
+ * \return pointer to LtpProtocol instance
*/
virtual Ptr<LtpProtocol> GetProtocol () const;
@@ -140,7 +137,7 @@
* Assign Routing protocol for resolution of LTP engine IDs
* to IP addresses.
*
- * \param prot pointer to routing protocol instance.
+ * \param pointer to routing protocol instance.
*/
virtual void SetRoutingProtocol (Ptr<LtpIpResolutionTable> prot);
@@ -150,20 +147,21 @@
virtual Ptr<LtpIpResolutionTable> GetRoutingProtocol () const;
private:
+
/* Attribute values */
- uint16_t m_serverPort; //!< Port to listen for incoming connections
+ uint16_t m_serverPort; //!< Port to listen for incoming connections
uint16_t m_keepAliveValue; //!< Keep Alive
/* Sockets */
- Ptr<Socket> m_rcvSocket; //!< Receiving socket
- Ptr<Socket> m_rcvSocket6; //!< Receiving socket for Ipv6
+ Ptr<Socket> m_rcvSocket; //!< Receiving socket
+ Ptr<Socket> m_rcvSocket6; //!< Receiving socket for Ipv6
std::map<uint64_t, Ptr<Socket> > m_l4SendSockets; //!< Socket for sending data to remote LTP egnines.
/* Pointers */
- Ptr<LtpProtocol> m_ltp; //!< LTP protocol
+ Ptr<LtpProtocol> m_ltp; //!< LTP protocol
Ptr<LtpIpResolutionTable> m_ltpRouting; //!< LTP routing protocol
};
--- a/src/ltp-protocol/test/ltp-protocol-channel-loss-test-suite.cc Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/test/ltp-protocol-channel-loss-test-suite.cc Mon Aug 11 01:28:34 2014 +0200
@@ -1,14 +1,22 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * ltp-protocol-channel-losses-test-suite.cc
+ * Copyright (c) 2014 Universitat Autònoma de Barcelona
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
*
- * Created on: Aug 5, 2014
- * Author: administrador
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Rubén Martínez <rmartinez@deic.uab.cat>
*/
-
-
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-
-// Include a header file from your module to test.
#include "ns3/ltp-header.h"
#include "ns3/sdnv.h"
#include "ns3/log.h"
@@ -23,19 +31,17 @@
#include "ns3/pointer.h"
#include "ns3/ltp-protocol.h"
#include "ns3/ltp-protocol-helper.h"
-
-// An essential include is test.h
#include "ns3/test.h"
-
-// Do not put your test classes in namespace ns3. You may find it useful
-// to use the using directive to access the ns3 namespace directly
using namespace ns3;
using namespace ltp;
NS_LOG_COMPONENT_DEFINE ("LtpProtocolRetransTestCase");
-// This is an example TestCase.
+/*
+ * This test checks the reliability of the LTP protocol
+ * under channels with varying degree of packet losses.
+ */
class LtpProtocolRetransTestCase : public TestCase
{
public:
@@ -59,16 +65,19 @@
uint32_t offset );
private:
+
virtual void DoRun (void);
- uint32_t m_sentData;
- uint32_t m_rcvData;
- uint32_t m_expectedData;
- uint32_t m_redPartSz;
- std::list<uint32_t> m_lossesReceiver;
- std::list<uint32_t> m_lossesSender;
+
+ uint32_t m_sentData; // Size in bytes of sent data.
+ uint32_t m_rcvData; // Size in bytes of sent data.
+ uint32_t m_expectedData; // Size in bytes of the data which is expected to be received
+ uint32_t m_redPartSz; // Block suffix that corresponds to red data.
+
+ std::list<uint32_t> m_lossesReceiver; // List of packets that will be lost upon reception at the receiver
+ std::list<uint32_t> m_lossesSender; // List of packets that will be lost upon reception at the sender
};
-// Add some help text to this case to describe what it is intended to test
+
LtpProtocolRetransTestCase::LtpProtocolRetransTestCase ()
: TestCase ("LtpHeaderTestCase test case (checks serialization and deserialization methods)"),
m_sentData (0),
@@ -80,7 +89,6 @@
{
}
-// Add some help text to this case to describe what it is intended to test
LtpProtocolRetransTestCase::LtpProtocolRetransTestCase (uint32_t sentData, uint32_t expectedData, uint32_t redPartSz, std::list<uint32_t> listReceiver, std::list<uint32_t> listSender )
: TestCase ("LtpHeaderTestCase test case (checks serialization and deserialization methods)"),
m_sentData (sentData),
@@ -93,8 +101,6 @@
}
-// This destructor does nothing but we include it as a reminder that
-// the test case should clean up after itself
LtpProtocolRetransTestCase::~LtpProtocolRetransTestCase ()
{
}
@@ -110,6 +116,11 @@
{
}
+/* This method receives LTP protocol instance notifications.
+ * It keeps track of the received amount of data across each call.
+ * Finally, upon reception of the SESSION END notice, it checks
+ * whether the received data size is equal to the expected data size.
+ * */
void
LtpProtocolRetransTestCase::ClientServiceInstanceNotificationsRcv (SessionId id,
StatusNotificationCode code,
@@ -130,9 +141,18 @@
}
//
-// This method is the pure virtual method from class TestCase that every
-// TestCase must implement
+// This method sets up two nodes with the following network topology
//
+// n0 n1
+// | |
+// =================
+// PointToPoint
+//
+// The nodes use the LTP protocol to transmit a block of data from n0 to n1
+// it defines a ReceiveListErrorModel that causes several transmission losses.
+// The size of the block and the number of lost segments are provided in the
+// parametized constructor of the class.
+
void
LtpProtocolRetransTestCase::DoRun (void)
{
@@ -177,7 +197,7 @@
ltpHelper.SetAttributes ("CheckPointRtxLimit", UintegerValue (20),
"ReportSegmentRtxLimit", UintegerValue (20),
"RetransCyclelimit", UintegerValue (20));
- ltpHelper.SetRoutingProtocol (routing);
+ ltpHelper.SetLtpIpResolutionTable (routing);
ltpHelper.SetBaseLtpEngineId (0);
ltpHelper.SetStartTransmissionTime (Seconds (1));
ltpHelper.InstallAndLink (nodes);
@@ -193,7 +213,6 @@
std::vector<uint8_t> data ( m_sentData, 65);
// Transmit if from n0 to n1.
- std::cout << "RedPartSize" << m_redPartSz << std::endl;
uint64_t receiverLtpId = nodes.Get (1)->GetObject<LtpProtocol> ()->GetLocalEngineId ();
nodes.Get (0)->GetObject<LtpProtocol> ()->StartTransmission (ClientServiceId,ClientServiceId,receiverLtpId,data,m_redPartSz);
@@ -201,10 +220,6 @@
Simulator::Destroy ();
}
-// The TestSuite class names the TestSuite, identifies what type of TestSuite,
-// and enables the TestCases to be run. Typically, only the constructor for
-// this class must be defined
-//
class LtpProtocolChannelLossTestSuite : public TestSuite
{
public:
@@ -217,14 +232,14 @@
LogComponentEnable ("LtpProtocol", LOG_LEVEL_ALL);
/* Block of 5000 bytes of data, mtu 1500
* split in 5 data segments:
- * - 1 Red Segment (Id : 0) -- Receiver
+ * - 1 Red Segment (Id : 0) -- Receiver
* - 1 Red Segment + EORP + CP (Id: 1) -- Receiver
* - 2 Green Segments (Id: 2-3) -- Receiver
- * - 1 Green Segment + EOB (Id: 4) -- Receiver
+ * - 1 Green Segment + EOB (Id: 4) -- Receiver
*
* Additionally the transmission generates 2 additional control segments:
*
- * - 1 Report Segment. (Id: 0) -- Sender
+ * - 1 Report Segment. (Id: 0) -- Sender
* - 1 Report ACK Segment. (Id: 5) -- Receiver
*
* */
--- a/src/ltp-protocol/test/ltp-protocol-test-suite.cc Sun Aug 10 18:01:59 2014 +0200
+++ b/src/ltp-protocol/test/ltp-protocol-test-suite.cc Mon Aug 11 01:28:34 2014 +0200
@@ -651,11 +651,11 @@
m_testTimers.Add (test);
}
-class LtpProtocolTestCase : public TestCase
+class LtpProtocolAPITestCase : public TestCase
{
public:
- LtpProtocolTestCase ();
- virtual ~LtpProtocolTestCase ();
+ LtpProtocolAPITestCase ();
+ virtual ~LtpProtocolAPITestCase ();
void ClientServiceIntanceNotifications (SessionId id,
StatusNotificationCode code,
@@ -670,18 +670,16 @@
};
-
-
-LtpProtocolTestCase::LtpProtocolTestCase ()
- : TestCase ("LtpProtocolTestCase test case (check protocol core)")
+LtpProtocolAPITestCase::LtpProtocolAPITestCase ()
+ : TestCase ("LtpProtocolAPITestCase test case (check protocol core)")
{
}
-LtpProtocolTestCase::~LtpProtocolTestCase ()
+LtpProtocolAPITestCase::~LtpProtocolAPITestCase ()
{
}
void
-LtpProtocolTestCase::ClientServiceIntanceNotifications (SessionId id,
+LtpProtocolAPITestCase::ClientServiceIntanceNotifications (SessionId id,
StatusNotificationCode code,
std::vector<uint8_t> data,
uint32_t dataLength,
@@ -695,14 +693,14 @@
void
-LtpProtocolTestCase::DoRun (void)
+LtpProtocolAPITestCase::DoRun (void)
{
Ptr<LtpProtocol> prot = CreateObject<LtpProtocol> ();
prot->SetAttribute ("RandomVariable", StringValue ("ns3::UniformRandomVariable"));
/* Test 1: Register Client Service*/
uint64_t id = 304;
- CallbackBase cb = MakeCallback (&LtpProtocolTestCase::ClientServiceIntanceNotifications, this);
+ CallbackBase cb = MakeCallback (&LtpProtocolAPITestCase::ClientServiceIntanceNotifications, this);
bool test = prot->RegisterClientService (id, cb);
NS_TEST_ASSERT_MSG_EQ (test,true,"New Client Service registration failed");
@@ -716,8 +714,6 @@
prot->UnregisterClientService (id);
id = 304;
- /* Test 3: Start Transmission : Moved to example */
-
}
@@ -738,7 +734,7 @@
AddTestCase (new LtpHeaderTestCase, TestCase::QUICK);
AddTestCase (new LtpQueueSetTestCase, TestCase::QUICK);
AddTestCase (new LtpSessionStateRecordTestCase, TestCase::QUICK);
- AddTestCase (new LtpProtocolTestCase, TestCase::QUICK);
+ AddTestCase (new LtpProtocolAPITestCase, TestCase::QUICK);
}
// Do not forget to allocate an instance of this TestSuite