Commit f4c667ea authored by Shashi Guruprasad's avatar Shashi Guruprasad

Fixed the traffic generator TCL statement ordering problem.

Now, an agent connect statement can come before application attach-agent
which complies with NS. In addition, the order of
"$ns attach-agent <node> <agent>" and "$ns connect <agent1> <agent2>"
can by anything now. Reversing the order in NS causes problems for this though.
However, in emulab's case, we don't need that order. Most of these checks
are now moved to updatedb reducing some clutter in traffic.tcl

One thing that NS supports and it would be difficult for us is the order
of application attach-agent and "$ns at" statements. In NS, its ok to
flip the order. In emulab, its still not. Thats coz "$ns at" statements
need to know what vnode is the event going to. Of course, this can be
fixed by making "$ns at" storing the eventstring as is and only parsing
during the updatedb/$ns run phase. Seems like its not worth changing now.
parent f90ef5e8
......@@ -82,8 +82,7 @@ Agent instproc set_application {application} {
Agent instproc connect {dst} {
$self instvar destination
if {$destination != {}} {
perror "\[connect] $self already has a destination: $destination."
return
puts stderr "*** WARNING: \[connect] $self is already connected to $destination"
}
set destination $dst
}
......@@ -110,6 +109,10 @@ Agent instproc updatedb {DB} {
$self instvar port
$self instvar link
if {$node == {}} {
perror "\[updatedb] $self is not attached to a node."
return
}
if {$role == {}} {
perror "\[updatedb] $self has no role."
return
......@@ -118,6 +121,10 @@ Agent instproc updatedb {DB} {
perror "\[updatedb] $self has no destination."
return
}
if { ($role == "source") && ($application == {}) } {
perror "\[updatedb] $self does not have an attached application."
return
}
set target_vnode [$destination set node]
set target_port [$destination set port]
......@@ -148,77 +155,15 @@ Agent instproc get_nseconfig {} {
# Agent/UDP
Agent/UDP instproc connect {dst} {
$self next $dst
$self instvar node
$self instvar application
$self instvar destination
set error 0
if {$node == {}} {
perror "\[connect] $self is not attached to a node."
set error 1
}
set dest [$destination set node]
if {$dest == {}} {
perror "\[connect] $destination is not attached to a node."
set error 1
}
# for the case when the node is simulated
# we just ignore
if { [$node set simulated] == 1 } {
return
}
if {$application == {}} {
perror "\[connect] $self does not have an attached application."
set error 1
}
# if {[llength [$node set portlist]] != 1} {
# perror "\[connect] $node must have exactly one link to be a traffic generator."
# set error 1
# }
if {$error} {return}
$self set proto "udp"
$self set role "source"
}
# Agent/TCP
Agent/TCP instproc connect {dst} {
$self next $dst
$self instvar node
$self instvar application
$self instvar destination
set error 0
if {$node == {}} {
perror "\[connect] $self is not attached to a node."
set error 1
}
set dest [$destination set node]
if {$dest == {}} {
perror "\[connect] $destination is not attached to a node."
set error 1
}
# for the case when the node is simulated
# we just ignore
if { [$node set simulated] == 1 } {
return
}
if {$application == {}} {
perror "\[connect] $self does not have an attached application."
set error 1
}
# if {[llength [$node set portlist]] != 1} {
# perror "\[connect] $node must have exactly one link to be a traffic generator."
# set error 1
# }
if {$error} {return}
$self set proto "tcp"
$self set role "source"
}
# Agent/TCP/FullTcp
......@@ -276,6 +221,10 @@ Agent/TCP/FullTcp instproc updatedb {DB} {
$self instvar port
$self instvar link
if {$node == {}} {
perror "\[updatedb] $self is not attached to a node."
return
}
if {$role == {}} {
perror "\[updatedb] $self has no role."
return
......@@ -284,6 +233,10 @@ Agent/TCP/FullTcp instproc updatedb {DB} {
perror "\[updatedb] $self has no destination."
return
}
if { ($role == "source") && ($application == {}) } {
perror "\[updatedb] $self does not have an attached application."
return
}
set target_vnode [$destination set node]
set target_port [$destination set port]
......@@ -361,37 +314,6 @@ Agent/TCP/FullTcp instproc connect {dst} {
$self instvar destination
$self instvar role
set error 0
if {$node == {}} {
perror "\[connect] $self is not attached to a node."
set error 1
}
# for the case when the node is simulated
# we just ignore
if { [$node set simulated] == 1 } {
return
}
if { ($role == "source") && ($application == {}) } {
perror "\[connect] $self does not have an attached application."
set error 1
}
set dest [$destination set node]
if {$dest == {}} {
perror "\[connect] $destination is not attached to a node."
set error 1
}
# This was an artifact of SEND-CONSUME CBR model. Now that we run freebsd on the
# traffic generator nodes, all we need to do is either enable OSPF routing by
# default or setup static routes
# if {[llength [$node set portlist]] != 1} {
# perror "\[connect] $node must have exactly one link to be a traffic generator."
# set error 1
# }
if {$error} {return}
$self set proto "tcp"
$dst set proto "tcp"
$node set osid "FBSD-STD"
......@@ -403,64 +325,12 @@ Agent/TCP/FullTcp instproc connect {dst} {
# Agent/Null
Agent/Null instproc connect {dst} {
$self next $dst
$self instvar node
$self instvar application
$self instvar destination
set error 0
if {$node == {}} {
perror "\[connect] $self is not attached to a node."
set error 1
}
set dest [$destination set node]
if {$dest == {}} {
perror "\[connect] $destination is not attached to a node."
set error 1
}
# for the case when the node is simulated
# we just ignore
if { [$node set simulated] == 1 } {
return
}
# if {[llength [$node set portlist]] != 1} {
# perror "\[connect] $node must have exactly one link to be a traffic consumer."
# set error 1
# }
if {$error} {return}
$self set role "sink"
}
# Agent/Null
Agent/TCPSink instproc connect {dst} {
$self next $dst
$self instvar node
$self instvar application
$self instvar destination
set error 0
if {$node == {}} {
perror "\[connect] $self is not attached to a node."
set error 1
}
set dest [$destination set node]
if {$dest == {}} {
perror "\[connect] $destination is not attached to a node."
set error 1
}
# for the case when the node is simulated
# we just ignore
if { [$node set simulated] == 1 } {
return
}
# if {[llength [$node set portlist]] != 1} {
# perror "\[connect] $node must have exactly one link to be a traffic consumer."
# set error 1
# }
if {$error} {return}
$self set role "sink"
$self set proto "tcp"
}
......@@ -478,6 +348,10 @@ Application instproc attach-agent {agent} {
}
Application instproc get_node {} {
$self instvar agent
if {$agent == {} } {
perror "\[Application get_node] $self is not attached to an agent."
return ""
}
return [$agent get_node]
}
Application instproc rename {old new} {
......
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