Subject: Re: iSCSI: 12-97 Bit Rule

From: Luben Tuikov <[email-masked]>
Date: Thu, 13 Jun 2002 18:57:46 -0400

[email-masked] wrote:
> 
> The meaning of bit numbers 0 through 7 is clear and explicit in this
> document. Both the information in 1.3 and the diagrams Chapter 9 make it
> clear that iSCSI normally uses bit 0 as the most significant bit of a byte.
> This is also the general IETF convention.

Uuuuh, I know all this Pat, why do you waste bandwidth?

BTW, this is NOT what you were saying in your other emails.
 
> I know that some of us find the alternate numbering more logical, but we are
> bound by IETF conventions.

We, in general are bound by many things, e.g. gravity.

This is why I tried to put forward an explanation of the
computation steps which are not bound by the conventions used,
but set forth their own ordering, and numbering, so as much
as you can take it out of context and it would still work!
 
> The draft is now consistant and unambiguous.

Are you sure Pat?

This is a big matso ball out there to make a statement like
this and tomorrow post a message saying that something somewhere
is ``unclear''.

Pat, you should stick with your story, and not change it on a daily
basis, like yesterday saying that ``bit rule is this and that'', and
``the CRC is this and that'', and today saying that ``everything is fine''.

Less politics, more constructive algorithms. (you can quote me on this)

-- 
Luben

---

From: [email-masked]
Date: Thu, 13 Jun 2002 16:44:43 -0600

Luben,

Pat

-----Original Message-----
From: Luben Tuikov [mailto:[email-masked]]
Sent: Thursday, June 13, 2002 11:15 AM
To: Julian Satran
Cc: iSCSI
Subject: Re: iSCSI: 12-97 Bit Rule

Julian Satran wrote:
> 
> I took out completely the bit rule.
> I reformulated the CRC text as:
>
> The CRC MUST be calculated by a method that produces the same results as
the following process:
> 
>  - The PDU bits are considered as the coefficients of a polyno-mial M(x)
of degree n-1; bit 7 of
> the lowest numbered byte is considered the most significant bit (x^n-1),
followed by bit 6 of the
> lowest numbered byte and through bit 0 of the high-est numbered byte
(x^0).

This description, taken by itself, as you quote it here,
mentions bit 7 of a byte. Normally, bit 7 of a byte is
the Most Significant bit (MSb).

But somewhere you MUST mention that bit 7 is, contrary to all
intuition, the LSb, NOT, as many of us would assume, the MSb.
(I.e. the _bit_ ordering as per the PDU template doesn't
imply bit significance, or does it?)

I.e. you need to mention that the bytes are mirrored.

Here it is, again:

1) The bytes of the message form a bit stream, ordered
   Most Significant Byte (MSB), Most Significant bit (MSb)
   in memory, i.e. Big endian on bytes, Big endian on bits.
   Call this bit stream P.

2) The bytes of P are mirrored, thus forming byte 0, LSb
   first to MSb, then byte 1, LSb first to MSb, etc,
   (Big endian on Bytes, Little endian on bits), this forms the
   bit sequence A = {a_0, a_1, ..., a_(n-1)}.

3) The first 32 bits of A are complemented (a_0 to a_31).

4) The bits of A are considered coefficients of M(x),
   where M(x) = a_0 x^(n-1) + ... + a_(n-1) x^0.

5) The polynomial M(x) is multiplied by x^32, then divided by G(x),
   where G(x) is the polynomial representation of 0x11edc6f41.
   This produces a remainder R(x) of degree <= 31.

6) The coefficients of R(x) are considered a 32 bit sequence,
   R(x) = r_31 x^31 + ... + r_0 x^0.

7) R(x) is complemented and mirrored, the result is CRC(x).

8) The message sent is P and appended at the end are the
   bit coefficients of CRC(x), with x^31 bit coefficient
   first, then x^30, etc.

9) A receiver of a "good" message sent as per step (8),
   will get the value 0x1c2d19ed as R(x) (steps (1) to (6)).

Note that CRC(x) is a polynomial and independent of
the machine's representation.

For clarity, I've omitted the fact that x^0 = 1.

So, steps 1 to 6 form ``R(x) = compute_crc(P)'',
and steps 7 to 8 form ``Send_This = inject_crc(P, R(x))''.

I.e. ``Magic_Value = compute_crc(inject_crc(P, compute_crc(P)))''

Thus, one sends ``inject_crc(P, compute_crc(P))'',
and the receiver does ``Magic_Value =?= compute_crc(message_received)'',
which is step 9.

-- 
Luben