Swarm

Devcon 8, Resilient Networking Hub

Swarm, under the hood

The docs, repos and papers behind how Swarm finds, keeps and serves data over libp2p, plus the tools to run it yourself.

How does a request find its data?

Bee, the Swarm client, runs on libp2p. Nodes and chunks (4 KB pieces of a file) share one address space, and each node stores the chunks closest to its own address. Requests hop toward that address, a scheme called forwarding Kademlia.

Your nodeasks for a chunk
A peercloser to the chunk’s address
A closer peercloser still
The storerholds the chunk
Request: each hop goes to a peer closer to the chunk’s address. Chunk: comes back along the same path.

What happens when the publisher goes offline?

Once an upload has synced, it no longer depends on the publisher’s machine. It stays available as long as its postage stamp, the storage paid for with each upload, is valid.

Publisheruploads, then goes offline
Neighborhoodthe nodes closest to the chunk each keep a copy
Readerstill gets the file
Request from the reader. Chunk. The dashed arrow is the upload, made before the publisher went offline. Offline node. The rest of the neighborhood still has the chunk. If too many copies go missing, erasure coding’s spare chunks let the file be rebuilt from what’s left.

What if your browser is the node?

Freedom is a browser with a Swarm node built in, so it opens Swarm content straight from the network, with no gateway in between. It runs on desktop and mobile, and the team is now bringing streaming to Android.

Can I run the pieces myself?

A gateway, an HTTP server that fetches Swarm content for browsers without a node of their own, is the easy way to start, but it means depending on whoever runs it. You can run your own gateway in front of your own node instead. For development, a local Swarm on your laptop needs no real funds, and SwarmScan shows the live network from the outside.

Go deeper

Developer resourcesSDKs, examples, gateways and tools in one list.docs.ethswarm.org/docs/develop/resources bee-jsThe JavaScript and TypeScript SDK.bee-js.ethswarm.org/docs DiscordAsk the people who build and run Swarm.discord.ethswarm.org The Book of SwarmThe full technical book on Swarm’s architecture.docs.ethswarm.org/the-book-of-swarm.pdf Swarm papersTechnical papers and research.papers.ethswarm.org SWIPsSwarm Improvement Proposals: follow or shape where the protocol goes.github.com/ethersphere/SWIPs

This page lives on Swarm

It isn’t stored on a hosting server. Its files are spread across Swarm’s nodes, and the gateway that showed it to you is only one way in. Open the same address through your own Bee node, or in Freedom Browser, and you get the same page.

Swarm DesktopOne install runs an ultra-light Bee node on your computer. Open this page through your own node.ethswarm.org/build/desktop Freedom BrowserOpens Swarm addresses through its own built-in node.freedom.baby