[Sumover-dev] [svn commit] r4657 - in vic/branches/cc: .

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Mon Mar 1 20:29:20 GMT 2010


Author: soohyunc
Date: Mon Mar  1 20:29:20 2010
New Revision: 4657

Added:
   vic/branches/cc/cc/cc_timer.cpp   (contents, props changed)
   vic/branches/cc/cc/cc_timer.h   (contents, props changed)
Modified:
   vic/branches/cc/Makefile.in
   vic/branches/cc/cc/tfwc_sndr.cpp
   vic/branches/cc/cc/tfwc_sndr.h

Log:
-- added a timer for calculating TFWC's retransmission timeout

(To-do)
need to add some sort of send method when this timer goes off



Modified: vic/branches/cc/Makefile.in
==============================================================================
--- vic/branches/cc/Makefile.in	(original)
+++ vic/branches/cc/Makefile.in	Mon Mar  1 20:29:20 2010
@@ -152,7 +152,8 @@
 	render/color-gray.o render/color-mono.o render/color-hist.o \
 	render/rgb-converter.o render/vw.o render/ppm.o \
 	@V_OBJ@ \
-	cc/tfwc_sndr.o cc/tfwc_rcvr.o cc/tfrc_sndr.o cc/tfrc_rcvr.o
+	cc/tfwc_sndr.o cc/tfwc_rcvr.o cc/tfrc_sndr.o cc/tfrc_rcvr.o \
+	cc/cc_timer.o
 
 
 OBJ3 =	cm0.o cm1.o huffcode.o version.o bv.o codec/pvh-huff.o \

Added: vic/branches/cc/cc/cc_timer.cpp
==============================================================================
--- (empty file)
+++ vic/branches/cc/cc/cc_timer.cpp	Mon Mar  1 20:29:20 2010
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2010 University College London
+ * All rights reserved.
+ *
+ * AUTHOR: Soo-Hyun Choi <s.choi at .cs.ucl.ac.uk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor of the Laboratory may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#include <assert.h>
+#include "cc_timer.h"
+
+void CcTimerHandler::sched(double delay) {
+	if (status_ != TIMER_IDLE)
+		abort();
+
+	msched(delay);
+	status_ = TIMER_PENDING;
+}
+
+void CcTimerHandler::resched(double delay) {
+	if (status_ == TIMER_PENDING)
+		return;
+
+	msched(delay);
+	status_ = TIMER_PENDING;
+}
+
+void CcTimerHandler::cancel() {
+	if (status_ != TIMER_PENDING)
+		abort();
+
+	status_ = TIMER_IDLE;
+}

Added: vic/branches/cc/cc/cc_timer.h
==============================================================================
--- (empty file)
+++ vic/branches/cc/cc/cc_timer.h	Mon Mar  1 20:29:20 2010
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010 University College London
+ * All rights reserved.
+ *
+ * AUTHOR: Soo-Hyun Choi <s.choi at .cs.ucl.ac.uk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor of the Laboratory may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#ifndef vic_cc_timer_h
+#define vic_cc_timer_h
+
+#include "timer.h"
+
+class CcTimerHandler : public Timer {
+public:
+	CcTimerHandler() : status_(TIMER_IDLE) {}
+
+	virtual void timeout() = 0;
+	void sched(double delay);
+	void resched(double delay);
+	void cancel();
+	enum CcTimerStatus {TIMER_IDLE, TIMER_PENDING, TIMER_HANDLING};
+	inline int status() { return status_; };
+
+protected:
+	int status_;
+
+private:
+};
+#endif /* vic_cc_timer_h */

Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp	(original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp	Mon Mar  1 20:29:20 2010
@@ -43,6 +43,17 @@
 #include "transmitter.h"
 #include "tfwc_sndr.h"
 
+
+/*
+ * retransmission timer
+ */
+void TfwcRtxTimer::timeout() {
+	s_ -> expire(TFWC_TIMER_RTX);
+}
+
+/* 
+ * TFWC sender definition
+ */
 TfwcSndr::TfwcSndr() :
 	seqno_(0),
 	cwnd_(1),
@@ -564,3 +575,42 @@
 	fprintf(stderr, "%d", history_[i]);
 	if (j < hsz_ - 1) fprintf(stderr, ", ");
 }
+
+/*
+ * retransmission timer-out
+ */
+void TfwcSndr::expire(int option) {
+	if (option == TFWC_TIMER_RTX)
+		reset_rtx_timer(1);
+	else
+		reset_rtx_timer(0);
+}
+
+/*
+ * reset Rtx Timer
+ */
+void TfwcSndr::reset_rtx_timer (int backoff) {
+	if(backoff)
+		backoff_timer();
+
+	set_rtx_timer();
+}
+
+/*
+ * backoff Rtx Timer
+ */
+void TfwcSndr::backoff_timer() {
+	if (srtt_ < 0) srtt_ = 1.0;
+	rto_ = 2.0 * srtt_;
+
+	if (rto_ > maxrto_)
+		rto_ = maxrto_;
+}
+
+/*
+ * set Rtx Timer
+ */
+void TfwcSndr::set_rtx_timer() {
+	// resched() is basically msched(miliseconds)
+	rtx_timer_ -> resched(rto_ * 1000.);
+}

Modified: vic/branches/cc/cc/tfwc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.h	(original)
+++ vic/branches/cc/cc/tfwc_sndr.h	Mon Mar  1 20:29:20 2010
@@ -35,6 +35,7 @@
 #define vic_tfwc_sndr_h
 
 #include "bitmap.h"	// bitmap operations
+#include "cc_timer.h"
 
 #define DUPACKS 3   // simulating TCP's 3 dupacks
 #define TSZ	1000	// tsvec_ size
@@ -53,6 +54,23 @@
 
 #define BITLEN	16
 
+// timer related
+#define TFWC_TIMER_RTX		0
+#define TFWC_TIMER_RESET	1
+
+class TfwcSndr;
+
+// re-transmission timer
+class TfwcRtxTimer : public CcTimerHandler {
+public:
+	TfwcRtxTimer(TfwcSndr *s) : CcTimerHandler() { s_ = s;}
+	virtual void timeout();
+
+protected:
+	TfwcSndr *s_;
+};
+
+// TFWC sender class
 class TfwcSndr {
 public:
 	TfwcSndr();
@@ -96,6 +114,9 @@
 	u_int16_t seqno_;	// packet sequence number
 	u_int32_t cwnd_;	// congestion window
 
+	// Rtx timer
+	void expire(int option);
+
 protected:
 	// generate sequence numbers
 	void gen_seqvec(u_int16_t *v, int n);
@@ -150,6 +171,12 @@
 		fprintf(stderr, " )\n");
 	}
 
+	// retransmission timer
+	TfwcRtxTimer *rtx_timer_;
+	void set_rtx_timer();
+	void reset_rtx_timer(int backoff);
+	void backoff_timer();
+
 	int mvec_[DUPACKS]; // margin vec (simulatinmg TCP 3 dupacks)
 	u_int16_t *ackv_;	// received AckVec (from TfwcRcvr)
 	u_int32_t pvec_;	// sent packet list
@@ -162,6 +189,7 @@
 	double now_;		// real-time now
 	double so_recv_;	// SO_TIMESTAMP (XR packet reception)
 	double tao_;		// sampled RTT
+
 private:
 	// update RTT
 	void update_rtt(double tao);



More information about the Sumover-dev mailing list