Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Wiki / Layer1Experiment

Layer1Experiment

Experiments With Layer 1 Connections and Layer 2 Paths

Experiments With Layer 1 Connections and Layer 2 Paths

To create a layer 1 link in an experiment, see this NS file:

source tb_compat.tcl
set ns [new Simulator]

set n1 [$ns node]
set n2 [$ns node]

set seg1 [$ns duplex-link $n1 $n2 * 0ms DropTail]
tb-set-link-layer $seg1 1

$ns rtproto Static
$ns run

The link seg1 is a layer 1 link, which will be created on our Apcon physical layer switch.

If you want to use a switch node to connect two layer 1 links, try this NS file:

source tb_compat.tcl

set ns [new Simulator]

set n1 [$ns node]
set sw [$ns node]
set n2 [$ns node]

tb-set-node-os $sw PROCURVE-13-68-STD
tb-fix-node $sw hpswitch1
tb-set-node-failure-action $sw "nonfatal"

#
# Create two Layer 1 links, between the switch and edge nodes
#
set seg1 [$ns duplex-link $n1 $sw * 0ms DropTail]
set seg2 [$ns duplex-link $sw $n2 * 0ms DropTail]

# you have to set the fixed interfaces, the available ifaces are listed in the following table.
# for each link, if it uses the switch node, set a different iface for the switch node.
tb-fix-interface $sw $seg1 "eth16"
tb-fix-interface $sw $seg2 "eth17" 

tb-set-link-layer $seg1 1
tb-set-link-layer $seg2 1

$ns rtproto Static
$ns run

You can specify the iface of the switch port used in layer 1 link with tb-fix-interface. The available interfaces are show below:

+-----------+------+------+----------------+-------+------+
| node_id   | card | port | interface_type | iface | role |
+-----------+------+------+----------------+-------+------+
| hpswitch1 |    1 |   13 | apcon_1G       | eth13 | expt | 
| hpswitch1 |    1 |   14 | apcon_1G       | eth14 | expt | 
| hpswitch1 |    1 |   15 | apcon_1G       | eth15 | expt | 
| hpswitch1 |    1 |   16 | apcon_1G       | eth16 | expt | 
| hpswitch1 |    1 |   17 | apcon_1G       | eth17 | expt | 
| hpswitch1 |    1 |   18 | apcon_1G       | eth18 | expt | 
| hpswitch1 |    1 |   19 | apcon_1G       | eth19 | expt | 
| hpswitch1 |    1 |   20 | apcon_1G       | eth20 | expt | 
| hpswitch1 |    1 |   21 | apcon_1G       | A21   | expt | 
| hpswitch1 |    1 |   22 | apcon_1G       | A22   | expt | 
| hpswitch1 |    1 |   23 | apcon_1G       | A23   | expt | 
| hpswitch1 |    1 |   24 | apcon_1G       | A24   | expt | 
| hpswitch1 |    2 |    3 | apcon_1G       | B3    | expt | 
| hpswitch1 |    2 |    4 | apcon_1G       | B4    | expt | 
| hpswitch1 |    2 |    5 | apcon_1G       | B5    | expt | 
| hpswitch1 |    2 |    6 | apcon_1G       | B6    | expt | 
| hpswitch1 |    2 |    7 | apcon_1G       | B7    | expt | 
| hpswitch1 |    2 |    8 | apcon_1G       | B8    | expt | 
| hpswitch1 |    2 |    9 | apcon_1G       | B9    | expt | 
| hpswitch1 |    2 |   10 | apcon_1G       | B10   | expt | 
| hpswitch1 |    2 |   11 | apcon_1G       | B11   | expt | 
| hpswitch1 |    2 |   12 | apcon_1G       | B12   | expt | 
| hpswitch1 |    2 |   13 | apcon_1G       | B13   | expt | 
| hpswitch1 |    2 |   14 | apcon_1G       | B14   | expt | 
| hpswitch1 |    2 |   15 | apcon_1G       | B15   | expt | 
| hpswitch1 |    2 |   16 | apcon_1G       | B16   | expt | 
| hpswitch1 |    2 |   17 | apcon_1G       | B17   | expt | 
| hpswitch1 |    2 |   18 | apcon_1G       | B18   | expt | 
| hpswitch1 |    2 |   19 | apcon_1G       | B19   | expt | 
| hpswitch1 |    2 |   20 | apcon_1G       | B20   | expt | 
| hpswitch1 |    2 |   21 | apcon_1G       | B21   | expt | 
| hpswitch1 |    2 |   22 | apcon_1G       | B22   | expt | 
| hpswitch1 |    2 |   23 | procurve_gigE  | B23   | ctrl | 
| hpswitch2 |    2 |    3 | apcon_1G       | B3    | expt | 
| hpswitch2 |    2 |    4 | apcon_1G       | B4    | expt | 
| hpswitch2 |    2 |    5 | apcon_1G       | B5    | expt | 
| hpswitch2 |    2 |    6 | apcon_1G       | B6    | expt | 
| hpswitch2 |    2 |    7 | apcon_1G       | B7    | expt | 
| hpswitch2 |    2 |    8 | apcon_1G       | B8    | expt | 
| hpswitch2 |    2 |    9 | apcon_1G       | B9    | expt | 
| hpswitch2 |    2 |   10 | apcon_1G       | B10   | expt | 
| hpswitch2 |    2 |   11 | apcon_1G       | B11   | expt | 
| hpswitch2 |    2 |   12 | apcon_1G       | B12   | expt | 
| hpswitch2 |    2 |   13 | apcon_1G       | B13   | expt | 
| hpswitch2 |    2 |   14 | apcon_1G       | B14   | expt | 
| hpswitch2 |    2 |   15 | apcon_1G       | B15   | expt | 
| hpswitch2 |    2 |   16 | apcon_1G       | B16   | expt | 
| hpswitch2 |    2 |   17 | apcon_1G       | B17   | expt | 
| hpswitch2 |    2 |   18 | apcon_1G       | B18   | expt | 
| hpswitch2 |    2 |   19 | apcon_1G       | B19   | expt | 
| hpswitch2 |    2 |   20 | apcon_1G       | B20   | expt | 
| hpswitch2 |    2 |   21 | apcon_1G       | B21   | expt | 
| hpswitch2 |    2 |   22 | apcon_1G       | B22   | expt | 
| hpswitch2 |    2 |   24 | procurve_gigE  | B24   | ctrl | 
| hpswitch3 |    2 |    3 | apcon_1G       | B3    | expt | 
| hpswitch3 |    2 |    4 | apcon_1G       | B4    | expt | 
| hpswitch3 |    2 |    5 | apcon_1G       | B5    | expt | 
| hpswitch3 |    2 |    6 | apcon_1G       | B6    | expt | 
| hpswitch3 |    2 |    7 | apcon_1G       | B7    | expt | 
| hpswitch3 |    2 |    8 | apcon_1G       | B8    | expt | 
| hpswitch3 |    2 |    9 | apcon_1G       | B9    | expt | 
| hpswitch3 |    2 |   10 | apcon_1G       | B10   | expt | 
| hpswitch3 |    2 |   11 | apcon_1G       | B11   | expt | 
| hpswitch3 |    2 |   12 | apcon_1G       | B12   | expt | 
| hpswitch3 |    2 |   13 | apcon_1G       | B13   | expt | 
| hpswitch3 |    2 |   14 | apcon_1G       | B14   | expt | 
| hpswitch3 |    2 |   15 | apcon_1G       | B15   | expt | 
| hpswitch3 |    2 |   16 | apcon_1G       | B16   | expt | 
| hpswitch3 |    2 |   17 | apcon_1G       | B17   | expt | 
| hpswitch3 |    2 |   18 | apcon_1G       | B18   | expt | 
| hpswitch3 |    2 |   19 | apcon_1G       | B19   | expt | 
| hpswitch3 |    2 |   20 | apcon_1G       | B20   | expt | 
| hpswitch3 |    2 |   21 | apcon_1G       | B21   | expt | 
| hpswitch3 |    2 |   22 | apcon_1G       | B22   | expt | 
| hpswitch3 |    2 |   23 | procurve_gigE  | B23   | ctrl | 
+-----------+------+------+----------------+-------+------+

Finally, here is a more complete example that creates a Layer 2 "link" between two nodes that runs through a dedicated switch.  First, the example creates two Layer 1 links between each node and the switch; then creates a Layer 2 "path" that is implemented by the Layer 1 links.  Emulab creates the Layer 2 path by configuring the dedicated switch in your experiment with a basic configuration, including placing the two switch ports connected to the PCs into a single VLAN.  Each PC will receive an IP address, just like in a normal Emulab link.

source tb_compat.tcl

set ns [new Simulator]

set n1 [$ns node]
set sw [$ns node]
set n2 [$ns node]

tb-set-node-os $sw PROCURVE-13-68-STD
tb-fix-node $sw hpswitch1
tb-set-node-failure-action $sw "nonfatal"

#
# Create two Layer 1 links, between the switch and edge nodes
#
set seg1 [$ns duplex-link $n1 $sw * 0ms DropTail]
set seg2 [$ns duplex-link $sw $n2 * 0ms DropTail]

# you have to set the fixed interfaces, the available ifaces are listed in the table above.
# for each link, if it uses the switch node, set a different iface for the switch node.
tb-fix-interface $sw $seg1 "eth16"
tb-fix-interface $sw $seg2 "eth17" 

tb-set-link-layer $seg1 1
tb-set-link-layer $seg2 1

#
# Create a Layer 2 link
#
set mypath [$ns make-path "seg1 seg2"]
set link0 [$ns duplex-link $n1 $n2 * 0ms DropTail]
$link0 implemented_by $mypath

$ns rtproto Static
$ns run

Hope this can help.