Selasa, 22 Mei 2012

Tutorial SNMP dan MRTG di ubuntu 11.10


N4C_WP7_complex_example_scenarios_part_5.avi

Network Simulation

sw2011

How to configure snmpd

Install and Setup SNMP Ubuntu


NS3 (Compile and Run Network Simulator Program)

1.Development Tools
NS3 support development programming C++ and Python
2.Getting Started

Code I copy paste from NS3 sample codes, main-simple.cc


#include <iostream>

#include "ns3/core-module.h"
#include "ns3/helper-module.h"
#include "ns3/node-module.h"
#include "ns3/simulator-module.h"

using namespace ns3;

static void
GenerateTraffic (Ptr<Socket> socket, uint32_t size)
{
std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, tx bytes=" << size << std::endl;
socket->Send (Create<Packet> (size));
if (size > 0)
{
Simulator::Schedule (Seconds (0.5), &GenerateTraffic, socket, size - 50);
}
else
{
socket->Close ();
}
}

static void
SocketPrinter (Ptr<Socket> socket)
{
Ptr<Packet> packet;
while (packet = socket->Recv ())
{
std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, rx bytes=" << packet->GetSize () << std::endl;
}
}

static void
PrintTraffic (Ptr<Socket> socket)
{
socket->SetRecvCallback (MakeCallback (&SocketPrinter));
}

void
RunSimulation (void)
{
NodeContainer c;
c.Create (1);

InternetStackHelper internet;
internet.Install (c);


TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
Ptr<Socket> sink = Socket::CreateSocket (c.Get (0), tid);
InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80);
sink->Bind (local);

Ptr<Socket> source = Socket::CreateSocket (c.Get (0), tid);
InetSocketAddress remote = InetSocketAddress (Ipv4Address::GetLoopback (), 80);
source->Connect (remote);

GenerateTraffic (source, 500);
PrintTraffic (sink);


Simulator::Run ();

Simulator::Destroy ();
}

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

return 0;
}
Selanjutnya


## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-

def build(bld):
env = bld.env_of_name('default')
if not env['ENABLE_EXAMPLES']:
return;

obj = bld.create_ns3_program('hello-world-ns3',
['core', 'simulator'])
obj.source = 'hello-world-ns3.cc'

3.Create waf file and write this script exec "`dirname "$0"`"/../waf "$@"
4.Compile and Run
./waf --run "hello-world-ns3"



Prerequisites
The following list of packages should be accurate for Ubuntu 10.10 release.

requirements for C++ (release)

sudo apt-get install gcc g++ python
requirements for Python (release)

sudo apt-get install gcc g++ python python-dev
Mercurial:

sudo apt-get install mercurial

python bindings:

sudo apt-get install bzr
Debugging

sudo apt-get install gdb valgrind
GNU Scientific Library (GSL):



sudo apt-get install gsl-bin libgsl0-dev libgsl0ldbl
The Network Simulation Cradle (nsc):

sudo apt-get install flex bison
To read pcap packet traces:

sudo apt-get install tcpdump
Sqlite for statistics framework

sudo apt-get install sqlite sqlite3 libsqlite3-dev
Xml-based version of the config store

sudo apt-get install libxml2 libxml2-dev
A GTK-based

sudo apt-get install libgtk2.0-0 libgtk2.0-dev
To experiment with virtual machines and ns-3

sudo apt-get install vtun lxc
utils/check-style.py code style check program

sudo apt-get install uncrustify
Doxygen

sudo apt-get install doxygen graphviz imagemagick
sudo apt-get install texlive texlive-latex-extra texlive-generic-extra texlive-generic recommended
Texinfo

sudo apt-get install texinfo dia texlive texlive-latex-extra texlive-extra-utils texlive-generic-recommended texi2html
ustavo Carneiro's ns-3-pyviz visualizer

sudo apt-get install python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev
Installation
Now we can start to install NS3. Firstly we download ns-allinone-3.9.tar.bz2 file and put on a specific folder such as repos


Extract ns-allinone-3.9.tar.bz2

tar xjf ns-allinone-3.9.tar.bz2
Change to directory ns-allinone-3.9 and build NS3

./build.py
If success, you can see output messages displayed as below

'build' finished successfully (..)
Leaving directory './ns-3.9'
Collapse this post