[Sumover-dev] [svn commit] r4803 - vic/branches/cc/cc

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Sat May 8 14:40:44 BST 2010


Author: soohyunc
Date: Sat May  8 14:40:44 2010
New Revision: 4803

Modified:
   vic/branches/cc/cc/tfrc_rcvr.cpp
   vic/branches/cc/cc/tfrc_rcvr.h
   vic/branches/cc/cc/tfrc_sndr.cpp
   vic/branches/cc/cc/tfrc_sndr.h

Log:
basic TFRC send/recv methods are added 
	- almost identical to TFWC up to this point.



Modified: vic/branches/cc/cc/tfrc_rcvr.cpp
==============================================================================
--- vic/branches/cc/cc/tfrc_rcvr.cpp	(original)
+++ vic/branches/cc/cc/tfrc_rcvr.cpp	Sat May  8 14:40:44 2010
@@ -45,5 +45,136 @@
 // TfrcRcvr instance
 TfrcRcvr TfrcRcvr::instance_;
 
-TfrcRcvr::TfrcRcvr() {
+TfrcRcvr::TfrcRcvr() :
+	ackofack_(0),
+	begins_(1),
+	ends_(1),
+	numElm_(1),
+	numVec_(1)
+{
+	// tfrcAV (bit vector)
+	tfrcAV = (u_int16_t *) malloc(sizeof(u_int16_t *));
+	clear_avec(numVec_);
 }
+
+// retrive ackofack from RTCP control channel
+void TfrcRcvr::recv_aoa(u_int16_t type, u_int16_t *chunk)
+{
+  int num_chunks = 1;
+
+  switch (type) {
+  case XR_BT_1:
+  {
+	  // received ackofack
+	  ackofack_ = ntohs(chunk[num_chunks-1]);
+  }
+	break;
+
+  case XR_BT_3:
+	break;
+
+  default:
+	break;
+  } // end switch (type)
+}
+
+// retrieve data packet sequence number from RTP data channel
+void TfrcRcvr::recv_seqno(u_int16_t seqno)
+{
+    // required number of AckVec elements
+    numElm_ = seqno - ackofack_;
+
+    // required number of AckVec chunks
+    numVec_ = numElm_/BITLEN + (numElm_%BITLEN > 0);
+
+    // reset necessary variables before start
+    reset();
+
+    // reference vector
+    for (int i = 1; i <= numElm_; i++)
+        rvec_.push_back(ackofack_ + i);
+
+    // push back the current seqno
+    // (if this is duplicate seqno, skip adding it)
+    if (find(avec_.begin(), avec_.end(), seqno) == avec_.end())
+        avec_.push_back(seqno);
+    sort(avec_.begin(), avec_.end());
+
+    // then, trim upto ackofack (inclusive)
+    avit_ = find(avec_.begin(), avec_.end(), ackofack_);
+    if (avit_ != avec_.end())
+        avec_.erase(avec_.begin(), ++avit_);
+
+    // now, build tfrcAV chunks
+    tfrc_ackvec();
+
+    // set 'start seqno' that this AckVec reports
+    begins_ = ackofack_ + 1;
+    // set 'end seqno plus one' that this AckVec report
+    ends_ = seqno + 1;
+
+    // print refvec, actual vec, and bitvec
+    //print_vec(rvec_);
+    //print_vec(avec_);
+    //print_tfrcAV();
+
+}
+
+// build tfrcAV chunks
+void TfrcRcvr::tfrc_ackvec() {
+    int cv = 0; // vector counter
+    int cb = 0; // bit counter
+
+    // find reference vector elements from the actual sequence vector
+    for (rvit_ = rvec_.begin(); rvit_ != rvec_.end(); rvit_++) {
+        // find rvec_ elements in avec_
+        avit_ = find(avec_.begin(), avec_.end(), *rvit_);
+
+        // found
+        if (avit_ != avec_.end()) {
+            if (cb < BITLEN) {
+                tfrcAV[cv] = (tfrcAV[cv] << 1) | 1;
+                cb++;
+            }
+            if (cb == BITLEN) {
+                cb = 0;
+                cv++;
+            }
+        }
+        // not found
+        else {
+            if (cb < BITLEN) {
+                tfrcAV[cv] = (tfrcAV[cv] << 1) | 0;
+                cb++;
+            }
+            if (cb == BITLEN) {
+                cb = 0;
+                cv++;
+            }
+        }
+    } // end for(;;)
+}
+
+// print vector elements
+void TfrcRcvr::print_vec(std::vector<int> v) {
+    std::vector<int>::iterator iter;
+    fprintf(stderr, "\t>> vec: ");
+    for (iter = v.begin(); iter != v.end(); iter++)
+        fprintf(stderr, "%d ", *iter);
+    fprintf(stderr, "\n");
+}
+
+// print bit vectors (in decimal format)
+void TfrcRcvr::print_tfrcAV() {
+    fprintf(stderr, "\t>> tfrcAV: ");
+    for (int i = 0; i < numVec_; i++)
+        fprintf(stderr, "[%d:%d] ", i, tfrcAV[i]);
+    fprintf(stderr, "\n");
+}
+
+// reset
+void TfrcRcvr::reset() {
+    rvec_.clear();
+    clear_avec(numVec_);
+}
+

Modified: vic/branches/cc/cc/tfrc_rcvr.h
==============================================================================
--- vic/branches/cc/cc/tfrc_rcvr.h	(original)
+++ vic/branches/cc/cc/tfrc_rcvr.h	Sat May  8 14:40:44 2010
@@ -42,6 +42,9 @@
 public:
 	TfrcRcvr();
 
+	void recv_aoa(u_int16_t type, u_int16_t *chunk);
+	void recv_seqno(u_int16_t seqno);
+
 	// TfrcRcvr instance
 	static inline TfrcRcvr& instance() { return instance_; }
 
@@ -49,8 +52,48 @@
 
 	static TfrcRcvr instance_;
 
-private:
+	/*
+	 * Variables
+	 */
+	u_int16_t *tfrcAV;		// AckVec array (bit vector array)
+	u_int16_t ackofack_;	// ackofack
+	u_int16_t begins_;		// begin seqno that XR chunk is reporting
+	u_int16_t ends_;		// end seqno + 1 that XR chunk is reporting
+	int numElm_;			// number of tfrcAV elements
+	int numVec_;			// number of tfrcAV chunks
 
+private:
+	// TFRC sender's AckVec Routine
+	void tfrc_ackvec();
+	void reset();
+
+	// calculate the number of AckVec chunks
+	// (based on the number of given elements, i.e, numelm)
+	inline int getNumVec (int numelm) {
+		int num = numelm/BITLEN + 1;
+		if (numelm%BITLEN == 0) num--;
+		return num;
+	}
+
+	// returning AckOfAck
+	inline u_int16_t ackofack() { return ackofack_; }
+
+	// clear tfrcAV
+	inline void clear_avec(int num) {
+		for (int i = 0; i < num; i++)
+		tfrcAV[i] = 0;
+	}
+
+	// print built AckVec
+	void print_tfrcAV();
+	void print_vec(std::vector<int> v);
+
+	// actual AckVec and its iterator
+	std::vector<int> avec_;
+	std::vector<int>::iterator avit_;
+	// reference vector and its iterator
+	std::vector<int> rvec_;
+	std::vector<int>::iterator rvit_;
 };
 
 #endif

Modified: vic/branches/cc/cc/tfrc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfrc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfrc_sndr.cpp	Sat May  8 14:40:44 2010
@@ -143,6 +143,8 @@
 	nakp_++;
 	// so_timestamp
 	so_recv_ = so_rtime;
+	// revert to the previous history?
+	bool revert = false;
 
 	// get start/end seqno that this XR chunk reports
 	begins_ = begin;	// lowest packet seqno
@@ -165,9 +167,11 @@
 	clear_ackv(num_vec_);
 	// clone AckVec from Vic
 	clone_ackv(chunk, num_vec_);
+	print_vec("ackvec", ackv_, num_vec_);
 
 	// generate seqno vector
 	gen_seqvec(ackv_, num_vec_);
+
 	// generate reference vector
 	// (it represents seqvec when no losses)
 	// @begin: aoa_+1 (lowest seqno)
@@ -184,6 +188,9 @@
 	tao_ = so_recv_ - tsvec_[jacked_%TSZ];
 	// update RTT with the sampled RTT
 	update_rtt(tao_);
+
+	// reset variables for the next pkt reception
+	reset_var(revert);
   }
   break;
 
@@ -250,6 +257,18 @@
 	} fprintf(stderr, " )\n");
 }
 
+void TfrcSndr::reset_var(bool reverted) {
+	// init vars------------*
+	num_missing_ = 0;
+	//----------------------*
+
+	if(!reverted) {
+	}
+
+	// finally, free ackvec
+	free(ackv_);
+}
+
 /*
  * calculate sending rate
  */

Modified: vic/branches/cc/cc/tfrc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfrc_sndr.h	(original)
+++ vic/branches/cc/cc/tfrc_sndr.h	Sat May  8 14:40:44 2010
@@ -76,6 +76,8 @@
 	void gen_seqvec(u_int16_t *v, int n);
 	// generate reference seqno
 	void gen_refvec(int end, int begin);
+	// reset variables
+	void reset_var(bool reverted);
 
 	u_int16_t *ackv_;	// received AckVec
 	u_int16_t aoa_;	// ack of ack
@@ -156,6 +158,25 @@
 	u_int16_t ends_;	// end seqno + 1 that this XR chunk reports
 	int num_elm_;		// number of ackvec elements
 	int num_vec_;		// number of ackvec chunks
+
+	// print vec
+	inline void print_vec(const char* str, u_int32_t *vec, int c) {
+	fprintf(stderr, "\t%s: (", str);
+		for (int i = 0; i < c; i++)
+		fprintf(stderr, " %d", vec[i]);
+	fprintf(stderr, " )\n");
+	}
+	inline void print_vec(const char* str, u_int16_t *vec, int c) {
+	fprintf(stderr, "\t%s: (", str);
+		for (int i = 0; i < c; i++)
+		fprintf(stderr, " %d", vec[i]);
+	fprintf(stderr, " )\n");
+	}
+
+	// print the actual packet size and EWMA estimated one
+	inline void print_psize(double now, int size, int len) {
+	fprintf(stderr, "\tnow: %f psize: %d actual: %d\n", now, size, len);
+	}
 };
 
 #endif



More information about the Sumover-dev mailing list