Professional Documents
Culture Documents
TCL File Explanation
TCL File Explanation
TCL File Explanation
set ns [new Simulator] -> here set is a command ns is a pointer variable new is command and
Simulator is inbuilt class inside ns
How to create an inter simulator and when to start and when to stop
1. set n1[new Node] -> Node is the object or class which is available in the NS2
2. set n2[new Node]
AGENTS
Link is established now on what kind of service they should work on
For connection full oriented we use TCP
For connection less service we will be using UDP
1) TCP-FTP
2) UDP-CBR
SETTING A TCP CONNECTION
1. set tcp[new Agent/TCP] -> setting a tcp pointer variable to the tcp agent
2. $ns attach-agent $n1 $tcp -> attach tcp agent to n1 n1 becomes the tcp agent (sending tcp
agent)
3. set sink [new Agent/TCPSink] destination can be initialized by using the TCPSink
4. $ns attach-agent $n2 $sink
5. $ns connect $tcp $sink -> we will connect both by using this connect keywork
6. $tcp set fid_1 -> fid is flowid it is used to differentiate between sending and receiving
data (n data flows which are happening at the same time)
7. $tcp set packetSize_552 -> if we don't send the packet size then we it will be by default
1k (1000)
FTP
File transfer protocol is a standard mechanism provided by internet for transferring files from
one host to another
FTTP use the service of TCP
Port 21 is use for control connection and post 20 is use for data transfer