Skip to main content


Showing posts from October, 2014

MANET Routing Protocols using ns3


Download the Code here:

Check the Video for Detailed instruction and how to use the plots, graphs and source code.

Comparison of MANET routing Protocols 1. AODV
3. DSR
using NS3 (Network Simulator 3)
B.Tech, M.Tech, PhD...
1. Reactive Vs Proactive routing
2. PErformance comparison of MANET protocols
3. AODV Vs DSDV Comparison and also at my channel.

What Version: ns-3.29
My Ubunut OS is: Ubuntu 18.04

This file we are going to use for our simulation:

Once you under stand the code, now lets run this example

Step 1: Copy the above file in to ~ns-3.29/scratch/ folder

Step 2: Understand this code.
Step 3: Run this code
Open the terminal, Go to ns-3.29 and run the following command

$] ./waf --run scratch/manet-routing-compare

enable the following header file

#include "ns3/flo…

youtube-dl (Command Based Youtube Downloader)

Downloading videos to local machine is always a challenge as the streaming sites keep on updating their policies in blocking the videos.
But there is a tool that is available in the command line (Terminal based) on Linux Operating Systems.
That is youtube-dl, this is a python based code and can be executed in linux OS without any hassles.

youtube-dl in windows or Mac OS can be achieved by installing python interpreter and try it.

for installing in linux, the command is
$prompt] sudo yum install youtube-dl (in redhat or centos or fedora)
$prompt] sudo apt-get install youtube-dl (ubuntu or linux mint)
See the image for downloading in Fedora 20

In ubuntu, you can update the sudo package before installing the youtube-dl.
sudo apt-get update

To download videos 
$prompt] youtube-dl

the above command will download the video in the best possible format. See the image below.
The video downloaded is of the format webm (Its a Web Movie format …

Blogging and Google Adsense get me a DSLR Camera

By blogging and Google Adsense, my long time wish have come true that I got an DSLR (Nikon D5100). 
Blogging is a word that seems to be a "No man's Land" when I started this blog in 2006. Yes I started this blog mainly for providing lecture notes to my students. Initially I started this with and a year later, I purchased (this website) and shared contents.  Initially I was not bothered about the ranking, search engine optimisation (SEO), page rank, etc. My main motive was to create content for the student community. Slowly, I improvise my contents to satisfy the global readers too. The topics that covered in my domains play a vital role in the provide information to open source research community.  The topics of interest are  Network simulator 2LinuxOpen Source TechnologiesMOODLEWordpressPHP, MySQLReal TIme SystemsEmbedded systems,Java and etc. This website was hacked twice and contents gets deleted. So I moved to Blogger for sometime. Go…

nohup command in Linux

Often you come across a situation where you try to open a machine remotely using ssh and try to start a server or a run a command indefinitely.

But once you close the ssh session, your session also terminates and the background process also terminates. So here is a solution.

To open ssh remotely,

prompt $] ssh username@machinename
Ex: ssh root@
Ex: ssh 
prompt $] ssh -X username @machinename 
Ex. ssh -X root@ 

(this -X indicates the remote session can be opened in X window (GUI) mode)

Assume we need to start a httpd server in the remote machine.
we can issue the command like this

prompt$] nohup command 
if any error or log information may be stored in the nohup.out file. if you want to redirect to a file use the redirected symbol (1>  indicates standard output and 2> indicates standard Error). Specify the filenames for the output. Here is the typical nohup command to start the httpd server.

prompt $] nohup  /etc/init.d/httpd start  1…

How to display Product name and Vendor name in Linux

This post will help you to find out the

Product NameSystem Vendor Name  This will help you to find the suitable device drivers if any.
The following is the command to find the System Vendor (in my case it is Hewlett Packard) prompt $] cat /sys/class/dmi/id/sys_vendor
Here is the command to find the product name
prompt $] cat /sys/class/dmi/id/product_name

cat is the command to concatenate the files and print it to the standard output
 T S Pradeep Kumar

C Programming Examples - Part 2

Here is the list of sample programs using C, This is list number 2. There are 21 more programs at this post.
C Program 1 – To find the reversal of a given number
Assume the number 1234, after reversal the number becomes 4321.
Input: One number, Ex 1234, declared to num
Output : One number, Ex 4321, rev is the variable
separate each digit using modulo operator from the right and bring that number to frontdivide the given number by 10, so the right most digit will be till the number becomes <=0 output the result
#include <stdio.h>
#include <conio.h>

int main()
    int num,rev=0;
    printf("enter the number to be reversed");
    scanf("%d", &num);

    while(num>0) //till the number is positive, perform the process
    rev=rev*10 + (num%10);
//separate each digit and bring it to the first

Passing a Structure to a Function

A function can accept a structure as a parameter and even it returns a parameter too.Either the individual structure elements can be passed or the entire structure can be passed. Here is the example, for passing the entire structure to a function
#include <stdio.h>
#include <conio.h>
//Structure declaration
struct student
char name[10];
int no;
//Function prototypes
void read(struct student);
struct student display(struct student); //function which takes the entire structure as a parameter and it returns a structure also
int main()
    struct student s1,s;
     printf("Enter the details");
    scanf("%s %d",,&;
    s=display(s1);  //function call
printf("Name is %s and number is %d",,;
//Function definition
struct student display(struct student s)
return s;
} Nested Structures
A structure can be declared within…

Structures and Unions

Structure in C groups different data type under a common name struct is a keyword to declare a structure The size of the structure depends on the size of the different data types Structure declaration always ends with a semicolon Example:
struct employee
char name[50];
int empid;
float salary;
}; The total size occupied by the above structure is 50 + 2 + 4 = 56 bytes (on TC compiler) and 50 + 4 + 4= 58 (on other compilers like GCC, etc). Again the size depends on the compiler.
GCC compiler always increase the size of structure which is divisible by 4 for faster code generation, so the above structure takes 60 bytes of memory
Declaring a structure does not consume any memory, only when the structure object is created memory occupies Variables initialization will not be done during the structure declaration The above syntax declaration does not consume memory, but the following do
int main()
struct employee e1;
} Now e1 consumes memory of 60 bytes.
Simple Structure to get some …

String Functions in C

Like numbered arrays, C handles character arrays (strings).
Each string is identified as a character array and ends with a ‘\0’(null) character (the compiler automatically adds the null character). So the end of string is identified as a null character. Being an array, all the elements of the string array stored in continuous memory locationsfollowing is the declaration of character array
char name[50];
char name[]=”Pradeep Kumar”;
char name[20]=”Hello Pradeep”; Strings can be handled or manipulated through loops or library functions. There are some library functions to handle strings are available at string.h
Some of them are
This is to find the length of the string and returns an integer For example, if “Hello” is the string, the length will be 5 and “Hello “, the length is 6 (there is a blank space after o in hello)strcat(String1, string2)
to concatenate two strings One string will be appended to another string (the concatenation happens by inserting t…

Arrays of C Program

Arrays in C programming starts with memory addresses. Yes the compiler handles arrays as memory addresses.
Similar elements group together with a single name is called arraythe indexing always starts with 0 and ends at n-1 (if the size of the array is n)Array elements stores in consecutive memory location. The array elements usually stores in consecutive memory location. For example,
int a[10];  //Array with size 10 the above example is an integer array with size 10 or this array can hold 10 variables.
The elements starts from a[0], a[1], a[2]…..a[9], so totally there are 10 elements.
Array elementsvaluesmemory address locationa[0]32600AH  (This address is called as the base address)a[1]34600EHa[2]236012Ha[3]356016Ha[4]45601AHa[5]67601EHa[6]566022Ha[7]16026Ha[8]34602AHa[9]25602EH The memory addresses shown above are in hexadecimal, that’s why each address suffixed with a letter H. The memory addresses in each machine will be different.
The base address is the address where the first e…

User Defined Functions in C

Almost all the programming languages uses functions. Functions are the entities which are grouping a set of statements which do a specific job or set of jobs.
Example: sum of integers, sum of float number, complex number addition.
All the above three can be implemented as a single function or three separate functions.
When someone wants to use that, a function can be simply called.
So function implementation happens as
Function prototype or Function declarationFunction definition or function implementationFunction callFunction prototype
It is necessary to specify the name of the function, the parameters and the return type to the compiler that the function is being defined in this program.The prototype ends with a semicolon syntax:
int sum(int, int); //function prototypeFunction Definition
This is the actual function definition which shows the function implementation.
for the above syntax here is the function
int sum(int a, int b)
int c;
return c;
} The above function is …

Decision Making and Looping

C supports Decision Making and Looping (Interations)
In decision Making,
if, if-else, if- else if – else, switch – case is used.
//These statements are executed only if the condition is true or 1
} if – else
//These statements are executed only if the condition is true or 1
//these statement are executed only if the condition is false or 0
(in the above example, there is no else part means that for some situation, there may not be a need for else part) if – else if – else
if(condition 1)
//These statements are executed if the condition 1 is true or 1
else if (condition 2)
//These statements are executed if the condition 2 is true or 1
//These statements are executed neither condition 1 nor condition 2 are true
// if all the conditions fails, then this statement will execute
} Switch Case
switch (expression)
case 1: statement 1;
case 2: statement 2;
case 3: statement 3;
default: statement d;

Data Types in C Programming

Declaration of variable names does two things
it tells the compiler what the variable name is specifies what type of data the variable will hold So it is mandatory that each variable should belong to a particular data type. C supports different data types like integer, character, float, double, etc.
Data type Size on a 16 bit machineRangechar1 byte or 8 bits-128 to 127signed char1 byte-128 to 127unsigned char1 byte0 to 255short int or short1 byte-128 to 127int2 bytes-32768 to 32767unsigned int2 bytes0 to 65535long int or long4 bytes-2,147,483,648 to 2,147,483,647unsigned long int4 bytes0 to 4,294,967,295float4 bytes3.4E-38 to 3.4 E+38double8 bytes1.7E-308 to 1.7E+308long double10 bytes3.4E-4932 to 1.1E+4932 Example of declaring variables
int a=20,b=20,c;
int a=10;
int b=9;
int c=20;
float c=3.5;
char a =’A’;
long int al or long a;
short int b or short b;
double c;
long double c;
 T S Pradeep Kumar

C Tokens

Tokens are classified as
KeywordsIdentifiersOperatorsConstantsSpecial SymbolsKeywords
Keywords are reserved by the compilers and keywords will not be redefined (means the keywords are not been declared as variable names, etc). There are standard 32 keywords in C compiler, and some compilers uses more keywords based on their specification. Here is the list of 32 keywords
Identifiers are variable names declared inside the program. They use alphabets, number, symbols like _ and $They must begin with  alphabet or _ They are case sensitive i.e Var_name is different from var_nameSome valid identifiers are
johnValuer_siex1x2ChennaiSum1abcdinvalid identifiers
123%(super)25th1stab-dsum of total
operators are further classified into different categories like
Arithmetic operators +  - for addition   1+3 = 4
-  …

IO Functions - printf and scanf

Printf() is a function to print strings to the display unit and
scanf() is to scan the input through the keyboard
the f in the printf and scanf are called as format. That is, printf() and scanf() will print and scan in some particular format, it is the duty of the developer to provide that formats.
For example
printf(“a=%d, b=%d”, a,b); //This function will print a=10, b=20 if the values of a and b are 10 and 20
scanf(“%f”, &a); //this will accept a float number as the specifier is %f which is for float, See the Ampersand symbol which to tell the compiler to store the variable into the address. Here is the list of format codes or format specifiers
scanf() format codes
CodeMeaning%cread a single character%dread a decimal integer%fread a floating point value%eread a floating point value (even in exponential format)%gread a floating point value%hread a decimal, heaxadecimal or octal integer%oread an octal integer%sread a string%uread an unsigned integer%xread a hexadecimal intege…

Simple C Program

/* This program is written by T S Pradeep Kumar on 28th Sep 2010
This is to display Hello World to the display unit
#include <stdio.h> //including the standard IO functions like printf(), scanf()
int main()
printf(“Hello World \n”);
return 0;
}stdio.h is the library which contains the printf(), scanf() and other standard IO functions, so before we use any function we need to include in our C program. Most of the compilers will take stdio.h automatically, even if we dont include in our programint main() {} is the main functionprintf(“Hello World\n”); printf() is the function which is printing to the display unit and it is displaying Hello World. Whatever is there inside the double quotes will displayed as it is in the monitor except the format specifiers or format codes (%d, %f, %c)return 0; is the final statement which returns the integer value 0 (this is just to make the compiler happy) Here in the above program, you can see there are semi colons ;
Every C stateme…

C Programming - Introduction

This post and the subsequent posts will help you in understanding the intricacies of C programming. These posts just shows you the basics of C programming and some worked examples for that. 

Features of C Programming
C is a small language having lesser number of keywords than Java or pascal.C is a native language of Unix, Linux. Not only that many of the windows packages, database programs, graphics libraries are written in C programC is portable – it provides standard set of libraries that work on the same way with all machinesC is modular, as it supports functions to divide the program in to sub program C is efficient on most machines, because certain constructs are machine dependant. Structure of a C program
Comments the comments are usually ignored by the compilerso this part informs about the author of the programwhat is the usefulness of this programupdation or creation of the programExample: //  - Single line comment/* ----- multi line comments    ….*/Preprocessor Directives bef…

Simple C Programs for Beginners

This post has no relation with networks, however these C programs help anyone who started learning C programming. It covers from basics of C to Arrays and Functions.
The readers are requested to get their outputs, as the output screenshots were lost. Also most of these programs were solved by my student friends. If you encounter any errors in the programs, kindly comment below to get it rectified through other readers.

To compile these programs in
Windows : Use Dev-C++ for compilation (It GUI Based), Also you may remove #include <conio.h> if you encounter any error during compilation

In Linux: 
You may try the gcc or g++ compiler
Delete the #include <conio.h>
delete the line that contains getch(); 
Here is the command 
$] gcc -o first file.c 
$] ./first
(The file.c is compiled and linked to the binary file first and the output is executing in the second line using ./first)
See the following screenshot for the Question 1.

Question 1 
The straight line method of computing the yearl…