Thursday, 15 August 2013

  Current slowdown may be the worst ever for job-seekers

Naresh Lal, 23, had a dream. In 2008 he enrolled in an obscure engineering college in Indore where he paid an annual fee of Rs 4.5 lakh for a four-year course. Lal was the first in the family to go to college. "My father was happy that I'd be a software engineer and get a good job at one of the IT firms," says Lal.

It didn't quite work out that way. After graduating last year, Lal did not land a job for months. A move to Bangalore — the cradle of software services — followed, but the job didn't. Sporadically he would get leads of a recruitment drive from his friends and they would all flock to the IT firm's campus. "There would be a long line of 3,000-4,000 people," he says. Overwhelmed, companies would have little option but to call in just a fraction of that number for the interview, and ask the others to go.

In February this year, Lal moved out of Bangalore to Bhopal where he joined a small IT company. "They said they will start paying after three months," he says. Five months of working without pay wore Lal down, who early this month returned to Indore. "I had thought after my college I will ease my father's burden. I feel terrible that I am myself a burden today."

Lal (whose name has been changed as he did not want to reveal his identity) is not alone. Some 500 engineers graduate out of his college every year. Indore alone has roughly 150 such colleges. Across India, close to 17.6 lakh engineers graduated from 3,500-odd engineering colleges in 2012-13. Beyond the 2 lakh who would have passed from Tier I and II institutions, virtually all of the remaining may well be staring at a predicament similar to that of Lal.

"I haven't seen anything like this in my career since my early Infosys days," says TV Mohandas Pai, who joined the IT services giant in 1994, and is now chairman at Manipal Global Education. "Nobody is hiring — IT, manufacturing, infrastructure, construction, government...nobody. Jobseekers are despondent. They are losing hope."

The All-round Squeeze

India, the world's second-most populous country and home to the world's second largest workforce (469 million workers), has a problem. Sure, the ongoing economic slowdown and the accompanying woes — rising inflation and interest rates, a weakening rupee and stalled investments — will inevitably take its toll on jobs. Yet, a wide section of CXOs, HR honchos and employees that ET Magazine spoke to reckon that this is the worst job market since liberalisation in terms of severity, duration, sweep and scale.

Even the sudden crash precipitated by the global financial crisis five years ago and the aftershocks on the employment front appear less severe than the current scenario.

"In 2008, India never really saw gloom and doom. It was also very short. This time I cannot even begin to describe the mood. It is the most difficult job market that I have seen," says Arun Das Mahapatra, partner-in-charge, Heidrick & Struggles India, a global executive search firm. His firm has always been growing at 15-20% over the years but Mahapatra says this year he would be happy if he is able to do as much business as he did a year ago.




Mahapatra's mood mirrors what executives are feeling. A little over half of the 2,096 respondents to an ET online poll agreed that this is the worst job market they have ever seen (a little over a third of the respondents disagreed). The majority of those polled also feared they could lose their jobs. Almost three-fourths of them don't fancy a chance of getting a job offer from a firm in the sector they're currently employed in. And perhaps the worst manifestation of the despondency is that 63% either do not expect or are unsure wether the job market will improve in the next 12 months.

Source : ET

EC-Council eyes 40,000 cyber professionals in India by 2014

HYDERABAD: EC-Council -- which provides information security education, training and certification -- aims to train around 40,000 cyber security professionals in India by 2014.

"We have a target of tying up with 140 partners whom we would train. They would in turn impart education to train 40,000 cyber security professionals by next year. We already have 72 partners," Jay Bavisi, co-founder and president of EC-Council said.

The head office of EC-Council is located in Hyderabad and the expansion as well as execution plans would be monitored from here, he said adding that around Rs 20 crore has already being invested by EC-Council in India.

According the government estimates, India would require close to 5 lakh cyber-security professional to mitigate the threats in the virtual world.

"With the push from the central government to introduce cybersecurity programmes in the educational institutions, I expect the market to grow rapidly in the country," Bavisi explained.

He pointed out that the company is already in talks with various educational institutes to provide cyber security courses and the company is targeting around 300 institutes by the end of 2013.

According to industry estimates, the current Indian cybersecurity market is close to Rs 1,500 crore and it is growing at a pace of 18% per annum.

Meanwhile, the company said that Bavisi had received the Industry Leadership Award 2013 awarded by National Security Agency (NSA) for the outstanding leadership in the cybersecurity industry and information assurance education.

Source : TOI

Cisco to lay off 4,000 employees

Cisco's earnings and revenue grew in the latest quarter as demand for its computer networking equipment increased. But CEO John Chambers called the global economy "challenging and inconsistent" and the company said it is cutting about 4,000 jobs, or about 5% of its work force.

Cisco's revenue guidance for the current quarter was weaker than Wall Street expected, and shares fell sharply in extended trading.

The company's stock fell $2.51, or 9.5%, to $23.87 in extended trading after the results were released. The stock closed up 6 cents at $26.38 in the day's regular trading session.

Cisco Systems earned $2.27 billion, or 42 cents per share, in the three months that ended on July 27. That's up from $1.92 billion, or 36 cents per share, a year earlier.

Adjusted earnings were 52 cents per share in the latest quarter, squeaking past Wall Street's expectations by a penny. This figure excludes charges stemming from a patent settlement with TiVo and other one-time items.

Revenue rose 6% to $12.42 billion from $11.69 billion.

Analysts, on average, had expected revenue of $12.41 billion, according to a poll by FactSet.

Cisco's performance is widely regarded as a bellwether for the technology industry. That's because the San Jose, California, company cuts a broad swath, selling routers, switches, software and services to corporate customers and government agencies. Cisco's fiscal quarters end a month later than most other major technology companies, giving it additional time to assess economic conditions.

Cisco's product orders grew 4% year-over-year, the same as in the third quarter of this year. Orders in the Americas region grew 5%, while Asia declined 3% due to economic challenges in the region, Chambers said. Europe, the Middle East, Africa and Russia increased 6%. On its own, Europe was up 9%.

Chambers said that economic conditions in Europe still "vary significantly" by region, with the north and the UK showing "very positive progress."

"We remain cautious, however, given the instability of the southern region," he added.

The caution is evident in Cisco's guidance. For the current quarter, the company said that said it expects revenue to grow 3% to 5% year-over-year. Analysts are expecting $12.72 billion, a 7% increase from last year's $11.9 billion.

Over the long term, Chambers said that the company still expects revenue to grow 5% to 7%, and added that Cisco is in a "better position in the market today than ever before."

Source : TOI

Internship must for engineering graduates

Hyderabad: Engineering students are all set to go the way of medicos from this academic year with regard to internship. State universities will implement “mandatory internship” in all its affiliated engineering colleges for students taking admissions into BE/ B.Tech courses from this academic year as per the directions of All India Council for Technical Education, to improve employ-ability skills among engineering graduates.

The state has the worst employability record with less than 10 per cent engineering graduates finding employment from the thousand of engineers being churned out by over 700 engineering colleges. The internship period will vary from 3 months to 24 months in the final three semesters, depending on the branch of study.

Unlike medical students, there is no such provision for mandatory internship for engineering students in the state. Some colleges have been adopting “industry-oriented projects” for students pursuing third and fourth year to help them secure jobs in good companies during campus recruitment drives.

Since this is being done on an ‘optional basis,’ only few city colleges with good track record have been giving hands-on training to students. “The mandatory internship is being introduced from this year as per the directions of AICTE issued in May this year.

This will be applicable to students in fifth, sixth and seventh semesters which will vary from 3 months to 24 months depending on the branch of study. The aim is to enhance the employability of students,” said Prof N.V. Ramana Rao, registrar, JNTU-Hyderabad.

He said the initiative is being undertaken as part of the AICTE’s National Employability Enhancement Mission. AICTE is also planning to launch its own job portal.

Source : DC

 ns-2.34 Configuring with Eclipse Galileo in Ubuntu 12.04


In this post I shall explain about how to configure ns-2.34 with Eclipse Galileo. I faced certain problems while configuring ns-2.34 with eclipse as after successful configuration ns-2.34 would compile with errors. This gave me headaches and after lot of working around I found the correct method. So this guide would configure ns-2.34 with eclipse and ns-2.34 would build and compile without giving any errors.
Operating System   : Ubuntu 12.04
Network Simulator v: ns-2.34

Note: Hope u have downloaded and installed ns-allinone-2.34 fixed and patched by me. If you have not u can follow the guide <here>.
First of all in order to run eclipse u need to set up a JAVA environment on your UBUNTU 12.04. Three easy commands in the terminal will set it up for u, if JAVA environment is not present on your Ubuntu.
Open Terminal using Ctrl + Alt + T. And enter the following commands one after the another..
sudo apt-get install openjdk-7-jre
sudo apt-get install openjdk-7-jdk
sudo apt-get install icedtea6-plugin
This setups a Java environment for you.
Step 1) Download Eclipse Galileo (Eclipse IDE for C/C++ developers) from the eclipse website. Or u can download it from <here>.
U also need to download the CDT plugin for Eclipse. U can download it from <here> or from eclipse website.


Step 2) Extract eclipse in the home directory by right clicking on the file eclipse-cpp-galileo-linux-gtk.tar.gz and selecting open with archive manager. Now extract it using the extract button in the home directory. After extraction a directory with the name eclipse should be created in your home directory.

Step 3) Now right click on the file (i.e. the CDT plugin downloaded) cdt-master-6.0.2.zip and select open with archive manager. Now extract it using the extract button on top. Note: When u extract it, extract it inside the eclipse directory created earlier in your home directory and not anywhere else.

Step 4) Now open the eclipse folder and run eclipse. It will ask to select a workspace. Browse to the ns-allinone-2.34 directory in your home folder and select it. U can also make it default and set it to not ask each and every time u start eclipse.

Step 5) After eclipse opens. Browse to File –> New –> C++ Project.

Step 6) A window will open asking u to create a C++ Project. (Now u need to be careful)
In the Project Name field enter ns-2.34. It shall prompt that a directory/project with that name already exists. Ignore it.

Now under the Project Type. Select MakeFile Project.
And Under MakeFile Project. Select Empty Project.
Now Under the ToolChains section (on the right). Select Linux GCC.
And press Next.
Step 7) Now ns-2.34 will be added under your projects listing. To the left of the eclipse window.
Now go to Project –> Build All (It shall build without any errors.)
Now go to Project –> Clean and select ns-2.34 and press OK. (It shall compile without any errors).
Now go to Run –> Run (A % sign should appear on the console below).

Installing ns-2.34 (network simulator) in Ubuntu 12.04 LTS 


Recently, I had been trying to install ns-2.34 in my ubuntu 12.04 which i have on a HP G62 pavilion notebook. Although i successfully installed it many a times but it was just a basic install (i.e. for a noob to work upon with basic tcl scripting and viewing simulations). Installing it completely without any compilation errors was the most challenging task as in order to modify ns2 u have to install it flawlessly.
In this post I shall teach you how to install ns-2.34 in ubuntu 12.04 (specifically).
First of all u need to download my version of ns-2.34 from the link given below. In this version of ns-2.34, I have made all the necessary changes (i.e. to Makefile and certain other files in ns-2.34 directory).
Download it from here.
The package is a complete ns-allinone-package with all changes done without the need of having u to make any further changes. If the following steps are followed in order u might get a full clean install of ns2.
Note : We shall install ns-2.34 in the home directory and no where else. So please copy the downloaded file in your home directory. And if u do not know where the home directory is u can google it :) .
Step 1) Remove any previous ns2 versions installed on your OS
rm -rf /home/<your-homedirectory-name>/ns-allinone-2.34
instead of ns-allinone-2.34 u can put prior versions of ns2 if installed. And to find your home directory open terminal using Ctrl + Alt + T and then type pwd in it.
Step 2) After step 1, enter the following commands
sudo apt-get update
sudo apt-get install build-essential autoconf automake libxmu-dev libxt-dev libx11-dev xorg-dev xgraph gcc g++
The above command will install all necessary dependencies in order for ns-2.34 to run and install successfully.
Step 3) Now unzip the downloaded ns-allinone-2.34.tar.gz folder by right clicking on it and selecting open with archive manager and extract it in your home folder. Then open terminal using Ctrl + Alt + T.
Browse to the ns-allinone-2.34 directory by typing :
cd ns-allinone-2.34
now browse to ns-2.34 directory by typing :
cd ns-2.34
now type the following commands in order.
./configure
make clean
make depend
make
They should run successfully without showing any error. If you get any problems ask in comments.
Now go back to ns-allinone-2.34 directory by typing
cd ..
Now install ns-2.34 by typing
./install
It should install successfully. Now close the terminal by typing exit. If u get any errors ask in comments section.
Step 4) Now its time to setup your environment variables. This is the tricky part.
open terminal by pressing Ctrl + Alt + T. And enter the following command:
sudo gedit ~/.bashrc
bashrc file would open in gedit. At the end of the file add the following lines (Do it carefully)
# LD_LIBRARY_PATH
OTCL_LIB=/home/arya/ns-allinone-2.34/otcl-1.13
NS2_LIB=/home/arya/ns-allinone-2.34/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB
# TCL_LIBRARY
TCL_LIB=/home/arya/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/arya/ns-allinone-2.34/bin:/home/arya/ns-allinone-2.34/tcl8.4.18/unix:/home/arya/ns-allinone-2.34/tk8.4.18/unix:/home/arya/ns-allinone-2.34/xgraph-12.1/
NS=/home/arya/ns-allinone-2.34/ns-2.34/
NAM=/home/arya/ns-allinone-2.34/nam-1.13/
export PATH=$PATH:$XGRAPH:$NS:$NAM

NOTE: change arya in the above paths to your home directory’s name. (DO NOT FORGET THAT).
Close the bashrc file. Log off and log in again.
Step 5) Now open terminal using Ctrl + Alt + T and type ns.
A % sign should appears and that marks a clean installation of ns-2.34.

New Unicast Routing Protocol for MANETs* in ns-2.34.. (With tcl file)


In this post I would tell u about how to successfully perform the steps to Implement a New Unicast Routing Protocol for MANETs by F. J. Ros and P. M. Ruiz While performing this task I faced a no. of problems. The tutorial by F. J. Ros and P. M. Ruiz is complete for a beginner to start working with. However it has certain anomalies (not in the code) such as typographical errors or case sensitivity problems. The tutorial is also designed for earlier versions of ns2. So I tried working on this tutorial which is quite excellent and and after facing a lot of problems and issues I successfully implemented it in ns-2.34.
If u perform the steps according to this post. U shall be able to implement the protocol succesfully. I shall not go into explaining the source code as it has already been beautifully explained in the original document. The source of  the document is given at the end of this post. Thus, for successfull implementation u should read this post very carefully.
NOTE: Beware of Case Sensitiveness and perform as I shall tell below.
Step 1) First of all create a directory in your ns-2.34 directory with the following files.
protoname_pkt.h
protoname_rtable.cc
protoname_rtable.h
Protoname.cc        \\ Note the capital P in the beginning (it should be capital P)
protoname.h
Step 2) The code for protoname_pkt.h is given below (u can copy paste)
#ifndef PROTONAME_PKT_H_
#define PROTONAME_PKT_H_

#include <packet.h>
#include <config.h>
#include <random.h>
#include <timer-handler.h>
#include <trace.h>
#include <classifier-port.h>
#define HDR_PROTONAME_PKT(p) hdr_protoname_pkt::access(p)
struct hdr_protoname_pkt {
nsaddr_t pkt_src_;       //Node which originated this packet
u_int16_t pkt_len_;    //Packet length (in bytes)
u_int8_t pkt_seq_num_; //Packet Sequence Number
inline nsaddr_t& pkt_src() {return pkt_src_;}
inline u_int16_t& pkt_len() {return pkt_len_;}
inline u_int8_t& pkt_seq_num() {return pkt_seq_num_;}
static int offset_;
inline static int& offset() {return offset_;}
// To access the hdr_protoname_pkt packet header in a packet pointed by p, we use the access fn
inline static hdr_protoname_pkt* access(const Packet* p) {
return (hdr_protoname_pkt*)p->access(offset_);
}
};
#endif /* PROTONAME_PKT_H_ */

Step 3) The code for protoname_rtable.cc is given below
#include "protoname_rtable.h"
#include "ip.h"

protoname_rtable::protoname_rtable() { }
void protoname_rtable::print(Trace* out) {
sprintf(out->pt_->buffer(), "p\tdest\tnext");
out->pt_->dump();
for (rtable_t::iterator it = rt_.begin(); it != rt_.end(); it++) {
sprintf(out->pt_->buffer(), "P\t%d\t%d", (*it).first, (*it).second);
out->pt_->dump();
}
}
void
protoname_rtable::clear() {
rt_.clear();
}
void
protoname_rtable::rm_entry(nsaddr_t dest) {
rt_.erase(dest);
}
void
protoname_rtable::add_entry(nsaddr_t dest, nsaddr_t next) {
rt_[dest] = next;
}
nsaddr_t
protoname_rtable::lookup(nsaddr_t dest) {
rtable_t::iterator it = rt_.find(dest);
if (it == rt_.end())
return IP_BROADCAST;
else
return (*it).second;
}
u_int32_t
protoname_rtable::size() {
return rt_.size();
}

Step 4) The code for protoname_rtable.h is given below

#ifndef PROTONAME_RTABLE_H_
#define PROTONAME_RTABLE_H_

#include <trace.h>
#include <map>
#include <ip.h>
typedef std::map<nsaddr_t, nsaddr_t> rtable_t;
class protoname_rtable {
rtable_t rt_;
public:
protoname_rtable();
void print(Trace*);
void clear();
void rm_entry(nsaddr_t);
void add_entry(nsaddr_t, nsaddr_t);
nsaddr_t lookup(nsaddr_t);
u_int32_t size();
};
#endif /* PROTONAME_RTABLE_H_ */

Step 5) The code for Protoname.cc is given below

#include "protoname.h"
#include "protoname_pkt.h"
#include "protoname_rtable.h"
#include <timer-handler.h>
#include <node.h>
#include <random.h>
#include <cmu-trace.h>
#include <iostream>
#include <classifier-port.h>
#include <packet.h>
#include <address.h>

// To Bind our packet in OTcl Interface
int hdr_protoname_pkt::offset_;
static class ProtonameHeaderClass : public PacketHeaderClass {
public:
ProtonameHeaderClass() : PacketHeaderClass("PacketHeader/PROTONAME", sizeof(hdr_protoname_pkt)) {
bind_offset(&hdr_protoname_pkt::offset_);
}
}class_rtProtoProtoname_hdr;
static class ProtonameClass : public TclClass
{
public:
ProtonameClass() : TclClass("Agent/PROTONAME") {}
TclObject* create(int argc, const char*const* argv) {
assert(argc==5);
return(new Protoname((nsaddr_t)Address::instance().str2addr(argv[4])));
}
}class_rtProtoProtoname;
void
Protoname_PktTimer::expire(Event* e) {
agent_->send_protoname_pkt();
agent_->reset_protoname_pkt_timer();
}
Protoname::Protoname(nsaddr_t id) : Agent(PT_PROTONAME), pkt_timer_(this) {
bind_bool("accessible_var_", &accessible_var_);
ra_addr_ = id;
}
int
Protoname::command(int argc, const char*const* argv) {
if(argc == 2) {
if (strcasecmp(argv[1], "start") == 0) {
pkt_timer_.resched(0.0);
return TCL_OK;
}
else if (strcasecmp(argv[1],"print_rtable") == 0) {
if(logtarget_ != 0) {
sprintf(logtarget_->pt_->buffer(), "P %f _%d_ Routing Table", CURRENT_TIME, ra_addr());
logtarget_->pt_->dump();
rtable_.print(logtarget_);
}
else {
fprintf(stdout, "%f _%d_ If you want to print this routing table ""you must create a trace file in your TCL Script",CURRENT_TIME, ra_addr());
}
return TCL_OK;
}
}
else if (argc == 3) {
//Obtains corresponding dmux to carry packets to upper layer
if (strcmp(argv[1], "port-dmux") == 0) {
dmux_ = (PortClassifier*)TclObject::lookup(argv[2]);
if (dmux_ == 0) {
fprintf(stderr, "%s: %s lookup of %s failed \n", __FILE__,argv[1],argv[2]);
return TCL_ERROR;
}
return TCL_OK;
}
//Obtains corresponding tracer
else if (strcmp(argv[1], "log-target") == 0 || strcmp(argv[1], "tracetarget") == 0) {
logtarget_ = (Trace*)TclObject::lookup(argv[2]);
if (logtarget_ == 0)
return TCL_ERROR;
return TCL_OK;
}
}
//Pass the command to the base class
return Agent::command(argc, argv);
}
void
Protoname::recv(Packet* p, Handler* h) {
struct hdr_cmn* ch    = HDR_CMN(p);
struct hdr_ip* ih     = HDR_IP(p);
if (ih->saddr() == ra_addr()){
//If there exists a routing loop, drop the packet
if(ch->num_forwards() > 0) {
drop(p, DROP_RTR_ROUTE_LOOP);
return;
}
//else if this is a packet I am originating, must add IP header
else if(ch->num_forwards() == 0)
ch->size() += IP_HDR_LEN;
}
// If it is a protoname packet, must process it
if(ch->ptype() == PT_PROTONAME)
recv_protoname_pkt(p);
//Otherwise, must forward the packet (unless TTL reaches zero
else {
ih->ttl_--;
if(ih->ttl_ == 0) {
drop(p, DROP_RTR_TTL);
return;
}
forward_data(p);
}
}
void
Protoname::recv_protoname_pkt(Packet* p) {
struct hdr_ip* ih                = HDR_IP(p);
struct hdr_protoname_pkt* ph    = HDR_PROTONAME_PKT(p);
// All routing messages are sent from and to port RT_PORT, so we shall check it
assert(ih->sport() == RT_PORT);
assert(ih->dport() == RT_PORT);
/* processing of protoname packet */
// Release resources
Packet::free(p);
}
void
Protoname::send_protoname_pkt() {
Packet* p                        = allocpkt();
struct hdr_cmn* ch                = HDR_CMN(p);
struct hdr_ip* ih                = HDR_IP(p);
struct hdr_protoname_pkt* ph     = HDR_PROTONAME_PKT(p);
ph->pkt_src()                     = ra_addr();
ph->pkt_len()                    = 7;
ph->pkt_seq_num()                = seq_num_++;
ch->ptype()                        = PT_PROTONAME;
ch->direction()                    = hdr_cmn::DOWN;
ch->size()                        = IP_HDR_LEN + ph->pkt_len();
ch->error()                        = 0;
ch->next_hop()                    = IP_BROADCAST;
ch->addr_type()                    = NS_AF_INET;
ih->saddr()                     = ra_addr();
ih->daddr()                        = IP_BROADCAST;
ih->sport()                        = RT_PORT;
ih->dport()                        = RT_PORT;
ih->ttl()                        = IP_DEF_TTL;
Scheduler::instance().schedule(target_, p, JITTER);
}
void
Protoname::reset_protoname_pkt_timer() {
pkt_timer_.resched((double)5.0);
}
void
Protoname::forward_data(Packet* p) {
struct hdr_cmn* ch = HDR_CMN(p);
struct hdr_ip* ih = HDR_IP(p);
if(ch->direction() == hdr_cmn::UP && ((u_int32_t)ih->daddr() == IP_BROADCAST || ih->daddr() == ra_addr())) {
dmux_->recv(p, NULL);
return;
}
else {
ch->direction() = hdr_cmn::DOWN;
ch->addr_type() = NS_AF_INET;
if ((u_int32_t)ih->daddr() == IP_BROADCAST)
ch->next_hop() = IP_BROADCAST;
else {
nsaddr_t next_hop = rtable_.lookup(ih->daddr());
if(next_hop == IP_BROADCAST) {
debug("%f: Agent %d can not forward a packet destined to %d \n", CURRENT_TIME,ra_addr(),ih->daddr());
drop(p, DROP_RTR_NO_ROUTE);
return;
}
else
ch->next_hop() =  next_hop;
}
Scheduler::instance().schedule(target_, p, 0.0);
}
}

Step 6) The code for protoname.h is given below

#ifndef PROTONAME_H_
#define PROTONAME_H_

#include "protoname_pkt.h"
#include "protoname_rtable.h"
#include <agent.h>
#include <packet.h>
#include <trace.h>
#include <timer-handler.h>
#include <random.h>
#include <classifier-port.h>
#include "arp.h"
#include "ll.h"
#include "mac.h"
#include "ip.h"
#include "delay.h"
#define CURRENT_TIME Scheduler::instance().clock()
#define JITTER (Random::uniform()*0.5)
class Protoname;    //Forward Declaration
/* TIMERS */
class Protoname_PktTimer : public TimerHandler {
public :
Protoname_PktTimer(Protoname* agent) : TimerHandler() {
agent_ = agent;
}
protected:
Protoname* agent_;
virtual void expire(Event* e);
};
/* Agent */
class Protoname : public Agent {
/* Friends */
friend class Protoname_PktTimer;
/*Private Members*/
nsaddr_t             ra_addr_;
//protoname_state     state_;
protoname_rtable     rtable_;
int                 accessible_var_;
u_int8_t             seq_num_;
protected :
PortClassifier*     dmux_;            //For Passing Packets Up To Agents
Trace*                logtarget_;        //For Logging
Protoname_PktTimer     pkt_timer_;        //Timer for sending packets
inline nsaddr_t&         ra_addr()             {return ra_addr_; }
//inline protoname_state& state()                {return state_;}
inline int&             accessible_var()     {return accessible_var_;}
void forward_data(Packet*);
void recv_protoname_pkt(Packet*);
void send_protoname_pkt();
void reset_protoname_pkt_timer();
public:
Protoname(nsaddr_t);
int command(int, const char*const*);
void recv(Packet*, Handler*);
};
#endif /* PROTONAME_H_ */

Note: Now we have to make changes to certain ns-2.34 files. The steps given below are most important for successful implementation so perform them very carefully.
Step 7) Open file packet.h under ns-2.34/common/packet.h. Do the changes given below.
Under typedef unsigned int packet_t; lots of constants would have been defined.
Go down and at Line 182 u will find
// AOMDV packet
static const packet_t PT_AOMDV = 61;

After it insert the line as follows
// insert new packet types here
static const packet_t    PT_PROTONAME = 62;

and change PT_NTYPE value from 62 (earlier) to 63 now.
static packet_t PT_NTYPE = 63; // This MUST be the LAST one
Then in the same file move down till u find p_info(). In it search for the function
static packetClass classify(packet_t type) {
and perform the following changes in it by entering the 2nd line below.

type == PT_AODV ||
type == PT_PROTONAME)
return ROUTING;

In the same file, go below and search for the function static void initName(). Now at the end of this function u shall find this

// AOMDV patch
name_[PT_AOMDV]= "AOMDV";

After this enter the following line.

name_[PT_PROTONAME] = "PROTONAME";
name_[PT_NTYPE]= "undefined"; // let it remain as it is

Step 8) Open the file cmu-trace.h under ns-2.34/trace/cmu-trace.h
At line 162 u shall find

void    format_aomdv(Packet *p, int offset);

After it enter the following line

void format_protoname(Packet *p, int offset);

Step 9) Now open the file cmu-trace.cc in the same folder ns-2.34/trace/cmu-trace.h
Include the following header file at the beginning.

#include <protoname/protoname_pkt.h>

Now at the end write the following code ( u can always copy-paste) :)

void
CMUTrace::format_protoname(Packet* p, int offset)
{
struct hdr_protoname_pkt* ph = HDR_PROTONAME_PKT(p);

if(pt_->tagged()) {
sprintf(pt_->buffer() + offset, “-PROTONAME:o %d -PROTONAME:s %d -PROTONAME:l %d”, ph->pkt_src(), ph->pkt_seq_num(), ph->pkt_len());
}
else if (newtrace_) {
sprintf(pt_->buffer() + offset, “-P PROTONAME -Po %d -Ps %d -Pl %d “, ph->pkt_src(), ph->pkt_seq_num(), ph->pkt_len());
}
else {
sprintf(pt_->buffer() + offset, “[PROTONAME %d %d %d] “, ph->pkt_src(), ph->pkt_seq_num(), ph->pkt_len());
}
}
After the above steps search for the function (in the same file) at Line 1305 (most probably)

void CMUTrace::format(Packet* p, const char *why)

move down and after

case PT_PING:
break;

Enter the following lines

case PT_PROTONAME:
format_protoname(p, offset);
break;

Step 10) Open the file ns-packet.tcl under ns-2.34/tcl/lib/ns-packet.tcl
Search at Line 113 for
foreach prot {
Enter the following after to it to make it look like this

foreach prot {
PROTONAME
# Common:
Common
Flags
IP     # IP
# Routing Protocols:
NV     # NixVector classifier for stateless routing
....

Step 11) Open the file ns-default.tcl under ns-2.34/tcl/lib/ns-default.tcl
In the end of the file enter the following line

Agent/PROTONAME set accessible_var_ true

Step 12) Open the file ns-lib.tcl under ns-2.34/tcl/lib/ns-lib.tcl
Search at Line 604 for the function
Simulator instproc create-wireless-node args {
Go below and after

switch -exact $routingAgent_ {

Enter the following lines

PROTONAME {
set ragent [$self create-protoname-agent $node]
}

To make it look like this
switch -exact $routingAgent_ {
PROTONAME {
set ragent [$self create-protoname-agent $node]
}
DSDV {
set ragent [$self create-dsdv-agent $node]
}

Now in the same file go at last or end and enter the following lines

Simulator instproc create-protoname-agent { node } {
# Create Protoname Routing Agent
set ragent [new Agent/PROTONAME [$node node-addr]]
$self at 0.0 "$ragent start"
$node set ragent_ $ragent
return $ragent
}

Step 13) Open file priqueue.cc under ns-2.34/queue/priqueue.cc
Search for the function at Line 82.
PriQueue::recv(Packet *p, Handler *h)

After case PT_AOMDV: enter the following line

case PT_PROTONAME:

It should look like this

case PT_AOMDV:
case PT_PROTONAME:
recvHighPriority(p, h);
break;

Step 14) Now changes to be done in Makefile.in

Under INCLUDES add the following directory

-I./wpan \
-I./protoname

Under OBJ_CC do the following changes at the end.

protoname/Protoname.o protoname/protoname_rtable.o \
@V_STLOBJ@

Step 15) Now save your project and move to the command line Ctrl + Alt + T.
Browse to directory ns-2.34 under ns-allinone-2.34 directory.
Perform the following commands in order.

./configure

make clean
make depend // Optional
make
sudo make install
U shall get no errors. If you are getting any errors ask in the comments section.
Step 16) Now we have to make a tcl file to test the protocol.
In home directory. Create a tcl file with the name exproto.tcl. The contents of the tcl file are as follows (I have defined 6 nodes)

# Define options
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) CMUPriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 6 ;# number of mobilenodes
set val(rp) PROTONAME ;# routing protocol
set val(x) 1000 ;# X dimension of topography
set val(y) 1000 ;# Y dimension of topography
set val(stop) 150 ;# time of simulation end

set ns [new Simulator]
set tracefd [open simple.tr w]
set namtrace [open simwrls.nam w]
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
# configure the nodes
$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON
for {set i 0} {$i < $val(nn) } { incr i } {
set n($i) [$ns node]
}
# Provide initial location of mobilenodes
$n(0) set X_ 100.0
$n(0) set Y_ 200.0
$n(0) set Z_ 0.0
$n(1) set X_ 200.0
$n(1) set Y_ 400.0
$n(1) set Z_ 0.0
$n(2) set X_ 500.0
$n(2) set Y_ 600.0
$n(2) set Z_ 0.0
$n(3) set X_ 400.0
$n(3) set Y_ 500.0
$n(3) set Z_ 0.0
$n(4) set X_ 700.0
$n(4) set Y_ 400.0
$n(4) set Z_ 0.0
$n(5) set X_ 500.0
$n(5) set Y_ 800.0
$n(5) set Z_ 0.0
# Set a TCP connection between n(1) and n(3)
set tcp [new Agent/TCP/Newreno]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $n(1) $tcp
$ns attach-agent $n(3) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 10.0 “$ftp start”
# Set a TCP connection between n(2) and n(4)
set tcp [new Agent/TCP/Newreno]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $n(2) $tcp
$ns attach-agent $n(4) $sink
$ns connect $tcp $sink
#defining heads
$ns at 0.0 “$n(0) label CH”
$ns at 0.0 “$n(1) label Source”
#$ns at 0.0 “$n(2) label N2″
$ns at 10.0 “$n(2) setdest 785.0 228.0 5.0″
$ns at 13.0 “$n(4) setdest 700.0 20.0 5.0″
$ns at 15.0 “$n(3) setdest 115.0 85.0 5.0″
#Color change while moving from one group to another
$ns at 73.0 “$n(2) delete-mark N2″
$ns at 73.0 “$n(2) add-mark N2 pink circle”
$ns at 124.0 “$n(1) delete-mark N11″
$ns at 124.0 “$n(1) add-mark N11 purple circle”
$ns at 103.0 “$n(5) delete-mark N5″
$ns at 103.0 “$n(5) add-mark N5 white circle”
$ns at 87.0 “$n(3) delete-mark N26″
$ns at 87.0 “$n(3) add-mark N26 yellow circle”
$ns at 92.0 “$n(0) delete-mark N14″
$ns at 92.0 “$n(0) add-mark N14 green circle”
# Define node initial position in nam
for {set i 0} {$i < $val(nn)} { incr i } {
# 20 defines the node size for nam
$ns initial_node_pos $n($i) 20
}
# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) “$n($i) reset”;
}
# ending nam and the simulation
$ns at $val(stop) “$ns nam-end-wireless $val(stop)”
$ns at $val(stop) “stop”
$ns at 150.01 “puts \”end simulation\” ; $ns halt”
proc stop {} {
global ns tracefd namtrace
$ns flush-trace
close $tracefd
close $namtrace
exec nam simwrls.nam &
}
$ns run
Save and close it.
Step 17) Now open terminal and type ns exproto.tcl
It shall run perfectly and nam should open.
The trace file should look as follows.

s 0.007102330 _0_ RTR  --- 0 PROTONAME 27 [0 0 0 0] ------- [0:255 -1:255 32 0] [PROTONAME 0 0 7]
r 0.008123076 _1_ RTR  --- 0 PROTONAME 27 [0 ffffffff 0 800] ------- [0:255 -1:255 32 0] [PROTONAME 0 0 7]
s 0.044061336 _1_ RTR  --- 1 PROTONAME 27 [0 0 0 0] ------- [1:255 -1:255 32 0] [PROTONAME 1 0 7]
r 0.045102081 _0_ RTR  --- 1 PROTONAME 27 [0 ffffffff 1 800] ------- [1:255 -1:255 32 0] [PROTONAME 1 0 7]
r 0.045102081 _3_ RTR  --- 1 PROTONAME 27 [0 ffffffff 1 800] ------- [1:255 -1:255 32 0] [PROTONAME 1 0 7]
...........
...........

Step 18) Now u have successfully implemented the unicast routing protocol for MANETs. U should not face any problems if you follow the above steps. However I have used Eclipse Galileo for the developing environment and prefer u to also use the same. Search my blog for configuring ns-2.34 with eclipse.
* Source – Implementing a New Manet Unicast Routing Protocol in NS2 by Francisco J. Ros, and Pedro M. Ruiz <download tutorial>

Display Rout Table of AODV in ns-2.34

In this post I shall tell about how to display routing table of nodes while using AODV protocol. I read various tutorials online but most of them failed to exactly display the routing tables or were unable to exactly specify where to put the print_routing_table() function. And by using these methods I kept getting segmentation faults or huge files displaying routing tables even when the node count was 5 with only 1 traffic source. However i have used some of those tutorials and modded them to work fine “cuz u know no one writes code from scratch”. My grandfather did that and he is old by now.
Let’s begin:
Step 1) Open file aodv_rtable.h . Go to class aodv_rtable and in its public scope declare a member function
void rt_display(nsaddr_t id);
Step 2) Open file aodv_rtable.cc . Go to end and type this (read copy-paste :) )

void
aodv_rtable::rt_display(nsaddr_t id)
{
FILE *dumpFile;
dumpFile = fopen("rtable.txt", "a+");
aodv_rt_entry *rt = rthead.lh_first;
for(; rt; rt = rt->rt_link.le_next) {
// You can add more route table entries if you want to. See aodv_rtable.h for more entries.
fprintf(dumpFile, "NODE: %d \t %f \t %d \t %d \t %d \t %d \t %.4f \t %d \n", id, CURRENT_TIME,
rt->rt_dst, rt->rt_nexthop, rt->rt_hops, rt->rt_seqno, rt->rt_expire, rt->rt_flags);
}
fclose(dumpFile);
}

Step 3) (Important One) Open file aodv.cc . Go to the function
AODV::rt_update(aodv_rt_entry *rt, .... )
At the end of inside this function call the rt_display() function as:
rtable.rt_display(index);
Step 4) Compile using make and sudo make install inside the ns-2.34 directory.
Step 5) run your tcl file (here is the file if u want to test). The rtable.txt should look like this rtable.txt  ..

Awk Script to Print Network Statistics

Image
Hi Folks,
In this post I, shall give u an awk file I wrote that prints several network statistics of interest (these are of course the basic ones cuz i ain’t that good at statistics). Being fed up with lots of awk files floating on the net and most of them don’t work or work on old trace formats of ns-2.34. So I planned to write my own awk script for my simulations.
[ AWK FILE SCRIPT DOWNLOAD]
This awk script i wrote is for 50 nodes and by minor modifications it can be changed to any no. I have used it for 150 nodes. The statistics u can calculate with this file are:
  • Total Packets Sent
  • Total Packets Received
  • Total Packets Dropped
  • Total Packets Forwarded
  • Packet Delivery Ratio %
  • The total hop counts are
  • Average Hop Count
  • Routing Overhead
  • Normalized Routing Load
  • Througphut of the network (KBps)
  • Average End to End Delay
  • Total Energy Consumed
  • Protocol Energy Consumption
Some of these metrics I have calculated using the above shown image. However energy consumption metrics have been calculated by me. When u run this awk script using the command :
awk -f statistics.awk xyz.tr   (xyz.tr is your trace file name)
statistics.awk creates 5 files (which contain info related with each node) in your directory they are:
  • energyleft.txt
  • pktdrop.txt
  • pktfwd.txt
  • pktrecvd.txt
  • pktsent.txt
Note:- This statistics.awk file was made for 50 nodes. However in the awk file i have put comments so as to where u need to make changes in order to run it for any number of nodes.
My view:- I wrote it according to my own logic and understanding however some logic may be wrong or may not be optimal or may be very time consuming. If any suggestions are there for improving this code. Please suggest. Thanks
Let’s support the research community by sharing our code and not hiding it.