npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

stungun

v0.0.20210828

Published

highly scalable webrtc mesh-like network for data channels

Downloads

2

Readme

What is this?

StunGun is a modification of GUN that uses as much webrtc peer to peer goodness as possible. It's an experiment to see if we can make a network of millions of webrtc connections and use them to transfer data amongst eachother.

How it works

Peer discovery

For each application, we'll use a different tree and save/load it using GunJS, a peer to peer protocol that can be used as a database. When a user wants to join, they specify their desired application. Gun looks for a tree with that application name, and creates one if it does not exist. An optional "desiredUploadSpeed" (in kbs) is provided, otherwise it defaults to 50 (sufficient for real time audio streaming). StunGun checks the user's bandwidth capabilities and divides their available upload speed by the desiredUploadSpeed to calculate the maximum number of children they should have connected to them. This info is saved in the "meta" property of their node object that is soon saved into Gun for other peers to see. StunGun takes the tree fetched through Gun and traverses it using breadth-first-search until it finds a node that has less children than their maximum allowed number of children. The client then connects to that node using PeerJS.

Prophet Nodes

Prophet nodes sit at the highest level of the tree. They are the nodes with the highest bandwidth,

Data transmission

When a user would like to send some data to other peers

Examples

The examples folder contains different apps (only one right now) that demonstrate how StunGun can be used for real-time purposes. There is no real benefit to the design of StunGun over any other webrtc framework if you are only using a handful of clients. To really demonstrate the power of StunGun, you should have dozens of active clients. Sadly, this will likely degrade your performance if you are running all these tabs on one machine, so in practice it might actually be difficult to test by yourself. I will host each example application and link to it here, and doing a genuine test might require some group coordination (or this package getting really popular and people using the demos frequently). Eventually, these apps should serve a real purpose such that they can be used as real applications and benchmarks for StunGun.

Instant Messenger

This is a React app written in Typescript. Pretty self explanatory, it allows many people to send messages to eachother.

Different Methodologies

I can see two possible design systems that would vary in difficulty/simplicity and performance. Both methods involve every peer on the network being ultimately connected through a series of peers, but they differ in performance.

Application Targeted Grouping

Peers using the same application are more closely grouped together. This means that latency would be reduced when peers are talking to eachother over the same app, which is definitely the more likely scenario anyways.

Global tree

Peers' positions in the tree are only determined by what will give them the best performance when communicating with any random peer on average. This is probably easier to implement, but I'm not sure how "real-time" things get when you have millions of peers connected.

Helpful articles

This blog post talks about some of the challenges with building a large-scale webrtc mesh network. https://bloggeek.me/webrtc-p2p-mesh/

Some rambling...

I'm not sure how this will/should work. I'm going to try to just use the GUN API as much as possible but without using any relay peers. My naive solution is this...

  1. create a layered mesh network of webrtc connections/data channels
  2. use GUN to save data locally,
  3. when new data occurs, send it over the mesh network with instructions for GUN
  4. when the clients receive the data and instructions, they simply save it locally with GUN