521 | | The program builds the topology by creating a [TopdlLibrary#ComputerClass computer object] that is the center of the star, then creates other computers that are connected to the center. The connection is accomplished by creating a [TopdlLibrary#SubstrateClass Substrate object] that represents the connection and adding [TopdlLibrary#InterfaceClass Interface objects] to the center computer and the satellite that bind them to the substrate. |
522 | | |
523 | | |
| 521 | The [attachment:ten.py program] builds the topology by creating a [TopdlLibrary#ComputerClass Computer object] that is the center of the star, then creates other computers that are connected to the center. The connection is accomplished by creating a [TopdlLibrary#SubstrateClass Substrate object] that represents the connection and adding [TopdlLibrary#InterfaceClass Interface objects] to the center computer and the satellite that bind them to the substrate. |
| 522 | |
| 523 | For comparison, [attachment:ten.tcl here] is the equivalent ns2 description: |
| 524 | |
| 525 | {{{ |
| 526 | source tb_compat.tcl |
| 527 | set ns [new Simulator] |
| 528 | |
| 529 | # Create the center node (named by its variable name) |
| 530 | set center [$ns node] |
| 531 | |
| 532 | # Connect 10 satellites |
| 533 | for { set i 0} { $i < 10 } { incr i} { |
| 534 | # Create node n-1 (tcl n($i) becomes n-$i in the experiment) |
| 535 | set n($i) [$ns node] |
| 536 | # Connect center to $n($i) |
| 537 | ns duplex-link $center $n($i) 100Mb 0ms DropTail |
| 538 | } |
| 539 | |
| 540 | # Creation boilerplate |
| 541 | $ns rtptoto Static |
| 542 | $ns run |
| 543 | }}} |
| 544 | |
| 545 | == A More Complex Topology == |
| 546 | |
| 547 | The next few examples will build on one another to show a more complex change to a topology. We will take a topology, find the degrees of nodes, assign operating systems to them based on that degree, and output DETER-ready ns2. |
| 548 | |
| 549 | To try this we need a more complex topology. The program below creates a topology with {{{nrouters}}} completely connected routers, each of which has {{{nleaves}}} leaves, except for one central router that has none. |