Skip to main content

Posts

Showing posts with the label style

TOUR DE NS2 REVEALING PROGRAMMING STYLE

TOUR DE NS2 REVEALING PROGRAMMING STYLE Friends, Today we are going to have a look in why we run ns2 program as "ns program.tcl"? Before that we have to go through basic C++ programmings in ns2.Consider a basic C++ instruction only program i .e for example; we are considering a program to calculate time taken for a packet travel from uppermost node to lower most node with the time taken to travel packet between each nodes (t) are constant (say t=1ms) and the number of nodes as n. (say n=10). And we have to find out overall time taken to reach packet to lowermost node. The C++ program new.cc is given below and after compiling we get a executable file " new ". //new.cc main(){ float time = 0 , t = 1; int i, n = 10;  for(i = 1; i < n; i++) time = time+i ; printf("Overall time is  %f seconds. ",time); } Now we execute the program from terminal, we can see the following results; >> ./new Overall time is 10.0 seconds. But this programming style is not ...