| 342 | Summary: The Tcl Client automates control of warpnode parameters. The Tcl Client sends values to the server. Attached are two versions of the tcl client. The ''automated_client.tcl'', which loops through changing txpowers and modOrders with a set time interval, and the ''interactive_client.tcl'', which pauses before transmitting a request to start transmission on nodes, asks for a time interval or defaults to a user input for stopping the data transmission. To run a tcl program, open up a command line such as a terminal and type: |
| 343 | {{{ |
| 344 | tclsh filename.tcl |
| 345 | }}} |
| 346 | |
| 347 | |
| 348 | Initially, a few user specified global parameters needs to be set. This includes the filename for where statistics are written, the number of nodes, and information for connecting to the socket. In this set up, the dumb_server contains the IP address of 10.0.0.6 and connects through port 9090. |
| 349 | |
| 350 | {{{ |
| 351 | set filename "PacketData.m" |
| 352 | set NumNodes 2; |
| 353 | set dumbServerIP 10.0.0.6 |
| 354 | set dumbServerPort 9090 |
| 355 | }}} |
| 356 | |
| 357 | |
| 358 | To main code for developing an automated experiment that writes statistic data to a file begins by connecting the socket with the dumb server and configuring the socket to automate flushing of the memory |
| 359 | |
| 360 | {{{ |
| 361 | #Open a socket connection |
| 362 | set sock [socket $dumbServerIP $dumbServerPort] |
| 363 | |
| 364 | #Automate flushing of the socket |
| 365 | fconfigure $sock -buffering none -blocking 0 |
| 366 | }}} |
| 367 | |
| 368 | Next a default time interval is set and an blank file $filename is created (clears the file if it contains data) |
| 369 | |
| 370 | {{{ |
| 371 | set TimeInterval 100 |
| 372 | ;#Create Blank File |
| 373 | set fileID [open $filename "w"] |
| 374 | }}} |
| 375 | |
| 376 | A create a test for sweeping through txpowers would use a for loop that modifies the txpower value in the control structure. |
| 377 | |
| 378 | The following lists supported structures definitions and examples of how to use them: |
| 379 | |
| 380 | {{{ |
| 381 | ;# Control Struct: structType, nodeID, modOrder, txPower, coding, channel |
| 382 | set ControlStruct0 [list 50 0 4 63 3 9 ] |
| 383 | set ControlStruct1 [list 50 1 4 63 3 9 ] |
| 384 | |
| 385 | ;# Traffic Struct: structType, nodeID, trafficMode 0 = RECEIVE 1 = TRANSMIT , reserved0, txInterval, txPacketLen, reserved1 |
| 386 | set TrafficStruct0 [list 52 0 1 0 0 1470 0 ] |
| 387 | set TrafficStruct1 [list 52 1 1 0 0 1470 0 ] |
| 388 | |
| 389 | ;# structType, nodeID is only relevant for ack on stop, cmdID, cmdParam |
| 390 | set CommandStructStart [list 51 0 102 0 ] |
| 391 | set CommandStructStop [list 51 0 103 0 ] |
| 392 | |
| 393 | ;# structType, nodeID, cmdID, cmdParam |
| 394 | set CommandStructStats0 [list 51 0 104 0 ] |
| 395 | set CommandStructStats1 [list 51 1 104 0 ] |
| 396 | set CommandStructResetStats0 [list 51 0 97 0 ] |
| 397 | set CommandStructResetStats1 [list 51 1 97 0 ] |
| 398 | }}} |
| 399 | |
| 400 | The function ''senddata'' sends a struct to the dumb server. The first parameter is the struct to send. The second parameter specifies modes, such as requesting an ackPacket with ''$SendAck'' or statPacket from the server with ''$WriteStat.'' The default parameter requests nothing from the server. |
| 401 | |
| 402 | The following highlights a test for sweeping through txPowers from 0 to 63 while changing from QPSK to 16QAM: |
| 403 | |
| 404 | {{{ |
| 405 | for {set power 0} {$power < 64} {incr power} { |
| 406 | for {set mod 1} {$mod<3} {incr mod} { ;#set mod |
| 407 | |
| 408 | #Send a Control Struct to node 0 |
| 409 | senddata $sock [list 50 0 [expra {$mod*2}] $power 3 9 ] $SendAck |
| 410 | #Send a Control Struct to node 1 |
| 411 | senddata $sock [list 50 1 [expr {$mod*2}] $power 3 9 ] $SendAck |
| 412 | |
| 413 | #Send a Traffic Struct to node 0 |
| 414 | senddata $sock [list 52 0 1 0 0 1470 0 ] $SendAck |
| 415 | #Send a Traffic Struct to node 1 |
| 416 | senddata $sock [list 52 1 1 0 0 1470 0 ] $SendAck |
| 417 | |
| 418 | #Reset Statistics on nodes, sets everything to 0 |
| 419 | senddata $sock $CommandStructResetStats0 $SendAck |
| 420 | senddata $sock $CommandStructResetStats1 $SendAck |
| 421 | |
| 422 | #Begin data transmission over the air |
| 423 | senddata $sock $CommandStructStart |
| 424 | after $TimeInterval |
| 425 | #Stop data tranmission over the air |
| 426 | senddata $sock $CommandStructStop $SendAck |
| 427 | |
| 428 | senddata $sock $CommandStructStats0 $WriteStat |
| 429 | senddata $sock $CommandStructStats1 $WriteStat |
| 430 | |
| 431 | } |
| 432 | } |
| 433 | }}} |
| 434 | |
| 435 | |
| 436 | The last step is to close the socket and exit the tcl script: |
| 437 | |
| 438 | {{{ |
| 439 | close $sock |
| 440 | exit |
| 441 | }}} |
| 442 | |
| 443 | |
| 444 | |
| 445 | |