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

    Sunday, March 7, 2010

    Entrepreneurial Principles: Disruption, The Sumptuous Impertinence

    Disruption

    Disruption refers to the act of breaking equilibrium. In the old time, people go out an hunt animal everyday. Their routine is in equilibrium. Then along come agriculture, which disrupt their routine. Just like agriculture, online recommender communities would disrupt the current business model called Antelope Hunt Business Model.

    Antelope Hunt Business Model

    Impala









    A picture of an antelope
    An antelope hunt business model is old business model which works like this 1) Hunting an antelope (i.e., find a customer), 2) Kill it, bring it home, and eat it (Sell things to customer), and 3) Find another one. It is wasteful and costly. While the antelope hunt business model shrinks the market with each sale, the online community business model expands the market with each sale.

    Members of an online community find the community by themselves, pay the monthly fee for the privilege of being in the community (possibly for a year or longer), share search and information with other members.

    By now, you might wonder who would want to pay for monthly fee, just to be in the community. Well, read along and you will see that the community is a platform where only the members earns money while solving their pain.

    Benefit Number 1: A Pain Solver

    A recommendation online community is borned from pain. Each member of the community share pain and would be delighted if the community can help them relieve the pain. The pain arises from, for example, time needed to look for what they need. If they are not able to find solution, they will have to put up with what the vendor offers in the market. The first benefit of an online recommender community is to help member solve pain.

    Benefit Number 2: A Transfer of Wealth

    An online recommender community can act as a revenue generating platform for the members. Again, this is the place where the member rate, review, and recommend products. There are 18 revenue channels, which are the result of the members' actions. The community should share a part of its revenue with members to motivate the member to create more valuable content.

    Cost of products consists of production cost and marketing cost. An online community can leverage the marketing cost by doing the marketing for product vendors. The conversation of members can be sliced, diced, and then sold anonymously to the vendor. The vendors will, in turn, benefit from market cost reduction.

    Apart from 18 revenue channels discussed earlier, product branding is another one. When a company wants to launch a product, it can hire the community to survey the market, draft a plan, and come up with a fair pricing. The community rates, votes, or even design new products for the company. A community can even sell its brand to the company. The consumers who appreciate the community are likely to purchase the product with community's brand.

    Privilege of Being in a Community: Viewing or Creating the Content

    Being in a community gives members two above benefits. The former one, pain solver is pretty obvious. Members benefit from truthful information from other members.

    But the interesting is the latter one: A revenue generating platform. Here, the privilege is not for viewing the content, but for creating the content. The member can use the community as a marketplace where they can offer their content for sale. The high-quality content will get picked and purchased by the community, product vendors, and/or other members.

    The Endowment Effect

    People often things they own more than things they do not own. The value of a house depreciated as time elapses. Yet, the owners often refuse to sell their house at the depreciated price.

    Similarly, when people become a member, they tend to stick around. It is easier to keep the member in the community, than to persuade people to become a member. But it is also important to give member a glue factor such as lockers, closets, watch us grow page. See [here] for the elaboration of glue factors.



    Source: Social Network Business Plan by David Silver, Chapter 6.
    About the summary: It takes time to finish up a book. And, when you do, how would you review what you learn from the book. Flip through the books? What if the book is audiobook? You might have to go over the book again. Not plesant.


    The summary here contains insights I grasped when I read the book. It will tell you what to expect of the book. Giving key insights and the organization of books, the summary makes it easier and more entertaining when reading the book.


    What the summary does not give you is the details (e.g., business cases, anecdotes) and entertainments. So if you think this book will entertain you, you may buy it online here. Also you might want to check out the review of the book which shall be up soon.

    Thursday, March 4, 2010

    Classifiers and Routing Modules

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

    Classifiers

    Typically residing in a Node, a classifier is an NS2 component responsible for classifying packets. A classifier has one input link and several output links. When packets enters a classifier (via an input link), they are classified based on predefined criteria. Packets of different categories are forwarded to the different corresponding output links. These output links refer to logical connections from a classifier to another NS2 object such as a physical link, a transport layer protocol, a prioritized queue, etc.
    A node can contains several classifiers. Configuring classifiers one by one is a laborious task. It would be more convenient to configure all the classifiers via a single point of management. In NS2, that single points is called Routing Module.

    Routing Modules

    Routing module is an NS2 component designed specifically for managing classifiers. Via routing module, all classifiers can be configured by using a single command (e.g., add-route).

    Relationship of Classifiers and Routing Modules
    By convention, NS2 uses one routing module to manage a classifier. When a node has multiple classifiers, NS2 creates multiple routing module and associated each routing module with each classifier. An example configuration is shown below:


    From the above figure, a routing module has a pointer "classifier_" which points to the associated classifier. Multiple routing modules are links together by using pointer "next_rtm_". When we need to add a routing entry to all classifiers (by calling the instproc add-route), we only need to send the command through the first routing module (RM1), and the chain of routing modules will automatically propagate the commend to all connecting classifiers.

    Great! Now, we understand the purpose of routing modules. But how do we create the structure like the above picture? Stay tune. I will blog about it soon!

    For more information about classifiers and routing module, see Chapter 6 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

    Changing domain name of NS2 website

    I just change the domain name of the NS2 website. It's now http:// www . ns2ultimate . com.

    Wednesday, March 3, 2010

    NS2, Windows 7, and Cygwin 1.7: What a nightmare

    The rumor has it that this is the worst combination ever. The reason? It doesn't work. I try it myself. Well what I did is to build NS2 (2.33 and 2.34) over Cygwin 1.7. It creates error when the installation suite builds Tcl.

    Looking for the solution online, someone also experience similar problems. Here is the summary:

    - NS2 works well over Cygwin 1.5, but does not work over Cygwin 1.7.
    - Cygwin 1.5 does not work on Windows 7 see[].

    Unfortunately, Cygwin 1.5 can not be obtained easily.

    Potential solution:

    I am planning to try this. If you have comments, please let me know.

    1. Use NS version 2.35 which has not officially available yet.
    2. Install Cygwin 1.5.
    - Windows XP: You have to get setup-legacy.exe file from Cygwin (instead of setup.exe). It helps install version 1.5 rather than version 1.7
    - Windows 7: Again, Windows 7 does not support Cygwin version 1.5. So you have to run it on the compatibility (Windows 95) mode.

    What I will do next is to test these solutions. I will blog about it again soon.

    Sunday, February 28, 2010

    Tcl Error Message in NS2

    Tcl error messages in NS2 can be pretty scary. You can see an example at the end of the post. But it's not that hard to deal with it. Here is what you should do.

    1. Relax.... Breath....
    2. Go lines by lines following the error reporting structure:

    invoked from within
    "code"
    (location)

    From top to bottom, these three line blocks repeat themselves from the erroneous code to the file from which the error is initiated.

    invoked from within

    Error is usually caused by calling another procedure. NS2 provided a mechanism to drill down the error levels by levels until the real erroneous code is found. Each level is separated by the line with the phrase "invoked from within". This is to say that the upper line is "invoked from within" the lower line.

    "code"

    This is the quote on the exact NS2 codes, which cause the error. The location of this part is indicated in the next line.

    (location)

    Enclosed in (...) are the location where the error occurs. The format of location is

    category [argument] line number

    • category is the location category. It can be file, procedure, classname (e.g., SplitObject), etc.
    • argument (optional) specifies the scope of the location category. Examples are filename (e.g., "smcc.tcl"), instproc name (e.g., unknown).
    • line number shows the exact location within the above scope.

    ---------- Example Code -------------------------
    "_o3 cmd queue-parameter _o17 _o24 2 6"
    invoked from within
    "catch "$self cmd $args" ret"
    invoked from within
    "if [catch "$self cmd $args" ret] {
    set cls [$self info class]
    global errorInfo
    set savedInfo $errorInfo
    error "error when calling class $cls: $args" $..."
    (procedure "_o3" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "$ns queue-parameter $n3 $n4 2 6"
    (file "smcc.tcl" line 94)


    For more information about Tcl, see Chapter 3 and Appendix A in the following book from Springer.

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

    Book Summary: Why Am I Doing This?

    You guys might have seen plenty of websites for book reviews. But, book summary, there are not many of them. Why I am I doing this? It actually come out of my frustration. In fact, I want to do it for myself. So, I might as well share it with you guys. The followings are the reasons why I am doing book summary. BTW, my choice is audiobooks, not paper-based books.

    What I Learn from Reading the Book

    It takes time to finish up a book. And, when you do, sometimes, you want to review what you learn from the book. One of the best way is to make note as we read (how many of us would do that?) After you reach the end of the book, you can review your note and recall what you've read earlier.

    Looking for a Piece of Information

    After some time, you may recall that you came across something. But you don't remember it very clearly. The summary of the book will help a lot.

    More than Book Review

    There are 3 pieces of information you may want to know before reading a book. The first one is book review, where reviewers share their opinion on books. I think the reviews is the best place to talk about the writing style of authors. The second one is the table of contents, which, I think, is very useful. Table of contents gives you the overall structure of the book. It shows you what to expect of the book. Finally, the last piece is the summary. This is the deepest level of information. It contains the insight drawn from the book.

    What the summary does not give you is the details and entertainments. If you love reading, you would know what I mean. A good book keeps you engaged. You want to keep reading one page after another, and you cannot put it down. The summary does not give you that kind of sensation. No offense, but if you think reading the summary will save you time from having to read the book, you are obviously wrong.

    Even Greater with Audiobooks

    All of the above positive things get intensified, when you are dealing with audiobooks. Unlike paper-based books, audiobooks cannot flipped through page by page. The longest audiobook that I have listened lasts for more than 21 hours. If you don't know where, within the 12 hours, what you are looking for is located, you're going to end up listening for a very long time. Not pleasant, right?

    Summary and Spoiler

    The line is quite thin. Summary is something useful to know before and after the reading. However, spoiler destroys the moods and the funs of reading the book. To me, I think summaries of novels are spoiler. Therefore, the summary you will find in this blog are mostly of the non-fiction genre. Giving key insights and the organization of books, the summary makes it easier and more entertaining when reading the book. Summary or spoiler? I guess you guys would be the judge.