Checkpoint
diff --git a/ccnx/ccnx-name.h b/ccnx/ccnx-name.h
index a6b6228..ec55397 100644
--- a/ccnx/ccnx-name.h
+++ b/ccnx/ccnx-name.h
@@ -51,7 +51,7 @@
size_t
length () const
{ return m_buf->length; }
-
+
private:
void init(ccn_charbuf *buf);
@@ -89,7 +89,7 @@
appendComp(const Name &name);
Name &
- appendComp(const void *buf, size_t size);
+ appendComp(const void *buf, size_t size);
/**
* Append int component
@@ -100,7 +100,11 @@
*/
Name &
appendComp(uint64_t number);
-
+
+ template<class T>
+ Name &
+ operator ()(const T &comp) { return appendComp (comp); }
+
int
size() const {return m_comps.size();}
diff --git a/src/fetcher.cc b/src/fetcher.cc
index 6745518..6afad5b 100644
--- a/src/fetcher.cc
+++ b/src/fetcher.cc
@@ -28,6 +28,7 @@
using namespace boost;
using namespace std;
+using namespace Ccnx;
Fetcher::Fetcher (FetchManager &fetchManger,
const Ccnx::Name &name, int32_t minSeqNo, int32_t maxSeqNo,
@@ -37,11 +38,12 @@
, m_name (name)
, m_forwardingHint (forwardingHint)
, m_minSendSeqNo (-1)
- , m_maxSendSeqNo (-1)
+ , m_maxInOrderRecvSeqNo (-1)
, m_minSeqNo (minSeqNo)
, m_maxSeqNo (maxSeqNo)
, m_pipeline (6) // initial "congestion window"
+ , m_activePipeline (0)
{
}
@@ -53,11 +55,47 @@
Fetcher::RestartPipeline ()
{
m_active = true;
+ m_minSendSeqNo = m_maxInOrderRecvSeqNo;
+
+ FillPipeline ();
+}
+
+void
+Fetcher::FillPipeline ()
+{
+ for (; m_minSendSeqNo < m_maxSeqNo && m_activePipeline < m_pipeline; m_minSendSeqNo++)
+ {
+ m_fetchManager.GetCcnx ()
+ ->sendInterest (Name (m_name)("file")(m_minSendSeqNo+1),
+ Closure (bind(&Fetcher::OnData, this, m_minSendSeqNo+1, _1, _2),
+ bind(&Fetcher::OnTimeout, this, m_minSendSeqNo+1, _1)));
+
+ m_activePipeline ++;
+ }
}
void
Fetcher::OnData (uint32_t seqno, const Ccnx::Name &name, const Ccnx::Bytes &)
{
+ m_activePipeline --;
+
+ ////////////////////////////////////////////////////////////////////////////
+ m_outOfOrderRecvSeqNo.insert (seqno);
+ set<int32_t>::iterator inOrderSeqNo = m_outOfOrderRecvSeqNo.begin ();
+ for (; inOrderSeqNo != m_outOfOrderRecvSeqNo.end ();
+ inOrderSeqNo++)
+ {
+ if (*inOrderSeqNo == m_maxInOrderRecvSeqNo+1)
+ {
+ m_maxInOrderRecvSeqNo = *inOrderSeqNo;
+ }
+ else
+ break;
+ }
+ m_outOfOrderRecvSeqNo.erase (m_outOfOrderRecvSeqNo.begin (), inOrderSeqNo);
+ ////////////////////////////////////////////////////////////////////////////
+
+ FillPipeline ();
// bla bla
if (0)
{
@@ -66,7 +104,9 @@
}
}
-void
+Closure::TimeoutCallbackReturnValue
Fetcher::OnTimeout (uint32_t seqno, const Ccnx::Name &name)
{
+ // Closure::RESULT_REEXPRESS
+ return Closure::RESULT_OK;
}
diff --git a/src/fetcher.h b/src/fetcher.h
index c6bc883..c41c23c 100644
--- a/src/fetcher.h
+++ b/src/fetcher.h
@@ -43,9 +43,12 @@
RestartPipeline ();
void
- OnData (uint32_t seqno, const Ccnx::Name &name, const Ccnx::Bytes &);
+ FillPipeline ();
void
+ OnData (uint32_t seqno, const Ccnx::Name &name, const Ccnx::Bytes &);
+
+ Ccnx::Closure::TimeoutCallbackReturnValue
OnTimeout (uint32_t seqno, const Ccnx::Name &name);
private:
@@ -56,14 +59,14 @@
Ccnx::Name m_forwardingHint;
int32_t m_minSendSeqNo;
- int32_t m_maxSendSeqNo;
+ int32_t m_maxInOrderRecvSeqNo;
+ std::set<int32_t> m_outOfOrderRecvSeqNo;
+
int32_t m_minSeqNo;
int32_t m_maxSeqNo;
uint32_t m_pipeline;
-
- // Ccnx::Closure m_onDataClosure;
- // Ccnx::Closure m_onTimeoutClosure;
+ uint32_t m_activePipeline;
boost::intrusive::list_member_hook<> m_managerListHook;
friend class FetchManager;