svn commit: r195161 - projects/mesh11s/sys/net80211

Rui Paulo rpaulo at FreeBSD.org
Mon Jun 29 16:35:00 UTC 2009


Author: rpaulo
Date: Mon Jun 29 16:34:59 2009
New Revision: 195161
URL: http://svn.freebsd.org/changeset/base/195161

Log:
  Finish the airtime link calculation algorithm now that I know how do it.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  projects/mesh11s/sys/net80211/ieee80211_mesh.c

Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_mesh.c	Mon Jun 29 16:15:26 2009	(r195160)
+++ projects/mesh11s/sys/net80211/ieee80211_mesh.c	Mon Jun 29 16:34:59 2009	(r195161)
@@ -1567,25 +1567,42 @@ ieee80211_add_meshpeer(uint8_t *frm, uin
  *
  * Based on D3.0.
  */
+/*
+ * Max 802.11s overhead.
+ */
+#define IEEE80211_MESH_MAXOVERHEAD \
+        (sizeof(struct ieee80211_qosframe_addr4) \
+	 + sizeof(struct ieee80211_meshcntl_ae11) \
+         + sizeof(struct llc) \
+         + IEEE80211_ADDR_LEN \
+         + IEEE80211_WEP_IVLEN \
+         + IEEE80211_WEP_KIDLEN \
+         + IEEE80211_WEP_CRCLEN \
+         + IEEE80211_WEP_MICLEN \
+         + IEEE80211_CRC_LEN)
 uint32_t
 ieee80211_airtime_calc(struct ieee80211_node *ni)
 {
 #define M_BITS 8
 #define S_FACTOR (2 * M_BITS)
-	uint64_t res;
-	uint32_t overhead, rate, errrate;
+	struct ieee80211com *ic = ni->ni_ic;
+	struct ifnet *ifp = ni->ni_vap->iv_ifp;
 	const static int nbits = 8192 << M_BITS;
+	uint32_t overhead, rate, errrate;
+	uint64_t res;
 
-	/* Channel access overhead */
-	overhead = 123 << M_BITS; /* XXX */
-	/* In Mbps */
+	/* Time to transmit a frame */
 	rate = ni->ni_txrate;
-	/* In percentage */
-	errrate = (10 << M_BITS) / 100;
+	overhead = ieee80211_compute_duration(ic->ic_rt,
+	    ifp->if_mtu + IEEE80211_MESH_MAXOVERHEAD, rate, 0) << M_BITS;
+	/* Error rate in percentage */
+	/* XXX assuming small failures are ok */
+	errrate = (((ifp->if_oerrors +
+	    ifp->if_ierrors) / 100) << M_BITS) / 100;
 	res = (overhead + (nbits / rate)) *
 	    ((1 << S_FACTOR) / ((1 << M_BITS) - errrate));
 
-	return (uint32_t) (res >> S_FACTOR);
+	return (uint32_t)(res >> S_FACTOR);
 #undef M_BITS
 #undef S_FACTOR
 }


More information about the svn-src-projects mailing list