Friday, December 4, 2009

Vista-XP File and Printer Sharing Compatibility

If you have recently installed window 7 or windows vista, you might have a networking problem with your previous windows servers. Here is the problem that I have.

I have a window XP running as a server at home, with password protected login capability. Everything works fines until I upgrade one of my systems to Window 7 (you might see the same problem if you are running Windows Vista). Then, I cannot logon to this XP server. It said the username/password is incorrect. The cause is the default networking of Windows 7 and Windows Vista do not work well with Windows XP. More specifically, it is the problem of what Microsoft called NTLM.

Standing for NT LAN Manager, NTLM is a Microsoft authentication protocol. It is used to verify who you are when you logon to a Microsoft-based machine. Various versions of NTLM are used as follows:


Window NT Challenge/Response (NTLM version 1 or NTLM 1)

Windows NT

LAN Manager (LM) Challenge Response:

Windows 95, 98, and 98SE

NTLM 2

Windows NT since SP4, Windows 2000, or later


Now that we know the cause of the problem. Let's fix it. Clearly, the solution is to activate NTLMv2. This is done by changing registry.

Solution: You will need to do to Here are the steps:
1. Start Registry Editor (Regedit.exe).
2. Look for the following key in the registry: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\LSA
3. On the Edit menu, click Add Value, and then add the following registry value
  • Value Name: LMCompatibility
  • Data Type: REG_DWORD
  • Value: 1 (for client; e.g., Vista or 7), 3 (for server; e.g., XP)
  • The description of the meaning of the values are given at the end of the post (read it if you are interested).
  • Note: A client machine is the one you are using. You are using this computer to logon to the server. The value must be set to 1. As for the server, you can set the value to be either 1 or 3.
4. Quit Registry Editor.

Meaning of the value for LMCompatibility. Client refers to your client computer, while domain controller refers to your server.
  • Level 0 - Send LM and NTLM response; never use NTLM 2 session security.
  • Level 1 - Use NTLM 2 session security if negotiated.
  • Level 2 - Send NTLM response only.
  • Level 3 - Send NTLM 2 response only.
  • Level 4 - Domain controllers refuse LM responses.
  • Level 5 - Domain controllers refuse LM and NTLM responses (accept only NTLM 2).
To read more visit:
[1] "How to enable NTLM 2 authentication", Microsoft Knowledge Base Article 239869, http://support.microsoft.com/kb/239869
[2] "NTLM", Wikipedia, http://en.wikipedia.org/wiki/NTL

Thursday, November 19, 2009

Grave accent: A language switching key or an opening quotation mark?

Are you a LaTeX user? If so, you must know that the opening (left) quotation is in fact the grave accent (`). Writing two of (') would give you two ending (right) quotation marks. This works fine, until you install two keyboard layouts in your Windows OS.

By default, Windows use a grave accent key to switch between language. Hence, you cannot type an opening quotation mark. If you press on a grave accent, instead of showing (') on the screen, Windows will switch the language for you.

Does it mean you cannot use LaTex under multiple keyboard layout setting? Well, there are two workarounds:

  1. Use different key for language switching bar: Windows allows you to use either alt+shift or ctrl+shift. I don't like this option, since I tend to miss one of the keys. And, it will mess up my typing rhythm.
  2. Use Windows key: Most new computers would have a window key. By pressing windows+grave accent, Windows will show an opening quotation mark on the screen (rather than switching the language).
Well, the WINDOW+GRAVE ACCENT is my savior!!

Wednesday, October 7, 2009

[NS2] Updated NS2 Lecture Note.

I just updated the NS2 lecture note at the following URL.

http://www.ece.ubc.ca/~teerawat/NS2.htm

They are now in one slide per page. Easier to read, eh? BTW, if you are an instructor and need a power point slide feel free to contact me, (Due to the spammer, I don't wanna give out my email here. My email is provided in the NS2 book), or you may put the comments on the blog.

Here is the book from Springer:

T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator
NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3

Sunday, September 27, 2009

[NS2] Deterministic v.s. Random

Deterministic Setting

By default, NS2 runs deterministic simulation. That is, you will get the same result for every run. The deterministic setting is usually good for debugging, where you would like to know what goes wrong at an exact point.

Random Setting

Statistical analysis involves running simulation for several times and find averages/variance for all the runs. NS2 is deterministic by default. The results from every run with default setting are the same, and the variance of the results is therefore zero. Statistical analysis require randomness so that the avarages and variances would be meaningful.

In order to introduce a randomness to NS2, you will need to insert the following line into the Tcl Simulation script prior to "$ns run":

$defaultRNG seed n

where is an integer. If n is zero, the simulation would be totally random. The result would be different for every run. If n is another integer, NS2 will use n as a seed for random number generator.


By default, NS2 sets n to "1". Therefore, every run generate the same result. If you set n to 101, by executing

$default seed 101

the result would be different from the result corresponding to the default setting. But all the result with n = 101 would still be the same.

For more information about Random Number Generators, see Chapter 12 in the following book from Springer:

T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator
NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3

You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm

Saturday, September 19, 2009

iTune 9.0 and the missing podcasts

Can't find the content? Perhaps You are in the wrong country.

Do you know that iTune stores are different from countries to countries. If you are in an unfortunate country (e.g., Russia, Thailand). The content in the iTune store you see is quite limited. See below for example,



I am one of an unfortunate man, since the contents I like are mostly in the US. A fresh installation of iTune 9.0 does not allow me to see a wide variety of contents. On the other hand, people who install iTune 9.0 on a some country can access a lot more contents such as music, movies, podcasts, and so on. Look below for a screenshot for iTune stores in the US.


Unfortunately, my favorite podcasts (e.g., Security now, Businessweek, the world) are not available in some countries (including mine). By default, I cannot access the content I like.

Still want the content? Let's get around.

In order to browse, search, or download podcasts, I need to fool iTune that I am not at the place where I am (e.g, not in Russia or Thailand). iTune does not make that easy for the users. But I get aound it and here is how.

  1. Go to iTune store
  2. Click "Sign In" (see the picture above)
  3. Click "Create New Account"
  4. Click "Continue"
  5. Click on the arrow after "If the billing address of your payment information is not in the United STates, click here"
  6. Now you can change your iTune store to your favourite country, by choosing at "Select a country" and click "Change Country"
And now, you should be able to see the content as people in the US see. I wish Apple would make this process easier. If any of you know an easier way to do this, please let me know. I am curious to know how.

Thursday, September 17, 2009

Crimson editor and Window Vista

CRIMSON EDITORS:

Crimson Editor is my favorite text editor. It is a free lightweight text editor (only 1.2 MB), and has several useful feature. The ones that I use the most are
  1. Syntax highlighting
  2. Built-in and user-defined spell-checker
  3. User tools and macros: This is very cool. You can define any shortcut (e.g., Ctrl+1) in order to run any executable file on your system with various types of input argument (e.g., file title, filename (title + extension).
I am a LaTeX user. The above three functionalities are all I need to write LaTeX documents.

Here is the link to the editor.

http://www.crimsoneditor.com/

PROBLEM WITH WINDOWS VISTA:

Unfortunately, UAC (User Account Control) of Windows Vista prevents the editor from using all its functionalities. For Crimson editor version 7, I cannot save the configuration of "User Tools". Once the editor is closed, the configuration is lost. When the editor is reopened, I have to reenter all the configuration for user tools.

To get around this problem, you have to right click on the Crimson Editor icon and click on "Run as administrator". By doing that, the configuration will be saved upon the exiting program.

Sunday, August 9, 2009

Packet Forwarding Mechanism

In NS2, objects that are able to pass packets around are called NsObject. They are the objects derived from class NsObject. Class NsObject declares function recv(p,h) as pure virtual, forcing its derived class to specify how a packet is received. For example,
  • Once a connector receives a packet, it immediately passes the packet to its forwarding object.
  • Once a queue receives a packet, it puts the packet in its buffer. The queue will send out only the head-of-the-line packet.
As you might guess from the name of the function, NS2 models packet forwarding by "receiving" rather than "sending". In most cases, a packet forwarder asks a packet receiver to receives a packet by calling the function recv(p,h) of the packet receiver For example, as a packet forwarder, a Connector contains a pointer "target_" to a packet receiver. When a connect needs to send a packet "*p" to a packet receiver, it executes target_->(p,h), where "h" is a pointer to a handler.

In general, an NsObject forwards packets in two following ways:
  1. Immediate packet forwarding: A packet forwarder forwards a packet as soon as it receives the packet. The packet receiver receives the packet at the same time as the packet forwarder does. For example, a Connector forwards a packet to its downstream object by invoking target_->recv(p,h). In this case, the packet receiver (i.e., "*target_") receives the packet "*p" at the same time as the Connector does.
  2. Delayed packet forwarding: To delay packet forwarding, the packet "*p" is cast to be an Event object, associated with a packet receiving NsObject (i.e., handler "*h"), and placed on the simulation timeline at a given simulation time"t". This is to schedule a packet reception event at time "t". When the simulation runs to time "t", function handle of the NsObject "*h" is invoked. From within function NsObject::handle, function recv is executed, and the packet "*p" is received by the NsObject "*h".
In case of delayed packet forwarding, the input argument "h" (i.e., a pointer to the handler) is mandatory. The handler is a reference to the NsObject which will receive the packet at a certain time "t". Without handler, NS2 will not know where it should send the packet to.

The handler is optional for immediate packet forwarding. It is not used when executing recv(p,h). We can simply provide the "h" as a null pointer. However, in some cases, the handler will be passed to the downstream objects. At the place where a delayed packet forwarding is invoked, the handler "h" will be used as an input argument.

For more information about NsObject and packet forwarding, see the
following book from Springer:

T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator
NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3

You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm

Tuesday, July 28, 2009

[AIT09] ARQ Transmitter

This question is from Thanapol, 107929.
  1. What is responsibility of tARQ_ in ACK passing?
  2. What is the base class of ARQRx and ARQTx ?

Sunday, July 26, 2009

[AIT09] TCP Agent

This question is from Rujipol:

  1. Why does a TCP protocol need 3-way handshake? When does it being used?
  2. What does functionalities that TCP have that UDP does not have?
  3. What does variable "reason" in ~/tcp.h do? When does it being used?
  4. How many error control mechanism does TCP have? What are they?
[I suggest you to answer one question only]

[AIT09] Packets

This question is from Rujipol.

  1. How do we initialize the packet? What if we didn't initialize packet, what will happened?
  2. How do we deallocate a packet?
  3. What is the purpose of having packet header, and who is responsible for configuring the packet header?
  4. What is the actual data type of enum?
  5. Who is responsible for packet construction?
  6. What are two main parts of protocol specific header?
[I suggest each of you to answer one question only]

Friday, July 24, 2009

[AIT09] Update assignment submission

Dear all,

Please find status of your assignment submission in Here. The last day that you can submit the assignment is Jul. 29, 2009.

Teerawat

Tuesday, July 21, 2009

[AIT09] RTO

This question is from Shujaat.

1. What is the main difference between Bounded and unbounded RTO?
2. Which one does TCP use? Why does it choose that choice?

[AIT09] Connector

This question is from Thein Tun Aung

  1. What are the main variables of class Connector?
  2. Which ones are the pointer?
  3. Where do they point to? Is the object they point to an abstract object? If so, how?
  4. How do we fit the connector to a class composition framework?

[AIT09] Assignment Status

Dear all,

Here is the current status of assignment submission. Please check your own status. We have overall 9 assignments.

Best,
Teerawat

[AIT09] Assignment

Hi all,

I marked few assignments. I left your assignment on a desk of the Hallway, where you hand in assignment for other courses. Please go and pick up.

See you on Saturday,
Teerawat

Monday, July 20, 2009

[AIT09] Queue

This question is from Thein Tun:

How do you get the length of the queue ? Can you give examples of different types of queue?

[From Teerawat: Do not give more than one example per person]

Thursday, July 16, 2009

[AIT 09] HashClassifier

These questions are from Nakrop:

1. What are the differences between PortClassifier and HashClassfier?
What are their the based classes?
2. How important is a hash table is important to a hash classifier? Why? What information is stored in the hash table?
3. In the implementation of function classify(p)of class DestHashClassifier, what does the statement "set_hash(0,d,0,slot)" do?
4. How is OOP used to implement function hashkey(...) of class HashClassifier?

[AIT 09] OTcl, Route, and TCP

This question is from Muhammad Hasanain Chaudary:

1. What is the Role of keyword “self” in the OTcl?
2. What is the instproc (and what is the associated class) used to compute the optimal route in NS2?
3. What’s the difference between Fast Retransmit and Fast Recovery? What is their relationship?
4.Is there any drawback of TCP?

Wednesday, July 15, 2009

[AIT09] Classifier

This question is from Nakrop.

1. What are the based class of class Classifier?

2. What are two key variables of the C++ class Classifier? What are their purposes?

3. "Function classify(p) is the most important function of a classifier"
Do you agree with this statement? If you agree, please give your reasons.

4. What are the default values of shift_ and mask_ ?
Which function use these variables?

Monday, July 13, 2009

[AIT09] New Lecture Notes

Guys,

I just post a new lecture note on the website. I also fixed the broken file for chapter about UDP. Please have a look at

http://www.ece.ubc.ca/~teerawat/NS2.htm

Sunday, July 12, 2009

[AIT09] instvar classifier_ and next_rtm_ of class RtModule

This question is from Wattanadej

1. Why the instvar classifier_ and next_rtm_ of RtModule(OTcl) are not bind with the variable classifier_ and next_rtm_ of the compiled class(C++)?

2. What is the C++ class corresponding to the OTcl class RtModule?

[AIT09] RTT and RTO for TCP

This question is from our friend Shujaat

Suppose we have average RTT of 1.5 ms, and RTT variation of 0.5 ms. Suppose further that the next RTT sample is 3 ms.
1) What is the average value of RTT corresponding to the last RTT Sample above.
2) What is the value of RTT variation
3) What is the value of RTO

[AIT09] Output Queue

This question is from Thein Tun Aung:

How is an output queue of a node implemented ?
What will happen if the buffer capacity of output queue is exceeded ?

Friday, July 10, 2009

[AIT09] How to create a two-way TCP

This question is from our friend Shujaat

In our course we have studied TCP Agent for one way transmission by
sender (which obey different congestion and error control
techniques)and sink(receiver). If we want to transmitt in two ways. Is
is possible to transmit in 2 ways in NS2?
If possible then how?

Thursday, July 9, 2009

[AIT09] Addressing in NS2

This question is from our friend Hasanain.

The question is
  1. What is the address format in NS2?
  2. Where do we store (IP) address?
  3. How do we store the IP address? (using what function or instproc?)
Any comments?

Wednesday, July 8, 2009

[AIT09] A Welcome Message

Welcome, everyone. As we'll be discuss in the class, this would be the place where we discuss about NS2 course. The purpose is to have you all participate in a meaningful way. Here is how it works.

  1. You send me an email stating problems or questions you have.
  2. I select questions and post the selected questions (with title beginning with [AIT09] and label AIT09) on the blog. The selected question would earn marks.
  3. You help each other by trying to commenting or answering the question. Each thoughtful comment and answer earns marks. The meaningless comments such as "I think so" do not earn marks.

Try to come back here as often as you can. You know, it is easier to comment if you read the discussion first.

Good Luck... Teerawat

Wednesday, April 29, 2009

How an application sends a message to an agent

NS2 defines applications in class Application (see ~ns/apps/app.h,cc). The derive classes of application are for example TrafficGenerator (e.g., CBR) or FTP. The application models user demand. Therefore it need to send message to an agent saying that a use needs to send data. Here is how.

Class Application have a pointer to an Agent object, agent_. In order to send a message with size nbyte bytes to an associated agent. It executes

agent->sendmsg(nbytes);

where the function sendmsg(...) belongs to class Agent. There are several more ways that an Agent object can received a message. Those ways are defined in function of class Agent (see ~ns/common/agent.cc).

For more information about Agents and Applications, see Chapters 9-11 in the following book from Springer:

T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3

You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm

Friday, March 13, 2009

[NS2] Dropping a Packet

Suppose you have a pointer "p". You can drop the packet by executing

Packet::free(p)
Also the packet "*p" can be dropped from within the Connector object by invoking function drop as follows:
drop(p);

Note that "drop(p)" is a function of class Connector, and therefore must be invoked from within the scope of class Connector.


For more information about Connector and Packet, see Chapters 5 and 8, respectively, in the following book from Springer:

T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3

You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm

Wednesday, March 11, 2009

"no-slot" error for classifiers

"no-slot" error for classifiers

From previous post, a classifier is a multi-target packet forwarder. It classifies incoming packets into categories, and forwards packets in the same categories to the same NsObject.

The forwarding NsObject is installed in a so-called "slot". Class Classifier defines a link-list variable "slot_" which holds forwarding NsObjects. The NsObject is "i" slot can be obtained by referring to "slot[i]". If no NsObject is placed in slot "i", and you are trying to access "slot_[i]", a "no-slot" error will be shown on the screen.

Example (trying to access slot "-1"):

_o18: no target for slot -1
_o18 type: Classifier/Hash/Dest
content dump:
classifier _o18
0 offset
0 shift
2147483647 mask
1 slots
slot 2: _o116 (Classifier/Port)
-1 default



For more information about Classifiers, see Chapter 6 in the following book from Springer:

T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3

You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm

Tuesday, March 3, 2009

NS2 Trace Format

When using trace-all in NS2, a trace string is created in a trace file. The format of a trace string is shown below:



where 12 fields of the trace string are as follows.

1. Type Identifier:
  • "+": a packet enque event
  • "-": a packet deque event
  • "r": a packet reception event
  • "d": a packet drop (e.g., sent to dropHead_) event
  • "c": a packet collision at the MAC level
2. Time: at which the packet tracing string is created.
3. Source Node and Destination Node: denote the IDs of the source and the destination nodes of the tracing object.
4. Packet Name: Name of the packet type
5. Packet Size: Size of the packet in bytes.
6. Flags: A 7-digit flag string
  • "-": disable
  • 1st = "E": ECN (Explicit Congestion Notification) echo is enabled.
  • 2nd = "P": the priority in the IP header is enabled.
  • 3rd : Not in use
  • 4th = "A": Congestion action
  • 5th = "E": Congestion has occurred.
  • 6th = "F": The TCP fast start is used.
  • 7th = "N": Explicit Congestion Notification (ECN) is on.
7. Flow ID
8-9. Source Address and Destination Address: the format of these two fields is "a.b", where "a" is
10. the address and "b" is the port.
11. Sequence Number
12. Packet Unique ID


For more information about tracing in NS2, see Chapter 13 in the following book from Springer:

T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3

You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm

Monday, March 2, 2009

Classifiers

A classifier is a multi-target packet forwarder. It classifies incoming packets into categories, and forwards packets in the same categories to the same object.

Main characteristic:
  • A classifier installs the target in its array slot_
  • A classifier is an NsObject. Therefore, it receives a packet using its function recv(p,h).
  • When receiving a packet p, it looks for a matching slot (i.e., node = find(p)) and forward th packet to the object installed in that slot (i.e., node->recv(p,h))
  • Function finds looks for a slot (i.e., cl) with matching criterion, using function classify(p).
  • Function classify(p) returns a slot with matching criterion. It is defined in the derived class.
void Classifier::recv(Packet* p, Handler* h)
{
NsObject* node = find(p);
if (node == NULL) {
Packet::free(p);
return;
}
node->recv(p,h);
}

NsObject* Classifier::find(Packet* p)
{
NsObject* node = NULL;
int cl = classify(p);
if (cl <>= nslot_ || (node = slot_[cl]) == 0) {
/*There is no potential target in the slot;*/
}
return (node);
}
Example: Suppose we would like to forward packets with port "i" to the same object.
1. Install NsObject in slot_[i] of the classifier
2. Make function classify(p) return the port number of "p"

For more information about Classifiers, see Chapter 6 in the following book from Springer:

T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3

You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm

Friday, February 27, 2009

Packet size in NS2

In general, a packet consists of packet header and data payload. Packet header stores packet attributes (e.g., source and destination IP addresses) necessary for packet delivery, while data payload contains user information. Although this concept is typical in practice, NS2 models packets differently.

In most cases, NS2 extracts information from data payload and stores the information into packet header. This idea removes the necessity to process data payload at runtime. For example, instead of counting the number of bits in a packet, NS2 stores packet size in variable hdr_cmn::size_, and accesses this variable at runtime

Given a pointer to a Packet object p, the following statement sets the packet size to be "my_size"

hdr_cmn* hdr = hdr_cmn::access(p);
hdr->size() = my_size;

For more information about Packets, see Chapter 8 in the following book from Springer:

T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3

You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm

Sunday, February 8, 2009

[NS2] The difference between an instproc "compute-routes" and a C++ function "computes_routes()"

Two NS2 functions and instproc has very similar name: "compute-routes{}" and "compute_routes()". The differences are shown below:

compute-routes{}
  • is an OTcl command
  • is defined in class Simulator
  • is defined in file ~ns/tcl/lib/ns-route.tcl
  • populate routing information into nodes

compute_routes()
  • is a C++ function
  • is defined in class RouteLogic
  • is defined in file ~ns/routing/route.cc
  • computes the routing information for all pairs of nodes

For more information about Nodes and Route setup, see Chapter 6 in the following book from Springer:

T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator
NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3

You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm

Saturday, January 31, 2009

Correction for NS2 Book: ARQ Codes

This is the correction for the following book:

T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator
NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3


If you are trying to run the ARQ codes in chapter 14, it will not work. You need to add the following code into your arq.cc file:

static class ARQTxClass: public TclClass {
public:
ARQTxClass() : TclClass("ARQTx") {}
TclObject* create(int, const char*const*) {
return (new ARQTx);
}
} class_arq_tx;


You might also find the following slide useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm

Best,
Teerawat

Wednesday, January 21, 2009

"Can I use NS2" v.s. "Do I need NS2"

Yes, NS2 is a very powerful network simulation tools. A lot of people wants to use it (some without knowing whether they really need NS2). A common question is that "Can I use NS2 for my work?" Unfortunately, no one knows the answer more than yourself. In fact, it is more appropriate to rephrase the question as "Do you really need NS2?" A tough one, eh?

So, here are some question which can help you determine whether you need NS2.

- You don't want to use NS2 if your work is self-contained. If your work does not need any interaction with many other component (e.g., determine bit error rate for a particular modulation), it would be easier to write codes in a basic programming language (e.g., C++).
- You want to use NS2 if you work is so connected to other components and you don't want to re-create those component. NS2 has a whole lot of modules that you can re-use. Those modules are written and proved by others. They are quite robust and ready to use. If for example you want to study TCP performance for your new modulation scheme, you might consider writing your own modulation module and use TCP module available in NS2.

Come back to our original question: "Can I use NS2 for my work?" Well, the answer is always YES! NS2 is just a combination of C++ and Tcl. If your work can be programmed by using C++, Tcl, or both. You can use and integrate your work into NS2. But, again, if you don't need to, don't bother using NS2. After all, use NS2 to make your life easier. Do not enslave yourself by using NS2 :)

For more information about language structure (C++-Tcl) in NS2, please look at chapter 3 in the following book:

T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator
NS2", Springer 2008.

Here is the link:
http://www.springer.com/engineering/signals/book/978-0-387-71759-3

You might also find the following slide useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm

Best,
Teerawat