Commit 6673fe15 authored by Shashi Guruprasad's avatar Shashi Guruprasad

NSE with event system check in

parent c6163a2d
#
# This is the defaults definitions file for configure.
#
# Use the --with-TBDEFS=filename to specify your own. If you add a variable,
# be sure to go and update configure.in.
#
TBDBNAME=tbdb
WWWDEFS=mini
WWWDEFS=shash-mini
TBADMINGROUP=flux
TBOPSEMAIL=shash+mini-ops@cs.utah.edu
TBLOGSEMAIL=shash+mini-log@cs.utah.edu
TBACTIVEARCHIVE=shash+activearch@cs.utah.edu
TBUSERSARCHIVE=shash+usersarch@cs.utah.edu
IPBASE=192.168
DELAYCAPACITY=1
BOSSNODE=boss.mini.emulab.net
USERNODE=users.mini.emulab.net
FSNODE=fs.mini.emulab.net
OURDOMAIN=mini.emulab.net
FSDIR_GROUPS=/z/groups
FSDIR_PROJ=/z/proj
FSDIR_USERS=/z/users
......@@ -13,14 +13,9 @@ b) NSE executable file. To build it, do a "cvs co ns-2" in this
./install
cp ns-2.1b8a/nse <sup_directory>
The current NSE trafgen has the following caveats:
0) The Telnet and FTP traffic generators will automatically start
30 seconds after "$ns run" in nseinput.tcl has been called. This just
arbitrary and will be fixed in the event system version of NSE.
1) nseinput.tcl does tmcc ready barrier synchronization which is not
sufficient across reboots. Again, this will be fixed
2) It comes with all the bugs and idiosyncrasies of the FullTcp, FTP and
The current NSE trafgen comes with a major caveat:
0) It comes with all the bugs and idiosyncrasies of the FullTcp, FTP and
Telnet models in NS.
Here is an example scenario:
......@@ -59,5 +54,11 @@ $ns attach-agent $nodeA $tcp3
$ns connect $tcp2 $tcp3
$ns at 30.0 "$ftp0 start"
$ns at 120.0 "$ftp0 stop"
$ns at 60.0 "$telnet0 start"
$ns at 90.0 "$tcp2 set segsize_ 256; $tcp3 set segsize_ 512"
$ns at 150.0 "$telnet0 stop"
#Run the simulation
$ns run
......@@ -61,14 +61,25 @@ foreach tcpsubclass [Agent/TCP/FullTcp info subclass] {
lappend tcpclasses $tcpsubclass
}
set objnamelist ""
foreach tcpclass $tcpclasses {
set tcpobjs [$tcpclass info instances]
foreach tcpobj $tcpobjs {
$ns attach-agent $n0 $tcpobj
lappend objnamelist [$tcpobj set objname]
}
}
foreach ftpobj [Application/FTP info instances] {
lappend objnamelist [$ftpobj set objname]
}
foreach telnetobj [Application/Telnet info instances] {
lappend objnamelist [$telnetobj set objname]
}
# for each entry in `tmcc trafgens` that has NSE as the generator
# configure that object to connect to a newly created
# TCPTap along with the required Live and RAW IP objects. Set the filter and interface
......@@ -131,4 +142,19 @@ foreach trafgen $trafgenlist {
}
# get some params to configure the event system interface
set boss [lindex [split [exec tmcc bossinfo] " "] 0]
set pideidlist [split [exec hostname] "."]
set vnode [lindex $pideidlist 0]
set eid [lindex $pideidlist 1]
set pid [lindex $pideidlist 2]
set logpath "/proj/$pid/exp/$eid/logs/nse-$vnode.log"
# Configuring the Scheduler to monitor the event system
set evsink [new TbEventSink]
$evsink event-server "elvin://$boss"
$evsink objnamelist [join $objnamelist ","]
$evsink logfile $logpath
[$ns set scheduler_] tbevent-sink $evsink
$ns run
......@@ -61,14 +61,25 @@ foreach tcpsubclass [Agent/TCP/FullTcp info subclass] {
lappend tcpclasses $tcpsubclass
}
set objnamelist ""
foreach tcpclass $tcpclasses {
set tcpobjs [$tcpclass info instances]
foreach tcpobj $tcpobjs {
$ns attach-agent $n0 $tcpobj
lappend objnamelist [$tcpobj set objname]
}
}
foreach ftpobj [Application/FTP info instances] {
lappend objnamelist [$ftpobj set objname]
}
foreach telnetobj [Application/Telnet info instances] {
lappend objnamelist [$telnetobj set objname]
}
# for each entry in `tmcc trafgens` that has NSE as the generator
# configure that object to connect to a newly created
# TCPTap along with the required Live and RAW IP objects. Set the filter and interface
......@@ -131,4 +142,19 @@ foreach trafgen $trafgenlist {
}
# get some params to configure the event system interface
set boss [lindex [split [exec tmcc bossinfo] " "] 0]
set pideidlist [split [exec hostname] "."]
set vnode [lindex $pideidlist 0]
set eid [lindex $pideidlist 1]
set pid [lindex $pideidlist 2]
set logpath "/proj/$pid/exp/$eid/logs/nse-$vnode.log"
# Configuring the Scheduler to monitor the event system
set evsink [new TbEventSink]
$evsink event-server "elvin://$boss"
$evsink objnamelist [join $objnamelist ","]
$evsink logfile $logpath
[$ns set scheduler_] tbevent-sink $evsink
$ns run
#include "tbevent.h"
static class TbEventSinkClass : public TclClass {
public:
TbEventSinkClass() : TclClass("TbEventSink") {}
TclObject* create(int /* argc */, const char*const* /* argv */) {
return (new TbEventSink);
}
} class_realtime_sched;
void
TbEventSink::callback(event_handle_t handle,
event_notification_t notification, void *data) {
TbEventSink *obj = (TbEventSink *)data;
obj->gotevent = 1;
char buf[7][64];
int len = 64;
char argsbuf[8192];
buf[0][0] = buf[1][0] = buf[2][0] = buf[3][0] = 0;
buf[4][0] = buf[5][0] = buf[6][0] = buf[7][0] = 0;
event_notification_get_site(handle, notification, buf[0], len);
event_notification_get_expt(handle, notification, buf[1], len);
event_notification_get_group(handle, notification, buf[2], len);
event_notification_get_host(handle, notification, buf[3], len);
event_notification_get_objtype(handle, notification, buf[4], len);
event_notification_get_objname(handle, notification, buf[5], len);
event_notification_get_eventtype(handle, notification, buf[6], len);
event_notification_get_arguments(handle, notification, argsbuf, sizeof(argsbuf));
struct timeval now;
gettimeofday(&now, NULL);
info("Received Event: %lu:%ld \"%s\"\n", now.tv_sec, now.tv_usec, argsbuf);
// All events coming in to NSE should be MODIFY events and we just need to
// evaluate the string in args. If the user sent code with wrong syntax,
// we just print a warning in the log. Also we need a mechanism
// to report the error back to the experimenter
// XXX: fix needed
if( Tcl_GlobalEval( Tcl::instance().interp(), argsbuf ) != TCL_OK ) {
error( "Tcl Eval error in code: \"%s\"\n", argsbuf );
}
}
TbEventSink::~TbEventSink() {
if( ehandle != 0 ) {
/*
* Unregister with the event system:
*/
if (event_unregister(ehandle) == 0) {
fatal("could not unregister with event system");
}
}
}
void
TbEventSink::init() {
char buf[BUFSIZ] ;
if( logfile[0] != 0 ) {
loginit(0, logfile);
} else {
loginit(1, "Testbed-NSE");
}
if( server[0] == 0 ) {
fatal("event system server unknown\n");
}
/*
* Get our IP address. Thats how we name ourselves to the
* Testbed Event System.
*/
struct hostent *he;
struct in_addr myip;
if (gethostname(buf, sizeof(buf)) < 0) {
fatal("could not get hostname");
}
if (! (he = gethostbyname(buf))) {
fatal("could not get IP address from hostname");
}
memcpy((char *)&myip, he->h_addr, he->h_length);
strncpy(ipaddr, inet_ntoa(myip), sizeof(ipaddr));
/*
* Register with the event system.
*/
ehandle = event_register(server, 0);
if (ehandle == NULL) {
fatal("could not register with event system");
}
}
int
TbEventSink::poll() {
int rv;
rv = event_poll(ehandle);
if (rv)
fatal("event_poll failed, err=%d\n", rv);
if(gotevent) {
gotevent = 0 ;
return 1;
} else {
return 0;
}
}
int TbEventSink::command(int argc, const char*const* argv)
{
if( argc == 3 ) {
if(strcmp(argv[1], "event-server") == 0) {
strncpy(server, argv[2], sizeof(server));
return(TCL_OK);
}
if(strcmp(argv[1], "objnamelist") == 0) {
strncpy(objnamelist, argv[2], sizeof(objnamelist));
return(TCL_OK);
}
if(strcmp(argv[1], "logfile") == 0) {
strncpy(logfile, argv[2], sizeof(logfile));
return(TCL_OK);
}
}
return (TclObject::command(argc, argv));
}
void
TbEventSink::subscribe() {
/*
* Construct an address tuple for subscribing to events for
* this node.
*/
address_tuple_t tuple = address_tuple_alloc();
if (tuple == NULL) {
fatal("could not allocate an address tuple");
}
tuple->host = ipaddr[0] ? ipaddr : ADDRESSTUPLE_ANY;
tuple->site = ADDRESSTUPLE_ANY;
tuple->group = ADDRESSTUPLE_ANY;
tuple->expt = ADDRESSTUPLE_ANY; /* pid/eid */
tuple->objtype = TBDB_OBJECTTYPE_TRAFGEN;
if( objnamelist[0] != 0 ) {
tuple->objname = objnamelist;
} else {
tuple->objname = ADDRESSTUPLE_ANY;
}
tuple->eventtype = ADDRESSTUPLE_ANY;
info( "TRAFGEN event subscription for object list: \"%s\" for node %s\n", tuple->objname, tuple->host);
if (!event_subscribe(ehandle, callback, tuple, this)) {
fatal("could not subscribe to TRAFGEN events for objects %s", tuple->objname );
}
address_tuple_free(tuple);
}
#ifndef TBEVENT_H
#define TBEVENT_H
/* NSE includes */
#include "config.h"
/* event library stuff */
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/param.h>
#include "tbdefs.h"
#include "log.h"
#include "event.h"
#ifdef __cplusplus
}
#endif
#include <netdb.h>
#include <netinet/in.h>
class TbEventSink : public TclObject {
public:
TbEventSink() : gotevent(0), ehandle(0) {
bzero(ipaddr, sizeof(ipaddr));
bzero(server, sizeof(server));
bzero(objnamelist, sizeof(objnamelist));
bzero(logfile, sizeof(logfile));
}
~TbEventSink();
virtual int command(int argc, const char*const* argv);
void init();
void subscribe();
int poll();
private:
char server[BUFSIZ];
int gotevent;
event_handle_t ehandle;
char ipaddr[BUFSIZ];
char objnamelist[BUFSIZ];
char logfile[MAXPATHLEN];
static void
callback(event_handle_t handle,
event_notification_t notification, void *data);
};
#endif
......@@ -320,6 +320,26 @@ Simulator instproc at {time eventstring} {
set vnode [$obj get_node]
set vname $obj
}
"Agent/TCP/FullTcp" -
"Agent/TCP/FullTcp/Reno" -
"Agent/TCP/FullTcp/Newreno" -
"Agent/TCP/FullTcp/Tahoe" -
"Agent/TCP/FullTcp/Sack" -
"Application/FTP" -
"Application/Telnet" {
# For events sent to NSE, we don't distinguish
# between START, STOP and MODIFY coz the entire
# string passed to '$ns at' is sent for evaluation to the node
# on which NSE is running: fix needed for the
# case when the above string has syntax errors. Maybe
# just have a way reporting errors back to the
# the user from the NSE that finds the syntax errors
set otype TRAFGEN
set etype MODIFY
set args "\$$obj $cmd [lrange $event 2 end]"
set vnode [$obj get_node]
set vname $obj
}
"Link" {
set otype LINK
switch -- $cmd {
......@@ -515,4 +535,4 @@ Simulator instproc get_subnet {} {
Simulator instproc use_subnet {subnet} {
$self instvar subnets
set subnets($subnet) {}
}
\ No newline at end of file
}
......@@ -267,6 +267,7 @@ Agent/TCP/FullTcp instproc get_nseconfig {} {
$self instvar role
$self instvar simulated
$self instvar application
$self set objname $self
set nseconfig ""
......@@ -281,7 +282,7 @@ Agent/TCP/FullTcp instproc get_nseconfig {} {
} else {
set nseconfig "set $self \[new Agent/TCP/FullTcp/$tcptype]\n"
}
if { $role == "sink" } {
append nseconfig "\$$self listen\n\n"
}
......@@ -459,13 +460,15 @@ Application/FTP instproc get_nseconfig {} {
$self instvar agent
set nseconfig "set $self \[new Application/FTP]\n"
append nseconfig "\$$self set objname $self\n"
if { $agent != {} } {
append nseconfig "\$$self attach-agent \$$agent\n\n"
}
# XXX temporary untill event system changes get in
append nseconfig "\[Simulator instance] at 30.0 \"\$$self start\"\n\n"
# append nseconfig "\[Simulator instance] at 30.0 \"\$$self start\"\n\n"
return $nseconfig
}
......@@ -492,6 +495,8 @@ Application/Telnet instproc get_nseconfig {} {
$self instvar interval_
set nseconfig "set $self \[new Application/Telnet]\n"
append nseconfig "\$$self set objname $self\n"
append nseconfig "\$$self set interval_ $interval_\n"
if { $agent != {} } {
......@@ -499,7 +504,7 @@ Application/Telnet instproc get_nseconfig {} {
}
# XXX temporary untill event system changes get in
append nseconfig "\[Simulator instance] at 30.0 \"\$$self start\"\n\n"
# append nseconfig "\[Simulator instance] at 30.0 \"\$$self start\"\n\n"
return $nseconfig
}
<?php
#
# Mac's definitions. Selected via configure.
#
$WWWHOST = "www.mini.emulab.net";
$WWW = "$WWWHOST/~shash/www";
$TBBASE = "https://$WWW";
$TBDOCBASE = "http://$WWW";
$TBWWW = "<$TBBASE/>";
$TBAUTHDOMAIN = ".emulab.net";
$TBSECURECOOKIES= 1;
$TBCOOKIESUFFIX = "-mini";
#
# Title Page stuff.
#
$TITLECOLOR = "#E04050";
$BANNERCOLOR = "#4080FF";
$THISHOMEBASE = "Mini-Shash@Emulab.Net";
$THISPROJECT = "The Mini Shash Network Testbed";
$TBMAILADDR_OPS = "shash+mini-ops@cs.utah.edu";
$TBMAIL_OPS = "Shash Testbed Ops <$TBMAILADDR_OPS>";
$TBMAILADDR_WWW = "shash+mini-www@cs.utah.edu";
$TBMAIL_WWW = "Shash Testbed WWW <$TBMAILADDR_WWW>";
$TBMAILADDR_APPROVAL = "shash+mini-approve@cs.utah.edu";
$TBMAIL_APPROVAL = "Shash Testbed Approval <$TBMAILADDR_APPROVAL>";
$TBMAILADDR_LOGS = "shash+mini-log@cs.utah.edu";
$TBMAIL_LOGS = "Shash Testbed Logs <$TBMAILADDR_LOGS>";
$TBMAILADDR_AUDIT = "shash+mini-audit@cs.utah.edu";
$TBMAIL_AUDIT = "Testbed Audit <$TBMAILADDR_AUDIT>";
?>
......@@ -206,15 +206,15 @@ Time Node Agent Type Event Arguments
120.000 nodeA cbr1 TRAFGEN START PACKETSIZE=500
RATE=100000
INTERVAL=0.005
120.000 nodeA ftp0 NSETRAFGEN MODIFY $ftp0 start
120.000 nodeA ftp0 TRAFGEN MODIFY $ftp0 start
130.000 nodeA cbr1 TRAFGEN MODIFY PACKETSIZE=512
130.000 nodeA cbr1 TRAFGEN MODIFY INTERVAL=0.01
140.000 tbsdelay0 link0 LINK DOWN
140.000 nodeA tcpfull0 NSETRAFGEN MODIFY $tcpfull0 set segsize_ 256
140.000 nodeA tcpfull0 NSETRAFGEN MODIFY $tcpfull0 set segsperack_ 2
145.000 nodeB tcpfull1 NSETRAFGEN MODIFY $tcpfull1 set nodelay_ true
140.000 nodeA tcpfull0 TRAFGEN MODIFY $tcpfull0 set segsize_ 256
140.000 nodeA tcpfull0 TRAFGEN MODIFY $tcpfull0 set segsperack_ 2
145.000 nodeB tcpfull1 TRAFGEN MODIFY $tcpfull1 set nodelay_ true
150.000 tbsdelay0 link0 LINK UP
150.000 nodeA ftp0 NSETRAFGEN MODIFY $ftp0 stop
150.000 nodeA ftp0 TRAFGEN MODIFY $ftp0 stop
160.000 nodeA cbr1 TRAFGEN STOP </code></pre>
<p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment