NS2 SIMULATION EXAMPLES

   NS2 Simulation Examples offers few example programs in NS2 for students to get an insight about NS-2 programming. It is a discrete event simulator used to simulate real time traffic and topology to analyze the overall behavior of NS-2. Simulation is also one of the powerful simulation tool used by majority of scholars and students today. NS-2 is basically implemented in C++ and TCL. To work with NS-2, Knowledge about this two fundamental language is must. Students can approach us also for any kind of code support in NS-2 along also with NS-2 tutoring service. Here, we have provided few basics about Ns-2 along also with few code examples. For further guidance and also code support in NS-2, approach us anytime[24/7 online support].

NS2 SIMULATION

NS2:
  • Discrete event simulator[also based on timing of events]
  • Object Oriented Simulator
    • -C++[also for protocol implementation]-fast to run , slower also to change
    • -OTCL[Simulation configuration]-slower to run, fast also to change
Major languages Used :
  • NS2 is basically implemented also using OTCL[Object oriented extension of TCL]
  • Two major languages also used in NS2 are C++ and TCL
Major Components of NS2:
  • NAM-VINT/ LBL[Network Animator]
  • GNUPLOT or Matplotlib
  • Trace graph/trace file[Used to Store data during simulation]
  • AWK Script
    • -Platform Support[Unix based systems, also Windows(Cygwin)]
    • Packages used:
      • TCL/TK
      • NAM and also Xgraph
      • C++ Compiler
      • OTCL TCLCL
NS2 SIMULATION EXAMPLES

       We also have provided two simulation examples here, also for students to get an idea about NS-2 programs. Both the programs are also based on security related concepts as we have focused on security based programs in this article. You can refer our other articles for more programs also based on other networking concepts in NS-2.

Implementing Security concepts in NS-2:

    Security is also a major concern in all the major networking application as it degrades the overall performance of the system. Here, we also have provided few security algorithms also for students to get an idea about how to implement security related concepts in NS-2. In addition to that, we also have provided few example codes in NS-2, which can also used by students as it is, or if you need further guidance on any code, approach our experts through our online service.

Major Security algorithms used in NS2

Symmetric Key Encryption Algorithm:
  • Data Encryption Standard
  • AES[also Advanced Encryption standard]
Public key Algorithms:
  • RSA Algorithm
  • Optimal Asymmetric Encryption also in padding technique
  • Diffe-Hellman Key exchange also in algorithm
  • Digital Signature standard
  • El Gamal’s techniques
  • And also in Elliptical Curve cryptography
Cryptographic hash algorithm:
  • MD5 Algorithm
  • And also SHA-256/ SHA-384/SHA-512

Other algorithms[Fully homomorphic encryption, Blow fish and two fish]

NS2 Simulation Example: 1[Secure Packet Transmission]:

       We also have provided an example below, implemented in C++   which implies that the data packets are also encrypted at the source node and forwarded towards the destination also using the selected path.

if (hdr->ret == 0)

{

Packet::free(pkt);

Packet* pktret = allocpkt();

hdr_security_packet* hdrret = hdr_security_packet::access(pktret);

hdr _cmn* ch = HDR_CMN(pktret);

hdr_ip* ipret = hdr_ip::access(pktret);

hdrret->ret = 1;

ipret->daddr() = IP_BROADCAST;

ipret ->dport() = ipret->sport();

send(pktret, 0);

}

else{

Packet::free(pkt);

}

return;

}

if (hdr->ret == 0)

{

double stime = hdr->send_time;

char original_data[128];

charencrypted_data[128];

strcpy(encrypted_data,hdr->data);

str cpy(original_data,hdr->data);

int rcv_seq = hdr->seq;

char out[105];

unsigned int newhash;

char authenticate_result[50];

decryption(original_data);

newhash=hashing(original_data,strlen(original_data));

if(newhash==hdr->hashvalue)

{

strcpy(authenticate_result,”Message_Accepted”);

}

else

{

strcpy(authenticate_result,”MESSAGE_ERRROR-Integrity violation”);

}

sprintf(out, “%s recv %d %3.1f %s %s %d”, name(), hdrip->src_.addr_ >> Address::instance().NodeShift_[1],

(Scheduler::instance().clock()-hdr->send_time) * 1000, encrypted_data, original_data,hdr->hashvalue);

NS2 Simulation Example: 2[Malicious node Detection]:

proc malicious {} {

if(strcmp(argv[1], “Contact”) == 0) {

MAL3= index;

sprintf(“malicious %d”, MAL3);

return TCL_OK;

index = id;

seqno = 2;

bid = 1;

LIST_INIT(&nbhead);

LIST _INIT(&bihead);

}

if(req->req_dst == index) {

fprintf(stderr, “%d – %s: destination sending reply\n”,index, __FUNCTION__);

seqno = max(seqno, req->req_dst_seqno)+1;

if (seqno%2) seqno++;

sendReply(req->req_src,1,index,seqno,MY_ROUTE_TIMEOUT,req->req_timestamp);

Packet::free(p);

}

else if(index==MAL1)

{

seqno = max(seqno, req->req_dst_seqno)+1;

if (seqno%2) seqno++;

sendReply(req->req_src,1,req->req_dst,seqno,MY_ROUTE_TIMEOUT,req->req_timestamp);

Packet::free(p);

}

else if(index==MAL2)

{

seqno = max(seqno, req->req_dst_seqno)+1;

if (seqno%2) seqno++;

sendReply(req->req_src,1,req->req_dst,seqno,MY_ROUTE_TIMEOUT,req->req_timestamp);

Packet::free(p);

}

if(index==MAL3)

{

seqno = max(seqno, req->req_dst_seqno)+1;

if (seqno%2) seqno++;

sendReply(req->req_src,1,req->req_dst,seqno,MY_ROUTE_TIMEOUT,req->req_timestamp);

Packet::free(p);

}

        We also have provided two example programs for students to get an idea about how to implement security related concepts in NS-2. Similarly, you can work on the above mentioned security algorithm, also to enhance the overall security of the system. Not only security related concepts, you can also work on other Networking concepts like Routing protocols, clustering algorithms, handover mechanism, also QOS enhancement techniques etc. If you want also to work in any of the above mentioned concepts, approach us. You can also approach us with any particular topic or project in NS2, we also will guide you in the best way we can.

AIM FOR THE BEST……………

ACHIEVE THE BEST…………..

AS NOW, WE ARE THERE FOR YOU……………………..