Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
86fbcacd
Commit
86fbcacd
authored
May 27, 2002
by
Shashi Guruprasad
Browse files
Changes for NSE integration
parent
2d4de575
Changes
2
Hide whitespace changes
Inline
Side-by-side
event/nsetrafgen/nseinput.tcl
View file @
86fbcacd
...
...
@@ -28,7 +28,7 @@ proc getipaddr {name} {
# consults tmcc ifconfig and findif to find the interface name
# returns the interface name for ipaddr
proc get
mac
{
ipaddr
}
{
proc get
if
{
ipaddr
}
{
set tmccifconfig
[
open /etc/testbed/tmcc.ifconfig r
]
set ifconf
[
read $tmccifconfig
]
...
...
@@ -45,6 +45,29 @@ proc getmac {ipaddr} {
return
""
}
proc getmac
{
ipaddr
}
{
set tmccifconfig
[
open /etc/testbed/tmcc.ifconfig r
]
set ifconf
[
read $tmccifconfig
]
close $tmccifconfig
set ifconfiglist
[
split $ifconf
"
\n
"
]
foreach ifconfig $ifconfiglist
{
scan $ifconfig
"INTERFACE=%s INET=%s MASK=%s MAC=%s "
iface inet mask mac
if
{
$inet == $ipaddr
}
{
set macaddrchars
[
split $mac
""
]
set i 0
while
{
$i <
[
llength $macaddrchars
]
}
{
lappend mac2chars
"
[
lindex $macaddrchars $i
][
lindex $macaddrchars
[
expr $i + 1
]]
"
set i
[
expr $i + 2
]
}
return
[
join $mac2chars
":"
]
}
}
puts stderr
"NSE: Could not find the interface name for
$ipaddr
"
return
""
}
set tmccnseconfigs
[
open /etc/testbed/tmcc.nseconfigs r
]
set nseconfig
[
read $tmccnseconfigs
]
close $tmccnseconfigs
...
...
@@ -164,7 +187,7 @@ if { $nsetrafgen_present == 1 } {
set peeripaddr
[
getipaddr $peername
]
# find interface name with a helper subroutine
set interface
[
get
mac
$myipaddr
]
set interface
[
get
if
$myipaddr
]
# one TCPTap object per TCP class that we have instantiated
set tcptap
(
$i
)
[
new Agent/TCPTap
]
...
...
@@ -210,7 +233,7 @@ if { $simcode_present == 1 } {
}
set nodeinst_ipaddr
[
$nodeinst
set nsenode_ipaddr
]
if
{
$nodeinst_ipaddr !=
{}
}
{
set iface
[
get
mac
$nodeinst_ipaddr
]
set iface
[
get
if
$nodeinst_ipaddr
]
# one iptap per node that has real - simulated link
set iptap
(
$i
)
[
new Agent/IPTap
]
...
...
@@ -219,7 +242,12 @@ if { $simcode_present == 1 } {
# except for the current host itself
set bpf_ip
(
$i
)
[
new Network/Pcap/Live
]
set dev_ip
(
$i
)
[
$bpf
_ip
(
$i
)
open readonly $iface
]
$bpf
_ip
(
$i
)
filter
"ip and not dst host
$nodeinst
_ipaddr"
set nodeinst_mac
[
getmac $nodeinst_ipaddr
]
if
{
$nodeinst_mac !=
{}
}
{
$bpf
_ip
(
$i
)
filter
"ip and not dst host
$nodeinst
_ipaddr and not ether src
$nodeinst
_mac"
}
else
{
$bpf
_ip
(
$i
)
filter
"ip and not dst host
$nodeinst
_ipaddr"
}
# associate the 2 network objects in the IPTap object
$iptap
(
$i
)
network-outgoing $ipnet
...
...
event/nsetrafgen/nseinput.tcl.in
View file @
86fbcacd
...
...
@@ -28,7 +28,7 @@ proc getipaddr {name} {
# consults tmcc ifconfig and findif to find the interface name
# returns the interface name for ipaddr
proc get
mac
{ipaddr} {
proc get
if
{ipaddr} {
set tmccifconfig [open /etc/testbed/tmcc.ifconfig r]
set ifconf [read $tmccifconfig]
...
...
@@ -45,6 +45,29 @@ proc getmac {ipaddr} {
return ""
}
proc getmac {ipaddr} {
set tmccifconfig [open /etc/testbed/tmcc.ifconfig r]
set ifconf [read $tmccifconfig]
close $tmccifconfig
set ifconfiglist [split $ifconf "\n"]
foreach ifconfig $ifconfiglist {
scan $ifconfig "INTERFACE=%s INET=%s MASK=%s MAC=%s " iface inet mask mac
if { $inet == $ipaddr } {
set macaddrchars [split $mac ""]
set i 0
while { $i < [llength $macaddrchars] } {
lappend mac2chars "[lindex $macaddrchars $i][lindex $macaddrchars [expr $i + 1]]"
set i [expr $i + 2]
}
return [join $mac2chars ":"]
}
}
puts stderr "NSE: Could not find the interface name for $ipaddr"
return ""
}
set tmccnseconfigs [open /etc/testbed/tmcc.nseconfigs r]
set nseconfig [read $tmccnseconfigs]
close $tmccnseconfigs
...
...
@@ -164,7 +187,7 @@ if { $nsetrafgen_present == 1 } {
set peeripaddr [getipaddr $peername]
# find interface name with a helper subroutine
set interface [get
mac
$myipaddr]
set interface [get
if
$myipaddr]
# one TCPTap object per TCP class that we have instantiated
set tcptap($i) [new Agent/TCPTap]
...
...
@@ -210,7 +233,7 @@ if { $simcode_present == 1 } {
}
set nodeinst_ipaddr [$nodeinst set nsenode_ipaddr]
if { $nodeinst_ipaddr != {} } {
set iface [get
mac
$nodeinst_ipaddr]
set iface [get
if
$nodeinst_ipaddr]
# one iptap per node that has real - simulated link
set iptap($i) [new Agent/IPTap]
...
...
@@ -219,7 +242,12 @@ if { $simcode_present == 1 } {
# except for the current host itself
set bpf_ip($i) [new Network/Pcap/Live]
set dev_ip($i) [$bpf_ip($i) open readonly $iface]
$bpf_ip($i) filter "ip and not dst host $nodeinst_ipaddr"
set nodeinst_mac [getmac $nodeinst_ipaddr]
if { $nodeinst_mac != {} } {
$bpf_ip($i) filter "ip and not dst host $nodeinst_ipaddr and not ether src $nodeinst_mac"
} else {
$bpf_ip($i) filter "ip and not dst host $nodeinst_ipaddr"
}
# associate the 2 network objects in the IPTap object
$iptap($i) network-outgoing $ipnet
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment