Commit deb7b404 authored by Leigh B. Stoller's avatar Leigh B. Stoller

node.tcl: Run agent-attach through the node so that we can record

which agents are attached to which node, so that we can assign
portnumbers to them. Also add code to updating the DB with these
agents (virt_trafgens).

sim.tcl: Get rid of $pid_$eid_events (per experiment events table),
and replace with global eventlist table. Revisit this later, since it
was causing problems and we do not really have a problem right now.
Maybe later.

traffic.tcl: Add virt_trafgens DB table update code. Get rid of oskit
based traffic generators and replace with FreeBSD nodes, which will
boot up and check if they are traffic gen source. Add get_params call,
called by the event code im sim.tcl to get the current params for the
START event.
parent 11896853
...@@ -21,6 +21,13 @@ Node instproc init {s} { ...@@ -21,6 +21,13 @@ Node instproc init {s} {
# on port i. # on port i.
$self set portlist {} $self set portlist {}
# A list of agents attached to this node.
$self set agentlist {}
# A counter for udp/tcp portnumbers. Assign them in an increasing
# fashion as agents are assigned to the node.
$self set next_portnumber_ 5000
# iplist, like portlist, is supported by portnumber. An entry of # iplist, like portlist, is supported by portnumber. An entry of
# {} indicates an unassigned IP address for that port. # {} indicates an unassigned IP address for that port.
$self set iplist {} $self set iplist {}
...@@ -80,6 +87,7 @@ Node instproc updatedb {DB} { ...@@ -80,6 +87,7 @@ Node instproc updatedb {DB} {
$self instvar failureaction $self instvar failureaction
$self instvar routertype $self instvar routertype
$self instvar fixed $self instvar fixed
$self instvar agentlist
var_import ::GLOBALS::pid var_import ::GLOBALS::pid
var_import ::GLOBALS::eid var_import ::GLOBALS::eid
var_import ::GLOBALS::default_ip_routing_type var_import ::GLOBALS::default_ip_routing_type
...@@ -100,6 +108,10 @@ Node instproc updatedb {DB} { ...@@ -100,6 +108,10 @@ Node instproc updatedb {DB} {
incr i incr i
} }
foreach agent $agentlist {
$agent updatedb $DB
}
# Update the DB # Update the DB
sql exec $DB "insert into virt_nodes (pid,eid,vname,type,ips,osname,cmd_line,rpms,deltas,startupcmd,tarfiles,failureaction,routertype,fixed) values (\"$pid\",\"$eid\",\"$self\",\"$type\",\"$ipraw\",\"$osid\",\"$cmdline\",\"$rpms\",\"$deltas\",\"$startup\",\"$tarfiles\",\"$failureaction\",\"$default_ip_routing_type\",\"$fixed\")"; sql exec $DB "insert into virt_nodes (pid,eid,vname,type,ips,osname,cmd_line,rpms,deltas,startupcmd,tarfiles,failureaction,routertype,fixed) values (\"$pid\",\"$eid\",\"$self\",\"$type\",\"$ipraw\",\"$osid\",\"$cmdline\",\"$rpms\",\"$deltas\",\"$startup\",\"$tarfiles\",\"$failureaction\",\"$default_ip_routing_type\",\"$fixed\")";
} }
...@@ -138,3 +150,21 @@ Node instproc ip {port args} { ...@@ -138,3 +150,21 @@ Node instproc ip {port args} {
Node instproc find_port {lanlink} { Node instproc find_port {lanlink} {
return [lsearch [$self set portlist] $lanlink] return [lsearch [$self set portlist] $lanlink]
} }
# Attach an agent to a node. This mainly a bookkeeping device so
# that the we can update the DB at the end.
Node instproc attach-agent {agent} {
$self instvar agentlist
lappend agentlist $agent
$agent set_node $self
}
#
# Return and bump next agent portnumber,
Node instproc next_portnumber {} {
$self instvar next_portnumber_
set next_port [incr next_portnumber_]
return $next_port
}
...@@ -216,21 +216,8 @@ Simulator instproc run {} { ...@@ -216,21 +216,8 @@ Simulator instproc run {} {
$vtype updatedb $DB $vtype updatedb $DB
} }
catch "sql exec $DB \"drop table ${pid}_${eid}_events\""
sql exec $DB "CREATE TABLE ${pid}_${eid}_events ( \
idx int unsigned NOT NULL auto_increment, \
time float(10,3) NOT NULL default 0.000, \
vnode varchar(32) NOT NULL default '', \
vname varchar(20) NOT NULL default '', \
objecttype smallint unsigned NOT NULL default 0, \
eventtype smallint unsigned NOT NULL default 0, \
arguments tinytext default NULL, \
atstring tinytext default NULL, \
PRIMARY KEY (idx), \
KEY (vnode) \
) TYPE=MyISAM;"
foreach event $event_list { foreach event $event_list {
sql exec $DB "insert into ${pid}_${eid}_events (time,vnode,vname,objecttype,eventtype,arguments,atstring) values ([lindex $event 0],\"[lindex $event 1]\",\"[lindex $event 2]\",$objtypes([lindex $event 3]),$eventtypes([lindex $event 4]),\"[lindex $event 5]\",\"[lindex $event 6]\")" sql exec $DB "insert into eventlist (pid,eid,time,vnode,vname,objecttype,eventtype,arguments,atstring) values (\"$pid\",\"$eid\",[lindex $event 0],\"[lindex $event 1]\",\"[lindex $event 2]\",$objtypes([lindex $event 3]),$eventtypes([lindex $event 4]),\"[lindex $event 5]\",\"[lindex $event 6]\")"
} }
} }
...@@ -245,7 +232,7 @@ Simulator instproc attach-agent {node agent} { ...@@ -245,7 +232,7 @@ Simulator instproc attach-agent {node agent} {
perror "\[attach-agent] $node is not a Node." perror "\[attach-agent] $node is not a Node."
return return
} }
$agent set_node $node $node attach-agent $agent
} }
# connect <src> <dst> # connect <src> <dst>
...@@ -290,8 +277,14 @@ Simulator instproc at {time event} { ...@@ -290,8 +277,14 @@ Simulator instproc at {time event} {
"Application/Traffic/CBR" { "Application/Traffic/CBR" {
set otype TRAFGEN set otype TRAFGEN
switch -- $cmd { switch -- $cmd {
"start" {set etype START} "start" {
"stop" {set etype STOP} set params [$obj get_params]
set etype START
set args $params
}
"stop" {
set etype STOP
}
"set" { "set" {
if {[llength $event] < 4} { if {[llength $event] < 4} {
punsup "Wrong number of arguments: at $time $event" punsup "Wrong number of arguments: at $time $event"
...@@ -304,7 +297,8 @@ Simulator instproc at {time event} { ...@@ -304,7 +297,8 @@ Simulator instproc at {time event} {
set args "PACKETSIZE=$arg" set args "PACKETSIZE=$arg"
} }
"rate_" { "rate_" {
set args "RATE=$arg" set bw [parse_bw $arg]
set args "RATE=$bw"
} }
"interval_" { "interval_" {
set args "INTERVAL=$arg" set args "INTERVAL=$arg"
...@@ -334,7 +328,8 @@ Simulator instproc at {time event} { ...@@ -334,7 +328,8 @@ Simulator instproc at {time event} {
return return
} }
set arg [lindex $event 2] set arg [lindex $event 2]
set args "BANDWIDTH=$arg" set bw [parse_bw $arg]
set args "BANDWIDTH=$bw"
set etype MODIFY set etype MODIFY
} }
"delay" { "delay" {
......
...@@ -25,11 +25,15 @@ Agent instproc init {} { ...@@ -25,11 +25,15 @@ Agent instproc init {} {
$self set node {} $self set node {}
$self set application {} $self set application {}
$self set destination {} $self set destination {}
$self set proto {}
$self set role {}
$self set port {}
global ::GLOBALS::last_class global ::GLOBALS::last_class
set ::GLOBALS::last_class $self set ::GLOBALS::last_class $self
} }
Agent instproc set_node {node} { Agent instproc set_node {node} {
$self set node $node $self set node $node
$self set port [$node next_portnumber]
} }
Agent instproc get_node {} { Agent instproc get_node {} {
$self instvar node $self instvar node
...@@ -37,6 +41,8 @@ Agent instproc get_node {} { ...@@ -37,6 +41,8 @@ Agent instproc get_node {} {
} }
Agent instproc set_application {application} { Agent instproc set_application {application} {
$self set application $application $self set application $application
$self set role [$application set role]
} }
Agent instproc connect {dst} { Agent instproc connect {dst} {
$self instvar destination $self instvar destination
...@@ -54,12 +60,47 @@ Agent instproc rename {old new} { ...@@ -54,12 +60,47 @@ Agent instproc rename {old new} {
} }
} }
# updatedb DB
# This adds rows to the virt_trafgens table corresponding to this agent.
Agent instproc updatedb {DB} {
var_import ::GLOBALS::pid
var_import ::GLOBALS::eid
$self instvar application
$self instvar destination
$self instvar node
$self instvar proto
$self instvar role
$self instvar port
if {$role == {}} {
perror "\[updatedb] $self has no role."
return
}
if {$destination == {}} {
perror "\[updatedb] $self has no destination."
return
}
set target_vnode [$destination set node]
set target_port [$destination set port]
if {$role == "sink"} {
set application [$destination set application]
set proto [$destination set proto]
}
# set src_link [lindex [$node set portlist] 0]
# set dst_link [lindex [$target_vnode set portlist] 0]
# Update the DB
sql exec $DB "insert into virt_trafgens (pid,eid,vnode,vname,role,proto,port,target_vnode,target_port) values ('$pid','$eid','$node','$application','$role','$proto', $port,'$target_vnode',$target_port)";
}
# Agent/UDP # Agent/UDP
Agent/UDP instproc connect {dst} { Agent/UDP instproc connect {dst} {
$self next $dst $self next $dst
$self instvar node $self instvar node
$self instvar application $self instvar application
$self instvar destination $self instvar destination
set error 0 set error 0
if {$node == {}} { if {$node == {}} {
perror "\[connect] $self is not attached to a node." perror "\[connect] $self is not attached to a node."
...@@ -78,33 +119,10 @@ Agent/UDP instproc connect {dst} { ...@@ -78,33 +119,10 @@ Agent/UDP instproc connect {dst} {
perror "\[connect] $node must have exactly one link to be a traffic generator." perror "\[connect] $node must have exactly one link to be a traffic generator."
set error 1 set error 1
} }
set gateport [lindex [$node set portlist] 0]
set gate {}
foreach nodeport [$gateport set nodelist] {
set n [lindex $nodeport 0]
if {$n != $node} {
set gate $n
break
}
}
if {$gate == {}} {
perror "\[connect] No gateway found for $node."
set error 1
}
if {$error} {return} if {$error} {return}
$node set osid "SEND" $self set proto "udp"
$node set osid "FBSD-STD"
set interval [$application set interval_]
set packetsize [$application set packetSize_]
if {$interval != {}} {
set pktrate [expr int(1.0/$interval)]
} else {
set rate [parse_bw [$application set rate_]]
set pktrate [expr int(($rate*1024*1024) / (8*$packetsize))]
}
$node set cmdline "DST_NAME=$dest GATE_NAME=$gate PKT_SIZE=$packetsize PKT_RATE=$pktrate"
} }
# Agent/Null # Agent/Null
...@@ -127,28 +145,16 @@ Agent/Null instproc connect {dst} { ...@@ -127,28 +145,16 @@ Agent/Null instproc connect {dst} {
perror "\[connect] $node must have exactly one link to be a traffic consumer." perror "\[connect] $node must have exactly one link to be a traffic consumer."
set error 1 set error 1
} }
set gateport [lindex [$node set portlist] 0]
set gate {}
foreach nodeport [$gateport set nodelist] {
set n [lindex $nodeport 0]
if {$n != $node} {
set gate $n
break
}
}
if {$gate == {}} {
perror "\[connect] No gateway found for $node."
set error 1
}
if {$error} {return} if {$error} {return}
$node set osid "CONSUME" $self set role "sink"
$node set cmdline "DST_NAME=$dest GATE_NAME=$gate" $node set osid "FBSD-STD"
} }
# Application # Application
Application instproc init {} { Application instproc init {} {
$self set agent {} $self set agent {}
$self set role {}
global ::GLOBALS::last_class global ::GLOBALS::last_class
set ::GLOBALS::last_class $self set ::GLOBALS::last_class $self
} }
...@@ -162,7 +168,7 @@ Application instproc get_node {} { ...@@ -162,7 +168,7 @@ Application instproc get_node {} {
} }
Application instproc rename {old new} { Application instproc rename {old new} {
$self instvar agent $self instvar agent
# In normal condition sthis will never occur. # In normal condition this will never occur.
if {$agent != {}} { if {$agent != {}} {
$agent set_application $self $agent set_application $self
} }
...@@ -174,4 +180,26 @@ Application/Traffic/CBR instproc init {} { ...@@ -174,4 +180,26 @@ Application/Traffic/CBR instproc init {} {
$self set rate_ "100Mbps" $self set rate_ "100Mbps"
$self set interval_ {} $self set interval_ {}
$self next $self next
$self set role "source"
}
Application/Traffic/CBR instproc get_params {} {
$self instvar packetSize_
$self instvar rate_
$self instvar interval_
if {$rate_ != {} && $rate_ != 0} {
set rate [parse_bw $rate_]
} else {
set rate -1
}
set param "PACKETSIZE=$packetSize_ RATE=$rate"
if {$interval_ != {} && $interval_ != 0} {
set param "$param INTERVAL=$interval_"
} else {
set param "$param INTERVAL=-1"
}
return $param
} }
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