/** * \brief The entry point of the sample */ int main(int argc, char *argv[]) { // Start console application and check arguments ConsoleApplication app(argc, argv); // Enable logging Log::enable(Log::LOG_LEVEL_INFO); // Setup emulator BasicEmulator emulator("10.0.0.1", 3201); emulator.setParam("Algorithm", "htb"); emulator.setParam("FairQueue", "on"); emulator.setParam("TxRate", "256kbps"); emulator.setParam("RxRate", "2000kbps"); emulator.commit(); // Setup router SshTerminal terminal("-p voyage ssh [email protected]"); // use sshpass terminal.start(); // Exec tests for (int test_index = 0; test_index < 2; test_index++) { // Setup Router if (test_index == 0) // In test one, fifo queues are applied as the default qdisc { terminal.enter("tc qdisc show\n"); } else // In test two, use htb { terminal.enter("tc qdisc add dev eth1 root handle 1: htb default 40\n"); terminal.enter("tc class add dev eth1 parent 1: classid 1:1 htb rate 1600kbit ceil 1600kbit quantum 1540\n"); terminal.enter("tc class add dev eth1 parent 1:1 classid 1:10 htb rate 400kbit ceil 1600kbit quantum 1540\n"); terminal.enter("tc class add dev eth1 parent 1:1 classid 1:20 htb rate 400kbit ceil 1600kbit quantum 1540\n"); terminal.enter("tc class add dev eth1 parent 1:1 classid 1:30 htb rate 400kbit ceil 1600kbit quantum 1540\n"); terminal.enter("tc class add dev eth1 parent 1:1 classid 1:40 htb rate 400kbit ceil 1600kbit quantum 1540\n"); terminal.enter("tc filter add dev eth1 parent 1: protocol ip prio 1 u32 match ip dst 172.16.0.16 flowid 1:10\n"); terminal.enter("tc filter add dev eth1 parent 1: protocol ip prio 1 u32 match ip dst 172.16.0.17 flowid 1:20\n"); terminal.enter("tc filter add dev eth1 parent 1: protocol ip prio 1 u32 match ip dst 172.16.0.18 flowid 1:30\n"); terminal.enter("tc filter add dev eth1 parent 1: protocol ip prio 1 u32 match ip dst 172.16.0.19 flowid 1:40\n"); } // Execute Test int threads[15] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; execTest(app, 3, 15, threads, true, true); // Reset router if (test_index == 1) { terminal.enter("tc qdisc del dev eth1 root\n"); } } emulator.reset(); terminal.close(); // Exit return 0; }
/** * \brief The entry point of the sample */ int main(int argc, char *argv[]) { // Start console application and check arguments ConsoleApplication app(argc, argv); // Enable logging Log::enable(Log::LOG_LEVEL_INFO); // Setup emulator BasicEmulator emulator("10.0.0.1", 3201); emulator.setParam("Algorithm", "htb"); emulator.setParam("FairQueue", "off"); emulator.setParam("TxRate", "256kbps"); emulator.setParam("RxRate", "2000kbps"); emulator.commit(); // Setup router SshTerminal terminal("-p voyage ssh [email protected]"); // use sshpass terminal.start(); // Exec tests for (int bulkUsers = 1; bulkUsers <= 9; bulkUsers++) { // Setup Router terminal.enter(QString( "tc qdisc add dev eth0 root handle 1: htb default %1\n") .arg((bulkUsers + 1) * 10)); terminal.enter( "tc class add dev eth0 parent 1: classid 1:1 htb rate 240kbit quantum 1540\n"); for (int i = 1; i <= bulkUsers + 1; i++) { terminal.enter(QString( "tc class add dev eth0 parent 1:1 classid 1:%1 htb rate %2kbit ceil 240kbit quantum 1540\n") .arg(i * 10).arg(240 / (bulkUsers + 1))); terminal.enter(QString( "tc filter add dev eth0 parent 1: protocol ip prio 1 handle %1 fw flowid 1:%1\n") .arg(i * 10)); terminal.enter(QString( "iptables -t mangle -A FORWARD -s 172.16.0.%1 -j MARK --set-mark %2\n") .arg(16 + i - 1).arg(i * 10)); } // Execute Test printf("\nTest %d: %d users\n", bulkUsers, bulkUsers); execTest(app, bulkUsers, 64, true, true); // Reset router terminal.enter("tc qdisc del dev eth0 root\n"); terminal.enter("iptables -t mangle -F FORWARD\n"); } emulator.reset(); terminal.close(); // Exit return 0; }
void executeInst(Inst inst) { #if 0 Register exp; regLookup("exp", &exp); insDump(inst); regPrint(exp); printf("\n"); #ifdef STACK_GUARDED #if 0 printStack(); #endif #endif #endif switch (insGetType(inst)) { case INST_ASSIGN: execAssign(inst); break; case INST_PERFORM: execPerform(inst); break; case INST_TEST: execTest(inst); break; case INST_LABEL: case INST_COMMENT: rsAdvancePc(); break; case INST_BRANCH: if (isFlagSet()) execJump(insGetBranch(inst)); else rsAdvancePc(); break; case INST_GOTO: execJump(insGetGoto(inst)); break; case INST_SAVE: execSave(inst); break; case INST_RESTORE: execRestore(inst); break; default: printf("Unknown instruction type\n"); break; } }