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

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Mon Sep 14 18:48:16 BST 2009


Author: soohyunc
Date: Mon Sep 14 18:48:16 2009
New Revision: 4511

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/session.cpp

Log:
slight changes for RTP data packet seqno retrieval process (for the data receiver):

we had RTCP XR carrying RTP data packet "seqno" and "ackofack" from the data
sender to the data receiver. this might end up acknowledging RTCP XR instead of
RTP data packet.

so, we had to move RTP data packet acknowledgement process from control channel
to data channel.

so, the RTP data packet number will be retrieved from
SessionManager::recv(DataHandler *dh), and the retrieved seqno will be
eventually passed to TFWC receiver module in order to build up AckVec.

As soon as this AckVec build-up, it has to send RTCP XR immediately carrying
AckVec information to the data sender.

This commit reflects this changes.
 


Modified: vic/branches/cc/cc/tfwc_rcvr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_rcvr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_rcvr.cpp	Mon Sep 14 18:48:16 2009
@@ -60,8 +60,19 @@
 	bzero(tfwcAV, AVSZ);
 }
 
-void TfwcRcvr::tfwc_rcvr_recv(u_int16_t type, u_int16_t seqno, 
-				u_int16_t *chunk, int num_chunks) 
+void TfwcRcvr::tfwc_rcvr_recv_aoa(u_int16_t type, u_int16_t *chunk, int num_chunks) 
+{
+	if (type == XR_BT_1) {
+		// received ackofack 
+		ackofack_ = ntohs(chunk[num_chunks-1]);
+	}
+	else if (type == XR_BT_2) {
+		// set timestamp echo
+		ts_echo_ = chunk[num_chunks-1];
+	}
+}
+
+void TfwcRcvr::tfwc_rcvr_recv_seqno(u_int16_t seqno)
 {
 	// variables
 	int numLoss		= 0;	// number of packet loss count
@@ -69,148 +80,139 @@
 	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) {
-		// received data packet seqno
-		currseq_ = seqno;
-		// received ackofack 
-		ackofack_ = ntohs(chunk[num_chunks-1]);
+	// received data packet seqno
+	currseq_ = seqno;
 
-		// number of AckVec element
-		currNumElm_	= currseq_ - ackofack_;
-		diffNumElm	= currNumElm_ - prevNumElm_;
-		int x = currNumElm_%BITLEN;
-		int y = prevNumElm_%BITLEN;
-
-		// number of chunks for building tfwcAV
-		currNumVec_	= getNumVec(currNumElm_);
-		diffNumVec	= currNumVec_ - prevNumVec_;
-
-		// for debugging purpose
-		printf("    [%s +%d] seqno:%d, ackofack:%d\n",
-			__FILE__,__LINE__,currseq_,ackofack_);
-		printf("    [%s +%d] currNumElm:%d, prevNumElm:%d\n", 
-			__FILE__,__LINE__,currNumElm_,prevNumElm_);
-		printf("    [%s +%d] currNumVec:%d, prevNumVec:%d\n", 
-			__FILE__,__LINE__,currNumVec_,prevNumVec_);
-
-		// there is no packet loss (or reordering)
-		if (currseq_ == prevseq_ + 1) {
-			// we just need the same number of AckVec elements,
-			// hence just left shift by one and clear the top bit
-			if (diffNumElm == 0) {
-				// set next bit to 1
-				SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
-
-				// and clear the top bit which we don't need it anymore
-				if (x != 0)
-					CLR_BIT_AT(tfwcAV[currNumVec_-1], x+1);
-			}
-			// we just need less number of AckVec elements,
-			// hence first free unnecessary AckVec chunk(s) and set bit.
-			else if (diffNumElm < 0) {
-				// firstly, freeing unnecessary AcvVec chunk(s) 
-				if (currNumVec_ != prevNumVec_) {
-					for (int i = prevNumVec_; i > currNumVec_; i--) {
-						for (int j = 1; j <= BITLEN; j++)
-							SET_BIT_VEC(tfwcAV[i-1], 0);
-					}
-				}
-				// set next bit to 1
-				SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
-				// and clear the bit(s) that we don't need it anymore
-				int k = (x == 0) ? BITLEN: x;
-				for (int i = BITLEN; i > k; i--)
-					CLR_BIT_AT(tfwcAV[currNumVec_-1], i);
-			}
-			// otherwise, just set next bit to 1
-			// (i.e., we need more AckVec elements)
-			else
-				SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
-		} 
-		// we have one or more packet losses (or reordering)
-		else {
-			// number of packet loss
-			numLoss = currseq_ - prevseq_ - 1;
-			int z = numLoss%BITLEN;
+	// number of AckVec element
+	currNumElm_	= currseq_ - ackofack();
+	diffNumElm	= currNumElm_ - prevNumElm_;
+	int x = currNumElm_%BITLEN;
+	int y = prevNumElm_%BITLEN;
 
-			// we need more AckVec chunks (maybe one or more)
-			if (currNumVec_ != prevNumVec_) {
-				// currently available spaces in the previous tfwcAV array
-				int numAvail = BITLEN - y;
+	// number of chunks for building tfwcAV
+	currNumVec_	= getNumVec(currNumElm_);
+	diffNumVec	= currNumVec_ - prevNumVec_;
+
+	// for debugging purpose
+	printf("    [%s +%d] seqno:%d, ackofack:%d\n",
+		__FILE__,__LINE__,currseq_,ackofack());
+	printf("    [%s +%d] currNumElm:%d, prevNumElm:%d\n", 
+		__FILE__,__LINE__,currNumElm_,prevNumElm_);
+	printf("    [%s +%d] currNumVec:%d, prevNumVec:%d\n", 
+		__FILE__,__LINE__,currNumVec_,prevNumVec_);
+
+	// there is no packet loss (or reordering)
+	if (currseq_ == prevseq_ + 1) {
+		// we just need the same number of AckVec elements,
+		// hence just left shift by one and clear the top bit
+		if (diffNumElm == 0) {
+			// set next bit to 1
+			SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
 
-				// first, fill up zeros into those available spaces
-				for (int i = 0; i < numAvail; i++) {
-					SET_BIT_VEC(tfwcAV[prevNumVec_-1], 0);
-					numLoss--;
+			// and clear the top bit which we don't need it anymore
+			if (x != 0)
+				CLR_BIT_AT(tfwcAV[currNumVec_-1], x+1);
+		}
+		// we just need less number of AckVec elements,
+		// hence first free unnecessary AckVec chunk(s) and set bit.
+		else if (diffNumElm < 0) {
+			// firstly, freeing unnecessary AcvVec chunk(s) 
+			if (currNumVec_ != prevNumVec_) {
+				for (int i = prevNumVec_; i > currNumVec_; i--) {
+					for (int j = 1; j <= BITLEN; j++)
+						SET_BIT_VEC(tfwcAV[i-1], 0);
 				}
+			}
+			// set next bit to 1
+			SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
+			// and clear the bit(s) that we don't need it anymore
+			int k = (x == 0) ? BITLEN: x;
+			for (int i = BITLEN; i > k; i--)
+				CLR_BIT_AT(tfwcAV[currNumVec_-1], i);
+		}
+		// otherwise, just set next bit to 1
+		// (i.e., we need more AckVec elements)
+		else
+			SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
+	} 
+	// we have one or more packet losses (or reordering)
+	else {
+		// number of packet loss
+		numLoss = currseq_ - prevseq_ - 1;
+		int z = numLoss%BITLEN;
+
+		// we need more AckVec chunks (maybe one or more)
+		if (currNumVec_ != prevNumVec_) {
+			// currently available spaces in the previous tfwcAV array
+			int numAvail = BITLEN - y;
+
+			// first, fill up zeros into those available spaces
+			for (int i = 0; i < numAvail; i++) {
+				SET_BIT_VEC(tfwcAV[prevNumVec_-1], 0);
+				numLoss--;
+			}
 
-				// then, calculate "additional" AckVec chunks required
-				addiNumVec = getNumVec(numLoss);
-
-				// fill up zeros accordingly if addiNumVec is greater than 1
-				for (int i = 0; i < (addiNumVec - 1); i++) {
-					for (int j = 0; j < BITLEN; j++) {
-						SET_BIT_VEC(tfwcAV[prevNumVec_+i], 0);
-						numLoss--;
-					}
-				}
+			// then, calculate "additional" AckVec chunks required
+			addiNumVec = getNumVec(numLoss);
 
-				// we need to update 'z' accordingly
-				// (at this point, 'z' should be equal to 'numLoss')
-				z = numLoss%BITLEN;
-
-				// finally, fill up zeros at the latest AckVec chunk
-				for (int i = 0; i < z; i++) {
-					SET_BIT_VEC(tfwcAV[prevNumVec_+addiNumVec-1], 0);
+			// fill up zeros accordingly if addiNumVec is greater than 1
+			for (int i = 0; i < (addiNumVec - 1); i++) {
+				for (int j = 0; j < BITLEN; j++) {
+					SET_BIT_VEC(tfwcAV[prevNumVec_+i], 0);
+					numLoss--;
 				}
 			}
-			// current AckVeck chunk can cope with the elements
-			else {
-				// set next bit 0 into AckVec (# of packet loss)
-				for (int i = 0; i < numLoss; i++) 
-					SET_BIT_VEC(tfwcAV[currNumVec_-1], 0);
-			}
 
-			// then, set this packet as received (this is important)
-			SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
-
-			// and clear the top two bits which we don't need
-			// (because we have pushed '0' and '1' at the end of this AckVec)
-			// it doesn't really matter if diffNumElm is greater than 0.
-			if ( (diffNumElm <= 0) && (x != 0) ) {
-				int b = abs(diffNumElm) + x + z;
-				for (int i = x + 1; i <= b; i++)
-					CLR_BIT_AT(tfwcAV[currNumVec_-1], i);
+			// we need to update 'z' accordingly
+			// (at this point, 'z' should be equal to 'numLoss')
+			z = numLoss%BITLEN;
+
+			// finally, fill up zeros at the latest AckVec chunk
+			for (int i = 0; i < z; i++) {
+				SET_BIT_VEC(tfwcAV[prevNumVec_+addiNumVec-1], 0);
 			}
 		}
+		// current AckVeck chunk can cope with the elements
+		else {
+			// set next bit 0 into AckVec (# of packet loss)
+			for (int i = 0; i < numLoss; i++) 
+				SET_BIT_VEC(tfwcAV[currNumVec_-1], 0);
+		}
 
-		// print ackvec
-		print_ackvec(tfwcAV);
+		// then, set this packet as received (this is important)
+		SET_BIT_VEC(tfwcAV[currNumVec_-1], 1);
 
-		// start seqno that this AckVec is reporting
-		if (ackofack_ != 0)
-			begins_ = ackofack_ + 1;
-		else
-			begins_ = 1;
+		// and clear the top two bits which we don't need
+		// (because we have pushed '0' and '1' at the end of this AckVec)
+		// it doesn't really matter if diffNumElm is greater than 0.
+		if ( (diffNumElm <= 0) && (x != 0) ) {
+			int b = abs(diffNumElm) + x + z;
+			for (int i = x + 1; i <= b; i++)
+				CLR_BIT_AT(tfwcAV[currNumVec_-1], i);
+		}
+	}
 
-		// end seqno is current seqno plus one (according to RFC 3611)
-		ends_ = currseq_ + 1;
+	// print ackvec
+	print_ackvec(tfwcAV);
 
-		// store seqno, num of AckVec elem, and num of AckVec array
-		prevseq_ = currseq_;
-		prevNumElm_ = currNumElm_;
-		prevNumVec_ = currNumVec_;
-	}
-	else if (type == XR_BT_2) {
-		// set timestamp echo
-		ts_echo_ = chunk[num_chunks-1];
-	}
+	// start seqno that this AckVec is reporting
+	if (ackofack() != 0)
+		begins_ = ackofack() + 1;
+	else
+		begins_ = 1;
+
+	// end seqno is current seqno plus one (according to RFC 3611)
+	ends_ = currseq_ + 1;
+
+	// store seqno, num of AckVec elem, and num of AckVec array
+	prevseq_ = currseq_;
+	prevNumElm_ = currNumElm_;
+	prevNumVec_ = currNumVec_;
 }
 
 void TfwcRcvr::print_ackvec(u_int16_t *ackv) {
 	// start sequence number
-	int seqno = ackofack_+1;
+	int seqno = ackofack()+1;
 	int x = currNumElm_%BITLEN;
 
 	// printing...

Modified: vic/branches/cc/cc/tfwc_rcvr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_rcvr.h	(original)
+++ vic/branches/cc/cc/tfwc_rcvr.h	Mon Sep 14 18:48:16 2009
@@ -45,8 +45,8 @@
 class TfwcRcvr {
 public:
 	TfwcRcvr();
-	void tfwc_rcvr_recv(u_int16_t type, u_int16_t seqno, 
-			u_int16_t *chunk, int num_chunks);
+	void tfwc_rcvr_recv_aoa(u_int16_t type, u_int16_t *chunk, int num_chunks);
+	void tfwc_rcvr_recv_seqno(u_int16_t seqno);
 
 protected:
 	// AckVec clone
@@ -84,6 +84,9 @@
 		return num;
 	}
 
+	// returning AckOfAck
+	inline u_int16_t ackofack() { return ackofack_; }
+
 	// print built AckVec
 	void print_ackvec(u_int16_t *ackv);
 

Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp	Mon Sep 14 18:48:16 2009
@@ -104,7 +104,7 @@
 
 void TfwcSndr::tfwc_sndr_send(pktbuf* pb) {
 
-	// get RTP hearder information
+	// get RTP header information
 	rtphdr* rh =(rtphdr*) pb->data;
 
 	// get seqno and mark timestamp for this data packet

Modified: vic/branches/cc/rtp/session.cpp
==============================================================================
--- vic/branches/cc/rtp/session.cpp	(original)
+++ vic/branches/cc/rtp/session.cpp	Mon Sep 14 18:48:16 2009
@@ -959,6 +959,7 @@
 void SessionManager::recv(DataHandler* dh)
 {
 	int layer = dh - dh_;
+	u_int16_t seqno;	// received RTP data packet seqno
 	pktbuf* pb = pool_->alloc(layer);
 	Address * addrp;
 	/* leave room in case we need to expand rtpv1 into an rtpv2 header */
@@ -996,6 +997,21 @@
 		return;
 	}
 	pb->len = cc;
+
+	// RTP data receiver need to extract seqno
+	// and send XR report back to the sender.
+	if (!am_i_sender()) {
+		// retrieve RTP seqno
+		rtphdr* rh = (rtphdr*)pb->data;
+		seqno = ntohs(rh->rh_seqno);
+		// pass seqno to tfwc receiver to build up AckVec
+		tfwc_rcvr_recv_seqno(seqno);
+		printf("\n\treceived seqno: %d\n\n", seqno);
+
+		// send receiver side XR report (AckVec)
+		ch_[0].send_ackv();
+		//ch_[0].send_ts_echo();
+	}
 	
 	//bp += sizeof(*rh);
 	//cc -= sizeof(*rh);
@@ -1290,7 +1306,7 @@
 			// we need to call Transmitter::output(pb) to make Ack driven
 			cc_output();
 		}
-		// i am an RTP data receiver, so do the receiver stuffs (build AckVec)
+		// i am an RTP data receiver, so receive ackofack 
 		else {
 			int num_chunks = 1;
 			printf(">>> parse_xr - i_am_receiver\n");
@@ -1301,11 +1317,7 @@
 			u_int16_t *chunk = (u_int16_t *) ++xr1;
 			printf("    [%s +%d] begin:%d, chunk[0]:%d\n", 
 					__FILE__,__LINE__, begin, ntohs(chunk[0]));
-			tfwc_rcvr_recv(xr->BT, begin, chunk, num_chunks);
-
-			// send receiver side XR report
-			ch_[0].send_ackv();
-			//ch_[0].send_ts_echo();
+			tfwc_rcvr_recv_aoa(xr->BT, chunk, num_chunks);
 		} // end of XR block type 1
 	} else {
 		// XXX



More information about the Sumover-dev mailing list