🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #62441

Re: xBin (Power-Post 2003 - requesting input from authorities..)

#62441
From: Rene
Date: Tue, 24 Dec 2002 20:10
444 lines
22921 bytes
I hope you don't mind me concatenating the different messages for the sake
of "channeling" and focusing the discussion a bit.

curt@kcwc.com (Curt Welch) wrote:
> Testing it now - it took 5.4 seconds total to read the disk blocks and do
> the calculatlions for the 50MB file (compared to the 2.5 seconds to just
> calcuate the hash when all the disk blocks were in-core).  And the system
> I'm running it on is busy being a news transit box at the same time
> moving about 40 Mbits of traffic.

Ok, a bit hard to get good data when the box is doing lots of other things.
Then again I think we can leave the optimisations for now, especially
considering you convinced me, that line limit is more important.

> Here is a run against a 2GB file that's not likely to be cached using a
> hash block size of 4096:
> 81.207u 32.254s 3:02.80 62.0%   21+42966k 32204+0io 0pf+0w
> That works out to 4.5 seconds per each 50MB.
> And another 2GB file with a block size of 4500:
> 80.720u 30.956s 2:34.85 72.1%   21+38537k 32075+0io 0pf+0w

This statistic seems to say "bigger is better".

> FileIO shows 32K read operations for both which is interesting because
> that implies the reads were 64K blocks.  I don't know what that number is
> tracking (OS reads to the disk, application reads to the disk cache, sys
> calls???)

Interesting, might be the effect of a 64K read ahead. Most likely, the
behaviour will be different for another architecture.

> included in the middle of the file, but with Usenet, you just never know.
> Multipart uuencoded posts never noramally have a part which ends with a
> shorter line. You can't help but wonder if some tool somewhere is going
> to choke if you do something non-standard like that.

Ok, lets align to that then.

> > Damn, not a bit more tired now...
> You must be excited about Christmas! :)

Cursing at my insomnia rather... :)

----- next post -----
> If the newsreader was cross checking hash tree values between articles,
> that's true.  But because of the strength of hash, it's likely that many
> tools would not bother.  To verify an article, you can simply read it
> sequentially and decode the data and verify it in one pass.  You write
> the

Yes you can do that. Since CPU time is however much more cheaper than
bandwith it makes sense to pre-compute the header data. Its cheap to get
them and as an additional bonus, the newsreader can tell its user "I
currently see X valid parts of Y".

> Well, I take that back.  If you want to re-post parts of the file before
> you download all the parts, then you do need to save the hash tree values
> from the signature as you get them from each post.  So a more powerful
> tool that allowed you to repost segments from your "partial download"
> would need to save that - and as long as you are re-constructiong the
> hash tree and saving the data as you download each article, why not
> double check it and make the job of fake a few orders of magnatude
> further past "impossible".
> :)

Yep, if you want to re-use the tree you'd need to save it. Otherwise it can
be discarded. It can be discarded once the file is complete, since with one
intact file, you can recreate the tree fully.

> > Actually, the number of hashes needed sending (as header data) is a
> > function of the number of articles using your xbin. One article at
> > least needs the hashes up the path to the root, so thats a guaranteed
> > log2(N).

> In another article, I thought the answer was log2(N)+log2(M) where N is
> the number of blocks in the complete file and M is the number of blocks
> in each article.  But that's not right because if M == N then the number
> of hashes needed is 0.  if M is N/2 and M is a power of 2, then the
> number of hashes needed for each article is 1.

It gets quite complicated when you consider trees that are non-power of
two. All I'm sure right now is, that there will be a total of 2*N - 1
different hashes in the whole tree, no matter if the tree is power-of-two
or not.

If the tree is non-power of two, then you still create a tree the size of
the next larger power-of-two value and insert some "nonexistent" nodes
there. I've yet to formalize the rules of the creation of the tree. Target
is, to be able to create exactly one, well defined tree by use of only one
parameter: "number of blocks".

Depth of the tree will be log2(N), whereas N either is already a power of
two, or is being rounded up to be one. Depth is #levels - 1, so for N =
5..8, depth will be 3, #levels will be 4. There will be 2*N - 1 nodes with
hashes in total.

> > worst case is where the blocks overlap from the left-subtree into the
> > right-subtree (ie, crosses the "middle") because if it stays in its
> > subtree, then sooner or later up the path you reach a node you already
> > have, if you pass over to the right side however, you have a full
> > sub-tree to traverse upwards.
> For a file which has a power of two number of blocks, I think you are
> right and the worse case happens when the article has 2 blocks which
> overlaps the the center of the file.

Actually thinking about it: The worstcase is one article containing all
blocks, since that article will need to contain 2*N-1 hashes. (all of them)

Probably only of interest for small number of blocks. For large number of
blocks where there are several articles, I'll stay with my assumption that
the one article spanning blocks from the left-half to the right-half will
probably have the most hashes.

> Ah, I'm beginning to see it.  This is the same problem as counting the
> number of bits turned on in a binary number.

Well, the easy way of counting bits is simply
for(size of bit-array)
 if (bit-array &0x01 == 1) then count++
 bit-array >> 1;

There are clever ways though, AFAIK.

>Ah, but it's not even that simple because that gives you the correct value
>for the left side (which starts at the beginning of the file and is
>correctly aligned with the binary tree), but the number required for the
>right side depends on the alignment of the block with the binary tree for
>the entire file.

Its not as easy predictable as I thought. Consider the following n=8 tree:

       root
     /     \
    e       f
  /  \    /  \
 a   b   c   d
/ \ / \ / \ / \
1 2 3 4 5 6 7 8

Let's say one article has number 1 and 2. Then a is already defined, so we
only need b to get e. To reach the root, we additionally require f. So an
article having 1 and 2 needs to provide the hashes b and f.

If the article carries 2 and 3 however, we need 1, 4. Then a, b and e are
defined, we further need f. So thats 1,4,f.

If the article carries 4 and 5, we need 3,6, a and d.

So an article containing 2 blocks in this tree, can have 2, 3 or 4 hash
values (plus the root-hash) in the header. Position is important and I
don't see a pattern yet.

> I think some work is required here to get a better understanding of this
> because the worse case effects the max size of the Signature header, and
> that can limit the max possible file size which can be posted using this
> system while still keeping the header length to a size which various news
> servers can correctly deal with (which I think is around 1000 bytes).

Definitly. It must be established, what is allowed in the header. Then
based on this value we can calculate how many hashes that are. Then this
number directly defines with the max-block size, how large a file may
become.

>Let see, the hash and a few spaces takes up about 30 bytes per hash so
>that gives us around 32 hash values max in one header. If 2log2(N) is the
>worse

The hash is 160 bits large, that's 20 bytes (yielding 40 chars, not 20 like
I wrote before). So we best take those 20 bytes and encode them somewhat
(you use uuencode, as I've seen) maybe we should take another encoding to
gain more space. What alphabet is allowed in the header? Could we yEnc the
20 hash bytes in the header? Or not yEnc, because yEnc rotates the
byte-value, assuming there are less "00" that way. A hash value byte though
has an equal probability on every single of the 256 values.

> That's not as high as I'd like to see.

Yep, I think 2 GB at least should be reachable.

> One option I guess is to use a larger hash block size, but doubling the
> block size only doubles the max file size, and I'd like to see something
> that would allow a file size much much larger (100 GB) for example.

100GB is a bit much, considering widespread filesystems can't handle > 2GB
properly. But they slowly become obsoleted, so probably thinking about
really large files is not too wrong.

> The larger the parts the less hash values you need, but I'm not sure how
> to calcuate that.  Maybe the answer is if want to post a 100GB file you
> have to do it with 10MB posts. :)  That's not an unresonable requirement.
> Also, if the articles each hold an even power of 2 number of hash blocks,
> that reduces the worse case problems.  So many be the answer is that for
> really large files, the posting program has to be smart to avoid a header
> overflow problem.

Yep, having a worst case number of header-hashes would really help here.
I'm thinking a bit about it.

> And manybe I'm wrong about header length probelms.  For a header which
> the news serers don't have to deal with, and which the news reader is
> only going to get by doing a HEAD command, there may not be any news
> servers which care that there is a 2K header in the artcle?  Anyone know?

Don't know, you are the server guy :) I suspect however that headers get
indexed at servers. If I issue a XHEAD command in a newsgroup with
1'000'000 articles, I really doubt the server opens every single
file/article and gathers the headers toghether. I think headers are indexed
in a special database in advance, and if so, they probably DO have a size
constraint.

> I do.  I just iddn't know SHA-1 worked with an internal block size of 64
> bytes.
> I was also fairly sure that MD5 used an internal block size which matched
> the hash size of 16 bytes, but I could be wrong about that as well.

There is no difference between MD4, MD5 and SHA-1 what regards the internal
buffer or the padding, as far as I see. No wonder, that stuff comes largely
from the very same people.

> If you care, here's a really good description of the algorithm written
> for programmers to understand (it's in PDF):
> http://www.cs.utk.edu/~plank/plank/papers/CS-96-332.html

Thanks. That really is a very straight forward explanation.

> Once you get a basic understanding of it, it's really not as complex as
> it seems at first.

I knew it was basically a matrix / equotation system that's simply
overdefined. I didn't knew how to build up the matrices or calculate within
that specific number space.

> If you have any data files missing, then what you are left with is a set
> of simultanious equations with N unknowns where N is the number of files
> you are missing.  As long as you have N or more equations (i.e. par
> files), then you can solve using substitution for the unknown variables
> (files).

Yep, its like an equation with n lines and m variables. If m > n, then you
can't solve it. If you got m = n, then it has a solution. Now you go an
create parity files such as n > m. It is now "overdefined" and you can
delete any x lines until n = m and it is still solvable.

> And the use of hash trees for this same purpose (distribution of partial
> files over an unscure medium) has been defined for use with P2P I found.
> Search for "bitprint".

Searched and found. They are using it in the new Gnutella (P2P)-Protocol.
When I was discovering edonkey2000, that wasn't there yet. So I'd say ed2k
was faster. However I have no doubt that this has been in use before that.

----- next post -----
> Like I said in my other posts, there's what looks like a standard called
> bitprint which seems like it was defined for P2P use.  I can't tell if
> any P2P system is actually using it however.  But the name no doubt comes
> from

The new Gnutella protocol seems to use them. That's some odd-numbered
different client programs.

> They are no doubt trying to create a hash so unique that you can use it
> for thousands of years for every file createad and still have the odds of
> a collsion be near 0.

A bit "over the top" if you ask me.. but they certainly aren't going to
expand it to a bigger value soon...

> > Furthermore,
> > since the system uses a URL-scheme to easily select files of interest,
> > you can simply create a link like a http-link and users of this
> > p2p-software can just click and get that file hash added to their "to
> > download list" - which is a very clever and quite comfortable way.
> For xBin on usenet, the Message-ID of any article posted under the system
> acts as a unique identifier for that file.  (uniqe to 60 bits hash+file
> length) which I believe is large enough for this purpose).

Yep, thats right. I actually became aware of that later. Though I don't
know if it suffices. If I connect to a newsserver and request a message-id
(without delivering a groupname first) does it tell me in which group the
message was?

Ah stupid me, the header of the message in question should contain that
information. Then I can select that group and skim through the message
headers to seek the other parts of that article. Yes it works perfectly
already.

> For that mater, the announcement of the post should have the same xBin
> file signature in it's Message-ID so it could act like a part 0 post
> where the part 0 post was posted to the .d group and the data was posted
> to the .x group.  So then instead of having to put the Message-ID into
> the text, the

Hm I don't know about that... the newsreader may mix up the posts and
trying to decode parts out of the announcement. IF this should be made
possible, then it should get a well defined format, so there is no mixing
up articles with xBin signatures which are only "referrers" and articles
with xBin signatures which are truely xBin articles containing blocks.

> Or, maybe the idea of posting a set of files and listing the xBin ids of
> each file in the set in one article would be good as well.  A download
> tool could then have an option to extract all the xbin IDs from the text
> of the article and add them all to it's download list.

That's not far away from my system where you post the meta-information in a
0-post.

> > Yes, and this has prooven to work out well. However, if someone posts
> > the same file again BUT applies any transformation beforehand (he rar's
> > it with a different, never version) then the file he posts is of course
> > something different (bitwise compared) and it *will* get another file
> > hash.
> And some posters don't want people to know that the same file is being
> posted again, so they won't like the file-hash idea.  But it should be
> easy for them to both use xBin and get around that by finding ways to
> make minor changes to the file.  A 1 bit change anywhere gives it a new
> file-hash.

Yep, they can just repack it with an added .nfo or whatever. Shouldn't be
automated though. Makes reposting / filling a hell.

> It was suggested that the standard should allow for a random hash to be
> made up to allow people to that did not want their reposts to be tracked
> to still label their files with xBin but to get around the "fixed ID"
> issue they didn't no like.

No that defeats the basic idea of the hash.

> I think it would be wrong to allow that.  To keep things simpler, I think
> xBin should only allow a "real" hash.  There are plenty of ways to change
> the file or post it a different format (like ziped or rared etc) that
> would prevent it from being spoted for the people that care about that.

Yes I fully agree here. IF someone wants to make a distinct post, they
still can. They just need to do it by themselves.

> If you need to build and save the entire hash tree, I did by allocationg
> binary-tree nodes on the fly.  You could also di it in an array using
> positional encoding.  Or if you were worred about how much memory might
> be

For a reference algorithm, I think really building the tree with nodes
(which have pointers left, right, parent) will be the best solution. For a
real world implementation, one should probably use an array (heapsort is
the keyword here)

The array variant will be more efficient but less clear to someone trying
to understand how it works.

> available to you, could could calcaute the hash values in-core using only
> the small array as talked about above, but the write out every hash value
> as it is calcuated to a file.  The position of each hash value could be
> found in the file later by it's position.  I'd have to think a little
> more about that, but I'm sure it would work.

Memory is nothing nowadays... Sparing 2*N-1 times 20 bytes is bearable. You
don't want to run xBin on your wristwatch with embeddedLinux though.

> The other things that is "good" for usenet that is not commonly done is
> to try and equlize the size of all the articles in one multipart post.
> Articles tend to get filtered by size, and they tend to move faster or
> slower though Usenet based on their size.  If all the articles for one
> multipart set are the same size, it imporves the odds that they will all
> make it to the same servers, at about the same time which improves the
> odds they they will expire at about the same time, and expire in the same
> order hey were posted.

Ok, I see the problem. However if an xBin encoder stuffes, say, 5 blocks
per article, since a blocklength will be fixed, all the articles should be
more or less same sized (minus the last one, which will be shorter).

Not much different to what there is today. Of course the blocksize will
define the granularity with which a newsreader or its user will be able to
vary the article size.

> Today, the last article is very often substantically smaller.  These tend
> to move faster though usenet, and tend to make it to servers that the
> large articles might be filtered from.  And because they move faster,
> they can sometimes show up first even though they were posted last.  And
> then, because they showed up first, they expire first, leaving an
> incomplete set of "large" articles on the server and leaving users
> wondering why the small articles were "lost".

Well with xBin, even that small part will have the filehash-signature and
will therefor be picked up by an interested newsreader. The good part of
the hash tree's complexity is, that you can pick up articles in any order.

> > I'm currently working on a personal Java programm that fetches news for
> > me more or less autonomously. (Don't worry Curt, I haven't let it run
> > loose on your servers yet, I'm testing it with my local leafnode
> > installation ;-) )
> No problem.  You can't really do much harm if you are aren't posting.  If
 >there's anything I can do from my side to help with our code let me know.

At the moment I don't think I will ever make it to be able to post. Its
purpose mainly is to gain some understanding of the new Java IO subsystem
:) Second it should somewhen be able to fetch headers for me and process
them to a bit more easily readable format than what BNR2 is currently
giving me.

> > IF there is a specification (you already gave about most of it I think,
> > though some questions remain) I can programm something that tries to
> > understand that format. However I gladly let anyone step forward who
> > "really really wants to do it now" (tm).
> The only spec I have right now other than these posts is the code.  But
> if this to go somewhere, I'll be happy to work on a more formal
> definition and put it on my "nothining here yet" xbin.org web site.

I think I'll be implementing the xbin-system - the decoding part either
into that project or as a stand-alone proof of concept. I've already posted
some pseudo code for that. Its far from perfect but then again there are
some questions open still.

Before I start some real coding, some things need to be defined first:
- The exact building rule for the tree
- block size
- max allowed header data (which directly corresponds to blocksize)

> Well what you have to do is logically treat the one huge file as if it
> were split up into fixed sized segemets even though it is not.  Just like
> par got built into winrar to work better, the reed solomon codeing would
> have to get built into the download and posting tools to really work
> correctly with this.

If I understand you correctly, you're saying that will create "virtual
segements" ie segments that do not really exist, because the file will be
sent as one not segmented. But for the generation of PAR files, the
newsreader/poster looks at it as if it were. Is that right?

> But 8 bit Reed-Solomon coding is limited in the number of "files" it can
> protect.  It think that number is 128 or 256.  Or maybe it's actually
> that the number of data files + the number of par files you want post has
> to <= 256??

From your posted link, the m + n values (number of segments plus all part
files ever) may not be >= 2^wordsize. Using a wordsize of 16 bits, that's
already a safe value of 65535...

So, now off to church (it's traditional :-) )
Happy chritsmas !

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Technical Details
Message-ID: <20021224151028.847$pv@newsreader.com>
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!nntp.cs.ubc.ca!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed1.newsreader.com!newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mail
References: <cdda0v4h6t52ov7abf1j0qkpo843itf4se@4ax.com> <cfka0vsbjdlbdmtv2gg8qnehok033qh5f1@4ax.com> <20021223041127.986$6M_-_@newsreader.com> <1rfzsoaacf.fsf@vingodur.ifi.uio.no> <20021223180543.105$Wn@newsreader.com> <20021223185652.700$BS@newsreader.com> <20021223203608.351$Qp@newsreader.com> <20021223223311.286$Mx@newsreader.com> <20021224034919.081$PY@newsreader.com>

Show Full Headers
Complete Article Headers
Message-ID: <20021224151028.847$pv@newsreader.com>
Subject: Re: xBin (Power-Post 2003 - requesting input from authorities..)
Date: Tue, 24 Dec 2002 20:10:28 +0000
From: Rene <invalid@email.addr>
References: <cdda0v4h6t52ov7abf1j0qkpo843itf4se@4ax.com> <cfka0vsbjdlbdmtv2gg8qnehok033qh5f1@4ax.com> <20021223041127.986$6M_-_@newsreader.com> <1rfzsoaacf.fsf@vingodur.ifi.uio.no> <20021223180543.105$Wn@newsreader.com> <20021223185652.700$BS@newsreader.com> <20021223203608.351$Qp@newsreader.com> <20021223223311.286$Mx@newsreader.com> <20021224034919.081$PY@newsreader.com>
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!nntp.cs.ubc.ca!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed1.newsreader.com!newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mail
Organization: NewsReader.Com Subscriber
Newsgroups: news.software.nntp
X-Trace: NewsReader.Com oh+k/2b_efaJebyV0VKomxQ,7i7CemE48c0RLiF_@ndbliXn
Lines: 443