[Click] R: Re: [PATCH] Roofnet (1/3)

Roberto Riggio roberto.riggio at create-net.org
Tue Aug 26 10:50:09 EDT 2008


the attachment...

Signed-off-by: Roberto Riggio <roberto.riggio at create-net.org>

-- 

diff -urN sr2.old/sr2ettmetric.cc sr2.new/sr2ettmetric.cc
--- sr2.old/sr2ettmetric.cc	2008-08-26 16:47:07.000000000 +0200
+++ sr2.new/sr2ettmetric.cc	2008-08-26 16:06:11.000000000 +0200
@@ -11,7 +11,8 @@
  * holders in advertising related to the Software without their permission.
  * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
  * notice is a summary of the Click LICENSE file; the license in that file is
- * legally binding.  */
+ * legally binding.  
+ */
 
 #include <click/config.h>
 #include <click/confparse.hh>
@@ -26,8 +27,7 @@
 #define min(a, b) ((a) < (b) ? (a) : (b))
 
 SR2ETTMetric::SR2ETTMetric()
-  : SR2LinkMetric(), 
-    _link_table(0)
+  : SR2LinkMetric()
 {
 }
 
@@ -40,38 +40,12 @@
 {
   if (strcmp(n, "SR2ETTMetric") == 0)
     return (SR2ETTMetric *) this;
-  else if (strcmp(n, "LinkMetric") == 0)
+  else if (strcmp(n, "SR2LinkMetric") == 0)
     return (SR2LinkMetric *) this;
   else
     return 0;
 }
 
-int
-SR2ETTMetric::configure(Vector<String> &conf, ErrorHandler *errh)
-{
-  int res = cp_va_kparse(conf, this, errh,
-			 "LT", 0, cpElement, &_link_table, 
-			 cpEnd);
-  if (res < 0)
-    return res;
-  if (_link_table == 0) {
-    click_chatter("%{element}: no LTelement specified",
-		  this);
-  }
-  if (_link_table && _link_table->cast("LinkTable") == 0) {
-    return errh->error("LinkTable element is not a LinkTable");
-  }
-  return 0;
-}
-
-
-int 
-SR2ETTMetric::get_tx_rate(EtherAddress) 
-{
-
-  return 2;
-}
-
 void
 SR2ETTMetric::update_link(IPAddress from, IPAddress to, 
 		       Vector<SR2RateSize> rs, 
@@ -88,16 +62,15 @@
   }
 
 
-    int one_ack_fwd = 0;
+  int one_ack_fwd = 0;
   int one_ack_rev = 0;
   int six_ack_fwd = 0;
   int six_ack_rev = 0;
 
-
   /* 
    * if we don't have a few probes going out, just pick
    * the smallest size for fwd rate
-  */
+   */
   int one_ack_size = 0;
   int six_ack_size = 0;
 
@@ -188,8 +161,7 @@
   }
 }
 
-
-ELEMENT_PROVIDES(GridGenericMetric)
-ELEMENT_REQUIRES(bitrate)
 EXPORT_ELEMENT(SR2ETTMetric)
+ELEMENT_REQUIRES(bitrate)
+ELEMENT_REQUIRES(SR2LinkMetric)
 CLICK_ENDDECLS
diff -urN sr2.old/sr2ettmetric.hh sr2.new/sr2ettmetric.hh
--- sr2.old/sr2ettmetric.hh	2008-08-26 16:47:07.000000000 +0200
+++ sr2.new/sr2ettmetric.hh	2008-08-26 16:07:11.000000000 +0200
@@ -14,14 +14,8 @@
  * SR2ETTMetric
  * =s Wifi
  * Estimated Transmission Time (ETT) metric
- * 
- * =io
- * None
- *
  */
 
-
-
 inline unsigned sr2_ett_metric(int ack_prob, int data_prob, int data_rate) 
 {
   
@@ -38,8 +32,6 @@
 
 }
 
-class ETTStat;
-
 class SR2ETTMetric : public SR2LinkMetric {
   
 public:
@@ -50,22 +42,13 @@
   const char *class_name() const { return "SR2ETTMetric"; }
   const char *processing() const { return AGNOSTIC; }
 
-  int configure(Vector<String> &, ErrorHandler *);
-
   void *cast(const char *);
 
-  static String read_stats(Element *xf, void *);
-
   void update_link(IPAddress from, IPAddress to, 
 		   Vector<SR2RateSize> rs, 
 		   Vector<int> fwd, Vector<int> rev, 
 		   uint32_t seq);
 
-  int get_tx_rate(EtherAddress);
-
-private:
-  class LinkTable *_link_table;
-
 };
 
 CLICK_ENDDECLS
diff -urN sr2.old/sr2linkmetric.cc sr2.new/sr2linkmetric.cc
--- sr2.old/sr2linkmetric.cc	1970-01-01 01:00:00.000000000 +0100
+++ sr2.new/sr2linkmetric.cc	2008-08-26 15:55:21.000000000 +0200
@@ -0,0 +1,59 @@
+/*
+ * sr2linkmetric.{cc,hh}
+ *
+ * Copyright (c) 2003 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, subject to the conditions
+ * listed in the Click LICENSE file. These conditions include: you must
+ * preserve this copyright notice, and you cannot mention the copyright
+ * holders in advertising related to the Software without their permission.
+ * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
+ * notice is a summary of the Click LICENSE file; the license in that file is
+ * legally binding.  
+ */
+
+#include <click/config.h>
+#include <click/confparse.hh>
+#include <click/error.hh>
+#include <click/straccum.hh>
+#include "sr2linkmetric.hh"
+#include <elements/wifi/linktable.hh>
+CLICK_DECLS 
+
+#define max(a, b) ((a) > (b) ? (a) : (b))
+#define min(a, b) ((a) < (b) ? (a) : (b))
+
+SR2LinkMetric::SR2LinkMetric()
+  : _link_table(0)
+{
+}
+
+SR2LinkMetric::~SR2LinkMetric()
+{
+}
+
+int
+SR2LinkMetric::configure(Vector<String> &conf, ErrorHandler *errh)
+{
+  int res = cp_va_kparse(conf, this, errh,
+			 "LT", 0, cpElement, &_link_table, 
+			 cpEnd);
+  if (res < 0)
+    return res;
+
+  if (_link_table == 0) {
+    click_chatter("%{element}: no LTelement specified",
+		  this);
+  }
+
+  if (_link_table && _link_table->cast("LinkTable") == 0) {
+    return errh->error("LinkTable element is not a LinkTable");
+  }
+
+  return 0;
+}
+
+ELEMENT_PROVIDES(SR2LinkMetric)
+CLICK_ENDDECLS
diff -urN sr2.old/sr2linkmetric.hh sr2.new/sr2linkmetric.hh
--- sr2.old/sr2linkmetric.hh	2008-08-26 16:47:07.000000000 +0200
+++ sr2.new/sr2linkmetric.hh	2008-08-26 15:55:40.000000000 +0200
@@ -2,15 +2,18 @@
 #define SR2LINKMETRIC_HH
 #include <click/element.hh>
 #include <click/ipaddress.hh>
+#include "sr2ettstat.hh"
 CLICK_DECLS
 
-
 class SR2LinkMetric : public Element {
 public:
-  SR2LinkMetric() { }
-  
-  virtual ~SR2LinkMetric() { }
+  SR2LinkMetric();
+  virtual ~SR2LinkMetric();
+
+  int configure(Vector<String> &, ErrorHandler *);
 
+protected:
+  class LinkTable *_link_table;
 
 };
 
diff -urN sr2.old/sr2txcountmetric.cc sr2.new/sr2txcountmetric.cc
--- sr2.old/sr2txcountmetric.cc	2008-08-26 16:47:07.000000000 +0200
+++ sr2.new/sr2txcountmetric.cc	2008-08-26 16:06:38.000000000 +0200
@@ -22,12 +22,8 @@
 #include <elements/wifi/linktable.hh>
 CLICK_DECLS 
 
-#define max(a, b) ((a) > (b) ? (a) : (b))
-#define min(a, b) ((a) < (b) ? (a) : (b))
-
 SR2TXCountMetric::SR2TXCountMetric()
-  : SR2LinkMetric(), 
-    _link_table(0)
+  : SR2LinkMetric()
 {
 }
 
@@ -46,26 +42,6 @@
     return 0;
 }
 
-int
-SR2TXCountMetric::configure(Vector<String> &conf, ErrorHandler *errh)
-{
-  int res = cp_va_kparse(conf, this, errh,
-			 "LT", 0, cpElement, &_link_table, 
-			 cpEnd);
-  if (res < 0)
-    return res;
-  if (_link_table == 0) {
-    click_chatter("%{element}: no LTelement specified",
-		  this);
-  }
-  if (_link_table && _link_table->cast("LinkTable") == 0) {
-    return errh->error("LinkTable element is not a LinkTable");
-  }
-  return 0;
-}
-
-
-
 void
 SR2TXCountMetric::update_link(IPAddress from, IPAddress to, 
 		       Vector<SR2RateSize>, 
@@ -102,4 +78,5 @@
 
 EXPORT_ELEMENT(SR2TXCountMetric)
 ELEMENT_REQUIRES(bitrate)
+ELEMENT_REQUIRES(SR2LinkMetric)
 CLICK_ENDDECLS
diff -urN sr2.old/sr2txcountmetric.hh sr2.new/sr2txcountmetric.hh
--- sr2.old/sr2txcountmetric.hh	2008-08-26 16:47:07.000000000 +0200
+++ sr2.new/sr2txcountmetric.hh	2008-08-26 16:07:22.000000000 +0200
@@ -11,32 +11,11 @@
 
 /*
  * =c
- * SR2TXCountMetric(LinkStat, LinkStat)
+ * SR2TXCountMetric
  * =s Wifi
- * The Estimated Transmission Count metric (ETX).
- * =a ETTMetric
+ * The Estimated Transmission Count (ETX) metric
  */
 
-
-
-inline unsigned sr2_txcount_metric(int ack_prob, int data_prob, int data_rate) 
-{
-  
-  if (!ack_prob || ! data_prob) {
-    return 0;
-  }
-  int retries = 100 * 100 * 100 / (ack_prob * data_prob) - 100;
-  unsigned low_usecs = calc_usecs_wifi_packet(1500, data_rate, retries/100);
-  unsigned high_usecs = calc_usecs_wifi_packet(1500, data_rate, (retries/100) + 1);
-
-  unsigned diff = retries % 100;
-  unsigned average = (diff * high_usecs + (100 - diff) * low_usecs) / 100;
-  return average;
-
-}
-
-class ETTStat;
-
 class SR2TXCountMetric : public SR2LinkMetric {
   
 public:
@@ -47,20 +26,13 @@
   const char *class_name() const { return "SR2TXCountMetric"; }
   const char *processing() const { return AGNOSTIC; }
 
-  int configure(Vector<String> &, ErrorHandler *);
-
   void *cast(const char *);
 
-  static String read_stats(Element *xf, void *);
-
   void update_link(IPAddress from, IPAddress to, 
 		   Vector<SR2RateSize> rs, 
 		   Vector<int> fwd, Vector<int> rev, 
 		   uint32_t seq);
 
-private:
-  class LinkTable *_link_table;
-
 };
 
 CLICK_ENDDECLS


More information about the click mailing list