Search This Blog

Network Simulator - 2

Labels:

Reactions: 

The three main techniques to analyze the behavior of wired and wireless networks are: Analytical Modeling, Computer Simulations and Real Time Physical Measurements.

Analytical Modeling is very tedious and Real Time Physical Measurements may not be possible all the time. Computer Simulation is the only feasible approach to the quantitative analysis of networks. Computer Simulations can be Discrete Event Simulations (e.g.: arrival and departure of customers in a bank) or Continuous Simulations (e.g.: waterflow in a mountain). Computer Simulations are generally Discrete Event Simulations.

Network Simulator - 2 (NS-2) is a discrete event and packet level simulator developed at UC Berkeley to analyze the performance of wired and wireless networks. The architecture of NS-2 is composed of five components: Event Scheduler (there are four: List, Heap, Calendar and Real), Network Components (like nodes, links, protocols, etc), Tool command language with Classes (TclCL), Object Oreinted Tcl (OTcl) library and TCL scripting language. NS-2 has C++ as the back-end language and TCL as the front-end language.

For more information on NS - 2 and related references please visit my website:  www.mohit.ueuo.com

Comments (13)

Website www.mohit.ueuo has everything related to NS-2 Even the AWK scripts.... Very Informative

Hi Mohit,
the results after using every awk file which is in your website are giving 0. can you please check them and help providing a perfect awk file, that will be very helpful to my project. thank you

You want AWK script for which parameter?

This comment has been removed by the author.

Sir will u tell me how to calculate rtt value in ns2

Hello Sir... May i know how to solve the problem of finding shortest path and near neighbour in wired network using NS2 ? Is there any TCL scripts exists for these?

Hello Sir,

Can you help me regarding the tcl code for "Simulation of Congestion control in cloud computing environment using NS2" Please

Hello Sir,
First of all i would like to thank you for your initiative to help us.
I am doing a project on "Analysis and implementation of Black hole attack in MANETs".Sir I would like to know if is it possible to implement the Black hole attack in MANETs with random mobility and changing pause time using the "TCL Script Generator" ?
In either case ,Sir could you please help me out with the code.

Sir i am using NS2.35 for simulation of AODV protocol. But i am unable to see the AODV HELLO message in trace file. the line #define AODV_LINK_LAYER_DETECTION. already commented in files: aodv.cc and aodv,h

Hopping for your favorable response.

Good evening sir,
We are working on simulation on Mac layer of Ad hoc networks. We did not get the good source "How to add a new mac protocol to NS2". So, can you please send me the procedure.

we are working on iptrace back for dos attack. we have one problem is that ,we want to print cuurent node ip address in comman/ttl.cc file can you help us

sir please send simulation program for Simulate simple ESS and with transmitting nodes in wire-less LAN by simulation and determine the performance with respect to transmission of packets.

Hi sir,
my project is change the tcp working directory in ns3.

for example acknowledgement will dont send.

my tcp code is:


#include
#include
#include

#include "ns3/core-module.h"
#include "ns3/applications-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/ipv4-global-routing-helper.h"

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("TcpLargeTransfer");


static const uint32_t totalTxBytes = 2000000;
static uint32_t currentTxBytes = 0;
static const uint32_t writeSize = 1040;
uint8_t data[writeSize];


void StartFlow (Ptr, Ipv4Address, uint16_t);
void WriteUntilBufferFull (Ptr, uint32_t);

static void
CwndTracer (uint32_t oldval, uint32_t newval)
{
NS_LOG_INFO ("Moving cwnd from " << oldval << " to " << newval);
}

int main (int argc, char *argv[])
{

CommandLine cmd;
cmd.Parse (argc, argv);

// initialize the tx buffer.
for(uint32_t i = 0; i < writeSize; ++i)
{
char m = toascii (97 + i % 26);
data[i] = m;
}

NodeContainer n0n1;
n0n1.Create (2);

NodeContainer n1n2;
n1n2.Add (n0n1.Get (1));
n1n2.Create (1);

PointToPointHelper p2p;
p2p.SetDeviceAttribute ("DataRate", DataRateValue (DataRate (10000000)));
p2p.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (10)));

NetDeviceContainer dev0 = p2p.Install (n0n1);
NetDeviceContainer dev1 = p2p.Install (n1n2);

InternetStackHelper internet;
internet.InstallAll ();

Ipv4AddressHelper ipv4;
ipv4.SetBase ("10.1.3.0", "255.255.255.0");
ipv4.Assign (dev0);
ipv4.SetBase ("10.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer ipInterfs = ipv4.Assign (dev1);

Ipv4GlobalRoutingHelper::PopulateRoutingTables ();


uint16_t servPort = 50000;

PacketSinkHelper sink ("ns3::TcpSocketFactory",
InetSocketAddress (Ipv4Address::GetAny (), servPort));

ApplicationContainer apps = sink.Install (n1n2.Get (1));
apps.Start (Seconds (0.0));
apps.Stop (Seconds (3.0));

Ptr localSocket =
Socket::CreateSocket (n0n1.Get (0), TcpSocketFactory::GetTypeId ());
localSocket->Bind ();

Config::ConnectWithoutContext ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow", MakeCallback (&CwndTracer));

Simulator::ScheduleNow (&StartFlow, localSocket,
ipInterfs.GetAddress (1), servPort);

AsciiTraceHelper ascii;
p2p.EnableAsciiAll (ascii.CreateFileStream ("tcp-large-transfer.tr"));
p2p.EnablePcapAll ("tcp-large-transfer");

Simulator::Stop (Seconds (1000));
Simulator::Run ();
Simulator::Destroy ();
}

void StartFlow (Ptr localSocket,
Ipv4Address servAddress,
uint16_t servPort)
{
NS_LOG_LOGIC ("Starting flow at time " << Simulator::Now ().GetSeconds ());
localSocket->Connect (InetSocketAddress (servAddress, servPort)); //connect

localSocket->SetSendCallback (MakeCallback (&WriteUntilBufferFull));
WriteUntilBufferFull (localSocket, localSocket->GetTxAvailable ());
}

void WriteUntilBufferFull (Ptr localSocket, uint32_t txSpace)
{
while (currentTxBytes < totalTxBytes && localSocket->GetTxAvailable () > 0)
{
uint32_t left = totalTxBytes - currentTxBytes;
uint32_t dataOffset = currentTxBytes % writeSize;
uint32_t toWrite = writeSize - dataOffset;
toWrite = std::min (toWrite, left);
toWrite = std::min (toWrite, localSocket->GetTxAvailable ());
int amountSent = localSocket->Send (&data[dataOffset], toWrite, 0);
if(amountSent < 0)
{
// we will be called again when new tx space becomes available.
return;
}
currentTxBytes += amountSent;
}
localSocket->Close ();
}

Guest Book...!!!