Re: Is 1111 1110 10 equal to 0xfe80 or 0x3fa?

Karl Auer <kauer@biplane.com.au> Fri, 07 June 2019 06:53 UTC

Return-Path: <kauer@biplane.com.au>
X-Original-To: ipv6@ietfa.amsl.com
Delivered-To: ipv6@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id B044C120098 for <ipv6@ietfa.amsl.com>; Thu, 6 Jun 2019 23:53:48 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.409
X-Spam-Level:
X-Spam-Status: No, score=-1.409 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HELO_DYNAMIC_DHCP=0.206, RCVD_IN_DNSWL_LOW=-0.7, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id afxZxUc1753X for <ipv6@ietfa.amsl.com>; Thu, 6 Jun 2019 23:53:46 -0700 (PDT)
Received: from ipmailnode02.adl6.internode.on.net (ipmailnode02.adl6.internode.on.net [150.101.137.148]) by ietfa.amsl.com (Postfix) with ESMTP id 1DC8712008F for <ipv6@ietf.org>; Thu, 6 Jun 2019 23:53:45 -0700 (PDT)
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A2DR/QCO3/JbAKElwzFihQEFaxKDWEeId5kkjTY4AREBhCgDAQEBAoNsIzgSBAIEAhABAQEyUIU9AQUjDwEjMwgDGAICKjkeBoM1ggCnSIEvhUGEW4ELixGBQD+DdS6KWZ9xCX+QQIIkjlmPf4l0IIFWMxoIFxmUEzCBUAgTjSEBAQ
X-IronPort-SPAM: SPAM
Received: from pa49-195-37-161.pa.nsw.optusnet.com.au (HELO kt) ([49.195.37.161]) by ipmail02.adl6.internode.on.net with ESMTP; 07 Jun 2019 16:23:42 +0930
Message-ID: <1559890421.8612.53.camel@biplane.com.au>
Subject: Re: Is 1111 1110 10 equal to 0xfe80 or 0x3fa?
From: Karl Auer <kauer@biplane.com.au>
To: IPv6 <ipv6@ietf.org>
Date: Fri, 07 Jun 2019 16:53:41 +1000
In-Reply-To: <6c8190be-32f3-46f1-9a2e-35035a6fa453@gmail.com>
References: <a71b00b7-0e0c-242a-b3f7-147f4c6b2eb0@gmail.com> <63DC2EEC-C456-4090-9242-6675F47B6351@gmail.com> <6c8190be-32f3-46f1-9a2e-35035a6fa453@gmail.com>
Content-Type: text/plain; charset="UTF-8"
X-Mailer: Evolution 3.18.5.2-0ubuntu3.2
Mime-Version: 1.0
Content-Transfer-Encoding: 8bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/ipv6/C7HmysgSW6f1hU9h2LSNeSafFeY>
X-BeenThere: ipv6@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "IPv6 Maintenance Working Group \(6man\)" <ipv6.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/ipv6>, <mailto:ipv6-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/ipv6/>
List-Post: <mailto:ipv6@ietf.org>
List-Help: <mailto:ipv6-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/ipv6>, <mailto:ipv6-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 07 Jun 2019 06:53:49 -0000

On Fri, 2019-06-07 at 08:16 +0200, Alexandre Petrescu wrote:
> So I dont know how to write 1111 1110 10 in hexa.  I will look
> further.

As long as you look at that bit sequence in isolation, rather than
seeing it as the beginning of a 128-bit sequence, you will keep having
the same problem. If you just want to represent the bit pattern
1111111010, then 0x3fa is fine. But if it is an IPv6 prefix, there are
rules and a standardised notation. If you are trying to represent an
IPv6 prefix you need to you need to add in the rest of the 128 binary
digits before compressing it into hexadecimal.

We have a notation for "the rest of the digits", it is "::". But the
notation also requires implicit or explicit zero padding to make up
complete sets of sixteen bits where those bits are between two colons
or between a colon and either end of the entire sequence. If the
padding is omitted, then leading zeros are implied for any value less
than 0x8000. If right-hand padding is needed you need to make it
explicit.

3fa::/10 would only be correct if the bit pattern was 0000001111111010,
i.e. if there were six actual zero bits at the start of the sequence.

1111111010 is only ten bits, so must be explicitly right-hand padded to
sixteen bits (1111111010000000), then get converted into hex (FE80),
then get "::" tacked on the end to represent the remaining zeros
(FE80::) then get a prefix length to show how many bits from the left
are significant (in this case 10, so FE80::/10).

Regards, K.


-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer@biplane.com.au)
http://www.biplane.com.au/kauer
http://twitter.com/kauer389

GPG fingerprint: 8D08 9CAA 649A AFEF E862 062A 2E97 42D4 A2A0 616D
Old fingerprint: A0CD 28F0 10BE FC21 C57C 67C1 19A6 83A4 9B0B 1D75