Net-runner

Hello world?

1 year ago by Seva D. (sabrinarempel7@gmail.com)



Introduction

This post is intended to be an introductory post, describing the goal of this project and some features that will be added in the future. The initial goal of the website was to serve as an example of some networking basics, to help people to learn. But, regardless of the fact that I'm trying to create a website dedicated to the inner workings of computer networks, I have much to learn myself. And I think the best way to create a resource that will really help people to learn something is to create a resource that will help to learn something for yourself. Hence, I've integrated this blog page, that will be used not only to post some technical stuff, but to share some insights about networking.



Project development plan

The primary focus of this project development is the $ simulation module$ , which in fact is a Node.js wrapper around the $ NS3$  library. It can be used to experiment with existing network protocols and to create new ones from scratch via raw sockets support in the NS3. The latter feature demands the support of dynamic interaction between Node.js and NS3, which was added in the 1.0.9 $ release$  (and it is not a finite version, more like a prototype). And in this scenario the website can be used as a visualization tool for simulated networks. Hence, the recording functionality was added to the website, where you can run the simulation in your system and upload the results to the website ($ example$ ).

The example of uploading a simulation to the website from Node.js:

note:The API can change in the nearest future versions, but the core concept is formed.



const net = new Network({
  animeLen: 3,
});
const host1 = new Host({ name: 'UdpClient', x: 0, y: 0 });
const host2 = new Host({ name: 'UdpServer', x: 400, y: 0 });
host1.setupApplication(new UDPClient({
  addr: '192.168.1.3',
  port: 3000,
  onTick: ({ time, sendPacket }) => {
    if (time < 1000) {
      const buf = Buffer.from('hello');
      sendPacket(buf);
    }
    return '0.01s';
  },
}));
host2.setupApplication(new UDPServer({
  port: 3000,
  onReceive: ({ address, packet, reply }) => {
    console.log('[*] recieve', address, packet);
    const buf = Buffer.from('world?');
    reply(buf);
  },
}));
net.addNode(host1);
net.addNode(host2);
host1.connect(host2, {
  sourceIP: '192.168.1.2',
  targetIP: '192.168.1.3',
  dataRate: '1Mbps',
  delay: '1ms',
});
net.run(dstDir, { upload: true }).then(url => console.log('[*] done', url));

The key moment is to add { upload: true } to the run method. Currently there is no any API tokens, but it will be added as soon as I shall notice some overhead from API usage. At the time of writing this post, there is a lot to add with the module, here is an up-to-date checklist for the upcoming module features:

Uploading simulations to the website
Documentation
Raw socket applications
Async callbacks for applications
Internal stuff: automatic positioning, naming, better arguments validation