Article View: news.software.nntp
Article #63858Re: xBin Message-ID convention
From: Kjetil Torgrim Homme
Date: Wed, 05 Feb 2003 01:22
Date: Wed, 05 Feb 2003 01:22
277 lines
11464 bytes
11464 bytes
updated version. lots of edits, main one is removing the file set
concept.
====
xBin is a method for identifying and verifying files over Usenet. it
is especially useful for files larger than approx. 200 kB which
typically need to be split across several news articles, and
reassembled into one file by the reader of the newsgroup. the
integrity of an individual part can be proven by including a header
called Content-SHA1-Tree[TBD], which is described elsewhere. the
algorithm in Content-SHA1-Tree produces a 160-bit hash of the data in
the file which uniquely identifies its contents. the chance of two
files having the same hash but different content is infinitesimal: if
every person on Earth each owns 150 million million files which are
different from everyone else's files, there is a 50% chance of two
files, worldwide, having the same hash. this 160-bit identifying hash
is called the root hash.
in order to recognise which articles constitute parts of the file,
news reading software (from now on "reader" for short) has
traditionally looked at the Subject for substrings like "(3/9)", which
means part 3 in a sequence of 9. this is however prone to mistakes,
and the reader must filter out dataless replies or bogus data posted
to sabotage. furthermore, if someone posts the same file, but using a
different descriptive text in the Subject, the reader will not know
that it is the same file. if it knew, it could ignore it if the file
was completely downloaded, or take advantage of the data if it was
only partially downloaded.
xBin uses the root hash as an identifier which is put in the
Message-ID, a header which is efficiently available for the reader
from any news server. the root hash is a global identifier which is
constant regardless of who posts the file, and so the problems with
parsing Subject noted above go away.
in addition to the root hash, information on total size, offset into
the file and more is put into the msgid (the value of Message-ID) for
easy filtering by the reader or news server.
an xBin msgid is identified by a LHS (Left Hand Side of the @-sign)
containing the magic string "~XB", a number of parameters, and
terminated by the string "~~". there can only be one such xBin string
in a msgid, but arbitrary text either before or after the string is
allowed. it is highly recommended that the news posting software
("poster") includes random text outside the xBin string to make the
msgid unguessable. 18 bits or more of randomness, ie. at least three
BASE64 digits, would be suitable. each msgid should have a different
random component.
each parameter is on the form "~C" followed by a value, where C is
some character identifying the parameter. the parameters are:
H hash, the 72 most significant bits of the root hash. the type is
data. this parameter is mandatory.
S total size, the complete size of the file in octets. the type is
integer. this parameter is mandatory.
o offset, the first block of this fragment is OFFSET number of
blocks into the complete file. the type is integer. this
parameter defaults to 0.
s part size, the size of this fragment in blocks. the type is
integer. this parameter defaults to total size minus offset
(ie., the last fragment can and should leave this parameter out).
P parity file number. the type is integer. this parameter is
mandatory for parity files.
N parity fragment coverage. how many fragments the parity
information contains redundancy information for. the type is
integer. this parameter defaults to 100[TBD] or the number of
remaining fragments, whichever is smaller.
T type of file. the type is string. this parameter defaults to
"data".
datatypes
=========
data
----
the data type is coded using BASE64. if the number of octets is not a
multiple of three, the data will be padded using '=' as is normal for
BASE64 coding.
integer
-------
the integer values are coded as big-endians in base 64, using the
digit enumeration from BASE64. examples:
0 is encoded as "A"
4711 is encoded as "BJn"
("B" == 1, "J" == 9, "n" == 39, and 1*64*64 + 9*64 + 39 == 4711)
an xBin implementation MUST be able to encode and/or decode large
integers, ie. at least 63 bit values.
string
------
a string can contain characters from the set of allowable characters
in the base64 encoding, that is alphanumerics, plus and slash.
parity files
============
[more text needed. why S is mandatory and the slight change in
meaning for s and o must be explained.]
file types
==========
[enumerate possible values. point to definition of set files.]
other headers
=============
xBin posters should put all meta-data about the files in suitable
headers.
filename (mandatory):
Content-Disposition: attachment; filename="somefile.mp3"
filetype (optional):
Content-Type: audio/mpeg
these are MIME headers, but the article should not declare
"MIME-Version: 1.0" unless it is a well formed MIME document.
size of parts
=============
to ensure smooth propagation of all the parts of a file, the parts
should be as similar as possible in size.
many servers will transmit small articles faster than large articles,
and this can cause the last article to arrive much earlier (perhaps an
hour) than the first article. on a server with limited retention,
this may cause the last part to expire an hour or two before the
second-to-last part of the file, which is confusing to users.
even worse, some servers will drop articles larger than some size. if
the last article is much smaller than the others, it may be let
through, while all the large articles are ignored. the user will see
a newsgroup with only one part from each file: the last one. again
very confusing to users who may ask the other users of the newsgroup
for reposts to no avail.
how should the part size be calculated? the user should be allowed to
set an upper bound for the part size. this upper bound is measured
against the encoded size of the part. subtract a couple of KB for
miscellaneous headers, and use an appropriate estimate of encoding
overhead (40% for uuencode, 25% for BASE64, 3% for yEnc).
Content-SHA1-Tree requires the size of each fragment to be a complete
number of blocks (22500 octets[TBD]). only the last fragment can
contain an incomplete block.
here's some simple pseudo code to find a suitable size for each part:
file_size = <size of file>
block_size = 22500
max_part_size = 500000
raw_max_part_size = (max_part_size - 2000) * 0.75
part_size = trunc(raw_max_part_size / block_size) * block_size
# set it up so the loop condition is always true
too_much = 1
number_of_parts = 0
part_size = part_size + block_size
while (too_much > number_of_parts * block_size)
{
part_size = part_size - block_size
number_of_parts = trunc((file_size - 1) / part_size) + 1;
too_much = number_of_parts*part_size - $file_size;
}
# we now know how large the largest part will be. the last part
# will have the same number of blocks, but the last block is
# incomplete. the remainder surplus will be distributed among the
# next to last parts.
surplus_blocks = trunc((too_much-1) / block_size)
surplus_bytes = too_much - surplus_blocks*block_size
for i = 1 to (number_of_parts - surplus_blocks - 1)
print "part", i, "contains", part_size, "bytes"
for i = (number_of_parts - surplus_blocks) to (number_of_parts - 1)
print "part", i, "contains", part_size-block_size, "bytes"
print "part", number_of_parts, "contains", part_size-surplus_bytes, "bytes"
interaction with uuencode
=========================
existing decoders will depend on meta-information in Subject, and
therefore an xBin aware poster SHOULD follow existing conventions for
tagging multipart files in Subject. an xBin aware reader MUST NOT
rely on data in Subject.
the filename MUST be specified using Content-Disposition in the first
part. Content-Disposition MAY be included in other parts as well.
the filename SHOULD be the same as the filename specified in the
uuencode "begin" line.
xBin requires the size of each part except the last to be a multiple
of 22500 bytes. following the above algorithm will satisfy this
requirement.
interaction with yEnc
=====================
same issues as uuencode. an xBin reader MUST NOT rely on information
from the =ybegin line. an xBin poster MUST include valid information
in =ybegin.
interaction with MIME
=====================
the messages are constructed as usual, except for the part size
limitation. if split across several articles, message/partial MUST be
used. all the usual MIME headers are in use, and in addition
Content-SHA1-Tree MUST be included in the article headers of each
fragment. it is suggested that the xBin ID is used as the content-id.
here is an outline for how the first two articles in a series of 16
would look using MIME.
=== article 1 begins ===
From: someone@example.com
Subject: my wedding march
Newsgroups: alt.binaries.misc
Message-ID: <~XB~53F8b3f9C0/1~SVLIw~sBX5A~~hQa@example.com>
Content-SHA1-Tree: ....
MIME-Version: 1.0
Content-Type: message/partial; id="~XB~53F8b3f9C0/1~SVLIw~~@xbin";
fragment=1; total=16
Date: Sat, 25 Jan 2003 02:06:03 +0100
Content-Type: audio/mpeg
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="wedding.mp3"
data...
=== article 1 ends ===
=== article 2 begins ===
From: someone@example.com
Subject: my wedding march
Newsgroups: alt.binaries.misc
Message-ID: <~XB~53F8b3f9C0/1~SVLIw~sBX5A~oBX5A~~pI+@example.com>
References: <~XB~53F8b3f9C0/1~SVLIw~sBX5A~~hQa@example.com>
Content-SHA1-Tree: ....
MIME-Version: 1.0
Content-Type: message/partial; id="~XB~53F8b3f9C0/1~SVLIw~~@xbin";
fragment=2; total=16
Date: Sat, 25 Jan 2003 02:06:04 +0100
data...
=== article 2 ends ===
--
Kjetil T. | read and make up your own mind
| http://www.cactus48.com/truth.html
Technical Details
Message-ID:
<1rlm0vo71a.fsf@vingodur.ifi.uio.no>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!npeer.de.kpn-eurorings.net!news.csl-gmbh.net!feed.news.nacamar.de!uio.no!nntp.uio.no!ifi.uio.no!not-for-mailReferences:
<1rvg0ehvar.fsf@vingodur.ifi.uio.no>Show Full Headers
Complete Article Headers
Message-ID: <1rlm0vo71a.fsf@vingodur.ifi.uio.no> Subject: Re: xBin Message-ID convention Date: Wed, 05 Feb 2003 01:22:41 +0000 From: Kjetil Torgrim Homme <kjetilho@haey.ifi.uio.no> References: <1rvg0ehvar.fsf@vingodur.ifi.uio.no> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!npeer.de.kpn-eurorings.net!news.csl-gmbh.net!feed.news.nacamar.de!uio.no!nntp.uio.no!ifi.uio.no!not-for-mail Newsgroups: news.software.nntp Organization: Dept. of Informatics, Univ. of Oslo, Norway Lines: 276 NNTP-Posting-Host: vingodur.ifi.uio.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: maud.ifi.uio.no 1044408161 24761 129.240.68.200 (5 Feb 2003 01:22:41 GMT) X-Complaints-To: abuse@ifi.uio.no NNTP-Posting-Date: 5 Feb 2003 01:22:41 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7