?? netmodel.cc
字號:
if (strcmp(argv[1],"savelayout")==0) { save_layout(argv[2]); return (TCL_OK); } if (strcmp(argv[1],"select-traffic")==0) { strcpy(selectedTraffic_,argv[2]); return (TCL_OK); } if (strcmp(argv[1],"select-src")==0) { selectedSrc_ = atoi(argv[2]); return (TCL_OK); } if (strcmp(argv[1],"select-dst")==0) { selectedDst_ = atoi(argv[2]); return (TCL_OK); } if (strcmp(argv[1],"select-fid")==0) { selectedFid_ = atoi(argv[2]); return (TCL_OK); } if (strcmp(argv[1],"hide-traffic")==0) { strcpy(hideTraffic_,argv[2]); return (TCL_OK); } if (strcmp(argv[1],"hide-src")==0) { hideSrc_ = atoi(argv[2]); return (TCL_OK); } if (strcmp(argv[1],"hide-dst")==0) { hideDst_ = atoi(argv[2]); return (TCL_OK); } if (strcmp(argv[1],"hide-fid")==0) { hideFid_ = atoi(argv[2]); return (TCL_OK); } if (strcmp(argv[1],"color-traffic")==0) { resetf_ = 0 ; strcpy(colorTraffic_,argv[2]); return (TCL_OK); } if (strcmp(argv[1],"color-src")==0) { resetf_ = 0 ; colorSrc_ = atoi(argv[2]); return (TCL_OK); } if (strcmp(argv[1],"color-dst")==0) { resetf_ = 0 ; colorDst_ = atoi(argv[2]); return (TCL_OK); } if (strcmp(argv[1],"color-fid")==0) { resetf_ = 0 ; colorFid_ = atoi(argv[2]); return (TCL_OK); } if (strcmp(argv[1],"select-color")==0) { Paint *paint = Paint::instance(); selectedColor_ = paint->lookup(argv[2], 1); if (selectedColor_ < 0) { fprintf(stderr,"%s color: no such color: %s\n", argv[0], argv[2]); selectedColor_ = paint->lookup("black",1); if (selectedColor_ < 0) { tcl.resultf("%s no black! - bailing"); return (TCL_ERROR); } } return (TCL_OK); } if (strcmp(argv[1], "node") == 0) {// else if (argc == 3 && strcmp(argv[1], "node") == 0) /* * <net> node <name> <shape> <color> <addr> [<size>] * Create a node using the specified name * and the default size and insert it into this * NetModel's list of drawables. */ //Node* n = addNode(argc, argv); char * line = new char[strlen(argv[2])]; strncpy(line, argv[2],strlen(argv[2])); parsetable_.parseLine(line); Node * node = addNode(traceevent_); delete line; if (node) { return (TCL_OK); } else { tcl.resultf("Unable to create Node %s.", argv[2]); return (TCL_ERROR); } } } else if (argc >= 4 && strcmp(argv[1], "agent") == 0) { // Create a new agent /* * <net> agent <label> <role> <node> <flowcolor> <winInit> * <win> <maxcwnd> * <tracevar> <start> <producemore> <stop> * <net> agent <label> <role> <node> <flowcolor> <packetSize> * <interval> <start> <stop> */ int node = atoi(argv[4]); int partner_num; Node *n = lookupNode(node); if (n == 0) { tcl.resultf("Node %d doesn't exist.", node); return (TCL_ERROR); } Agent *a = new BoxAgent((char *)argv[2], n->size()); if (a == 0) { tcl.resultf("Cannot create Agent %s exist on Node %d", argv[2], node); return (TCL_ERROR); } placeAgent(a, n); a->node_ = n; n->add_agent(a); a->AgentRole_ = (atoi(argv[3])); if (a->AgentRole_ == 20) { a->setNumber(atoi(argv[5])); partner_num = (atoi(argv[6])); Agent *partner = lookupAgent(partner_num); if (partner) { a->AgentPartner_ = partner; partner->AgentPartner_ = a; } } else if ((a->AgentRole_ == 10) && (strcmp(argv[2], "CBR") == 0)) { if (strcmp(argv[5],"(null)")!=0) a->flowcolor((char *)argv[5]); a->packetSize(atoi(argv[6])); a->interval(atoi(argv[7])); a->startAt(atof(argv[8])); a->stopAt(atof(argv[9])); a->setNumber(atoi(argv[10])); partner_num = (atoi(argv[11])); Agent *partner = lookupAgent(partner_num); if (partner) { a->AgentPartner_ = partner; partner->AgentPartner_ = a; } } else if (a->AgentRole_ != 0) { if (strcmp(argv[5],"(null)")!=0) a->flowcolor((char *)argv[5]); a->windowInit(atoi(argv[6])); a->window(atoi(argv[7])); a->maxcwnd(atoi(argv[8])); a->tracevar((char *)argv[9]); a->startAt(atof(argv[10])); a->produce(atoi(argv[11])); a->stopAt(atof(argv[12])); a->setNumber(atoi(argv[13])); partner_num = (atoi(argv[14])); Agent *partner = lookupAgent(partner_num); if (partner) { a->AgentPartner_ = partner; partner->AgentPartner_ = a; } } a->Animation::insert(&animations_); return (TCL_OK); } else if (argc == 4) { if (strcmp(argv[1], "new_monitor_agent") == 0) { /* * <net> new_monitor_agent <node_id> <agent_name> */ int node = atoi(argv[2]); Node *n = lookupNode(node); if (n == 0) { tcl.resultf("Node %d doesn't exist.", node); return (TCL_ERROR); } Agent *a = n->find_agent((char *)argv[3]); if (a == 0) { tcl.resultf("Agent %s not exist at node %d", argv[3], node); return (TCL_ERROR); } tcl.resultf("%d", add_monitor(a)); return (TCL_OK); } if (strcmp(argv[1], "color") == 0) { /* * <net> color <packetClass> <colorName> * Display packets of the specified class using * the specified color. */ int c = atoi(argv[2]);// if ((unsigned int)c > 1024) {// tcl.resultf("%s color: class %d out of range",// argv[0], c);// return (TCL_ERROR);// } // Convert this color index to [0,255], so that // it matches correctly with packet flow ids. Paint *paint = Paint::instance(); if (c > nclass_) { int n, i; for (n = nclass_; n < c; n <<= 1); int *p = new int[n]; for (i = 0; i < nclass_; ++i) p[i] = paint_[i]; delete paint_; paint_ = p; nclass_ = n; paintMask_ = nclass_ - 1; int pno = paint->thin(); for (; i < n; ++i) paint_[i] = pno; } int pno = paint->lookup(argv[3], 1); if (pno < 0) { fprintf(stderr,"%s color: no such color: %s\n", argv[0], argv[3]); pno = paint->lookup("black",1); if (pno < 0) { tcl.resultf("%s no black! - bailing"); return (TCL_ERROR); } } paint_[c] = pno; oldpaint_[c] = pno; return (TCL_OK); } if (strcmp(argv[1], "ncolor") == 0) { /* * <net> ncolor <node> <colorName> * set color of node to the specified color. */ Paint *paint = Paint::instance(); Node *n = lookupNode(atoi(argv[2])); if (n == NULL) { fprintf(stderr, "No such node %s\n", argv[2]); exit(1); } int pno = paint->lookup(argv[3], 3); if (pno < 0) { fprintf(stderr,"%s ncolor: no such color: %s\n", argv[0], argv[3]); int pno = paint->lookup("black",1); if (pno < 0) { tcl.resultf("%s no black! - bailing"); return (TCL_ERROR); } } n->paint(pno); return (TCL_OK); } // ----- 5 tcl arguments ------ } else if (argc == 5) { if (strcmp(argv[1], "select-pkt") == 0) { selectPkt(atoi(argv[2]), atoi(argv[3]), atoi(argv[4])); return(TCL_OK); } if (strcmp(argv[1], "lookupColorName") == 0) { /* * <net> lookupColorName red green blue * get color name from its rgb value */ Paint *paint = Paint::instance(); int r = atoi(argv[2]); int g = atoi(argv[3]); int b = atoi(argv[4]); tcl.resultf("%s",paint->lookupName(r,g,b)); return(TCL_OK); } if (strcmp(argv[1], "queue") == 0) { /* * <net> queue <src> <dst> <angle> * Create a queue for the edge from 'src' to 'dst'. * Add it to this NetModel's queue list. * Display the queue at the specified angle from * the edge to which it belongs. */ int src = atoi(argv[2]); int dst = atoi(argv[3]); EdgeHashNode *h = lookupEdgeHashNode(src, dst); if (h == 0) { tcl.resultf("%s queue: no such edge (%d,%d)", argv[0], src, dst); return (TCL_ERROR); } /* XXX can we assume no duplicate queues? */ double angle = atof(argv[4]); Edge *e = h->edge; angle += e->angle(); Queue *q = new Queue(angle); h->queue = q; q->next_ = queues_; queues_ = q; return (TCL_OK); } if (strcmp(argv[1], "ecolor") == 0) { /* * <net> ecolor <src> <dst> <colorName> * set color of edge to the specified color. */ Paint *paint = Paint::instance(); EdgeHashNode* h = lookupEdgeHashNode(atoi(argv[2]), atoi(argv[3])); if (h == 0) { tcl.resultf("%s ecolor: no such edge (%s,%s)", argv[0], argv[2], argv[3]); return (TCL_ERROR); } int pno = paint->lookup(argv[4], 3); if (pno < 0) { fprintf(stderr,"%s ncolor: no such color: %s\n", argv[0], argv[3]); pno = paint->lookup("black",1); if (pno < 0) { tcl.resultf("%s no black! - bailing"); return (TCL_ERROR); } } h->edge->paint(pno); return (TCL_OK); } if (strcmp(argv[1], "edlabel") == 0) { /* * <net> edlabel <src> <dst> <colorName> * set label of edge. */ EdgeHashNode* h = lookupEdgeHashNode(atoi(argv[2]), atoi(argv[3])); if (h == 0) { tcl.resultf("%s ecolor: no such edge (%s,%s)", argv[0], argv[2], argv[3]); return (TCL_ERROR); } if (strcmp(argv[4],"(null)")!=0) { h->edge->dlabel((char *)argv[4]); // XXX Should never set edge size outside // scale_estimate()!!!!// h->edge->size(25.0); } return (TCL_OK); } if (strcmp(argv[1], "lanlink") == 0) { /* * <net> lanlink <src> <lan> <angle> * Create a link/edge between the specified source * and a lan. */ Node * src = lookupNode(atoi(argv[2])); Lan * lan = lookupLan(atoi(argv[3])); if (lan == NULL) { fprintf(stderr, "Error: lan %s does not exist.\n", argv[3]); exit(1); } double angle = atof(argv[4]); double bw = lan->bw(); double delay = (lan->delay())/2.0; Edge *e1 = new Edge(src, lan->virtual_node(), packet_size_, bw, delay, 0, angle+1); e1->init_color("black"); enterEdge(e1); e1->Animation::insert(&drawables_); src->add_link(e1); Edge *e2 = new Edge(lan->virtual_node(), src, packet_size_, bw, delay, 0, angle); e2->init_color("black"); enterEdge(e2); e2->Animation::insert(&drawables_); lan->add_link(e2); return (TCL_OK); } if (strcmp(argv[1], "set_node_tclscript") == 0) { //------------------------------------------------------------------ // $netModel set_node_tclscript $node_id $button_label $tcl_command // - from tcl/node.tcl // Animator instproc node_tclscript //------------------------------------------------------------------ // Sets the tcl_script for a node to be run when the // start_info exec button is pressed. Node * node = lookupNode(atoi(argv[2])); if (node) { // The following strings are deleted by the node when it // changes to another script or it is deleted node->setTclScript(argv[3], argv[4]); return TCL_OK; } else { return TCL_ERROR; } } } else if (argc == 6) { if (strcmp(argv[1], "lan") == 0) { /* * <net> lan <name> <bandwidth> <delay> <angle> * Create a link/edge between the specified source * and destination. Add it to this NetModel's list * of drawables and to the source's list of links. */ double bw = atof(argv[3]); double delay = atof(argv[4]); double angle = atof(argv[5]); Lan *l = new Lan(argv[2], this, packet_size_, bw, delay, angle); l->next_ = lans_; lans_ = l; l->insert(&drawables_); Node *n = l->virtual_node(); n->next_ = nodes_; nodes_ = n; return (TCL_OK); } } else if (argc == 8) { if (strcmp(argv[1], "link") == 0) { /* * <net> link <src> <dst> <bandwidth> <delay> <angle> * Create a link/edge between the specified source * and destination. Add it to this NetModel's list * of drawables and to the source's list of links. */ Edge * edge = addEdge(argc,argv)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -