| Attachment | Date | Size |
|---|---|---|
| 02/03/08 12:26 pm | 131.57 KB | |
| 02/03/08 4:07 pm | 334.33 KB |
P2P torrent on the iPhone, a sad tale of woe, misery, abject failure... and then eventually success!
Persistence finally pays off! - We even made it onto a TV show! *chortle*
(we are about 2mins in, I swear when I watched this on our tivo I damn near fell over!)
NOTE: PLEASE! What ever you do, don't attempt this on EDGE kids!
tcp4 0 0 10.146.247.xxx.50278 dsl51B7DBDF.fixi.11653 ESTABLISHED tcp4 0 0 10.146.247.yyy.50275 port0007-ahi-ads.40068 ESTABLISHED tcp4 0 0 10.146.247.zzz.50274 86.63.32.xxx.44629 ESTABLISHED
It does "work".... that was a netstat after disconnecting from EDGE.
PLEASE be careful out there! PLEASE!
This is a screen grabby after reconnecting via wireless after a quick Terminal.app test over EDGE - clearly I don't think it is uploading... but even so, it does not take a rocket scientist to work out that this could be erm... well "iffy" to say the least:

Update (7:30pm): transmission client code also added!
We noticed this post on TUAW:
Collin said...
Lame. P2P and the iPhone is all about the remote control, not running the client on the phone.
Yup - so it is still "lame", but remember this client could in theory be set to call home to another machine, but I digress... I'll never understand this stuff :)
iPhone:~/ root# ./transmission-daemon -f & iPhone:~/ root# ./transmission-remote -a ../gm1996-11-8.shnf.torrent iPhone:~/ root# ./transmission-remote -l gm1996-11-8.shnf (260 MiB) - 0.00% downloading at 32.9 KiB/s (UL at 0.00 B/s), done in 2 hours 14 minutes
The original post...
We managed to get this code from this wonderful site: http://www.transmissionbt.com/index.php running on the iPhone. Lots of fun now for some real time downloads etc. I've posted the binary of the cli above for those eager to get at it before it makes it to cydia. I'm using a legal torrent file from VMWARE here just to prove it works. Good times, I can finally close the book on all this crazy torrent stuff!
iPhone:~ root# ./transmissioncli -v2 Browser-Appliance-1.0.0.zip.torrent Transmission 1.06 (5136) - http://www.transmissionbt.com/ Thread 'libeventThreadFunc' started Starting libevent thread setrlimit( RLIMIT_NOFILE, 1024 ) 512 usable file descriptors Transmission 1.06 (5136) started found 7 peers in resume file Bound socket 6 to port 51413 Port Mapping: opened port 51413 to listen for incoming peer connections Progress: 0.02 %, 0 peers, dl from 0 (0.00 KB/s), ul to 0 (0.00 KB/s) [0.000] Torrent "Browser-Appliance-1.0.0.zip" tracker response: OK Torrent "Browser-Appliance-1.0.0.zip" got 10 new peers Progress: 0.02 %, 0 peers, dl from 0 (0.00 KB/s), ul to 0 (0.00 KB/s) [0.000] Progress: 0.02 %, 0 peers, dl from 0 (0.00 KB/s), ul to 0 (0.00 KB/s) [0.000] Progress: 0.02 %, 2 peers, dl from 0 (0.00 KB/s), ul to 0 (0.00 KB/s) [0.000] Progress: 0.02 %, 3 peers, dl from 1 (0.00 KB/s), ul to 0 (0.00 KB/s) [0.000] Progress: 0.02 %, 3 peers, dl from 1 (0.12 KB/s), ul to 0 (0.00 KB/s) [0.000] Progress: 0.02 %, 4 peers, dl from 2 (0.96 KB/s), ul to 0 (0.00 KB/s) [0.000] Progress: 0.03 %, 4 peers, dl from 2 (5.14 KB/s), ul to 0 (0.00 KB/s) [0.000] Progress: 0.04 %, 4 peers, dl from 2 (7.58 KB/s), ul to 0 (0.00 KB/s) [0.000] Progress: 0.07 %, 5 peers, dl from 2 (18.46 KB/s), ul to 0 (0.00 KB/s) [0.000] ^C
Regular downloads look like this, remember to open 51413, if you are behind a FW or use -p to change the port to 6881, what ever floats your boat...:
iPhone:~ root# ./transmissioncli Browser-Appliance-1.0.0.zip.torrent Transmission 1.06 (5136) - http://www.transmissionbt.com/ Progress: 6.54 %, 5 peers, dl from 5 (52.27 KB/s), ul to 1 (4.00 KB/s) [0.025]^C
and resume works:
Progress: 6.66 %, 4 peers, dl from 2 (37.46 KB/s), ul to 0 (0.00 KB/s) [0.024]
Hurray!
Here is a log to show that it works in my hands at least. I used a legit torrent file from vmware to run the tests, it's nice and big, and often does not have very many peers. It was started and stopped at least 15 times during the download. But first here is the standard wget, run on an intel imac so we can check the MD5 sum at the end, and make sure it is the same as the one via torrent and the iphone:
imac /~/ wget http://download3.vmware.com/software/vmplayer/Browser-Appliance-1.0.0.zi... --16:45:34-- http://download3.vmware.com/software/vmplayer/Browser-Appliance-1.0.0.zi... => `Browser-Appliance-1.0.0.zip' Resolving download3.vmware.com... 65.32.34.57, 65.32.34.74 Connecting to download3.vmware.com|65.32.34.57|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 271,028,202 (258M) [application/zip] 16:53:42 (543.64 KB/s) - `Browser-Appliance-1.0.0.zip' saved [271028202/271028202] imac /~/ md5 Browser-Appliance-1.0.0.zip MD5 (Browser-Appliance-1.0.0.zip) = b8797f94a67ae8550e5b589904dcf8bd
Here is the result of the torrent download on the iPhone:
iPhone:~ root# ./transmissioncli -p6881 -u-1 Browser-Appliance-1.0.0.zip.torrent Transmission 1.06 (5136) - http://www.transmissionbt.com/ Progress: 99.67 %, 6 peers, dl from 6 (14.05 KB/s), ul to 1 (0.00 KB/s) [0.017]^C iPhone:~ root# md5sum Browser-Appliance-1.0.0.zip b8797f94a67ae8550e5b589904dcf8bd Browser-Appliance-1.0.0.zip
Same MD5 as via the wget download - and it uncompressed!! Whoo hooo! Finally confirmation. Not that this particular file is much use on the iphone, but it proves a point that this thing finally works for downloading at any rate. :))
iPhone:~ root# mkdir tt iPhone:~ root# cd tt iPhone:~/tt root# unzip ../Browser-Appliance-1.0.0.zip Archive: ../Browser-Appliance-1.0.0.zip inflating: Browser-Appliance/bavm_getting_started_100.pdf inflating: Browser-Appliance/Browser-Appliance-1.0.0-README.txt inflating: Browser-Appliance/Browser-Appliance.nvram inflating: Browser-Appliance/Browser-Appliance.vmdk
Below is all the old history, but fun to keep reading to see what we tried and failed at. This was a long and fascinating journey, through the bizarre and twisted landscape that is closed source code, and a variety of false starts - all things iPhone are getting harder these days... well enjoy the assorted crazy approaches to getting this done :)
Update [1st March 2008]
So using saurik's awesome python from over at http://www.saurik.com/, we almost got there again, after installing Twisted, zope.interface and pycrypto:
iPhone:~ root# bittorrent-console Virus.mp4.torrent
saving: Virus.mp4
file size: 300,238,323 (286 MB)
percent done: 0.0
time left: initializing
download to: /var/root/BitTorrent Downloads/Virus.mp4
download rate: ---
upload rate: ---
[---8<----SNIP----8<----]
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/twisted/python/log.py", line 33, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
sock, addr = self._sock.accept()
socket.timeout: timed out
Sigh - so close, looks like there is something funky with the network code in python - this will need a lot more debug in the guts of /usr/lib/python2.5/site-packages/twisted/internet/tcp.py. I think I may also have built twisted the wrong way... ah well.
After many failed attempts, even with 4.2.1 as the new compiler, I just could not for the life of me get rtorrent to work, albeit we had a viable binary, all the exception handling stuff would always cause crashes. Albeit sigc++, libtorrent, and libcurl all build and the binary runs right up to handshake connection. libtorrent is very sensitive to compilers and any nascent issues they may have: http://libtorrent.rakshasa.no/wiki/LibTorrentKnownIssues
Maybe once the SDK comes the compiler will be more stable, and rtorrent will then live!
Anyway, to cut a rather long and sorry story short, here is yet another failed work around that was looking great right up to the point it fell over!
!STANDARD DISCLAIMERS APPLY!
NOTE: Please what ever you do, don't attempt this on EDGE kids, just in case one day it actually works!
1. Get saurik's jvm (add http://apptapp.saurik.com to installer.app, or pull jamvm from his dpkg/apt repository at http://atp.saurik.com) # java -fullversion java full version "jamvm-1.5.0" 2. Download the BitThief.jar: http://dcg.ethz.ch/projects/bitthief/download.php 3. Get a torrent (remember - keep it legal folks!) Given that telcos probably think this is a virus, I thought this video was most apposite! http://www.publicdomaintorrents.com/nshowmovie.html?movieid=808 http://www.publicdomaintorrents.com/bt/btdownload.php?type=torrent&file=... 4. Start up the torrent # mkdir torrent.out # java -jar BitThief.jar -m Virus.mp4.torrent -o torrent.out -g takes up a fair bit of CPU, and about 12% of the mem: # ps aux | head USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND root 234 98.7 12.5 311640 14868 p0 R+ 11:29AM 13:23.22 java -jar BitThief.jar 5. Sit back and watch the download come, it is really looking good... maybe we have cracked it this time! # pwd /var/root/torrent.out # du -sh Virus.mp4 47M Virus.mp4 160M Virus.mp4 236M Virus.mp4 ... whooo..! 6. Crash! zsh: bus error java -jar BitThief.jar -m Virus.mp4.t Bugger! All it was actually doing was setting up the file with zeros, very, very slowly! Doh! so that will teach me not to check netstat :). So then we busted out Azureus it is going to be a long shot... First we needed these jars: # curl -O http://azureus.sourceforge.net/cvs/commons-cli.jar # curl -O http://azureus.sourceforge.net/cvs/log4j.jar # java -jar Azureus3.0.4.2.jar --ui=console DEBUG::Fri Feb 22 12:42:03 GMT-05:00 2008::org.gudy.azureus2.core3.security.impl. SESecurityManagerImpl::initialise::152: No SSL provider available SESecurityManager::initialise::52,ConfigurationChecker::setSystemProperties::212, ConfigurationManager::initialise::150,ConfigurationManager::getInstance::83,COConfigurationManager ::initialise::107,AzureusCoreImpl::::154,AzureusCoreImpl::create::100,AzureusCoreFactory:: create::46,Main::main::159,Method::invokeNative::-1,Method::invoke::367,JarLauncher::main::49 changeLocale: *Default Language* != en (US). Searching without country.. changeLocale: Searching for language en in *any* country.. Looking good! Fingers crossed! Bugger! then our old friend "bus error" is back: zsh: bus error java -jar Azureus3.0.4.2.jar --ui=console sigh...
