Showing posts with label NS2. Show all posts
Showing posts with label NS2. Show all posts

Wednesday, September 15, 2010

Update on NS 2.35 Installation: Command not Found

During the last week, I have got few email about my previous NS2 installation.

The Error Message

After the installation some one type "ns" and get the following error
>>nsbash: ns: command not found
This could be because you have not set the $PATH variable. Therefore, the OS does not know where to look for the command "ns".



Monday, September 6, 2010

C++ and OTcl Linkage: Result — Passing Values between C++ and OTcl domains

ote: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapter 3 of the book for better understanding.

Introduction
This post is the second post in the series on C++ and OTcl Linkage:

   1. Why Two Languages?
   2. Binding C++ and OTcl classes [Main steps, The mechanism].
   3. Variable binding
   4. OTcl command: Invoking C++ statements from the OTcl domain [ Getting Started, Invocation process, Binding OTcl and C++ ]
   5. Eval: Invoking OTcl statements from the C++ domain
   6. Result: Passing Values between C++ and OTcl domains
   7. Object binding and object construction process.
In the previous post, I blogged about an approach to invoke OTcl statements from the C++ domain using function evalc(...) and evalf(...). This post discusses the way to pass results between C++ and OTcl domains using function result(...).

Passing Values Between C++ and OTcl

View more presentations from Teerawat Issariyakul.
======================================================
T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009.


You may also find lecture notes and other resource at the following website: http://www.ece.ubc.ca/~teerawat/NS2.htm

Monday, August 30, 2010

C++ and OTcl Linkage: Eval — Invoking OTcl statements from the C++ domain

Note: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapter 3 of the book for better understanding.

Introduction

This post is the second post in the series on C++ and OTcl Linkage:

   1. Why Two Languages?
   2. Binding C++ and OTcl classes [Main steps, The mechanism].
   3. Variable binding
   4. OTcl command: Invoking C++ statements from the OTcl domain [ Getting Started, Invocation process, Binding OTcl and C++ ]
   5. Eval and result: Invoking OTcl statements from the C++ domain
   6. Object binding and object construction process.
In the previous post, I blogged about an approach to invoke C++ statements from the OTcl domain. This post discuss the reverse: Invoking OTcl statements from the C++ domain.


 

View more presentations from Teerawat Issariyakul.
======================================================
T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009. Buy it now from

You may also find lecture notes and other resource at the following website: http://www.ece.ubc.ca/~teerawat/NS2.htm

Sunday, August 22, 2010

[NS2] Error message: Invalid command

Last week, I've got few messages asking me similar questions. The question was why do I see the following error message when running NS2 and how do I fix it?

invalid command name

Monday, August 16, 2010

C++ and OTcl Linkage: OTcl Commands — Binding OTcl and C++

Note: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapter 3 of the book for better understanding.

Introduction
This post is the second post in the series on C++ and OTcl Linkage:

   1. Why Two Languages?
   2. Binding C++ and OTcl classes [Main steps, The mechanism].
   3. Variable binding
   4. OTcl command: Invoking C++ statements from the OTcl domain [ Getting Started, Invocation process, Binding OTcl and C++ ]
   5. Eval and result: Invoking OTcl statements from the C++ domain
   6. Object binding and object construction process.
In the previous post, I blogged about the key steps in the OTcl domain when instproc or OTcl command is invoked. In this post, I will explain how NS2 moves from OTcl to C++.

Sunday, August 8, 2010

C++ and OTcl Linkage: OTcl Commands -- Invocation process

Note: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapter 3 of the book for better understanding.

Introduction
This post is the second post in the series on C++ and OTcl Linkage:

   1. Why Two Languages?
   2. Binding C++ and OTcl classes [Main steps, The mechanism].
   3. Variable binding
   4. OTcl command: Invoking C++ statements from the OTcl domain [ Getting Started, Invocation process ]
   5. Eval and result: Invoking OTcl statements from the C++ domain
   6. Object binding and object construction process.

In the previous post, I blogged about OTcl command. I took you to see how to create a OTcl command in C++ and invoke the command from the OTcl domain. how C++ and OTcl classes are bound together. In this post, I will explain the key steps for OTcl command invocation.

Monday, July 12, 2010

C++ and OTcl Linkage: OTcl Commands — Getting Started

Note: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapter 3 of the book for better understanding.
OTcl Command -- Getting Started

View more presentations from Teerawat Issariyakul.

Introduction

This post is the second post in the series on C++ and OTcl Linkage:

   1. Why Two Languages?
   2. Binding C++ and OTcl classes [Main steps, The mechanism].
   3. Variable binding
   4. OTcl command: Invoking C++ statements from the OTcl domain [ Getting Started, Make it more Interesting ]
   5. Eval and result: Invoking OTcl statements from the C++ domain
   6. Object binding and object construction process.

In the previous post, I blogged about how C++ and OTcl classes are bound together. In this post, I will explain how to bind C++ and OTcl class variable together.
=======================================================
T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009. Buy it now from

You may also find lecture notes and other resource at the following website: http://www.ece.ubc.ca/~teerawat/NS2.htm

Thursday, July 8, 2010

Segmentation Fault: A Common Error in NS2

Introduction

One of the most common error you might have found when running NS2 is "Segmentation Fault". This is just a type of runtime error. If you run, the same program in Win32 console application, Windows will show a run-time error message and terminate the program. So don't be intimidated by it. 

Monday, July 5, 2010

C++ and OTcl Linkage: Binding variables

Note: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapter 3 of the book for better understanding.

Introduction

This post is the second post in the series on C++ and OTcl Linkage:

   1. Why Two Languages?
   2. Binding C++ and OTcl classes [Main steps, The mechanism].
   3. Variable binding
   4. OTcl command: Invoking C++ statements from the OTcl domain
   5. Eval and result: Invoking OTcl statements from the C++ domain
   6. Object binding and object construction process.

In the previous post, I blogged about how C++ and OTcl classes are bound together. In this post, I will explain how to bind C++ and OTcl class variable together.
NS2: Binding C++ and OTcl variables


View more presentations from Teerawat Issariyakul.

=======================================================
T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009. 
You may also find lecture notes and other resource at the following website: http://www.ece.ubc.ca/~teerawat/NS2.htm

Wednesday, June 30, 2010

[ns2] C++ Command assert()

When delving into the C++ domain in NS2, you would be likely to find a C++ statement assert(<expr>). For example, in file ~ns/common/agent.cc,

assert(p!=NULL)

This function inspects its input argument <expr>. If the <expr> is
  • TRUE, it does nothing.
  • FALSE, it terminates the program.
For more information, please see [ this link ].

Sunday, June 20, 2010

C++ and OTcl Linkage: Binding C++ and OTcl classes — Part II

Note: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapter 3 of the book for better understanding.

Introduction

This post is the second post in the series on C++ and OTcl Linkage:

   1. Why Two Languages?
   2. Binding C++ and OTcl classes [Main steps, The mechanism].
   3. Variable binding
   4. OTcl command: Invoking C++ statements from the OTcl domain
   5. Eval and result: Invoking OTcl statements from the C++ domain
   6. Object binding and object construction process.

In the previous post, I blogged about how C++ and OTcl classes are bound together. In this post, I will explain the internal mechanism of the binding process.



Saturday, June 12, 2010

C++ and OTcl Linkage: Binding C++ and OTcl classes -- Part I

Note: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapter 3 of the book for better understanding.

Introduction

This post is the second post in the series on C++ and OTcl Linkage:

   1. Why Two Languages?
   2. Binding C++ and OTcl classes [Main steps, The mechanism].
   3. Variable binding
   4. OTcl command: Invoking C++ statements from the OTcl domain
   5. Eval and result: Invoking OTcl statements from the C++ domain
   6. Object binding and object construction process.

In the previous post, I blogged about the motivation of having 2 languages. In this post, I will show you how to bind a C++ class to an OTcl class so that when an OTcl object is created, a shadowed C++ object is automatically crated.

Tuesday, June 8, 2010

Error message: Undefined reference to vtable

Introduction
Another common error message when you compile NS2 would look like this

Book/otcl.o:otcl.cc:(.text+0x8c): undefined reference to `vtable for MyObject'
collect2: ld returned 1 exit status
make: *** [libns.dll] Error 1

Why?
This error is caused by declaring but not implementing one or more virtual function.

How to Fixed It?
Provide implementation to all virtual functions

Wednesday, May 5, 2010

[ns2] Do you really need NAM?

NAM
Recently, I've got few people asking about installation NAM (network animator) in NS2. Usually it is quite straightforward to do it in Linux. But it's quite tricky in Windows (with Cygwin). To be honest, I have not tried to use NAM in Cygwin. If I have time, I might try and let you know.



Wednesday, April 7, 2010

How to Read My Book

At the beginning, there was frustration.

First of all, I would like to thanks everyone for purchasing the NS2 book. The book was motivated by my frustration when I learned NS2 a long time ago. I guess everyone would at one time share that frustration with me. NS2 is a great tool. It has numerous modules.
Unfortunately, it does not have enough good documentation. With that, I began writing the book in order to help you guys get started with NS2. I appreciate everyone coming to this website, and every comment that you have on the book. Again, thank you.



Sunday, March 28, 2010

Classifiers and Routing Modules: Putting a default classifier in a node using "$ns node"

Note: This is a detailed note for the book, Introduction to Network Simulator NS2. You may have to read chapter 6 of the book for better understanding.

Introduction

This post is a sequel of the previous post, which demonstrated the relationship of classifiers, routing modules, and nodes: What are they, their purposes, their relationship, and how to configure them conceptually.

What's in This Post

Now that you get the concept, let's look at how NS2 actually configure them. I will demonstrate the process by walking through a command $ns node, which creates a node.
This post focuses mainly on how a default classifier, namely classifier_, is create and inserted into a node. I will discuss about routing modules in subsequent posts.

Sunday, March 21, 2010

Classifiers and Routing Modules: Configuration

Note: This is a detailed note for the book, Introduction to Network Simulator NS2. You may have to read the book for better understanding.

Introduction
This post is a sequel of the previous post, which demonstrated the relationship of classifiers, routing modules, and nodes: What are they, their purposes, and their relationship.
Great! Now that you know the relationship of classifiers, routing modules, and nodes. Let see how NS2 actually do it in Tcl! 

Wednesday, March 17, 2010

Including New Modules into NS2

Your New NS2 Modules
You are doing research. One day you come up with a great idea, and you want to show it to the world how great your idea is. So you decided to go for NS2. You start learning NS2, while developing your idea using C++ and Tcl.

The Coding Completes; Frustration Begins
Great! After a long work, you finish coding in C++ and Tcl. Now, you are asking yourself, "What do I do next?"

Of course you would like to incorporate you codes into NS2, you don't really know how. Frustrated, eh?

Including Your Modules into NS2
The following slide shows you how new modules are incorporated into NS2:
Including Your Modules into NS 2

View more presentations from Teerawat Issariyakul.

------------------------------------------------------------------------------------------------------------
For more information about incorporating new modules into NS2, see Chapter 2 in the following book from Springer:
T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009.

You may also find lecture notes and other resource at the following website: http://www.ece.ubc.ca/~teerawat/NS2.htm

Monday, March 8, 2010

For NS2 Newbies

Starting to Use NS2 is Easy

At first glance, learning NS2 is not very hard. You can go through the tutorial by Mark Greis' Tutorial, and learn NS2 in few hours.

Then you will feel like you are on the right track. NS2 is a very simple. The Tcl is a very simple and intuitive language. You can construct a complex network (e.g., TCP over wireless networks) very easily. Moreover, you can get a nice animation from nam (network animator) and plot graphs using Xgraph. What's more do you want?

Hit by Reality when Extending NS2 beyond its Scope

There is only one problem. One big problem. Things are simple as long as what you would like to work on is built-in to NS2. What's the odds? Very slim! If you are doing research, you would do something innovative. Something that no one has done before. And, that thing, my friends, is not very likely to be one of NS2 built-in modules.

From this point, everything goes downhill. A common question everyone ask is as follow. I have a great research idea. How can run NS2 to validate my idea.? Good question but the answer can be harsh.

Nothing in Life is Easy

I don't mean to discourage you. But learning NS2 beyond its scope is excruciatingly painful. You've got a lot of work to do. If you really want to know NS2, here is the step that I would suggest you should learn.

Quick Fix: An Easy Way in Doing Simulation in NS2 (not Recommended)

I started learning NS2 in a wrong way. I did not start from basic. So I chose a quick and easy way, trying to modified the NS2 codes to fit my needs and hoping that it'll work. Sometimes, it did. Sometimes, it did not. In the end, I had to abandon NS2, and wrote my own simulation code in C++. Do not follow my footstep!

Prerequisite

If you are reading upto this point, it means you do not want to follow my mistake, and you are commit yourself to seriously learn NS2. Here are few things that you need to do before proceed further:

1. Learn C++: Not just C. The OOP (object oriented programming) concept is the very core of NS2.
2. Learn Tcl: The scripting language by NS2. I find the following book quite useful. You only need to read chapters 3-7.

3. Learn OTcl: Objected Oriented version of OTcl. The most useful resource is [This website].
4. Install NS2. Go to [NS2 Webpage] for further instuction.
5. Go through Mark Greis' Tutorial.

    After you clear the above checklist, you can proceed to the key steps in learning NS2 below.

    Key Steps in Learning NS2

    Regardless of you research work, I believe you should get the basic first. And, here are the key steps.

    1. Learn how NS2 pass packets from one object to another (e.g., from a Node to a SimpleLink).
    2. Learn how to bind C++ and OTcl. This is a hard one. But, it will be easier when you understand the first step.
    3. Learn the module you are interested in. Really, it's quite hard if you don't have the basic in NS2, and want to jump start to do your own work. It's like a baby trying to jump before learning how to crawl!
    4. Modify, include, and build. This would be the final thing that you need to learn.
    -----------------------------------------------------------------------------------------
    The details of NS2 can be found in the following book from Springer:
    T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009. Buy it now from

    You may also find lecture notes and other resource at the following website: http://www.ece.ubc.ca/~teerawat/NS2.htm