[Sumover-dev] [svn commit] r4267 - in vic/branches/cc: rtp

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Wed Aug 13 18:59:47 BST 2008


Author: soohyunc
Date: Wed Aug 13 18:59:46 2008
New Revision: 4267

Modified:
   vic/branches/cc/cc/tfwc_sndr.cpp
   vic/branches/cc/cc/tfwc_sndr.h
   vic/branches/cc/rtp/session.cpp

Log:
o  the data sender has to specify if it received ackvec or ts echo from the data
   receiver (this is represented in this modification at rtp/session.cpp)

(on-going)
o  TfwcSndr's main reception path
   (1) what's done
       --  parse ackvec
       --  parse ts echo
       --  calculate margin vector
       --  calculate ackofack
       --  calculate sampled RTT
   (2) what's yet to be
       --  loss detection mechanism using the received ackvec
       --  calculate smoothed RTT, avg loss interval
       --  calculate congestion window 



Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp	Wed Aug 13 18:59:46 2008
@@ -44,47 +44,67 @@
 #include "transmitter.h"
 #include "tfwc_sndr.h"
 
-#define DUPACKS	3	// simulating TCP's 3 dupacks
-
 TfwcSndr::TfwcSndr() :
 	seqno_(0),
+	cwnd_(1),
 	aoa_(0),
+	now_(0),
 	ts_(0),
 	ts_echo_(0),
-	npkt_(0)
+	last_ack_(0),
+	ndtp_(0),
+	nakp_(0),
+	ntep_(0),
+	epoch_(1)
 {
 	// for simulating TCP's 3 dupack rule
 	u_int32_t mvec_ = 0x07;
+	UNUSED(mvec_);	// to shut up gcc-4.x
 }
 
 void TfwcSndr::tfwc_sndr_send(pktbuf* pb) {
 
 	// get RTP hearder information
 	rtphdr* rh =(rtphdr*) pb->data;
+
+	// get seqno and mark timestamp for this data packet
 	seqno_ = ntohs(rh->rh_seqno);
+	now_ = tfwc_sndr_now();
+
+	// timestamp vector for loss history update
+	tsvec_[seqno_%TSZ] = now_;
 
 	// sequence number must be greater than zero
 	assert (seqno_ > 0);
 	debug_msg("sent seqno:		%d\n", seqno_);
 
-	npkt_++;	// number of packet sent
+	ndtp_++;	// number of data packet sent
 }
 
-void TfwcSndr::tfwc_sndr_recv(u_int32_t ackv, u_int32_t ts_echo)
+void TfwcSndr::tfwc_sndr_recv(u_int16_t type, u_int32_t ackv, u_int32_t ts_echo)
 {
-	// retrieve ackvec and ts echo
-	ackv_ = ackv;
-	ts_echo_ = ts_echo;
-
-	// mask most 3 recent packets
-	if (npkt_ > DUPACKS)
-		ackv_ = ackv | mvec_;
-
-	tao_ = tfwc_sndr_now() - ts_echo_;
-
-	debug_msg(" ts echo:	%d\n", ts_echo_);
-}
-
-void TfwcSndr::ackofack() {
-	aoa_ = mvec_ | 0x01000000;
+	// retrieve ackvec
+	if (type == XR_BT_1) {
+		nakp_++;		// number of ackvec packet received
+		ackv_ = ackv;	// store ackvec
+
+		// store head of ackvec as last ack (real number)
+		last_ack_ = get_head_pos(ackv_) * epoch_;
+
+		// generate margin vector
+		marginvec(ackv_);
+		ackv_ |= mvec_;		// masking ackvec
+
+		// set ackofack (real number)
+		aoa_ = ackofack(mvec_) * epoch_;
+
+	}
+	// retrieve ts echo
+	else if (type == XR_BT_3) {
+		ntep_++;		// number of ts echo packet received
+		ts_echo_ = ts_echo;
+
+		tao_ = now_ - ts_echo_;
+		debug_msg(" ts echo:	%d\n", ts_echo_);
+	}
 }

Modified: vic/branches/cc/cc/tfwc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.h	(original)
+++ vic/branches/cc/cc/tfwc_sndr.h	Wed Aug 13 18:59:46 2008
@@ -36,39 +36,93 @@
 #ifndef vic_tfwc_sndr_h
 #define vic_tfwc_sndr_h
 
-// set AckVec bitmap
+#define DUPACKS 3   // simulating TCP's 3 dupacks
+#define CHB	0x80000000	// ackvec check bit (head search)
+#define CTB	0x01		// ackvec check bit (tail search)
+#define TSZ	1000	// tsvec_ size
+
+// set AckVec bitmap from LSB
 #define SET_BIT_VEC(ackvec_, bit) (ackvec_ = ((ackvec_ << 1) | bit))
 
-// see AckVec bitmap
-#define SEE_BIT_VEC(ackvec_, ix, seqno) ((1 << (seqno - ix)) & ackvec_)
+// AckVec bitmap at i-th location
+#define GET_BIT_VEC(ackvec_, i, seqno) ((1 << (seqno - i)) & ackvec_)
+
+// AckVec head search
+#define GET_HEAD_VEC(ackvec_, i) ( ackvec_ & (CHB >> i) )
+
+// AckVec tail search
+#define GET_TAIL_VEC(ackvec_, i) ( ackvec_ & (CTB << i) )
 
 class TfwcSndr {
 public:
 	TfwcSndr();
 	// parse RTP data packet from Transmitter module
 	void tfwc_sndr_send(pktbuf*);
-	void tfwc_sndr_recv(u_int32_t ackv, u_int32_t ts_echo);
+	void tfwc_sndr_recv(u_int16_t type, u_int32_t ackv, u_int32_t ts_echo);
+
+	// return current data packet's seqno
 	inline u_int16_t tfwc_sndr_get_seqno() { return seqno_; }
+	// return ackofack
 	inline u_int16_t tfwc_sndr_get_aoa() { return aoa_; }
+	// set timestamp (TfwcSndr)
 	inline u_int32_t tfwc_sndr_now() {
 		timeval tv;
 		::gettimeofday(&tv, 0);
-		return ((u_int32_t) tv.tv_sec + tv.tv_usec);
+		return (u_int32_t) (tv.tv_sec + tv.tv_usec);
 	}
-	inline u_int32_t tfwc_sndr_get_ts() { return tfwc_sndr_now(); }
-	void ackofack();	// set ack of ack
+	// return timestamp
+	inline u_int32_t tfwc_sndr_get_ts() { return now_; }
+
+	// variables
 	u_int16_t seqno_;	// packet sequence number
+	u_int32_t cwnd_;	// congestion window
 
 protected:
+	// get the first position in ackvec where 1 is marked (mod 32)
+	inline u_int32_t get_head_pos(u_int32_t ackvec) {
+		int l;
+		for (l = 0; l < 32; l++) {
+			if(GET_HEAD_VEC(ackvec, l))
+				break;
+		}
+		return (32 - l);
+	}
+	// get the last position in ackvec where 1 is marked
+	inline u_int32_t get_tail_pos(u_int32_t ackvec) {
+		int l;
+		for (l = 0; l < 32; l++) {
+			if(GET_TAIL_VEC(ackvec, l))
+				break;
+		}
+		return (l + 1);
+	}
+	// generate margin vector
+	inline void marginvec(u_int32_t ackvec) {
+		int head = get_head_pos(ackvec);
+
+		for (int i = 0; i < DUPACKS; i++)
+			mvec_ |= 1 << ((head-1) - i);
+	}
+	// ackofack
+	inline u_int16_t ackofack (u_int32_t ackvec) {
+		return (get_tail_pos(ackvec) - 1);
+	}
+
 	u_int32_t mvec_;	// margin vec (simulatinmg TCP 3 dupacks)
 	u_int32_t ackv_;	// received AckVec (from TfwcRcvr)
 	u_int32_t pvec_;	// sent packet list
 	u_int16_t aoa_;		// ack of ack
+	u_int32_t now_;		// the time when the data packet sent
 	u_int32_t ts_;		// time stamp
 	u_int32_t ts_echo_;	// echo time stamp from the receiver
+	u_int32_t *tsvec_;	// timestamp vector
 	u_int32_t tao_;		// sampled RTT
 private:
-	int npkt_;		// number of packet sent
+	u_int16_t last_ack_;	// last packet seqno from ackvec
+	int ndtp_;		// number of data packet sent
+	int nakp_;		// number of ackvec packet received
+	int ntep_;		// number of ts echo packet received
+	int epoch_;		// communication epoch
 };
 
 #endif

Modified: vic/branches/cc/rtp/session.cpp
==============================================================================
--- vic/branches/cc/rtp/session.cpp	(original)
+++ vic/branches/cc/rtp/session.cpp	Wed Aug 13 18:59:46 2008
@@ -1187,16 +1187,19 @@
 	// we received ackvec, so do sender stuffs here
 	else {
 		printf("SENDER SENDER!!\n");
-		// parse seqno, ackvec and timestamp echo from XR report block
+		// parse ackvec and timestamp echo from XR report block
 		if(flags == XR_BT_1) {
 			ackvec_ = ntohl((u_int32_t) &xr->chunk);
+
+			//this XR conveys ackvec, hence parse it
+			tfwc_sndr_recv(flags, ackvec_, 0);
 		}
 		else if(flags == XR_BT_3) {
 			ts_echo_ = ntohl((u_int32_t) &xr->chunk);
-		}
 
-		// parse ackvec and timestamp echo to TfwcSndr
-		tfwc_sndr_recv(ackvec_, ts_echo_);
+			// this XR conveys ts echo, hence parse it
+			tfwc_sndr_recv(flags, 0, ts_echo_);
+		}
 	}
 }
 



More information about the Sumover-dev mailing list