Article View: news.software.nntp
Article #62586xBin and PARity files
From: Rene
Date: Mon, 30 Dec 2002 18:33
Date: Mon, 30 Dec 2002 18:33
339 lines
18045 bytes
18045 bytes
Ok finally I got some time to write down my thoughts on the RS-RAID
(ReedSolomon-RAID) System. For short, I will name it "PAR-" or
"Parity"-System throughout this article, because that's what it does, it
creates parity information which can be used to repair lost data. (A quite
detailed description of how it actually works can be found here
http://www.cs.utk.edu/~plank/plank/papers/SPE-9-97.html )
The parity system works. It is in use today on usenet. A parity file
usually starts with a base name of the file(set) it is able to repair plus
an extension of the form .Pxx, whereas xx is the number describing the
parity file, from 01 to any number up. Often you also see a ".PAR" file,
which is NOT parity information but meta-information on the parity and the
original files themselves (containing filenames/crc values)
For any missing file of the fileset, you will need one parity file to
repair the loss. It does not matter which parity file you have. If you are
missing one file of the full fileset, you can use the P01, P02 or P99'th
parity file. Every single parity file belonging to that fileset can
recreate the missing file. If you are missing two parts, you will need two
*different* parity files. Again it matters not which ones that are, but you
will need two different parity files. For three missing files, that's three
different parity files, and so on.
So the great advantage of parity files is that one single parity file can
repair user A's missing part A, user B's missing part B etc. at the same
time. Therefor, they are more powerful than simple reposts. A repost of
part A only gives the data for that part A, while a Parity file can fix any
missing gap anywhere in the fileset that is smaller or equal in size as the
parity file itself.
The disadvantage of parity files is, that they must be calculated, which
eats some cpu cycles. I deem that a minor problem nowadays. However, the
Parity algorithms used to create parity data or fix data using parity files
is not trivial. It is certainly no insurmountable problem, but it is by far
more difficult than to implement say the xBin system that we are discussing
up until now.
This means that at this point we have two options regarding xBin with
Parity:
- we declare that a xBin-compliant client software must understand and
implement the parity system. By this we make xBin better, more efficient.
However, this also raises the bar for a prospective xBin implementator
significantly. In fact, I am convinced this would turn away almost all
programmers, leading to a nice standard noone is willing to implement.
- on the other hand, for sake of simplicity, we cut out parity from xBin.
We use full reposts and that's it. Its easy to implement. However we're
letting a chance pass to fix (or at least ease a bit) one of the problems
of binary usenet.
So that's it? Either all the way or none? Fortunately no. There is a middle
way, and this is what I suggest should be done:
Let us define xBin in a way such as articles with parity files are easily
distinguishable. A xBin-compliant client then must be able to distinguish
normal articles / reposts from parity data. It further must be able to
download parity data belonging to a certain file_hash should that be
necessary. However, the client is *not* required to implement the
ReedSolomon algorithms to actually fix files or to create parity files.
That way a client could then do the following:
1. For an incomplete file for which the client sees parity data, it
calculates how many parity files are required to fix the file.
2. The client fetches the parity data and saves them as separate files to
disk (P01, P02...)
3. The client starts an external application, which will do the necessary
computations to fix the file with the parity information
4. The client checks again the hash tree. This is necessary because we
cannot guarantee the parity files to be valid (more on that later) However,
the parity data cannot destroy more, it can only "not fix" the gaps. By
recalculating the hash tree of the file, the client knows for sure if the
file now is fixed or not. If it is fixed, then the job is done. If it was
not fixed, then the client discards those parity files and looks for more
parity files and/or reposts or files a repost request.
This way is not really all that different from what we have today. An
external application which does the ReedSolomon calculations. It also
complies with the unix way of life: Do one thing and do that well. We'll
have a (from the point of view of the newsreader) external application that
makes parity files or fixes them. And we have the newsreader. No need to
teach newsreaders what ReedSolomon is. They can still do that by
themselves, if they really want though.
The "external RS-Parity applications" already exist today. And they won't
work 1:1 with xBin either, because of the meta-data (see below) but I think
it is not too difficult to adapt them to "xBin-style parity data".
It would of course be cool if we'd come up with a reference implementation
of this external application so any implementer of xBin could use the
advantage of the parity system. And guess what, with only 5 minutes spent
googling, I've found the following sourceforge project:
http://parchive.sourceforge.net/
I haven't looked at the codebase yet, but they have some extensive
documentation about the PAR-file format that is in use currently. They also
seem to have clients for those parity files for about any operating system
(including MSDOS, MacOSX and a generic "unix" command line client) At least
the unix command line client includes source code.
So, with that out of the way, there are some differences between the way
the PAR-system works today and the way how it have to be under xBin. Most
of the differences stem from the fact that with xBin, we no longer have
filesets (one file splitted) but one big file. Of course xBin does not
hinder anyone to split his files, however everything in xBin is
file-centric in the sense of the file-hash or the root-hash of the
hash-tree of a file is the one single "induction-anchor" (if you follow my
meaning) and there is no relationship what so ever between one filehash and
another.
So here's the differences, or the problems that need to be adressed:
Blocksize
=========
The PAR-system as used now works with filesets. A fileset is simply a big
file splitted into several few. A PAR-Parityfile needs to be at least as
large as the largest file in the fileset.
Now we don't split files in xBin. But we can do as if we were. All we need
to do is to define a "virtual segment size", ie a size at which we would
split a file if we were splitting it. This virtual segment size then
defines the size of all parity files.
The value of this virtual segment size can either be static in the xBin
standard (like saying "every parity file is 10MB large") or it is a dynamic
size, depending of the file size of the original file ("a parity file is
always the size of N / 1000 blocks large, whereas N is the number of blocks
of the original file")
The virtual segment size in any case must be known because not only the
originator of a post may create parity files but anyone having that file in
full. Having mixed size parity files from different people would
complicate the maths involved in calcualting and reconstructing data by a
huge amount.
As of this time's writing, I'd go with a fixed size for this virtual
segment of about 10MB. This would lead to people using normal reposts for
small files but using the par-system for larger files.
But how should a newsreader react if the virtual segments does not match
(align) with the downloaded blocks? Ie consider the following picture:
+-----+-----+-----+-----+-----+-----+-----+
| A1 | A2 | A3 | A4 | A5 | A6 | A7 | articles
o o o x x x x x x x x x o o o o o o o o o <--- xBin blocks
� f1 � f2 � f3 � virtual segments
+-------------+-------------+-------------+
This depictes a file with the blocks in the middle. An article spans 3
blocks each. Our newsreader has got articles 1, 5, 6 and 7. It is missing
the blocks within the articles 2,3 and 4 (those blocks with an "x")
Below the blocks is the virtual segment size, regarding the PAR-system. So
the Par-system looks at this as if two files (f1, f2) are missing, even
though some blocks within that virtual segment are there. A "virtual file"
is therefor only complete, if all blocks within that virtual segment are
there.
For a newsreader, it is easy to decide at any point how many parity files
it would need to complete the file using parity-data. It is the total
number of virtual segments minus the number of completely filled virtual
segments.
Next item:
Header of Parity Data
=====================
If a newsreader wants to find parity data for an xBin posting, it must have
an easy way to do so. Therefor, the parity data must be strongly tied to
the original file's file hash.
To be able to create Parity files, you need the original file, therefor you
don't have a problem obtaining that file hash. To make that parity data
"belong" to a certain file hash, that parity data must also be posted under
the same "name", so the parity data gets posted with a message-id
containing the root hash of the original file and the root hash will also
be included in the X-Bin-Signature header.
To distinguish such a parity file from a normal part of an xBin file
however, there must be some change. One way to do that is to "overflow" the
offset variable in the message-id of an xBin posting. If that offset value
is larger than the total file length, an xBin client then could tell that
this must be "additional" data, what parity data in effect really is.
Some may look at this way as a nice way to use an already existing field,
others will say that this is a blatant misuse of a field. This is up to now
only a suggestion however. We can define entirely new fields, because the
x-Bin-Signature: header of parity data will not contain any hash except the
root hash. We unfortunately cannot guarantee the integrity of PAR-files
(see below under security) but at least that leaves us plenty of space in
the x-Bin-Signature header to mark this data as parity data.
What's also important is to give the sequence number of the parity data.
Having two P01 parity files is less than having a P02 and a P05 parity
file. So there must be a way of determing which parity file it actually is.
This is also important if user A gives 4 parity files (P01 to P04) but user
B is having 6 gaps to fill. Then user B can request additional 2 parity
files, which for example user X is going to give. But user X must know that
he should create P05 and P06 and not two parity files starting from 01...
So sequence numbers for parity files must be given, both in requests for
parity files as well as in the header of the xBin-parity files so a
newsreader knows what's there.
Next item:
Metadata
========
PAR-files as used currently not only contain data to reconstruct files
within filesets, they also contain meta-data. For example, for every file
in the fileset, a hash value (md5 seemingly) is computed. Also the filename
of every file is saved together with its position within the fileset. All
this information plus the sequence number of the PAR-file itself makes up
the meta-data. This meta-data is in every PAR-file. You can test this by
downloading a fileset, then change one or several of the files. Then
download any one Parity-File and feed it to FS-Raid or whatever tool you
use. The tool is then able to tell you which file is corrupt by using that
meta-data within the parity file.
The .PAR file only contains that meta-data, no data to reconstruct file
contents. That's why it is quite small.
With xBin however, we already have hashes of blocks, we already know when a
block is valid and when not. So we don't need that data. Furthermore, the
filenames are useless, since there is only one file. Splitting /
segmentation is purely virtual, so that's further useless data.
All the meta-data one xBin-parity file needs is actually the sequence
number of the parity file itself and the hash of the original's file.
Final item:
Security
========
It has been said in the posting already that we can't secure PAR files.
Here's why: Of course we could add parity files with any posting and add
the parity's data blocks under the xBin hash tree. However this enlarges
the hash tree (more hashes!) causes pro-active sending of parity data (more
volume) and makes selective retrieval of one single parity file or so more
clumsy.
But - arguably - most important of all: It's not what parity files are for!
Parity files must be something we opt to selectively retrieve. All blocks
under a hash-tree are blocks we absolutely want. Blocks we need. But parity
data is optional. We might need some of them. We might need none of them.
Somebody might want two parity files, someother might want three.
And parity files are expandable. Someone produces 3 parity files, another
person needs five though so another person creates two additional parity
files. How would they fit under a hash tree ? How do we keep track what is
needed and what is available?
So there's no simple way to secure parity data. Everybody with the full
original file can produce parity files, so everybody can produce wrong
parity files as well. Fortunately, having wrong parity files does not cause
corruption in your incomplete xBin-file. It does not fix the missing parts,
but it cannot kill the whole file or introduce more "errors". Of course if
you have some few valid blocks within one incomplete virtual segment, those
valid blocks will get lost using fake parity data. However from the view of
the virtual segments, there is no change: You had an incomplete virtual
segment, you still have an incomplete virtual segment.
Therefor, for the secure operation of xBin with parity, an xBin compliant
newsreader MUST check the hash tree after each attempt at parity repair.
That way, problems are detected and a corruption of the file is not
possible.
And if a corruption is not possible, attackers probably don't take up the
effort to even create fake-parity data, even though they could. Its simply
not worth it. If they do that however, the newsreader can throw aways the
parity data and try again with more parity files. If the problem persists,
the newsreader can fallback to repost-requests.
The End ?
=========
Wow you've read through all this. Now since that took me more time to think
about and write and formulate it out, I'm even going to give you a little
candy:
There's an easier way than that !
All we need is to define how a single file will be splitted and use a
common nameing scheme, as well as the virtual block size.
Let a newsreader who should produce PAR files use the following system:
1. It really splits the original file into N segments, all having the size
of virtual segment size (yet to be determined). The filename of those
splits is the original filename added by a dot added by a three digit
number starting from 000: a.000, a.001 ...
2. Use an ALREADY EXISTING external application to create M parity files.
3. Delete the splitted files.
4. Post the Parity data files according to xBin rules for parity data.
A newsreader wanting to use parity files to complete a file does the
following:
1. Determine how many parity files are necessary to complete the file
2. Get those parity files
3. Split the incomplete file into parts of virtual segment size each. Rule
for nameing the files as above.
4. Use the ALREADY EXISTING external application to fix the files using
parity data.
5. Concatenate the splits back to one single file, verify tree hash.
6. If ok, delete former incomplete file -> done. If not ok, delete parity
files, delete splits. Try to get more parity data.
The advantage is: With minimal effort, parity technology can be implemented
into xBin, NOW ! No adaption of PAR-technology needed, it's already there.
The disadvantage is: Uses more diskspace because of splitting, Parity files
have more meta-data than is actually needed.
Problems: Two users having the same file may have different file names, so
if those each create some parity files, they won't be able to fix data
because their meta-data does not match. So we chose as "basefilename" for
the split files the file-hash in an appropriate encoding (base64..)
So now we're really at the end of my parity with xBin excurse. Comments?
Additions? Corrections?
I *really* vote for the inclusion of Par-technology into xBin, and into
xBin v1.0, not later.
We really only need to define a new header-set, describing PAR files and
their sequence number as well as the "virtual block size". At least, that's
what I think is needed.
Let the discussion begin.
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
Technical Details
Message-ID:
<20021230133312.202$K5@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!cyclone.bc.net!sjc70.webusenet.com!rip!news.webusenet.com!feed3.newsreader.com!newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <20021230133312.202$K5@newsreader.com> Subject: xBin and PARity files Date: Mon, 30 Dec 2002 18:33:12 +0000 From: Rene <invalid@email.addr> 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!cyclone.bc.net!sjc70.webusenet.com!rip!news.webusenet.com!feed3.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 F8LHFl7Ano5fFk3=pMv-+PH0HRe@GhQh/cGGxEK.hN9Eh=k Lines: 338