Ubuntu

Ifconfig uses inconsistent units

Reported by Kasper Meerts on 2008-06-14
18
Affects Status Importance Assigned to Milestone
net-tools (Debian)
New
Unknown
net-tools (Fedora)
Fix Released
Unknown
net-tools (Ubuntu)
Low
Unassigned
Intrepid
Low
Unassigned

Bug Description

Binary package hint: net-tools

The manpage of ifconfig clearly states:

       Since net-tools 1.60-4 ifconfig is printing byte counters and human
       readable counters with IEC 60027-2 units. So 1 KiB are 2^10 byte. Note,
       the numbers are truncated to one decimal (which can by quite a large
       error if you consider 0.1 PiB is 112.589.990.684.262 bytes :)

Still, my current ifconfig gives me:

wlan0 Link encap:Ethernet HWaddr 00:08:d3:05:23:0c
          inet addr:172.19.3.3 Bcast:172.19.255.255 Mask:255.255.0.0
          inet6 addr: fe80::208:d3ff:fe05:230c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:2592640 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2322789 errors:998 dropped:998 overruns:0 carrier:0
          collisions:105271 txqueuelen:1000
          RX bytes:2617519809 (2.4 GB) TX bytes:969817396 (924.8 MB)
          Interrupt:17 Base address:0x8000

2617519809 bytes means 2.6 GB or 2.4 GiB. But 2.4 GB is completely incorrect.
Either fix the package or fix the man-page. I included a patch that should give correct behavior.

Binary package hint: net-tools

The manpage of ifconfig clearly states:

       Since net-tools 1.60-4 ifconfig is printing byte counters and human
       readable counters with IEC 60027-2 units. So 1 KiB are 2^10 byte. Note,
       the numbers are truncated to one decimal (which can by quite a large
       error if you consider 0.1 PiB is 112.589.990.684.262 bytes :)

Still, my current ifconfig gives me:

wlan0 Link encap:Ethernet HWaddr 00:08:d3:05:23:0c
          inet addr:172.19.3.3 Bcast:172.19.255.255 Mask:255.255.0.0
          inet6 addr: fe80::208:d3ff:fe05:230c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:2592640 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2322789 errors:998 dropped:998 overruns:0 carrier:0
          collisions:105271 txqueuelen:1000
          RX bytes:2617519809 (2.4 GB) TX bytes:969817396 (924.8 MB)
          Interrupt:17 Base address:0x8000

2617519809 bytes means 2.6 GB or 2.4 GiB. But 2.4 GB is completely incorrect.
Either fix the package or fix the man-page. I included a patch that should give correct behavior.

Eternal shame is mine. This is a correcter patch.

Changed in net-tools:
status: New → Confirmed
Brian Murray (brian-murray) wrote :

I think the more correct thing to do is change how units are display in ifconfig output from GB to GiB, rather than changing how the math is done. I found a corresponding upstream bug report with a patch for this and will add a bug watch for it.

Changed in net-tools:
importance: Undecided → Low
Changed in net-tools:
status: Unknown → New
Changed in net-tools:
status: Unknown → Fix Released

Our policy is to use the most appropriate unit that might be expected.

For disk sizes and partitioning, we use thousands of bytes since that is what disk manufacturers use. This means that a drive that is termed by the manufacturer as 80 GB will be shown as 80 GB.

For memory sizes and RAM, we use multiples of 1,024 bytes, since that is what RAM manufacturers use. This means that a computer with 2 GB of RAM will be shown as 2 GB.

Since ifconfig deals with bytes streamed, you can arguably claim it should be multiples of 1,024 or multiples of 1,000. Someone just needs to decide.

I would argue that we should use 1,024 since that is congruous with the power-of-2 relationship between Bytes and bits (and Bytes-per-second and bits-per-second). But I'm willing to debate that with someone with a better argument.

We absolutely _do_not_ use the "KiB", "MiB" or "GiB" forms anywhere! These should never be displayed, they are wrong for many reasons[0], have never been adopted outside of the pedant community, and simply confuse users.

Colin next to me pointed out we should find out what the actual speeds of things like 802.3 (ethernet), 802.11 (wifi), DSL, etc. are quoted in. Is a 100 Mb/s LAN 100,000,000 b/s or 104,857,600 b/s? If someone can provide a cited reference to the specification, we'll know what unit to use for ifconfig.

Neal McBurnett (nealmcb) wrote :

I vote for using standards consistently and logically. Doing otherwise leads to ongoing confusion. Haven't we learned, and championed, this message over and over in the past?

Marketing materials and even usage in standards will vary by country, culture, time and market niche. Basing technical specs on such ephemeral things will ensure confusion, since our users will run into different combinations of the above than whatever the developers use to make a decision.

Reporting quantities using different units, labelled the same, for different media for for size vs bandwidth is terribly confusing and broken, since it means normal arithmetic doesn't work. How . This will get worse over time as Moore's law widens the gap between decimal multiples and binary multiples for systems of a given cost.

Users will encounter a discrepancy between a quoted size on a box vs a number that shows up via ifconfig only once, but if we use "Giga" inconsistently, they will have to deal with figuring out how to correct for those internal inconsistencies every time they use their system.

If we choose to report in binary multiples because that is what people will see on boxex, I support simply using international standard SI prefixes for binary multiples, as documented at

  http://physics.nist.gov/cuu/Units/binary.html

Who really cares that it isn't usually interesting to divide a byte by 10? It doesn't usually make much sense to divide a bit by 10 either....

Please move towards increasing consistency in units.

Why do you think using WRONG units will decrease confusion. That's about as paradoxical as it gets. Standards were instituted for a reason. Is this not what we blame Microsoft always for?
It's this that is making me confused. If I see MB I don't know whether it means a million or a million 48 thousand bytes.
For downloads or files in the order of gigabytes, this difference MATTERS.

Neal McBurnett (nealmcb) wrote :

Bandwidth is generally measured using decimal multiples. 100 Mb/sec Ethernet is 100,000,000 bits/sec, and a 128 kbit/s MP3 stream consumes 128,000 bits per second.

IEEE, ISO, IEC, NIST and CENELEC all deprecate the use of SI units for other than powers of 10, and endorse binary prefixes like GiB. The main ongoing exception seems to be the JEDEC (for RAM, etc, which is typically built based on powers of two), though they note that ‘IEEE/ASTM SI 10-1997 states “This practice frequently leads to confusion and is deprecated.”

See http://en.wikipedia.org/wiki/Binary_prefix#Adoption for a list of 34 applications that are said to use the IEC standard binary multiple prefixes, and for lots more history and references on this.

Neal McBurnett (nealmcb) wrote :

I agree that a good citation on the units used for of datacom like ethernet would be useful. A bit of poking thru
 http://standards.ieee.org/getieee802/download/802.3-2005_section1.pdf

shows lots of references to things like "100 Mb/s" and "1000 Mb/s" but I haven't found a totally clear statement clarifying that they mean SI Mega = 10^6 when they say "M". This ongoing discussion of using "M" to mean 2^20 is the only thing that gives me pause.

But wikipedia, which cites the spec above, is quite clear that these are all real traditional SI powers of 10:

 http://en.wikipedia.org/wiki/Bit_rate

 When describing bitrates, binary prefixes have almost never been used and SI prefixes are almost always used with the standard, decimal meanings, not the old computer-oriented binary meanings. Binary usage may occasionally be seen when the unit is the byte/s, and is not typical for telecommunication links. Sometimes it is necessary to seek clarification of the units used in a particular context.

That all leads me to wonder why anyone would ever have divided by anything other than a power of 10 in ifconfig. I agree with Alan Cox (in the Redhat bug at https://bugzilla.redhat.com/show_bug.cgi?id=118006#c4 ) that we should just be using traditional SI units and dividing by 10^6, and update the man page at the same time.

ifstat labels bandwidth as KB/s, and iptraf labels it as kbits/s, but I haven't figured out an easy way to find out what they are really dividing by, and haven't checked the code.

At any rate, diverging from Debian just by calling "MiB" "MB" instead seems the worst of all worlds.

Neal McBurnett (nealmcb) wrote :

See the original change to ifconfig in Ubuntu for gutsy at https://bugs.edge.launchpad.net/ubuntu/+source/net-tools/+bug/119998 That was was a request to change to reporting by decimal multiples, but ended up just changing the names of the units from e.g. GiB to GB.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package net-tools - 1.60-19ubuntu2

---------------
net-tools (1.60-19ubuntu2) intrepid; urgency=low

  * Change units to be multiples of 10, there is compelling argument that
    this is better for transfer speeds and bandwidths. Remove mention of
    IEC 60027-2 units from the manpage. LP: #240073.

 -- Scott James Remnant <email address hidden> Thu, 17 Jul 2008 09:42:07 +0100

Changed in net-tools:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Related blueprints

Remote bug watches

Bug watches keep track of this bug in other bug trackers.