Skip to content

Freenet Network Monitor

nacho.d.g edited this page May 11, 2025 · 2 revisions

Debugging with Network Monitor

Network Monitor Setup

To effectively use the network monitor for debugging and observing network operations, you need to start two main components: the metrics server and the network monitor UI.

Start Metrics Server

Instructions on how to start the metrics server.

fdev network-metrics-server

You must see the following: image

Start Network Monitor UI

Instructions on how to start the network monitor UI.

# 1. Move to thenetwork-monitor directory inside freenet-core
cd freenet-core/network-monitor
# 2. Use npm to install dependencies
npm install
# 3. Start the metrics server
npm start

Once the network monitor UI is running, it should open the UI in your default web browser. You should see: image

Important Note: Nothing will be visualized in the network monitor until operations related to contracts begin to execute on the network.

Using Network Monitor to Debug and Verify Test Behavior

(Example with the ping app test)

This section focuses on using the network monitor to debug and verify the behavior of tests, specifically for the ping application.

Once the netowrk monitor server and UI are running, you can start executing tests that involve network operations. The network monitor will capture and visualize these operations in real-time.

  1. First run the ping application test:
RUST_LOG=debug cargo test test_ping_multi_node --package freenet-ping-app --test run_app -- --nocapture
  1. Once the test is running, switch to the network monitor UI. You should see operations being visualized in real-time. image

  2. Analyzing the Visualization:

    • Cached contracts: Observe the contracts that are cached in the network: image Clicking in the contract key will show you the contract details: image
    • Transactions: See all transactions that are being executed: image image Clicking in the transaction ID will show you the transaction details: image Inside the detail page you can filter by the requester, target, change type... only by clicking over the field you want to filter.
  3. Current UI Issues:

  • The connections visualization is not working properly, not all connections are shown. This is a known issue and will be fixed in the future.
  • Some transactions apper duplicated. This is a known issue and will be fixed in the future.

Using the Network Monitor on a Locally Raised Network

This section focuses on using the network monitor with a network simulation running locally on your local machine.

Prerequisites

  • The network monitor and the metrics server must be running before starting the network simulation.
  • To ensure other metrics are not shown in the network monitor, you can restart it.

1. Start the Network Simulation

Instructions on how to start the network simulation.

# 1. Move to the scripts folder
cd freenet-core/scripts
# 2. Start the network simulation
make -f local-network.mk clean
make -f local-network.mk setup
make -f local-network.mk start

It will run a local network with 1 gw and 1 node. You can run more nodes using the makefile commands.

2. Run the Ping Application

Instructions on how to run the ping application.

# 1. Move to the ping app folder
cd freenet-core/apps/freenet-ping
# 2. Install the app
make -f run-ping.mk install # It outputs the contract hash to use it in the next step
# 3. Run the ping app publishing the contract in the gw
freenet-ping --tag test --code-key GENERATED_HASH --put-contract --node-id gw --host 127.0.0.1:3001 --log-level INFO --frequency 5000ms --ttl 7200ms
# 4. Run the ping app in the node
freenet-ping --tag test --code-key 616kKaMYL8FFvMkvrTsgEHHQ8smJY5JUBmevQT8ZEQqG --node-id n1 --host 127.0.0.1:3002 --log-level INFO --frequency 5000ms --ttl 7200ms

3. Visualize the behavior in the Network Monitor

In the same way as in the previous section, you can visualize the behavior of the ping application in the network monitor. You should see operations being visualized in real-time.