[tor-bugs] #12752 [Stem]: stem: Microdescript bandwidth considered unmeasured by default

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Jul 31 12:21:47 UTC 2014


#12752: stem: Microdescript bandwidth considered unmeasured by default
--------------------+------------------------
 Reporter:  asn     |          Owner:  atagar
     Type:  defect  |         Status:  new
 Priority:  normal  |      Milestone:
Component:  Stem    |        Version:
 Keywords:          |  Actual Points:
Parent ID:          |         Points:
--------------------+------------------------
 Reading
 https://stem.torproject.org/api/descriptor/router_status_entry.html#stem.descriptor.router_status_entry.RouterStatusEntryMicroV3
 gave me the impression that `measured` would contain the bandwidth
 referenced in microdescriptor consensuses (since AFAIK the bandwidth in
 consensuses is '''measured'''), however it seems that stem puts the
 bandwidth in `bandwidth` (considering it unmeasured):

 The code of stem is here:
 {{{
     if w_key == "Bandwidth":
       if not (w_value and w_value.isdigit()):
         if not validate:
           return

         raise ValueError("%s 'Bandwidth=' entry needs to have a numeric
 value: w %s" % (desc._name(), value))

       desc.bandwidth = int(w_value)
     elif w_key == "Measured":
       if not (w_value and w_value.isdigit()):
         if not validate:
           return

         raise ValueError("%s 'Measured=' entry needs to have a numeric
 value: w %s" % (desc._name(), value))

       desc.measured = int(w_value)
     elif w_key == "Unmeasured":
       if validate and w_value != "1":
         raise ValueError("%s 'Unmeasured=' should only have the value of
 '1': w %s" % (desc._name(), value))

       desc.is_unmeasured = True
     else:
       desc.unrecognized_bandwidth_entries.append(w_entry)
 }}}

 which basically saves stuff to `bandwidth` except if an explicit
 `Measured` appears which makes it save to `measured`. OTOH, Tor assumes
 measured by default, and only adds the `Unmeasured` string if it's not:
 {{{
       /*     Now the weight line. */
       if (rs_out.has_bandwidth) {
         int unmeasured = rs_out.bw_is_unmeasured &&
           consensus_method >= MIN_METHOD_TO_CLIP_UNMEASURED_BW;
         smartlist_add_asprintf(chunks, "w Bandwidth=%d%s\n",
                                rs_out.bandwidth_kb,
                                unmeasured?" Unmeasured=1":"");
       }
 }}}

 I think the correct fix here is to assume that microdedescriptor bandwidth
 is `measured`, except if the `Unmeasured=1` string is present.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/12752>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list