File Transfer with PubSub

hey guys, i use go-libp2p-pubsub to build a p2p network. and i set the max message size to 1<<24.
when one peer send a message about 5MB to the topic, other peers will get this message about 2~3
seconds later.
there are only 3 nodes(docker containers in LAN) in this topic, network is no limit(very small latency,
Gbps bandwidth), why it cost so many time to broadcast the message? i think it can finish in 100ms,
what i can do to optimize settings to improve the transmission efficiency and latency?

Hi @TianshuDing,

On your specific problem of low-bandwidth, we would need more details to help you out.

On a high level, any of the gossip protocols (e.g. pubsub) should only really be used to broadcast small messages, e.g. notifications of the availability of a new file. The actual transfer of the large file can then be done via e.g. bitswap.

thanks for your reply. I want to desgin a App to transfer big file (100MB or more) using go-libp2p.
I have already written a sample demon by learning the pubsub chatroom example.
In my code, when set the NewGossipSub function, I give a option “WithMaxMessageSize” for big message transmission.but when node send a message (about 5MB) to the topic, other node wills wait
for a few seconds to get the message. 3 Nodes in the LAN, emulated by docker.
I test the bandwidth between nodes, it’s more than Gbps, and very low latency. So i think there must be some restrictions in pubsub, otherwise, it will finish in 100ms.
you tell me to use bitswap, so is there any example i can learn from?