Skip to content

swimos/swim-cellular

Repository files navigation

Swim Cellular Network Simulator

A tutorial application for teaching core Swim concepts. See a hosted version of this app running at https://cellular.swim.inc.

Getting Started

Prerequisites

  • Ensure that your JAVA_HOME environment variable points to the Java installation.
  • Ensure that your PATH includes $JAVA_HOME.

Running on Windows

$ gradlew.bat run

Running on Linux or MacOS

$ ./gradlew run

Viewing the UI

Open a web browser to http://localhost:9001.

Running a local cluster

Run two Swim instances on your local machine to distribute the application's Web Agents between two processes.

# Start the first fabric node in one terminal window
$ ./gradlew run -Dswim.config.resource=server-a.recon

# Start the second fabric node in another terminal window
$ ./gradlew run -Dswim.config.resource=server-b.recon

When both processes are up and running, you can point your browser at either http://localhost:9008 (Server A) or http://localhost:9009 (Server B). You will see a live view of all Web Agents, regardless of which server you point your browser at. Swim transparently demultiplexes links opened by external clients, and routes them to the appropriate server in the fabric.

Introspecting a running application

The Swim runtime exposes its internal subsystems as a set of meta web agents.

Host Introspection

Use the swim:meta:host agent to introspect a running host. Use the pulse lane to stream high level stats:

swim-cl i sync -h warps://cellular.swim.services -n swim:meta:host -l pulse

The nodes lane enumerates all agents running on a host:

swim-cli sync -h warps://cellular.swim.services -n swim:meta:host -l nodes

The fragment part of the nodes lane URI can contain a URI subpath filter:

swim-cli sync -h warps://cellular.swim.services -n swim:meta:host -l nodes#/

Node Introspection

You can stream the utilization of an individual web agent:

swim-cli sync -h warps://cellular.swim.services -n swim:meta:node/%2fcountry%2fUS -l pulse

And discover its lanes:

swim-cli sync -h warps://cellular.swim.services -n swim:meta:node/%2fcountry%2fUS -l lanes

Some additional examples:

swim-cli sync -h warps://cellular.swim.services -n swim:meta:node/%2fcountry%2fUS%2fstate%2fCA -l pulse
swim-cli sync -h warps://cellular.swim.services -n swim:meta:node/%2fcountry%2fUS%2fstate%2fCA -l lanes
swim-cli sync -h warps://cellular.swim.services -n swim:meta:node/%2fsite%2f1440 -l pulse
swim-cli sync -h warps://cellular.swim.services -n swim:meta:node/%2fsite%2f1440 -l lanes

Mesh introspection

swim-cli sync -h warps://cellular.swim.services -n swim:meta:edge -l meshes

Log introspection

You can stream log message for a particular web agent:

swim-cli sync -h warps://cellular.swim.services -n swim:meta:node/%2fsite%2f1440 -l debugLog

Or stream all log messages for a host:

swim-cli sync -h warps://cellular.swim.services -n swim:meta:host -l debugLog

Repository Structure

Key files

Key directories

  • src — backend and frontend source code, and configuration resources
  • pkg — support files for generated OS packages
  • docker — support files for generating Docker images
  • gradle — support files for the gradlew build script