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

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Fri Feb 6 20:11:47 GMT 2009


Author: soohyunc
Date: Fri Feb  6 20:11:46 2009
New Revision: 4379

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

Log:
Currerntly, AckVec build routine in TfwcRcvr is severely being re-written. This
commit is still "work-in-progress" stage - i.e., this commit may break Vic.

AckVec is now an integer array, and each array is acting as a bit vector. This
must be done because a single AckVec can only contain upto 16 bitvec elements
(we have declared AckVec as u_int16_t type earlier, which means it can only
carry upto 16 packet's information at a time.) If BDP (bandwidh-delay product) 
allows more than 16 packets "on-the-fly", this can cause problem for Vic system.

To-do (urgent job only listed):
(1) tfwc_rcvr.cpp: fix/finish routine when there are more losses that the current 
	AckVec array cannot hold in TfwcRcvr side.
(2) rtp/session.cpp: fix/finish routine in parse_xr_record() method so that it
	can retrieve and put the correct AckVec content.



Modified: vic/branches/cc/cc/tfwc_rcvr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_rcvr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_rcvr.cpp	Fri Feb  6 20:11:46 2009
@@ -47,17 +47,26 @@
 TfwcRcvr::TfwcRcvr() :
 	currseq_(0),
 	prevseq_(0),
-	ackofack_(0)
+	ackofack_(0),
+	begins_(0),
+	ends_(0),
+	currNumElm_(0),
+	prevNumElm_(0),
+	currNumVec_(0),
+	prevNumVec_(0)
 {
-	tfwcAV = 0;
+	tfwcAV = (u_int16_t *) malloc(sizeof(u_int16_t *));;
 }
 
 void TfwcRcvr::tfwc_rcvr_recv(u_int16_t type, u_int16_t seqno, 
 				u_int16_t ackofack, u_int32_t ts) 
 {
 	// variables
-	int cnt		= 0;
-	int num		= 0;
+	int cnt		= 0;	// number of packet loss count
+	int off		= 0;	// number of zero to be carried on
+	int diffNumElm	= 0;	// difference of AckVec elements (curr vs. prev)
+	int diffNumVec	= 0;	// difference of AckVec array (curr vs. prev)
+	int addiNumVec	= 0;	// additional AckVec array required
 
 	// parse the received seqno and ackofack
 	if (type == XR_BT_1) {
@@ -65,27 +74,55 @@
 		currseq_ = seqno;
 		ackofack_ = ackofack;
 
+		// number of required AckVec element
+		currNumElm_	= currseq_ - ackofack_;
+		diffNumElm	= currNumElm_ - prevNumElm_;
+
+		// number of array required for building tfwcAV
+		currNumVec_	= getNumVec(currNumElm_);
+		diffNumVec	= currNumVec_ - prevNumVec_;
+
 		// there is no packet loss
 		if (currseq_ == prevseq_ + 1) {
 			// set next bit to 1
-			SET_BIT_VEC(tfwcAV, 1);
+			SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
 		} 
-		// we have one or more packet loss
+		// we have one or more packet losses
 		else {
 			// number of packet loss
 			cnt = currseq_ - prevseq_ - 1;
 
-			// set next bit to 0 equal to the number of lost packets
-			for (int i = 0; i < cnt; i++) {
-				SET_BIT_VEC(tfwcAV, 0);
+			// we need more AckVec array (maybe one or more)
+			if (currNumVec_ != prevNumVec_) {
+				// currently available spaces in the previous tfwcAV array
+				int num_avail = 16 - prevNumElm_%16;
+
+				// first, fill up zeros into those available spaces
+				for (int i = 0; i < num_avail; i++) {
+					SET_BIT_VEC(tfwcAV[prevNumVec_-1], 0);
+					cnt--;
+				}
+
+				// then, calculate "additional" AckVec array required
+				addiNumVec = getNumVec(cnt);
+
+				for (int i = 0; i < addiNumVec; i++) {
+					SET_BIT_VEC(tfwcAV[prevNumVec_ + i], 0);
+				}
+			}
+			// current num of AckVeck array can cope with the elements
+			else {
+				// set next bit 0 into AckVec (# of packet loss)
+				for (int i = 0; i < cnt; i++) 
+					SET_BIT_VEC(tfwcAV[currNumVec_-1], 0);
 			}
 
 			// then, set this packet as received (this is important)
-			SET_BIT_VEC(tfwcAV, 1);
+			SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
 		}
 
 		// print ackvec
-		print_ackvec(ackofack_, currseq_, tfwcAV);
+		//print_ackvec(ackofack_, currseq_, tfwcAV);
 
 		// start seqno that this AckVec is reporting
 		if (ackofack_ != 0)
@@ -95,19 +132,14 @@
 
 		// end seqno is current seqno plus one (according to RFC 3611)
 		ends_ = currseq_ + 1;
-		
-		// number of elements in tfwcAV
-		num = ends_ - begins_;
-
-		//if (ackofack_)
-		//	trimvec(tfwcAV, offset);
-
-		// set this seqno to the prevseq before exit
+	
+		// store seqno, num of AckVec elem, and num of AckVec array
 		prevseq_ = currseq_;
+		prevNumElm_ = currNumElm_;
+		prevNumVec_ = currNumVec_;
 	}
-	// parse timestamp
-	else if (type == XR_BT_3) {
-		ts_echo_ = ts;
+	else if (type == XR_BT_2) {
+		UNUSED(ts);	
 	}
 }
 

Modified: vic/branches/cc/cc/tfwc_rcvr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_rcvr.h	(original)
+++ vic/branches/cc/cc/tfwc_rcvr.h	Fri Feb  6 20:11:46 2009
@@ -45,26 +45,39 @@
 			u_int16_t ackofack, u_int32_t ts);
 
 protected:
-	inline u_int16_t tfwc_rcvr_getvec() { return tfwcAV; }
+	// AckVec pointer
+	inline u_int16_t * tfwc_rcvr_getvec_p() { return tfwcAV; }
+	// ts echo
 	inline u_int32_t tfwc_rcvr_ts_echo() { return ts_echo_; }
 
+	// AckVec begin seqno
 	inline u_int16_t tfwc_rcvr_begins() { return begins_; }
+	// AckVec end seqno plus one
 	inline u_int16_t tfwc_rcvr_ends() { return ends_; }
+	// number of AckVec array
+	inline u_int16_t tfwc_rcvr_numvec() { return currNumVec_; }
 
 	/*
 	 * Variables
 	 */
-	u_int16_t tfwcAV;		// AckVec (bit vector)
+	u_int16_t *tfwcAV;		// AckVec array (bit vector array)
 	u_int16_t currseq_;		// current sequence number
 	u_int16_t prevseq_;		// previous sequence number
 	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
+	u_int16_t currNumElm_;	// number of current AckVec elements
+	u_int16_t prevNumElm_;	// number of previous AckVec elements
+	int	currNumVec_;		// numver of current AckVec array
+	int prevNumVec_;		// numver of previous AckVec array
 
 private:
-	// trim ackvec
-	inline void trimvec(u_int16_t vec, int offset) {
-		tfwcAV = vec >> offset;
+	// calculate the numver of AckVec array 
+	// (based on the number of given element, i.e, numelm)
+	inline int getNumVec (int numelm) {
+		int num = numelm/16 + 1;
+		if (numelm%16 == 0) num -= 1;
+		return num;
 	}
 
 	// print built AckVec

Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp	Fri Feb  6 20:11:46 2009
@@ -136,7 +136,7 @@
 
 		// generate seqno vec
 		gen_seqvec(begins_, ends_, jacked_, ackv);
-		//print_seqvec(begins_, ends_);
+		print_seqvec(begins_, ends_);
 
 		// generate margin vector
 		marginvec(jacked_);
@@ -198,12 +198,12 @@
 	bool is_there = false;
 
 	// generate tempvec elements
-	//printf("\tcomparison numbers: (");
+	printf("\tcomparison numbers: (");
 	for (int i = 0; i < numvec; i++) {
 		tempvec[i] = (begin + 1) + i;
-	//	printf(" %d", tempvec[i]);
+		printf(" %d", tempvec[i]);
 	}
-	//printf(" )\n");
+	printf(" )\n");
 
 	// number of seqvec element
 	int numseq = ends_ - begins_;

Modified: vic/branches/cc/rtp/rtp.h
==============================================================================
--- vic/branches/cc/rtp/rtp.h	(original)
+++ vic/branches/cc/rtp/rtp.h	Fri Feb  6 20:11:46 2009
@@ -134,6 +134,14 @@
 /*
  * RTCP Extended Report.
  * (RFC 3611)
+ *
+ *  0                   1                   2                   3
+ *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |      BT       | type-specific |         block length          |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * :             type-specific block contents                      :
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 #define XR_BT_1	0x01	// Loss RLE Report Block
 #define XR_BT_2	0x02	// Duplicate RLE Report Block
@@ -143,12 +151,11 @@
 	// extended report block header
 	u_int16_t xr_flags;	/* BT:8 TS:8 */
 	u_int16_t xr_len;	/* XR report block length (in bytes)*/
-
-	// extended report block contents
-	u_int32_t ssrc;	/* ssrc of the RTP data pkt being reported upon by this */
-	u_int16_t begin_seq; /* first seqno that this block report */
-	u_int16_t end_seq;	/* last seqno that this block report plus 1 */
-	u_int16_t chunk;	/* extended report chunks */
+	// type-specific block contents
+	//u_int32_t ssrc;/* ssrc of the RTP data pkt being reported upon by this */
+	//u_int16_t begin_seq; /* first seqno that this block report */
+	//u_int16_t end_seq;	/* last seqno that this block report plus 1 */
+	//u_int16_t chunk;	/* extended report chunks */
 };
 
 #define RTCP_PT_SR	200	/* sender report */
@@ -190,8 +197,8 @@
 /*
  * Motion JPEG encapsulation.
  *
- * 0                   1                   2                   3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *  0                   1                   2                   3
+ *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  * |      MBZ      |                frag offset                    |
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Modified: vic/branches/cc/rtp/session.cpp
==============================================================================
--- vic/branches/cc/rtp/session.cpp	(original)
+++ vic/branches/cc/rtp/session.cpp	Fri Feb  6 20:11:46 2009
@@ -652,58 +652,89 @@
 	// declare XR packet
 	rtcp_xr* xr = (rtcp_xr*)(rh + 1);
 
-	// ssrc of XR source (currently unused)
-	int xrssrc = 0;	
-	xr->ssrc = htonl(xrssrc);	// UNUSED
+	// number of XR block contents (initialization)
+	int num_ssrc;	// number of ssrc entry
+	int num_begins;	// number of begin_seq entry
+	int num_ends;	// number of end_seq entry
+	int num_chunks;	// number of block chunks
+
+	// declare XR report block 
+	// (type specific report block)
+	u_char *rb = (u_char *) malloc(sizeof(u_char *));
+
+	int xrssrc;	// it is currently unused
 
 	// i am an RTP data sender, so i convey a packet seqno and ackofack
 	if (am_i_sender()) {
 		// this block is used for giving seqno and ackofack
 		if(bt == XR_BT_1) {
+			// number of block entries
+			num_ssrc = 1;
+			num_begins = 1;
+			num_ends = 1;
+			num_chunks = 1;
+
 			// set XR block flags (block type and length)
 			xr->xr_flags = htons(XR_BT_1 << 8);
 
+			// allocate report block in memory
+			rb = (u_char *) malloc(sizeof(xr) + num_ssrc 
+					+ num_begins + num_ends + num_chunks);
+
+			// set report block entry pointer
+			u_int32_t *ent = (u_int32_t *) (sizeof(xr) + rb);
+
+			// ssrc of XR source (currently unused)
+			xrssrc = 0; ent[0] = xrssrc;
+
 			// get current RTP data packet seqno from TfwcSndr
-			xr->begin_seq = htons(tfwc_sndr_get_seqno());
-			xr->end_seq = htons(tfwc_sndr_get_seqno() + 1);
+			ent[1] = 0;
+			ent[1] |= htons(tfwc_sndr_get_seqno());
+			ent[1] <<= 16;
+			ent[1] |= htons(tfwc_sndr_get_seqno() + 1);
 
 			// set ack of ack
-			xr->chunk = htons(tfwc_sndr_get_aoa());
+			ent[2] = 0;
+			ent[2] |= htons(tfwc_sndr_get_aoa());
+			ent[2] <<= 16;
 
 			//debug_msg("	SeqNo:		%d\n", tfwc_sndr_get_seqno());
 		} 
-		// this block is used for giving timestamp
-		else if(bt == XR_BT_3) {
-			// set XR block flags (block type and length)
-			xr->xr_flags = htons(XR_BT_3 << 8);
-
-			// get timestamp from TfwcSndr
-			xr->chunk = htonl(tfwc_sndr_get_ts());
-
-			//debug_msg("	TS:		%ld\n", tfwc_sndr_get_ts());
-		}
 	} 
 	// i am an RTP data receiver, so i convey ackvec information
 	else {
 		// this block is used for giving ackvec
 		if (bt == XR_BT_1) {
+			// number of block entries
+			num_ssrc = 1;
+			num_begins = 1;
+			num_ends = 1;
+
 			// set XR block type
 			xr->xr_flags = htons(XR_BT_1 << 8);
 
-			// make 'begin_seq' equal to 'end_seq'
-			xr->begin_seq = htons(tfwc_rcvr_begins());
-			xr->end_seq = htons(tfwc_rcvr_ends());
+			// number of AckVec array
+			num_chunks = tfwc_rcvr_numvec();
 
-			// get ackvec from TfwcRcvr
-			xr->chunk = htons(tfwc_rcvr_getvec());
-		}
-		// this block is used for giving timiestamp echo
-		else if (bt == XR_BT_3) {
-			// set XR block type
-			xr->xr_flags = htons(XR_BT_3 << 8);
-	
-			// get timestamp echo from TfwcRcvr
-			xr->chunk = htonl(tfwc_rcvr_ts_echo());
+			// allocate report block in memory
+			rb = (u_char *) malloc(sizeof(xr) + num_ssrc 
+					+ num_begins + num_ends + num_chunks);
+
+			// set report block entry pointer
+			u_int32_t *ent = (u_int32_t *) (sizeof(xr) + rb);
+
+			// ssrc of XR source (currently unused)
+			xrssrc = 0;
+			ent[0] = xrssrc;
+
+			// begin/end for AckVec
+			ent[1] = 0;
+			ent[1] |= htons(tfwc_rcvr_begins());
+			ent[1] <<= 16;
+			ent[1] |= htons(tfwc_rcvr_ends());
+
+			// get AckVec pointer from TfwcRcvr
+			//xr->chunk = htons(tfwc_rcvr_getvec_p());
 		}
 	} // end of if (am_i_sender())
 
@@ -1193,9 +1224,12 @@
 	u_int16_t flags = xr->xr_flags;
 	
 	// parse XR information (begin, end, chunk)
-	u_int16_t begin	= ntohs(xr->begin_seq);
-	u_int16_t end	= ntohs(xr->end_seq);
-	u_int16_t chunk	= ntohs(xr->chunk);
+	//u_int16_t begin	= ntohs(xr->begin_seq);
+	//u_int16_t end	= ntohs(xr->end_seq);
+	//u_int16_t chunk	= ntohs(xr->chunk);
+	u_int16_t begin;
+	u_int16_t end;
+	u_int16_t chunk;
 
 	// i am an RTP data sender, so do the sender stuffs
 	if (am_i_sender()) {



More information about the Sumover-dev mailing list