When IPFS downloads chunks, is it possible to identify the owner(IP) of each downloaded chunk? I tried tracking log in debug level, but it’s too confusing. Using Wireshark, I could get some IP, but I can’t match them with each chunk.
What do you mean by the chunk’s “owner”? There could be multiple peers (with different IPs) providing various blocks of whichever file you’re downloading.
After IPFS decided which peer to download a specific chunk from, Is it possible to show which chunk and the IP of that peer?
I’m curious. What’s the use case for this?
I’m not sure what you tried previously with the debug output, but I think that’s probably the way to go. You can do this by parsing the debug output from
ipfs daemon and then looking up the addresses for the peer that sent the block.
For illustration, here’s an example where I’m interested in who is sending me a particular block after I request it.
$ ./ipfs --debug daemon 2>&1 | grep QmQHQHv9Ao16AasNS21JfW8j1QkPjBVCq6Vj7RwMmwUzsr 07:29:53.899 DEBUG cmds/http: incoming API request: /get?arg=QmQHQHv9Ao16AasNS21JfW8j1QkPjBVCq6Vj7RwMmwUzsr&encoding=json&stream-channels=true handler.go:88 07:29:53.899 DEBUG blockservi: BlockService GetBlock: 'QmQHQHv9Ao16AasNS21JfW8j1QkPjBVCq6Vj7RwMmwUzsr' blockservice.go:201 07:29:53.899 INFO bitswap: want blocks: [QmQHQHv9Ao16AasNS21JfW8j1QkPjBVCq6Vj7RwMmwUzsr] wantmanager.go:81 07:30:35.924 DEBUG blockservi: BlockService GetBlock: 'QmQHQHv9Ao16AasNS21JfW8j1QkPjBVCq6Vj7RwMmwUzsr' blockservice.go:201 07:30:35.924 INFO bitswap: want blocks: [QmQHQHv9Ao16AasNS21JfW8j1QkPjBVCq6Vj7RwMmwUzsr] wantmanager.go:81 07:30:55.639 DEBUG engine: got block [Block QmQHQHv9Ao16AasNS21JfW8j1QkPjBVCq6Vj7RwMmwUzsr] 1161 bytes engine.go:250 07:30:55.640 DEBUG bitswap: got block [Block QmQHQHv9Ao16AasNS21JfW8j1QkPjBVCq6Vj7RwMmwUzsr] from <peer.ID WTPu7d> bitswap.go:383
The last line of the output says who I received the block from. So if I look up that peer using
ipfs swarm peers I can see their address.
$ ./ipfs swarm peers | grep WTPu7d /ip4/100.200.300.400/tcp/4001/ipfs/QmWTPu7dq5dwTQTLd6FHxHbeVfin4F4HaVpXfQPh1CoiZR
If you wanted to do this for all peers and blocks, logging all of the “got block” debug messages from the daemon and all of the peers you’re connected to should let you match them up after-the-fact.
Note: I replaced the IP address (
100.200.300.400) and peer ID (containing
WTPu7d) with fake ones – which probably goes without saying for the IP . It was an AWS IP that I think is part of a public gateway, but I’m not sure and didn’t want to single anyone out.