Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1247)

Unified Diff: src/internet/model/mptcp-scheduler-fastest-rtt.cc

Issue 369810043: ns-3 mptcp
Patch Set: Removed debug/redundant code and update coding style Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/internet/model/mptcp-scheduler-fastest-rtt.h ('k') | src/internet/model/mptcp-scheduler-round-robin.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/internet/model/mptcp-scheduler-fastest-rtt.cc
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/internet/model/mptcp-scheduler-fastest-rtt.cc
@@ -0,0 +1,143 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2015 University of Sussex
+ * Copyright (c) 2015 Université Pierre et Marie Curie (UPMC)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Kashif Nadeem <kshfnadeem@gmail.com>
+ * Matthieu Coudron <matthieu.coudron@lip6.fr>
+ * Morteza Kheirkhah <m.kheirkhah@sussex.ac.uk>
+ */
+#include "ns3/mptcp-scheduler-fastest-rtt.h"
+#include "ns3/mptcp-subflow.h"
+#include "ns3/mptcp-socket-base.h"
+#include "ns3/log.h"
+
+NS_LOG_COMPONENT_DEFINE ("MpTcpSchedulerFastestRTT");
+
+namespace ns3 {
+
+static inline
+SequenceNumber64 SEQ32TO64 (SequenceNumber32 seq)
+{
+ return SequenceNumber64 (seq.GetValue());
+}
+
+TypeId
+MpTcpSchedulerFastestRTT::GetTypeId (void)
+{
+ static TypeId tid = TypeId ("ns3::MpTcpSchedulerFastestRTT")
+ .SetParent<MpTcpScheduler> ()
+ .AddConstructor<MpTcpSchedulerFastestRTT> ()
+ ;
+
+ return tid;
+}
+
+MpTcpSchedulerFastestRTT::MpTcpSchedulerFastestRTT ()
+ : MpTcpScheduler (),
+ m_metaSock (0)
+{
+ NS_LOG_FUNCTION (this);
+}
+
+MpTcpSchedulerFastestRTT::~MpTcpSchedulerFastestRTT (void)
+{
+ NS_LOG_FUNCTION (this);
+}
+
+void
+MpTcpSchedulerFastestRTT::SetMeta (Ptr<MpTcpSocketBase> metaSock)
+{
+ NS_ASSERT (metaSock);
+ NS_ASSERT_MSG (m_metaSock == 0, "SetMeta already called");
+ m_metaSock = metaSock;
+}
+
+int
+MpTcpSchedulerFastestRTT::FindFastestSubflowWithFreeWindow () const
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ int id = -1;
+
+ Time lowestEstimate = Time::Max ();
+ for (int i = 0; i < (int) m_metaSock->GetNActiveSubflows () ; i++)
+ {
+ Ptr<MpTcpSubflow> sf = m_metaSock->GetSubflow (i);
+ if (sf->AvailableWindow() <= 0)
+ {
+ continue;
+ }
+ if (sf->m_rtt->GetEstimate () < lowestEstimate)
+ {
+ lowestEstimate = sf->m_rtt->GetEstimate ();
+ id = i;
+ }
+ }
+ return id;
+}
+
+Ptr<MpTcpSubflow>
+MpTcpSchedulerFastestRTT::GetSubflowToUseForEmptyPacket ()
+{
+ NS_ASSERT (m_metaSock->GetNActiveSubflows() > 0 );
+ return m_metaSock->GetSubflow (0);
+}
+
+bool
+MpTcpSchedulerFastestRTT::GenerateMapping (int& activeSubflowArrayId, SequenceNumber64& dsn, uint16_t& length)
+{
+ NS_LOG_FUNCTION (this);
+ NS_ASSERT (m_metaSock);
+
+ uint32_t amountOfDataToSend = 0;
+ //! Tx data not sent to subflows yet
+ SequenceNumber32 metaNextTxSeq = m_metaSock->Getvalue_nextTxSeq ();
+ amountOfDataToSend = m_metaSock->m_txBuffer->SizeFromSequence (metaNextTxSeq);
+ uint32_t metaWindow = m_metaSock->AvailableWindow ();
+ if (amountOfDataToSend <= 0)
+ {
+ NS_LOG_DEBUG ("Nothing to send from meta");
+ return false;
+ }
+ if (metaWindow <= 0)
+ {
+ return false;
+ }
+
+ int id = FindFastestSubflowWithFreeWindow ();
+ if (id < 0)
+ {
+ NS_LOG_DEBUG ("No valid subflow");
+ return false;
+ }
+ Ptr<MpTcpSubflow> subflow = m_metaSock->GetSubflow (id);
+ uint32_t subflowWindow = subflow->AvailableWindow ();
+ uint32_t canSend = std::min (subflowWindow, metaWindow);
+
+ //! Can't send more than SegSize
+ //metaWindow en fait on s'en fout du SegSize ?
+ if (canSend > 0)
+ {
+ dsn = SEQ32TO64 (metaNextTxSeq);
+ canSend = std::min (canSend, amountOfDataToSend);
+ // For now we limit ourselves to a per packet basis
+ length = std::min (canSend, subflow->GetSegSize ());
+ return true;
+ }
+ return false;
+}
+
+} // namespace ns3
« no previous file with comments | « src/internet/model/mptcp-scheduler-fastest-rtt.h ('k') | src/internet/model/mptcp-scheduler-round-robin.h » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b