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

2 comments:

Teerawat Issariyakul said...

Test

Anonymous said...

Hello Teerawat! I'm using NS2 for the first time and I'm finding your book to be the most complete and easy to understand document on the topic. It has been absolutely helpful. Thank you very much for writing it!

I have a question for you: I want to connect a single application instance to lots of agents. This is possible since every agent has an app_ pointer. Once I've done that, is it possible to have the application select exactly one of the attached agents through its own agent_ pointer when it needs to send data?

Thank you very much in advance!

Stefano