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

Add Agent/TCP and Agent/TCPSINK so that we can use Mike's new trafgen

code in TCP mode. Simple changes. Works like this:

	set tcp0 [new Agent/TCP]
	$ns attach-agent $n2 $tcp0

	set cbr1 [new Application/Traffic/CBR]
	$cbr1 attach-agent $tcp0

	set null1 [new Agent/TCPSINK]
	$ns attach-agent $n3 $null1

Note, there are no state variables supported yet.
parent 0aa49acd
......@@ -9,7 +9,9 @@
Class Agent -superclass NSObject
Class Agent/UDP -superclass Agent
Class Agent/TCP -superclass Agent
Class Agent/Null -superclass Agent
Class Agent/TCPSINK -superclass Agent
Class Application -superclass NSObject
Class Application/Traffic/CBR -superclass Application
......@@ -17,6 +19,8 @@ Class Application/Traffic/CBR -superclass Application
namespace eval GLOBALS {
set new_classes(Agent/UDP) {}
set new_classes(Agent/Null) {}
set new_classes(Agent/TCP) {}
set new_classes(Agent/TCPSINK) {}
set new_classes(Application/Traffic/CBR) {}
}
......@@ -125,6 +129,37 @@ Agent/UDP instproc connect {dst} {
$node set osid "FBSD-STD"
}
# 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
}
if {$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
}
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"
$node set osid "FBSD-STD"
}
# Agent/Null
Agent/Null instproc connect {dst} {
$self next $dst
......@@ -151,6 +186,33 @@ Agent/Null instproc connect {dst} {
$node set osid "FBSD-STD"
}
# 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
}
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"
$node set osid "FBSD-STD"
}
# Application
Application instproc init {} {
$self set agent {}
......
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