Skip to main content

Discover Plotting Utility Within Ns2web

In my previous articles, I have discussed about the Virtual Labs and IEEE WCM Feature Article on ns2web. Today, I would briefly discuss about ns2web with specific focus on one of its more general features -- data plotting utility.

Ns2web is the core component of the Advanced Network Technology Virtual Labs. At a high level it has two basic jobs to perform:
  1. Execute the NS-2 simulations in a remote server based on the user input code.
  2. Help users perform different types of post-simulation analysis using the trace file generated.
As such, ns2web itself becomes a sort of mini-project :) Currently, ns2web and the version of it used with the ANT VLab differ on a few minor aspects. The former offers a ``guided scenario generator'' to the users, and an option to export the graphs as external images.

However, ns2web is not only for performing network simulations! The software provides a useful feature that might interest you if you want to quickly plot some nice line plots.

As shown in Figure 1,  just type in (or copy-paste) a sequence of (x, y) values, (optionally) specify the plot title and axes labels, and click on the ``Plot Data'' button. That's it! Your plot is ready.

Generate a line plot based on any data
Figure 1: Generate a line plot based on any data.

Figure 2 plots the squares of the first few positive integers using the above method.

Plot of squares of integers
Figure 2: Plot of squares of integers.

But wait, there's more! You can actually export the plot so generated into an EPS, PDF or a PNG file as well, as shown in Figure 3. The file in the EPS format is useful if you are authoring a research article.

Export the plot as an EPS/PDF/PNG file
Figure 3: Export the plot as an EPS/PDF/PNG file.
 As you might have noticed, the exported plots look a bit different from the one displayed in the website itself. Indeed, it is so. The matplotlib library of Python is used to generate the plots at the back-end.

Finally, as shown in Figure 4, you can plot multiple line plots together. And yes, you can export such multiple line plots into a single external file.

Plot multiple functions together
Figure 4: Plot multiple functions together.
So, happy (and easy) plotting!

Comments

Popular posts from this blog

Text Highlighting in Latex

While preparing a manuscript with Latex, it is often useful to highlight the changes made in the current revision with a different color. This can be achieved using the \ textcolor command provided by Latex. For example, \textcolor {red}{Hello World} would display the string "Hello World" in red color. However, the final/published copy of the manuscript does not contain any highlighted text. Therefore, if a large volume of changes were made, it becomes tiresome at the end to find and remove all the individual portions of highlighted text. This can be circumvented by defining a utility command to switch highlighting on and off as desired. In the following, we define a new Latex command, highlighttext , for this purpose. The command takes only a single argument—the text to be highlighted.     \usepackage {color}    % For highlighting changes in this version with red color   \newcommand { \highlighttext }[1] { \textcolor {red}{#1}}   % Remove all text highlighting

Specifying Source and Destination of Messages

One of the frequently asked questions in the community is how to specify which particular nodes would act as source(s) and destination(s) of the messages created in the ONE simulator. The simulator, in fact, provides a pair of settings (shown below in bold face) aimed for this particular purpose. Let us consider that there are $n + 1$ nodes in an OMN.  Further, let the nodes with addresses from $x$ to $y$, both inclusive, would create messages. The nodes in the range $w$ to $z$, both inclusive, would be the destinations of those messages, where $0 \le x \le y \le n$, and $0 \le w \le z \le n$. Then, the corresponding simulation scenario can be configured as follows. ## Message creation parameters # How many event generators Events.nrof = 1 # Class of the first event generator Events1.class = MessageEventGenerator # (Following settings are specific for the MessageEventGenerator class) # Creation interval in seconds (one new message every 25 to 35 seconds) Events1.interval = 25

The ONE KB has a new home

The ONE Knowledge Base is now hosted at http://theonekb.pythonanywhere.com/ If you are unaware, the ONE KB allows you to search the old email archives of the simulator's community. Therefore, if you have any question related to simulation, you may query the existing database at the above link. Chances are good that your question might already have been answered previously. If not, you can still post an email to the community's mailing list. Have you tried the ONE KB already? How was your experience? Was it helpful? Let me know in the comments!