Wednesday, December 2, 2015

My most used commands in Mininet

Introduction

A new thing that I learn today is mininet. Mininet is a set of software tools that I can use to simulate computer networks. The tools has build-in topology that that can get a non-sophisticate user like me to get my feet wet within a short time. This beats running into my lab and connecting cables to get my topology.

Mininet has extensive set of document and VM appliances that you can download and start right away. The VM image that I downloaded is based on Ubuntu 12.04. There are a lot of resources that you can use to learn about Ubuntu, VM, and virtualization on the web. I'll skip over these discussion for now, but may come back and talk about it later.

List of commands for Daily use

Mininet is known on the Ubuntu VM appliance as "mn" - its abbreviation *giggle*. Since mininet needs access to resources on the appliance, you will have to run "mn" at an elevated permission. On a Unix system such as Ubuntu you prefix mininet's command with sudo. This is how you start "mininet" once you get into the mininet appliance.
mininet@mininet-vm:~$ sudo mn
Mininet responses with the following output. It creates the default simple network topology.
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1)
*** Configuring hosts
h1 h2
*** Starting controller
*** Starting 1 switches
s1
*** Starting CLI:
mininet>
In this topology, we have 2 hosts and one switch. These hosts are denoted by h1 and h2. s1 represents the switch in this topology. "Links" are connections between a host and a switch. The link is always a point-to-point - meaning that the link connects between a pair only. The end-point of a link can be either a host, or a switch. These links in this topology shows as:
(h1, s1) (h2, s1)

There are several ways to review your network topology. The one that I use most is net. Here's the example of the output of the command:
mininet> net
c0
s1 lo: s1-eth1:h1-eth0 s1-eth2:h2-eth0
h1 h1-eth0:s1-eth1
h2 h2-eth0:s1-eth2
mininet>

Next time, we will go over other aspect of running the simple topology.

Example of running Java program calling external "jar" file

In this example, my java program is calling Juniper's Netconf.jar to interact with routers running JUNOS.
reia-mba:~/Devel/SRXFlowInfo/bin reia$ java -cp ../lib/Netconf.jar:. getFlowInfo arg0 arg1 arg2

In this example,

  • "reia-mba:~/Devel/SRXFlowInfo/bin reia$ " is the command prompt on my MacBook Air.
  • The next portion of the command is "java" - the name of Java virtual machine.
  • Next up is "-cp", this is called a flag. This particular flag - "cp" is an abbreviation of "CLASS PATH". This flag consumes the next argument - "../lib/Netconf.jar:.", which is the location of "Netconf.jar" Class Library that provided by Juniper.
  • getFlowInfo is the class that we want to execute. It is shown in the directory as getFlowInfo.class. This is the output of Java compiled code. Pretty much an equivalent of a.out, I think. I will have to look this out later on.
    One note about this .class extension. When you want to run the Java program, don't put in the .class extension. You will get an error that the java can not find "main"