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

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Thu May 6 14:11:02 BST 2010


Author: soohyunc
Date: Thu May  6 14:11:02 2010
New Revision: 4793

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/cc/tfwc_sndr.h
   vic/branches/cc/rtp/session.cpp
   vic/branches/cc/rtp/transmitter.cpp
   vic/branches/cc/rtp/transmitter.h

Log:
TfwcSndr and TfwcRcvr were the base class for Transmitter class, making
Transmitter and SessionManager being a derived class. However, this wasn't quite
scalable as we have more CC mechanisms.

So, what we did is to de-couple TfwcSndr and TfwcRcvr from Transmitter. Instead,
we created an instance for TfwcSndr and TfwcRcvr in Transmitter.

This change is about de-coupling TfwcSndr/TfwcRcvr from
Transmitter/SessionManager but created class instances.



Modified: vic/branches/cc/cc/tfwc_rcvr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_rcvr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_rcvr.cpp	Thu May  6 14:11:02 2010
@@ -42,6 +42,9 @@
 #include "transmitter.h"
 #include "tfwc_rcvr.h"
 
+// TfwcRcvr instance
+TfwcRcvr TfwcRcvr::instance_;
+
 TfwcRcvr::TfwcRcvr() :
 	ackofack_(0),
 	begins_(1),
@@ -57,7 +60,7 @@
 }
 
 // retrive ackofack from RTCP control channel
-void TfwcRcvr::tfwc_rcvr_recv_aoa(u_int16_t type, u_int16_t *chunk)
+void TfwcRcvr::recv_aoa(u_int16_t type, u_int16_t *chunk)
 {
 	int num_chunks = 1;
 	__ackofack_ = ackofack_;
@@ -83,7 +86,7 @@
 }
 
 // retrieve data packet sequence number from RTP data channel
-void TfwcRcvr::tfwc_rcvr_recv_seqno(u_int16_t seqno)
+void TfwcRcvr::recv_seqno(u_int16_t seqno)
 {
 	// out-of-order packet reception
 	// (use previous ackofack)

Modified: vic/branches/cc/cc/tfwc_rcvr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_rcvr.h	(original)
+++ vic/branches/cc/cc/tfwc_rcvr.h	Thu May  6 14:11:02 2010
@@ -41,21 +41,25 @@
 class TfwcRcvr {
 public:
 	TfwcRcvr();
-	void tfwc_rcvr_recv_aoa(u_int16_t type, u_int16_t *chunk);
-	void tfwc_rcvr_recv_seqno(u_int16_t seqno);
-
-protected:
+	void recv_aoa(u_int16_t type, u_int16_t *chunk);
+	void recv_seqno(u_int16_t seqno);
 	// AckVec clone
-	inline u_int16_t tfwc_rcvr_getvec(int i) { return tfwcAV[i]; }
+	inline u_int16_t getvec(int i) { return tfwcAV[i]; }
 	// ts echo
-	inline u_int32_t tfwc_rcvr_ts_echo() { return ts_echo_; }
-
+	inline u_int32_t ts_echo() { return ts_echo_; }
 	// AckVec begin seqno
-	inline u_int16_t tfwc_rcvr_begins() { return begins_; }
+	inline u_int16_t begins() { return begins_; }
 	// AckVec end seqno plus one
-	inline u_int16_t tfwc_rcvr_ends() { return ends_; }
+	inline u_int16_t ends() { return ends_; }
 	// number of AckVec array
-	inline u_int16_t tfwc_rcvr_numvec() { return numVec_; }
+	inline u_int16_t numvec() { return numVec_; }
+
+	// TfwcRcvr instance
+	static inline TfwcRcvr& instance() { return instance_; }
+
+protected:
+
+	static TfwcRcvr instance_;
 
 	/*
 	 * Variables

Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp	Thu May  6 14:11:02 2010
@@ -55,6 +55,9 @@
 	s_ -> expire(TFWC_TIMER_RTX);
 }
 
+// TfwcSndr instance
+TfwcSndr TfwcSndr::instance_;
+
 /* 
  * TFWC sender definition
  */
@@ -152,7 +155,7 @@
 	lambda2_ = .15;
 }
 
-void TfwcSndr::tfwc_sndr_send(pktbuf* pb, double now) {
+void TfwcSndr::send(pktbuf* pb, double now) {
 	// the very first data packet
 	if(seqno_ == 0)
 	ts_off_ = tx_ts_offset();
@@ -199,7 +202,7 @@
 /*
  * main TFWC reception path
  */
-void TfwcSndr::tfwc_sndr_recv(u_int16_t type, u_int16_t begin, u_int16_t end,
+void TfwcSndr::recv(u_int16_t type, u_int16_t begin, u_int16_t end,
 		u_int16_t *chunk, double so_rtime, bool recv_by_ch, pktbuf* pb)
 {
   switch (type) {

Modified: vic/branches/cc/cc/tfwc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.h	(original)
+++ vic/branches/cc/cc/tfwc_sndr.h	Thu May  6 14:11:02 2010
@@ -80,29 +80,29 @@
 	virtual ~TfwcSndr() {};
 
 	// virtual functions
-	virtual void cc_tfwc_output(bool recv_by_ch=0) = 0;
-	virtual void cc_tfwc_output(pktbuf*) = 0;
-	virtual void cc_tfwc_trigger(pktbuf* pb=0) = 0;
-	virtual double tx_ts_offset() = 0;
-	virtual int tx_buf_size() = 0;
+	virtual void cc_tfwc_output(bool recv_by_ch=0) {};
+	virtual void cc_tfwc_output(pktbuf*) {};
+	virtual void cc_tfwc_trigger(pktbuf* pb=0) {};
+	virtual double tx_ts_offset() {};
+	virtual int tx_buf_size() {};
 
 	// parse seqno and timestamp
-	void tfwc_sndr_send(pktbuf*, double);
+	void send(pktbuf*, double);
 
 	// main reception path (XR packet)
-	void tfwc_sndr_recv(u_int16_t type, u_int16_t begin, u_int16_t end,
+	void recv(u_int16_t type, u_int16_t begin, u_int16_t end,
 	u_int16_t *chunk, double so_rtime, bool recv_by_ch, pktbuf* pb);
 
 	// return ackofack
-	inline u_int16_t tfwc_sndr_get_aoa() { return aoa_; }
+	inline u_int16_t get_aoa() { return aoa_; }
 
 	// just acked seqno in packets and in bytes
-	inline u_int16_t tfwc_sndr_jacked() { return jacked_; }
-	inline int tfwc_sndr_bjacked() { return record_[bjacked_%PSR]; }
+	inline u_int16_t jacked() { return jacked_; }
+	inline int b_jacked() { return record_[bjacked_%PSR]; }
 
 	// tfwc controlled cwnd value in packets and in bytes
-	inline u_int32_t tfwc_magic() { return cwnd_; }
-	inline int tfwc_bmagic() { return bcwnd_; }
+	inline u_int32_t magic() { return cwnd_; }
+	inline int b_magic() { return bcwnd_; }
 
 	// set timestamp in double type (TfwcSndr)
 	inline double tfwc_sndr_now() {
@@ -123,7 +123,13 @@
 	// Rtx timer
 	void expire(int option);
 
+	// TfwcSndr instance
+	static inline TfwcSndr& instance() { return instance_; }
+
 protected:
+
+	static TfwcSndr instance_;
+
 	// generate sequence numbers
 	void gen_seqvec(u_int16_t *v, int n);
 
@@ -163,6 +169,7 @@
 
 	// retransmission timer
 	TfwcRtxTimer rtx_timer_;
+
 	void set_rtx_timer();
 	void reset_rtx_timer(int backoff);
 	void backoff_timer();

Modified: vic/branches/cc/rtp/session.cpp
==============================================================================
--- vic/branches/cc/rtp/session.cpp	(original)
+++ vic/branches/cc/rtp/session.cpp	Thu May  6 14:11:02 2010
@@ -463,7 +463,7 @@
 	// print RTP seqno
 	print_rtp_seqno(pb);
 	// record seqno and timestamp at TfwcSndr side
-	tfwc_sndr_send(pb, tx_get_now());
+	tfwc_sndr_.send(pb, tx_get_now());
 
 	// Using loop_layer for now to restrict transmission as well
 	if (pb->layer < loop_layer_) {
@@ -493,7 +493,7 @@
 	// print RTP seqno
 	print_rtp_seqno(pb);
 	// record seqno and timestamp at TfwcSndr side
-	tfwc_sndr_send(pb, tx_get_now());
+	tfwc_sndr_.send(pb, tx_get_now());
 
 	if (pb->layer < loop_layer_) {
 		Network* n = dh_[pb->layer].net();
@@ -692,7 +692,7 @@
 			case WBCC:
 				// this block is used for giving ackofack
 				// set AckofAck
-				chunks[num_chunks-1] = tfwc_sndr_get_aoa();
+				chunks[num_chunks-1] = tfwc_sndr_.get_aoa();
 
 				// send_xreport (sender's report)
 				// - just sending ackofack information
@@ -715,14 +715,14 @@
 			switch (cc_type_) {
 			case WBCC:
 				// get the number of required chunks for giving AckVec
-				num_chunks = tfwc_rcvr_numvec();
+				num_chunks = tfwc_rcvr_.numvec();
 				chunks = (u_int16_t *) 
 					malloc(num_chunks * sizeof(u_int16_t));
 			
 				// set/printing chunks
 				//fprintf(stderr, "\t   printing chunks: ");
 				for (int i = 0; i < num_chunks; i++) {
-					chunks[i] = tfwc_rcvr_getvec(i);
+					chunks[i] = tfwc_rcvr_.getvec(i);
 				//	fprintf(stderr, "[%d:%x] ", i, chunks[i]);
 				} 
 				//fprintf(stderr, "...........%s +%d\n",__FILE__,__LINE__);
@@ -733,8 +733,8 @@
 			}
 			// send_xreport (receiver's report)
 			// - sending AckVec
-			send_xreport(ch, XR_BT_1, 0, 0, tfwc_rcvr_begins(), 
-					tfwc_rcvr_ends(), chunks, num_chunks, 0);
+			send_xreport(ch, XR_BT_1, 0, 0, tfwc_rcvr_.begins(), 
+					tfwc_rcvr_.ends(), chunks, num_chunks, 0);
 		}
 		else if (bt == XR_BT_3) {
 			/*XXX*/
@@ -1052,7 +1052,7 @@
 		switch (cc_type_) {
 		case WBCC:
 			// pass seqno to tfwc receiver to build up AckVec
-			tfwc_rcvr_recv_seqno(seqno);
+			tfwc_rcvr_.recv_seqno(seqno);
 			fprintf(stderr, "\n\treceived seqno: %d\n\n", seqno);
 
 			// send receiver side XR report (AckVec)
@@ -1349,7 +1349,7 @@
 				//sender_xr_ts_info(so_rtime);
 
 				// TFWC sender (getting AckVec)
-				tfwc_sndr_recv(xr->BT, begin, end, chunk, recv_ts_, recv_by_ch, pb);
+				tfwc_sndr_.recv(xr->BT, begin, end, chunk, recv_ts_, recv_by_ch, pb);
 
 				// we need to call Transmitter::output(pb) to make Ack driven
 				if(recv_by_ch)
@@ -1368,7 +1368,7 @@
 				receiver_xr_info(chunk);
 
 				// TFWC receiver (getting ackofack)
-				tfwc_rcvr_recv_aoa(xr->BT, chunk);
+				tfwc_rcvr_.recv_aoa(xr->BT, chunk);
 				break;
 
 			case RBCC:

Modified: vic/branches/cc/rtp/transmitter.cpp
==============================================================================
--- vic/branches/cc/rtp/transmitter.cpp	(original)
+++ vic/branches/cc/rtp/transmitter.cpp	Thu May  6 14:11:02 2010
@@ -104,6 +104,8 @@
 
 	// CC related...
 	epc_ = 0;	// experimental packet counter
+	tfwc_sndr_ = TfwcSndr::instance();
+	tfwc_rcvr_ = TfwcRcvr::instance();
 }
 
 /* Return time of day in seconds */
@@ -324,7 +326,7 @@
 	case BYM:
 	{
 		int len = 0;
-		if(pb->len < tfwc_bmagic() - len) {
+		if(pb->len < tfwc_sndr_.b_magic() - len) {
 			len += pb->len;
 			// move head pointer
 			head_ = pb->next;
@@ -338,9 +340,9 @@
 		// pb is not null, hence parse it.
 		rtphdr* rh = (rtphdr *) pb->data;
 
-		if (ntohs(rh->rh_seqno) <= tfwc_magic() + tfwc_sndr_jacked()) {
-			//debug_msg("cwnd: %d\n", tfwc_magic());
-			//debug_msg("jack: %d\n", tfwc_sndr_jacked());
+		if (ntohs(rh->rh_seqno) <= tfwc_sndr_.magic() + tfwc_sndr_.jacked()) {
+			//debug_msg("cwnd: %d\n", tfwc_sndr_.magic());
+			//debug_msg("jack: %d\n", tfwc_sndr_.jacked());
 			
 			// move head pointer
 			head_ = pb->next;
@@ -376,7 +378,7 @@
 	case BYM:
 	{
 		int len = 0;
-		while(pb->len < tfwc_bmagic() - len) {
+		while(pb->len < tfwc_sndr_.b_magic() - len) {
 			len += pb->len;
 			// move head pointer
 			head_ = pb->next;
@@ -396,9 +398,9 @@
 		rtphdr* rh = (rtphdr *) pb->data;
 
 		// while packet seqno is within "cwnd + jack", send that packet
-		while (ntohs(rh->rh_seqno) <= tfwc_magic() + tfwc_sndr_jacked()) {
-			//debug_msg("cwnd: %d\n", tfwc_magic());
-			//debug_msg("jack: %d\n", tfwc_sndr_jacked());
+		while (ntohs(rh->rh_seqno) <= tfwc_sndr_.magic() + tfwc_sndr_.jacked()) {
+			//debug_msg("cwnd: %d\n", tfwc_sndr_.magic());
+			//debug_msg("jack: %d\n", tfwc_sndr_.jacked());
 
 			// move head pointer
 			head_ = pb->next;

Modified: vic/branches/cc/rtp/transmitter.h
==============================================================================
--- vic/branches/cc/rtp/transmitter.h	(original)
+++ vic/branches/cc/rtp/transmitter.h	Thu May  6 14:11:02 2010
@@ -60,12 +60,14 @@
 #define PKM		1	// PacKet Mode
 #define BYM		2	// BYtes Mode
 
+class TfwcSndr;
+class TfwcRcvr;
+
 /*
  * The base object for performing the outbound path of
  * the application level protocol.
  */
-class Transmitter : public TclObject, public Timer, 
-	public TfwcSndr, public TfwcRcvr {
+class Transmitter : public TclObject, public Timer {
     public:
 	Transmitter();
 	virtual void timeout();
@@ -118,6 +120,9 @@
 	// Tx pktbuf size
 	virtual int tx_buf_size();
 
+	TfwcSndr tfwc_sndr_;
+	TfwcRcvr tfwc_rcvr_;
+
 protected:
 	void update(int nbytes);
 	void dump(int fd, iovec*, int iovel) const;



More information about the Sumover-dev mailing list