Ifconfig uses inconsistent units

Bug #240073 reported by Kasper Meerts
18
Affects Status Importance Assigned to Milestone
net-tools (Debian)
Fix Released
Unknown
net-tools (Fedora)
Fix Released
Medium
net-tools (Ubuntu)
Fix Released
Low
Unassigned
Intrepid
Fix Released
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.

Revision history for this message
In , Petri (petri-redhat-bugs) wrote :

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6)
Gecko/20040122 Debian/1.6-1

Description of problem:
eth0 Link encap:Ethernet HWaddr 00:02:B3:63:DA:BE
          inet addr:80.222.51.178 Bcast:80.222.63.255 Mask:255.255.240.0
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:4643429 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4407272 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:463857499 (442.3 Mb) TX bytes:2823718271 (2692.9 Mb)

I think Mb (megabit = 1,000,000 bits) should be MiB (megabyte =
1,048,576 bytes).

Version-Release number of selected component (if applicable):
net-tools-1.60-22

How reproducible:
Always

Steps to Reproduce:
1. Use calculator: 2823718271 / 1024 / 1024 = 2692,90759182... MiB.
   1048576 * 2692,90759182 = 2823718271,00024832

Additional info:

Revision history for this message
In , Juha (juha-redhat-bugs) wrote :

debian uses [KMG]iB

eth0 Link encap:Ethernet HWaddr 00:50:04:6A:F7:3C
          inet addr:10.0.0.10 Bcast:10.0.0.255 Mask:255.255.255.0
          inet6 addr: fe80::250:4ff:fe6a:f73c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:2478006 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2866712 errors:0 dropped:0 overruns:0 carrier:0
          collisions:1706 txqueuelen:1000
          RX bytes:795139352 (758.3 MiB) TX bytes:3036864587 (2.8 GiB)

Revision history for this message
In , Petri (petri-redhat-bugs) wrote :

man 7 units

Revision history for this message
In , Tom (tom-redhat-bugs) wrote :

Created attachment 98528
Fix units to be SI standard

This fixes the unit issues, and adds support for units from KiB to EiB.

Revision history for this message
In , Alan (alan-redhat-bugs) wrote :

KiB and MiB are geekspeek, it would IMHO be far better simply to
divide by 1000, 1000000 et and use KB MB. MiB etc are also don't seem
to be SI approved units but a proposal.

Revision history for this message
In , Radek (radek-redhat-bugs) wrote :

Tom's patch is applied to net-tools-1.60-33. I agree with Alan that
"i" units are quite strange, but according to SI and that some other
free software started to using them I've included this patch.

Revision history for this message
In , David (david-redhat-bugs) wrote :

To correct the misinformation in comment #4 above:

The prefixes for binary multiples are not just 'geekspeek', and neither are they
merely 'a proposal'. They have been an IEC standard since 1998.

See http://physics.nist.gov/cuu/Units/binary.html for further background.

Revision history for this message
Kasper Meerts (kasperm-deactivatedaccount) wrote : Ifconfig uses incorrect units

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.

Revision history for this message
Kasper Meerts (kasperm-deactivatedaccount) wrote :
Revision history for this message
Kasper Meerts (kasperm-deactivatedaccount) wrote :

Eternal shame is mine. This is a correcter patch.

Changed in net-tools:
status: New → Confirmed
Revision history for this message
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
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

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.

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

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.

Revision history for this message
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.

Revision history for this message
Kasper Meerts (kasperm-deactivatedaccount) wrote :

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.

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
In , Alexander (alexander-redhat-bugs) wrote :

some more information:

The SI prefixes should only be used in the decimal sense: kilobyte and megabyte denote one thousand bytes and one million bytes respectively, while kibibyte and mebibyte denote 1024 bytes and 1,048,576 bytes respectively. This recommendation has been adopted by SI, IEEE, CIPM, NIST, ISO/IEC and some other leading national and international standards, which now state that the prefixes k, M and G should always refer to powers of ten, even in the context of information technology.
(reference: ISO/IEC IEC 80000-13:2008 )

reduced timeline:
1998:
IEC introduces unambigous prefixes for binary multiples (KiB, MiB, GiB etc.), reserving kB, MB, GB and so on for their decimal sense.

2005:
IEC prefixes are adopted by the IEEE after a two-year trial period.

2008:
NIST guidelines require use of IEC prefixes KiB, MiB ... (and not kB, MB) for binary byte multiples

“The names and symbols for the prefixes corresponding to 2 10 , 2 20 , 2 30 , 2 40 , 2 50 , and 2 60 are, respectively: kibi, Ki; mebi, Mi; gibi, Gi; tebi, Ti; pebi, Pi; and exbi, Ei. Thus, for example, one kibibyte would be written: 1 KiB = 2 10 B = 1024 B, where B denotes a byte.
Although these prefixes are not part of the SI, they should be used in the field of information technology to avoid the incorrect usage of the SI prefixes.”

also remember this:
decimal value binary value difference
1000^1 = 10^3 1024^1 = 2^10 2.4%
1000^2 = 10^6 1024^2 = 2^20 4.9%
1000^3 = 10^9 1024^3 = 2^30 7.4%
1000^4 = 10^12 1024^4 = 2^40 10.0%
1000^5 = 10^15 1024^5 = 2^50 12.6%
1000^6 = 10^18 1024^6 = 2^60 15.3%
1000^7 = 10^21 1024^7 = 2^70 18.1%
1000^8 = 10^24 1024^8 = 2^80 20.9%

also, this has a usability impact, since using the same wording with two different meanings is JUST PLAIN WRONG, and should end RIGHT NOW,
Regular users don't know that the units have dual meanings, and we shouldn't continue confusing them in this way.

Changed in net-tools (Debian):
status: New → Fix Released
Changed in net-tools (Fedora):
importance: Unknown → Medium
To post a comment you must log in.
This report contains Public information  
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.