Skip to main content

Posts

Showing posts with the label TCL

OTcl and C++ linkages in ns2 | NS2 Basics | Lecture 4

Understanding the Link Between OTcl and C++ in ns-2 Welcome! This post explores the fundamental connection between OTcl and C++ in the Network Simulator 2 (ns-2). We'll cover how these two languages work together to create a powerful simulation environment and examine the key TclCL classes that make this architecture possible. The Dual-Language Architecture of ns-2 Network Simulator 2 (ns-2) is built on a clever combination of two distinct languages: OTcl (an interpreted language) and C++ (a compiled language). This design strategically uses the unique strengths of each. OTcl (The Frontend) OTcl acts as the user-facing frontend of the simulator. User-Friendly: It's ideal for beginners, as you can start running simulations without deep C++ knowledge. Flexible and Fast to Modify: Since OTcl is interpreted, you can easily change network scenarios and parameters in your scripts without waiting for a lengthy re-compilation. This makes it perfect for tes...

Tcl/Tk Programming Basics | NS2 Basics | Lecture 3

Tcl/Tk Programming Basics In this chapter, you'll learn: ✅ The basics of Tcl/Tk Programming ✅ How to create and execute a Tcl script 📘 Introduction to Tcl Programming Over the past 25+ years, Tcl (Tool Command Language) has evolved through contributions from industry, academia, and open-source communities. It remains a popular scripting language in areas like: 🔧 Network equipment testing (e.g., routers, switches) 📐 Electronic IC design 🧪 Network Simulator 2 (NS2) scripting and simulation Created by John Ousterhout , Tcl was designed for embedded systems, offering: ⚡ Rapid prototyping 📦 Small memory footprint 📝 Versatile scripting abilities ✨ Key Features of Tcl/Tk Rapid Development: Tcl performs 5–10× faster in GUI, string handling, and integration tasks compared to other scripting languages. GUI Support: With the Tk toolkit, creating graphical interfaces is easy and powerful. Cross-Platform: Tcl/Tk works seamlessly o...

TCP Congestion Control using NS2

Congestion control is one of the performance metrics of TCP protocol. There are so many TCP Versions to control congestion in the network. NS2 also supports various TCP protocols like TCP Vegas, TCP Reno, TCP, TCP Sack, Full TCP, TCP linux, etc. The code can be downloaded from the following link https://drive.google.com/file/d/1EGeJOtqapDIB5NQy5Ar1L7nzPIihSyck/view?usp=sharing Each TCP protocols has different mechanism in controlling the congestion. Some are good at Congestion control, some are good at error ands flow control. Before understanding the congestion control, one has to know the congestion window of TCP. TCP has a congestion window (cwnd_ in ns2), this variable affects or predicts the congestion control. The value assigned to this variable will alter the congestion control. Here are the files that are of prime importance before dealing with congestion control. ~ns-2.35/tcp/tcp.cc  ~ns-2.35/tcp/tcp.h  ~ns-2.35/tcl/lib/ns-default.tcl (In this file, the co...

How to set Destination of Mobile nodes and Traffic Generation in ns2

This post will help you to understand the automatic TCL code generation for creating connections between the nodes, to create hops, generates tcp or cbr agents, etc. There are two things are used: setdest and cbrgen.tcl setdest is used to Create hops between the nodes using the GOD (General Operations Director) object. Create mobility for nodes in terms of metres/second Move from one place to another place using setdest (Set destination) with speed To execute, use ./setdest Example of Setdest is $] cd /home/pradeepkumar/ns-allinone-2.35/ns-2.35/indep-utils/cmu-scen-gen/setdest $] ./setdest -v 2 -n 10 -s 1 -m 10 -M 50 -t 30 -P 1 -p 1 -x 500 -y 500 > usersetdest.tcl The above output is redirected to usersetdest.tcl  cbrgen.tcl  create connections between the nodes , one can specify the maximum number of connections to be made for all the nodes in the network to create the type of agents between the nodes (cbr or tcp) rate at which the packets a...

NS2 Scenario Generator - Lecture 7

If you are tired of writing code using .tcl files, here is a solution for that. This software is a little bit old, as it released sometime during 2007, still some of the students/Researchers are not aware of this software. So, you need not waste your time in editing the tcl files. And since this software is written in java, it works well with almost any Operating System (With JRE installed on the System). Refer this video for more information You can download the software from this link  https://sites.google.com/site/pengjungwu/nsg Some features of this software wired and wireless nodes will be created establish connection between the nodes Creating links (Duplex-Link and Simplex-Link) TCP and UDP agents are supported Creating applications (CBR and FTP) Node movement And still there are lot more as the developer of this software is actively maintaining the software and you can expect lot more in the future also. You can download the software fro...

Promiscuous Mode in AODV (ns 2.34)

In a network, promiscuous mode allows a network device to intercept and read each network packet that arrives in its entirety. This mode of operation is sometimes given to a network snoop server that captures and saves all packets for analysis (for example, for monitoring network usage). Its often used to monitor network activity Files to be changed 1. ~ns-2.34/aodv/aodv.h 2. ~ns-2.34/aodv/aodv.cc 3. ~ns-2.34/lib/tcl/ns-mobilenode.tcl 1. Make AODV agent a child class of Tap (you should have a member function tap), and define the Mac variable 1: #include <mac.h> 2: class AODV: public Tap, public Agent { 3: public : 4: void tap( const Packet *p); 5: ...... 6: protected : 7: Mac *mac_; 8: ...... 9: } 2. Modify aodv/aodv.cc Define TCL command "install-tap" and implement AODV::tap() 1: int AODV::command( int argc, const char * const * argv) { 2:   3: ...... 4:   5: else if (argc == 3) { 6:   7: .....