Article View: news.software.readers
Article #85858Re: xnews filesize
From: Curt Welch
Date: Sun, 21 Oct 2001 20:33
Date: Sun, 21 Oct 2001 20:33
84 lines
5806 bytes
5806 bytes
rcamesz@dds.nl wrote: > Combining both line count and byte count might give more accurate > estimates. That idea entered my mind as well when responding to this thread. > If you take the average line length and round it up to the > nearest integer you'll _probably_ have the correct length of the > encoded lines. Even so, because UUENCODE has one byte extra overhead > per line compared to MIME, you can still only approximate the final > filesize to within roughly 2%, even if you estimate the line length and > the fixed overhead with absolute accuracy. If you have an accurate line count and byte count, you can probably predict with a much higher degree of accuracy whether the file was uuencoded or MIME base64 encoded. Uuencoded files always (expect for the rare special care of spammers trying to hide their spam) have exactly 61 charcters plus EOL characters. base64 encoded files probably never have 61 characters per line. If you can make an accurate estimate of the encoding used, then you can get much closer on estimating the file size. For example, one article I see has 64994 bytes and 1025 lines. The byte count includes the header, but the line count doesn't so you neen to estimate the size of the header. Average headers are about 1000 bytes. That lives 63994 estimated bytes in the body. uuencoded files end with ` on one line, and a "end" on the next. That counts for two lines and 8 bytes. They start with the "begin 644 filename", so that's one line and about 30 characters on the averge. So talking all that off of the line and byte numbers leaves us with around 1025-3 or 1022 lines, and 64994 - 8 - 30 or 64956 bytes. Looking at the ratio of those, we get 63.5 bytes per line. Which is close to the 63 we expect for a uuencoded file. And to calculate a file size from that, you would assume every 63 bytes encoded 45 bytes of file. So that's 64956 * 45 / 63 or 46397 bytes (45.3 KB). Or you could calculate it based on the lines, which would be 1022 * 45 or 45990 bytes for the file (44.9KB). The actual file in the above case was 45804 bytes or 44.7 KB. So both estimates were a bit high, but fairly accurate anyway. Looking at a mime article, the one I found was encoded with 72 characters per line. The number of lines was listed as 1518 and the bytes was 112742. Doing the same "uuencoding test" as above, 112742-1000-8-30 / 1518-3 works out to 73.7 bytes per line, which is no where near the 63 you would expect for uuencoding but very close to what you would expect for a 72 character per line (74 total) for a mime encoded article. I'm guessing 72 chracters per line is probably a very common value for mime encoded files. If you assume it's MIME base64 encoded with 72 characters per line, that would make for 54 file bytes per line, or 54/74 bytes. MIME adds a lot of extra overhead at the begining and end of each file (because most MIME articles are actually encoded as multipart/mixed so they can enclude some text as well). I don't have any numbers of how to adjust for that. But if we just ignore the overhead issue here, and instead just use the entire estimated body size of 112742-1000 or 111742 bytes, and adjust that by 54/74, that gives us an esitmated file size of 81541 bytes or (79.6 KB). Using lines of 1518 * 54 gives us 81972 (80.1 KB). The actual file was 81049 bytes (79.1 KB). If we used the uuencoding estimation algorithm on the mime file, the byte size of the file would tell us to expect about 77.9 KB file, or the line count would cause us to estimate a file of about 66.5 KB. Which are not as close a the estimates we came up when we assumed it was MIME encoded. And the MIME estiamtes would have been even better if we had tried to adjust for the "typical" MIME overhead. So it seems to me that a newsreader could use all the information it has and acutally come up with a fairly accurate estimate of the size of the file encoded in the article. Probably to within +-1 KB per article. If you were to analize a lot of articles, you could probably just do a curve fit and come up with a simple formula based on the line and byte counts to calculate the number. Actually, bytes - 2xlines * 3/4 would probably produce a number which was was more than accurate enough for an estimate. -- Curt Welch http://CurtWelch.Com/ curt@kcwc.com Webmaster for http://NewsReader.Com/
Technical Details
Message-ID:
<20011021163344.293$vH@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.readers.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!howland.erols.net!portc.blue.aol.com.MISMATCH!portc03.blue.aol.com!feed1.newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mailReferences:
<Xns913D53184D01Dtomaolde@194.231.40.11> <Xns913D605545611farkle@24.71.223.45> <Xns913E6D392D6FDtomaolde@194.231.40.11> <Xns913F8709C591rcamesz@amesz.demon.nl> <20011018211534.558$Tm@newsreader.com> <Xns913ECAF01FC63farkle@24.71.223.45> <Xns91413EA712BCArcamesz@amesz.demon.nl>Show Full Headers
Complete Article Headers
Message-ID: <20011021163344.293$vH@newsreader.com>
Subject: Re: xnews filesize
Date: Sun, 21 Oct 2001 20:33:44 +0000
From: curt@kcwc.com (Curt Welch)
References: <Xns913D53184D01Dtomaolde@194.231.40.11> <Xns913D605545611farkle@24.71.223.45> <Xns913E6D392D6FDtomaolde@194.231.40.11> <Xns913F8709C591rcamesz@amesz.demon.nl> <20011018211534.558$Tm@newsreader.com> <Xns913ECAF01FC63farkle@24.71.223.45> <Xns91413EA712BCArcamesz@amesz.demon.nl>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!howland.erols.net!portc.blue.aol.com.MISMATCH!portc03.blue.aol.com!feed1.newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mail
Organization: NewsReader.Com
Newsgroups: news.software.readers
X-Trace: NewsReader.Com Pz4JdZvc1=oVsK@2u9fOqCU+_MV0lz@v-Ylpfw8_sEgSA/r.
X-Face: "p}G*1KH{+F7EYGKLb>ogDguabZ+%,?^epeFB!nzu`)`$=QcvL1KF6<0GH!Tbc!Sqo[|tV5
%IW48mQf3K=Ci&gZ7]]aazx@]Y-nq!r5{yH/#,?@lDdUDvOfByB2hVW0.@OM%{l/{cT'{w
X-Url: http://CurtWelch.Com/
User-Agent: NewsReader.Com
Lines: 83