[Sumover-dev] [svn commit] r4319 - vic/branches/cc/cc/test

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Fri Nov 14 18:47:11 GMT 2008


Author: soohyunc
Date: Fri Nov 14 18:47:09 2008
New Revision: 4319

Added:
   vic/branches/cc/cc/test/bitvec.cpp   (contents, props changed)
   vic/branches/cc/cc/test/bitvec.h   (contents, props changed)
Modified:
   vic/branches/cc/cc/test/cc_output.h
   vic/branches/cc/cc/test/test.cpp

Log:
bitmap test code


Added: vic/branches/cc/cc/test/bitvec.cpp
==============================================================================
--- (empty file)
+++ vic/branches/cc/cc/test/bitvec.cpp	Fri Nov 14 18:47:09 2008
@@ -0,0 +1,48 @@
+/*
+ * bitvec.cpp
+ */
+
+/* $Id$ */
+
+#include <stdio.h>		// standard input/output
+#include <stdint.h>		// integer with certain length
+#include <stdbool.h>	// boolean type and values
+#include <sys/types.h>	// data types
+#include "bitvec.h"
+
+// variables
+static u_int32_t map = 0;	// bit vector
+static int seqno	 = 0;	// received seqno
+static int ackofack	 = 0;	// ack of ack
+static int lastseq	 = 0;	// last seqno
+static int mvec[DUPACKS];	// margin vec
+
+int bitvec () {
+
+	return 0;
+}
+
+int get_head_pos (int vec) {
+	int l;
+	for (l = 0; l < 32; l++) {
+		if (GET_HEAD_VEC(vec, l))
+			break;
+	}
+	return (32 - l);
+}
+
+int get_tail_pos (int vec) {
+	int l;
+	for (l = 0; l < 32; l++) {
+		if (GET_TAIL_VEC(vec, l))
+			break;
+	}
+	return (l + 1);
+}
+
+void marginvec (int vec) {
+	int hseq = get_head_pos(vec) + ackofack;
+
+	for (int i = 0; i < DUPACKS; i++) 
+		mvec[i] = ((hseq - i) < 0) ? 0 : (hseq - i);
+}

Added: vic/branches/cc/cc/test/bitvec.h
==============================================================================
--- (empty file)
+++ vic/branches/cc/cc/test/bitvec.h	Fri Nov 14 18:47:09 2008
@@ -0,0 +1,39 @@
+/*
+ * bitvec.h
+ */
+
+/* $Id$ */
+
+#ifndef vic_cc_test_bitvec_h
+#define vic_cc_test_bitvec_h
+
+#include <stdbool.h>		// boolean type and values
+#include "buffer.h"
+
+#define DUPACKS 3		// dupacks
+#define CHB 0x80000000  // ackvec check bit (head search)
+#define CTB 0x01        // ackvec check bit (tail search)
+
+// set AckVec bitmap from LSB
+#define SET_BIT_VEC(map, bit) (map = ((map << 1) | bit))
+
+// AckVec bitmap at i-th location
+#define GET_BIT_VEC(map, i, seqno) ((1 << (seqno - i)) & map)
+
+// AckVec head search
+#define GET_HEAD_VEC(map, i) ( map & (CHB >> i) )
+
+// AckVec tail search
+#define GET_TAIL_VEC(map, i) ( map & (CTB << i) )
+
+// check bit at i-th location
+#define CHECK_BIT_AT(map, i) ( map & (1 << (i-1)) )
+
+// functions
+int		bitvec();
+int		get_head_pos (int vec);
+int		get_tail_pos (int vec);
+void	marginvec (int vec);
+void	gen_seqvec (int vec);
+
+#endif /* vic_cc_test_bitvec_h */

Modified: vic/branches/cc/cc/test/cc_output.h
==============================================================================
--- vic/branches/cc/cc/test/cc_output.h	(original)
+++ vic/branches/cc/cc/test/cc_output.h	Fri Nov 14 18:47:09 2008
@@ -4,7 +4,12 @@
 
 /* $Id$ */
 
+#ifndef vic_cc_test_cc_output_h
+#define vic_cc_test_cc_output_h
+
 #include "buffer.h"
 
 int		cc_output();
 Buffer	gen_packets(int num);
+
+#endif /* vic_cc_test_cc_output_h */

Modified: vic/branches/cc/cc/test/test.cpp
==============================================================================
--- vic/branches/cc/cc/test/test.cpp	(original)
+++ vic/branches/cc/cc/test/test.cpp	Fri Nov 14 18:47:09 2008
@@ -1,8 +1,15 @@
+/*
+ * main.cpp
+ */
+
+/* $Id$ */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include "config.h"
 #include "buffer.h"
 #include "cc_output.h"
+#include "bitvec.h"
 
 #define UNUSED(x) (x) = (x)
 
@@ -11,7 +18,10 @@
 	UNUSED(argc);
 	UNUSED(argv);
 
-	int val = cc_output();
+	int val;
+
+	//val = cc_output();
+	val = bitvec();
 
 	return val;
 }



More information about the Sumover-dev mailing list