ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.01k stars 3k forks source link

Large file not transferring locally #1840

Open alanleftofthedot opened 8 years ago

alanleftofthedot commented 8 years ago

First of all I'm relatively new to IPFS so some of this issue may be with how I assume / hope network transfers work and not how they actually work. If so please close and point me to the documentation that relates. However based on the talk video I think I understand how it's supposed to work.

I have a unique file (10G), and add it to my local store. I send the hash to another user with a computer connected to the same local network. After the add is completed he ran 'ipfs cat hash >> foo.mp4' and the transfer did seem to run, but slowly, about the speed that I'd be able to upload to the internet from my computer.

It's my assumption that IPFS should be choosing the fastest path to connect, and since we're both on the local network, both can see each other in the ipfs swarm peers list (192.168.x.x), shouldn't the transfer be a very fast local LAN transfer? Based purely on speed and looking at what processes are sending what data where (using iftop on the linux machine and iState Menu on the mac) it seems like the transfer is going through the internet.

Am I completely confused as to how IPFS is supposed to work, or is there something I need to do to tell the daemon to prefer transfers from the local lan and not going out over the wan.

whyrusleeping commented 8 years ago

You assumption is correct that files get transferred over the LAN. The traffic you are seeing going out to the internet is:

from the node that added the file, messages informing the network that you have the file (a DHT put for each block)

from the node requesting the file, messages requesting the location of the file from the network.

Run over a LAN, it should be rather fast, but we havent optimized for larger file transfers yet, (each block request takes at least one RTT, until we merge the dev0.4.0 branch which should improve that, and a few other issues exist in various subsystems) so the slowness is just a result of code that needs to be worked on more.

You should expect the local transfer to take around the same time as the time it took to add the file originally (if you did so with your node online).

jbenet commented 8 years ago

It is also possible the only possible route was over the external router interface (sometimes internal networks are annoying, depends on the network config).

alanleftofthedot commented 8 years ago

The default route is set to the router, but it's about as standard a setup as you can get in terms of a home router, DHCP WAN to my cable modem, DHCP to the computers on the local network. When the WAN on the router was disabled, IPFS transferred properly across the local LAN as expected, however as soon as it was enabled the transfer went across the internet. I'm looking at integrating IPFS into a project to enable easier sharing of content in developing areas where the internet connections are (in a word) crappy, but if the protocol prefers WAN, I'll need to either figure out how to force it to prefer LAN or find another solution.

whyrusleeping commented 8 years ago

the data wasnt being transfered outside your network, as I mention above. Also to blame is our datastore implementation, its overly safe at the cost of way too many fsyncs (resulting in poor disk performance), more work needs to be done on that end to improve performance there.

jbenet commented 8 years ago

however as soon as it was enabled the transfer went across the internet.

it may be possible that it is, but i'd like to make sure-- what makes you think so? did you wireshark the packets? Also, the last hop it could've gone to is your gateway router (technically on the WAN/internet), as we do not yet relay connections.

jbenet commented 8 years ago

It would be useful to produce test networks that ehibit the same behaviors so can fix it.

and

but if the protocol prefers WAN, I'll need to either figure out how to force it to prefer LAN or find another solution.

no the protocol is supposed to prefer the fastest connection. we find it odd that you're observing this.

immartian commented 7 years ago

we have exactly the same issue transferring big file within LAN, it's like 1.29GB file took 5h to finish.

bionic6manuel commented 7 years ago

Im having the same problem using ipfs version 0.4.4 ipfs is great but this is just sad. Built from source and that did not help. Over wifi it is very slow 1gig more than an hour over cable same thing. I have solved my problem it seemed my hard disk was the problem. I have replaced the hard disk and everything is golden.

whyrusleeping commented 7 years ago

Huh, not sure why this was closed... Looks like it may have been a result of something else merging?