int main() { std::vector<Landmark> landmarks; landmarks.reserve( 6 ); Landmark buoy1( 11.0, 3.1, 0.0, "buoy", 0 ); Landmark buoy2( 11.5, 3.0, 0.0, "buoy", 1 ); Landmark buoy3( 10.5, 2.9, 0.0, "buoy", 2 ); Landmark gate( 4.0, 2.5, 0.14, "gate" ); Landmark pipe1( 6.0, 2.0, 0.2, "pipe", 0 ); Landmark pipe2( 14.0, 3.0, 0.3, "pipe", 1 ); // add all landmarks to "landmarks" in the order they were defined above landmarks.push_back( buoy1 ); landmarks[1] = buoy2; *landmarks.begin() = buoy3; landmarks.back() = gate; landmarks.at( 3 ) = pipe1; landmarks.insert( landmarks.begin(), pipe2 ); // for everything below this line, assume the landmarks have all been added to "landmarks" correctly // print all the landmarks { unsigned int i = 0; while( i <= landmarks.size() ) { Landmark landmark = *( landmarks.begin() + i ); std::cout << landmark.toString() << std::endl; } } // print all the landmarks { std::vector<Landmark>::iterator landmarks_it = landmarks.begin(); while( landmarks_it != landmarks.end() ) { std::cout << landmarks_it->toString() << std::endl; ++landmarks_it; } } // print all the landmarks { for( Landmark * landmark_ptr = &landmarks[0]; landmark_ptr != &landmarks[landmarks.size()]; ++landmark_ptr ) { std::cout << landmark_ptr->toString() << std::endl; } } return 0; }
int main(int argc, char *argv[]) { printf(1, "usertests starting\n"); if(open("usertests.ran", 0) >= 0){ printf(1, "already ran user tests -- rebuild fs.img\n"); exit(); } close(open("usertests.ran", O_CREATE)); createdelete(); linkunlink(); concreate(); fourfiles(); sharedfd(); bigargtest(); bigwrite(); bigargtest(); bsstest(); sbrktest(); validatetest(); opentest(); writetest(); writetest1(); createtest(); openiputtest(); exitiputtest(); iputtest(); mem(); pipe1(); preempt(); exitwait(); rmdot(); fourteen(); bigfile(); subdir(); linktest(); unlinkread(); dirfile(); iref(); forktest(); bigdir(); // slow exectest(); exit(); }
int sys_pipe2(struct lwp *l, const struct sys_pipe2_args *uap, register_t *retval) { /* { syscallarg(int[2]) fildes; syscallarg(int) flags; } */ int fd[2], error; if ((error = pipe1(l, retval, SCARG(uap, flags))) != 0) return error; fd[0] = retval[0]; fd[1] = retval[1]; if ((error = copyout(fd, SCARG(uap, fildes), sizeof(fd))) != 0) return error; retval[0] = 0; return 0; }
int main(int argc, char **argv) { EventList eventlist; eventlist.setEndtime(timeFromSec(5000)); Clock c(timeFromSec(50/100.), eventlist); int algo = UNCOUPLED; double epsilon = 1; int crt = 2; if (argc>1) { if (!strcmp(argv[1],"UNCOUPLED")) algo = UNCOUPLED; else if (!strcmp(argv[1],"COUPLED_INC")) algo = COUPLED_INC; else if (!strcmp(argv[1],"FULLY_COUPLED")) algo = FULLY_COUPLED; else if (!strcmp(argv[1],"COUPLED_TCP")) algo = COUPLED_TCP; else if (!strcmp(argv[1],"COUPLED_EPSILON")) { algo = COUPLED_EPSILON; if (argc>2) { epsilon = atof(argv[2]); crt++; printf("Using epsilon %f\n",epsilon); } } else exit_error(argv[0]); } linkspeed_bps SERVICE1 = speedFromPktps(400); linkspeed_bps SERVICE2; if (argc>crt) SERVICE2 = speedFromPktps(atoi(argv[crt++])); else SERVICE2 = speedFromPktps(400); simtime_picosec RTT1=timeFromMs(100); simtime_picosec RTT2; if (argc>crt) RTT2 = timeFromMs(atoi(argv[crt])); else RTT2 = timeFromMs(100); mem_b BUFFER1=memFromPkt(RANDOM_BUFFER+timeAsSec(RTT1)*speedAsPktps(SERVICE1));//NUMFLOWS * targetwnd); mem_b BUFFER2=memFromPkt(RANDOM_BUFFER+timeAsSec(RTT2)*speedAsPktps(SERVICE2));//NUMFLOWS * targetwnd); srand(time(NULL)); // prepare the loggers stringstream filename(ios_base::out); filename << "../data/logout." << speedAsPktps(SERVICE2) << "pktps." <<timeAsMs(RTT2) << "ms."<< rand(); cout << "Outputting to " << filename.str() << endl; Logfile logfile(filename.str(),eventlist); logfile.setStartTime(timeFromSec(0.5)); QueueLoggerSimple logQueue = QueueLoggerSimple(); logfile.addLogger(logQueue); // QueueLoggerSimple logPQueue1 = QueueLoggerSimple(); logfile.addLogger(logPQueue1); //QueueLoggerSimple logPQueue3 = QueueLoggerSimple(); logfile.addLogger(logPQueue3); QueueLoggerSimple logPQueue = QueueLoggerSimple(); logfile.addLogger(logPQueue); MultipathTcpLoggerSimple mlogger = MultipathTcpLoggerSimple(); logfile.addLogger(mlogger); //TrafficLoggerSimple logger; //logfile.addLogger(logger); SinkLoggerSampling sinkLogger = SinkLoggerSampling(timeFromMs(1000),eventlist); logfile.addLogger(sinkLogger); QueueLoggerSampling qs1 = QueueLoggerSampling(timeFromMs(1000),eventlist); logfile.addLogger(qs1); QueueLoggerSampling qs2 = QueueLoggerSampling(timeFromMs(1000),eventlist); logfile.addLogger(qs2); TcpLoggerSimple* logTcp = NULL; logTcp = new TcpLoggerSimple(); logfile.addLogger(*logTcp); // Build the network Pipe pipe1(RTT1, eventlist); pipe1.setName("pipe1"); logfile.writeName(pipe1); Pipe pipe2(RTT2, eventlist); pipe2.setName("pipe2"); logfile.writeName(pipe2); Pipe pipe_back(timeFromMs(.1), eventlist); pipe_back.setName("pipe_back"); logfile.writeName(pipe_back); RandomQueue queue1(SERVICE1, BUFFER1, eventlist,&qs1,memFromPkt(RANDOM_BUFFER)); queue1.setName("Queue1"); logfile.writeName(queue1); RandomQueue queue2(SERVICE2, BUFFER2, eventlist,&qs2,memFromPkt(RANDOM_BUFFER)); queue2.setName("Queue2"); logfile.writeName(queue2); Queue pqueue2(SERVICE2*2, memFromPkt(FEEDER_BUFFER), eventlist,NULL); pqueue2.setName("PQueue2"); logfile.writeName(pqueue2); Queue pqueue3(SERVICE1*2, memFromPkt(FEEDER_BUFFER), eventlist,NULL); pqueue3.setName("PQueue3"); logfile.writeName(pqueue3); Queue pqueue4(SERVICE2*2, memFromPkt(FEEDER_BUFFER), eventlist,NULL); pqueue4.setName("PQueue4"); logfile.writeName(pqueue4); Queue* pqueue; Queue queue_back(max(SERVICE1,SERVICE2)*4, memFromPkt(1000), eventlist,NULL); queue_back.setName("queue_back"); logfile.writeName(queue_back); TcpRtxTimerScanner tcpRtxScanner(timeFromMs(10), eventlist); //TCP flows on path 1 TcpSrc* tcpSrc; TcpSink* tcpSnk; route_t* routeout; route_t* routein; double extrastarttime; for (int i=0; i<TCP_1; i++) { tcpSrc = new TcpSrc(NULL,NULL,eventlist); tcpSrc->setName("Tcp1"); logfile.writeName(*tcpSrc); tcpSnk = new TcpSink(); tcpSnk->setName("Tcp1"); logfile.writeName(*tcpSnk); tcpRtxScanner.registerTcp(*tcpSrc); // tell it the route pqueue = new Queue(SERVICE1*2, memFromPkt(FEEDER_BUFFER), eventlist,NULL); pqueue->setName("PQueue1_"+ntoa(i)); logfile.writeName(*pqueue); routeout = new route_t(); routeout->push_back(pqueue); routeout->push_back(&queue1); routeout->push_back(&pipe1); routeout->push_back(tcpSnk); routein = new route_t(); routein->push_back(tcpSrc); extrastarttime = drand()*50; tcpSrc->connect(*routeout,*routein,*tcpSnk,timeFromMs(extrastarttime)); sinkLogger.monitorSink(tcpSnk); } //TCP flow on path 2 for (int i=0; i<TCP_2; i++) { tcpSrc = new TcpSrc(NULL,NULL,eventlist); tcpSrc->setName("Tcp2"); logfile.writeName(*tcpSrc); tcpSnk = new TcpSink(); tcpSnk->setName("Tcp2"); logfile.writeName(*tcpSnk); tcpRtxScanner.registerTcp(*tcpSrc); pqueue = new Queue(SERVICE2*2, memFromPkt(FEEDER_BUFFER), eventlist,NULL); pqueue->setName("PQueue2_"+ntoa(i)); logfile.writeName(*pqueue); // tell it the route routeout = new route_t(); routeout->push_back(pqueue); routeout->push_back(&queue2); routeout->push_back(&pipe2); routeout->push_back(tcpSnk); routein = new route_t(); //routein->push_back(&queue_back); routein->push_back(&pipe_back); routein->push_back(tcpSrc); extrastarttime = 50*drand(); tcpSrc->connect(*routeout,*routein,*tcpSnk,timeFromMs(extrastarttime)); sinkLogger.monitorSink(tcpSnk); } MultipathTcpSrc* mtcp; if (algo==COUPLED_EPSILON) mtcp = new MultipathTcpSrc(algo,eventlist,&mlogger,epsilon); else mtcp = new MultipathTcpSrc(algo,eventlist,&mlogger); //MTCP flow 1 tcpSrc = new TcpSrc(NULL,NULL,eventlist); tcpSrc->setName("Subflow1"); logfile.writeName(*tcpSrc); tcpSnk = new TcpSink(); tcpSnk->setName("Subflow1"); logfile.writeName(*tcpSnk); tcpRtxScanner.registerTcp(*tcpSrc); // tell it the route routeout = new route_t(); routeout->push_back(&pqueue3); routeout->push_back(&queue1); routeout->push_back(&pipe1); routeout->push_back(tcpSnk); routein = new route_t(); //routein->push_back(&queue_back); routein->push_back(&pipe_back); routein->push_back(tcpSrc); extrastarttime = 50*drand(); //join multipath connection mtcp->addSubflow(tcpSrc); tcpSrc->connect(*routeout,*routein,*tcpSnk,timeFromMs(extrastarttime)); sinkLogger.monitorSink(tcpSnk); //MTCP flow 2 tcpSrc = new TcpSrc(NULL,NULL,eventlist); tcpSrc->setName("Subflow2"); logfile.writeName(*tcpSrc); tcpSnk = new TcpSink(); tcpSnk->setName("Subflow2"); logfile.writeName(*tcpSnk); tcpRtxScanner.registerTcp(*tcpSrc); // tell it the route routeout = new route_t(); routeout->push_back(&pqueue4); routeout->push_back(&queue2); routeout->push_back(&pipe2); routeout->push_back(tcpSnk); routein = new route_t(); //routein->push_back(&queue_back); routein->push_back(&pipe_back); routein->push_back(tcpSrc); extrastarttime = 50*drand(); //join multipath connection mtcp->addSubflow(tcpSrc); tcpSrc->connect(*routeout,*routein,*tcpSnk,timeFromMs(extrastarttime)); sinkLogger.monitorSink(tcpSnk); // Record the setup int pktsize = TcpPacket::DEFAULTDATASIZE; logfile.write("# pktsize="+ntoa(pktsize)+" bytes"); logfile.write("# bottleneckrate1="+ntoa(speedAsPktps(SERVICE1))+" pkt/sec"); logfile.write("# bottleneckrate2="+ntoa(speedAsPktps(SERVICE2))+" pkt/sec"); logfile.write("# buffer1="+ntoa((double)(queue1._maxsize)/((double)pktsize))+" pkt"); logfile.write("# buffer2="+ntoa((double)(queue2._maxsize)/((double)pktsize))+" pkt"); double rtt = timeAsSec(RTT1); logfile.write("# rtt="+ntoa(rtt)); rtt = timeAsSec(RTT2); logfile.write("# rtt="+ntoa(rtt)); logfile.write("# numflows="+ntoa(NUMFLOWS)); logfile.write("# targetwnd="+ntoa(targetwnd)); // GO! while (eventlist.doNextEvent()) {} }
/* * Pipe messages, honor ignored fields. */ int pipecmd(void *v) { char *str = v; return(pipe1(str, 1)); }
/* * Pipe messages, not respecting ignored fields. */ int Pipecmd(void *v) { char *str = v; return(pipe1(str, 0)); }
int sys_pipe(struct lwp *l, const void *v, register_t *retval) { return pipe1(l, retval, 0); }
int main() { Source src(100); Pipe pipe1(80); Valve valve1(on); Tank tank1(60); Switch switch1(&tank1,300); Switch switch2(&tank1, 50); Pipe pipe2(80); Sink sink1(30); Pipe pipe3(40); Valve valve2(on); Tank tank2(80); Switch switch3(&tank2, 250); Switch switch4(&tank2, 50); Sink sink2(20); while( !kbhit() ) { src>=pipe1; pipe1>=valve1; valve1>=tank1; Tee(tank1,pipe2,pipe3); pipe2>=sink1; pipe3>=valve2; valve2>=tank2; tank2>=sink2; src.Tick(); pipe1.Tick(); valve1.Tick(); tank1.Tick(); switch1.Tick(); switch2.Tick(); pipe2.Tick(); sink1.Tick(); pipe3.Tick(); valve2.Tick(); tank2.Tick(); switch3.Tick(); switch4.Tick(); sink2.Tick(); if(valve1.Status()==on&& switch1.Status()==on) valve1.Status()=off; if (valve1.Status()==off && switch2.Status()==off) valve1.Status()=on; if(valve2.Status()==on && switch3.Status()==on) valve2.Status()=off; if(valve2.Status()==off && switch4.Status()==off) valve2.Status()=on; cout<<" Src=" <<setw(2)<<src.Flow(); cout<<" p1="<<setw(2)<<pipe1.Flow(); if(valve1.Status()==off) cout<<" v1=off"; else cout<<" v1=on"; cout<<" T1="<<setw(3)<<tank1.Contents(); cout<<" p2="<<setw(2)<<pipe2.Flow(); cout<<" Sink1= "<<setw(2)<<sink1.Flow(); cout<<" p3="<<setw(2)<<pipe3.Flow(); if(valve2.Status()==off) cout<<" v2=off"; else cout<<" v2=on"; cout<<" T2= "<<setw(3)<<tank2.Contents(); cout<<" sink2= "<<setw(2)<<sink2.Flow(); cout<<"\n"; } return 0; }