void BCubeTopology::init_network() { QueueLoggerSampling* queueLogger; assert(NUM_PORTS>0); assert(K>=0); assert(NUM_SRV==(int)pow(NUM_PORTS,K+1)); for (int i=0; i<NUM_SRV; i++) { address_from_srv(i,addresses[i]); for (int k=0; k<K; k++) { for (int j=0; j<NUM_SW; j++) { pipes_srv_switch[i][j][k] = NULL; queues_srv_switch[i][j][k] = NULL; pipes_switch_srv[j][i][k] = NULL; queues_switch_srv[j][i][k] = NULL; } } } // addresses[i][k] = ADDRESS(i,k); for (int k=0; k<=K; k++) { //create links for level K for (int i=0; i<NUM_SRV; i++) { int j; j = SWITCH_ID(i,k); //printf("SWITCH ID for server %d level %d is %d\n",i,k,j); //index k of the address queueLogger = new QueueLoggerSampling(timeFromMs(1000), *eventlist); //queueLogger = NULL; logfile->addLogger(*queueLogger); queues_srv_switch[i][j][k] = new RandomQueue(speedFromPktps(HOST_NIC), memFromPkt(SWITCH_BUFFER + RANDOM_BUFFER), *eventlist, queueLogger, memFromPkt(RANDOM_BUFFER)); queues_srv_switch[i][j][k]->setName("SRV_" + ntoa(i) + "(level_" + ntoa(k)+"))_SW_" +ntoa(j)); logfile->writeName(*(queues_srv_switch[i][j][k])); pipes_srv_switch[i][j][k] = new Pipe(timeFromUs(RTT), *eventlist); pipes_srv_switch[i][j][k]->setName("Pipe-SRV_" + ntoa(i) + "(level_" + ntoa(k)+")-SW_" +ntoa(j)); logfile->writeName(*(pipes_srv_switch[i][j][k])); queueLogger = new QueueLoggerSampling(timeFromMs(1000), *eventlist); //queueLogger = NULL; logfile->addLogger(*queueLogger); queues_switch_srv[j][i][k] = new RandomQueue(speedFromPktps(HOST_NIC), memFromPkt(SWITCH_BUFFER + RANDOM_BUFFER), *eventlist, queueLogger, memFromPkt(RANDOM_BUFFER)); queues_switch_srv[j][i][k]->setName("SW_" + ntoa(j) + "(level_" + ntoa(k)+")-SRV_" +ntoa(i)); logfile->writeName(*(queues_switch_srv[j][i][k])); pipes_switch_srv[j][i][k] = new Pipe(timeFromUs(RTT), *eventlist); pipes_switch_srv[j][i][k]->setName("Pipe-SW_" + ntoa(j) + "(level_" + ntoa(k)+")-SRV_" +ntoa(i)); logfile->writeName(*(pipes_switch_srv[j][i][k])); } } }
void TcpSrcPeriodic::reset() { _sawtooth = 0; _rtt_avg = timeFromMs(0); _rtt_cum = timeFromMs(0); _highest_sent = 0; _effcwnd = 0; _ssthresh = 0xffffffff; _last_acked = 0; _dupacks = 0; _rtt = 0; _rto = timeFromMs(3000); _mdev = 0; _recoverq = 0; _in_fast_recovery = false; _mSrc = NULL; _rtx_timeout_pending = false; _RFC2988_RTO_timeout = timeInf; }
void StarTopology::init_network() { QueueLoggerSampling* queueLogger; for (int i=0; i<NSRV; i++) { pipe_in_ns[i] = NULL; pipe_out_ns[i] = NULL; queue_in_ns[i] = NULL; queue_out_ns[i] = NULL; } for (int j = 0; j < NSRV; j++) { // Downlink queueLogger = new QueueLoggerSampling(timeFromMs(1000), *eventlist); //queueLogger = NULL; logfile->addLogger(*queueLogger); queue_in_ns[j] = new RandomQueue(speedFromPktps(HOST_NIC), memFromPkt(SWITCH_BUFFER + RANDOM_BUFFER), *eventlist, queueLogger, memFromPkt(RANDOM_BUFFER)); queue_in_ns[j]->setName("IN_" + ntoa(j)); logfile->writeName(*(queue_in_ns[j])); pipe_in_ns[j] = new Pipe(timeFromUs(RTT), *eventlist); pipe_in_ns[j]->setName("Pipe-in-" + ntoa(j)); logfile->writeName(*(pipe_in_ns[j])); queueLogger = new QueueLoggerSampling(timeFromMs(1000), *eventlist); //queueLogger = NULL; logfile->addLogger(*queueLogger); queue_out_ns[j] = new RandomQueue(speedFromPktps(HOST_NIC), memFromPkt(SWITCH_BUFFER + RANDOM_BUFFER), *eventlist, queueLogger, memFromPkt(RANDOM_BUFFER)); queue_out_ns[j]->setName("OUT_" + ntoa(j)); logfile->writeName(*(queue_out_ns[j])); pipe_out_ns[j] = new Pipe(timeFromUs(RTT), *eventlist); pipe_out_ns[j]->setName("Pipe-out-" + ntoa(j)); logfile->writeName(*(pipe_out_ns[j])); if (ff) { ff->add_queue(queue_in_ns[j]); ff->add_queue(queue_out_ns[j]); } } }
RtxTimer::RtxTimer(EventList& list): _eventList(list) { TimerBucket* bucket; simtime_picosec now; now = _eventList().now(); for (int i=50;i<=400;i*=2){ bucket = new TimerBucket(); bucket->base = timeFromMs(i); bucket->expire = now + bucket->base; } }
RcpSrc::RcpSrc(RcpLogger* logger, TrafficLogger* pktlogger, EventList &eventlist) : EventSource(eventlist,"rcp"), _logger(logger), _flow(pktlogger) { _maxcwnd = 30000; _highest_sent = 0; _effcwnd = 0; _ssthresh = 0xffffffff; _last_acked = 0; _dupacks = 0; _rtt = timeFromMs(3000); _mss = RcpPacket::DEFAULTDATASIZE; _recoverq = 0; _in_fast_recovery = false; }
void CClassification::ServiceGenJetCheckCommands( ) { #ifndef _WINDOWS // ------- Don't compile on windows ----- JetCommand cmd; Uint32 unTime; unTime = timeGetHighResTime() + timeFromMs( 50 ); for ( Int i=0; i<MAX_LANES; i++ ) { // clear the command for ( Int i=0; i<JetCommand::MAX_JETS; i++) cmd.aryJetState[i] = FALSE; // activate only one jet cmd.aryJetState[i] = TRUE; cmd.unCmdTime = unTime; // and add the command CJetControl::Instance()->AddCommand( &cmd ); // increase time unTime += timeFromMs( 200 ); } // send a clear all command for ( Int i=0; i<JetCommand::MAX_JETS; i++) cmd.aryJetState[i] = FALSE; cmd.unCmdTime = unTime; CJetControl::Instance()->AddCommand( &cmd ); #endif // ------------------------------------------------ }
void convInit( ) { convObject.unMillimetersPerTrigger = CONV_MILLIMETERS_PER_TRIGGER; convObject.unLastTicks = 0; convObject.unLastDeltaTicks = 0; convObject.unNumTotalTriggerSignals = 0; convObject.unTimeoutTicks = timeFromMs( convHal.unTimeout ); convObject.bStanding = TRUE; // PRE: the HWI link to our handler function is set by the config tool. IRQ_clear( convHal.unExtInterrupt ); IRQ_enable( convHal.unExtInterrupt ); // Enable the interrupt in the FPGA ppuMemory[CONV_REG_INTENABLE_ADDR] |= CONV_REG_INTENABLE_MASK; // Init the high res timer that we're going to use timeInit(); }
void TcpSrc::rtx_timer_hook(simtime_picosec now) { if (_highest_sent == 0) return; if (now <= _last_sent_time + timeFromMs(1000)) return; // RTX timer expired if (_logger) _logger->logTcp(*this, TcpLogger::TCP_TIMEOUT); if (_in_fast_recovery) { uint32_t flightsize = _highest_sent - _last_acked; _cwnd = min(_ssthresh, flightsize + _mss); } _ssthresh = max(_cwnd/2, (uint32_t)(2 * _mss)); _cwnd = _mss; _unacked = _cwnd; _effcwnd = _cwnd; _in_fast_recovery = false; _recoverq = _highest_sent; _highest_sent = _last_acked + _mss; _dupacks = 0; retransmit_packet(); //reset rtx timer _last_sent_time = now; }
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()) {} }
#include "network.h" #include "randomqueue.h" #include "pipe.h" #include "eventlist.h" #include "logfile.h" #include "loggers.h" #include "clock.h" #include "mtcp.h" #include "exoqueue.h" #include "cbr.h" string ntoa(double n); string itoa(uint64_t n); // Simulation params simtime_picosec RTT1=timeFromMs(1); simtime_picosec RTT2=timeFromMs(1); double targetwnd = 30; int NUMFLOWS = 2; #define TCP_1 1 #define TCP_2 1 linkspeed_bps SERVICE1 = speedFromPktps(8000);//NUMFLOWS * targetwnd/timeAsSec(RTT1)); linkspeed_bps SERVICE2 = speedFromPktps(8000);//NUMFLOWS * targetwnd/timeAsSec(RTT2)); #define RANDOM_BUFFER 3 #define FEEDER_BUFFER 2000 mem_b BUFFER1=memFromPkt(RANDOM_BUFFER+30);//NUMFLOWS * targetwnd);
void CVisDemoSorterClassifier::EjectObject( const FastLabelObject & obj ) { // Get the leftmost and rightmost lanes. Int nLeftLane = GetOuterLane( obj, -1 ); Int nRightLane = GetOuterLane( obj, 1 ); for ( Int nLane=nLeftLane; nLane <= nRightLane; nLane++ ) { // Calculate ejection time. Uint32 unEjectionTime = CalculateEjectionTime( obj.pTransformedCoords->fpMy, nLane ); #ifndef _WINDOWS // Add a command that turns the main jet on and then off. COutputDispatcher::Instance()->Channel( nLane ).AddCommand( m_unCurrentTime + unEjectionTime - timeFromMs( m_nMargin_ms ), true ); COutputDispatcher::Instance()->Channel( nLane ).AddCommand( m_unCurrentTime + unEjectionTime + timeFromMs( m_nMargin_ms ), false ); #endif } #ifdef _WINDOWS LogMsg("Ejected from lane %d to lane %d", nLeftLane, nRightLane ); #else //LogMsg("Ejected from lane %d to lane %d", nLeftLane, nRightLane ); #endif }
void CVisDemoSorterClassifier::DoProcessing() { Uint32 i; m_nNumObjectsClassifier_last = 0; if ( m_pModel == NULL ) return; FastLabelObject * objLabels = (FastLabelObject*)m_iportLabelData.GetBuffer(); ColorObject * objColors = (ColorObject*)m_iportColorData.GetBuffer(); // Get extents of valid area CVisFixpoint fLeft, fRight, fTop, fBottom; m_pModel->GetValidArea( fLeft, fRight, fTop, fBottom ); for ( i=1; i<objLabels[0].unNumObjects; i++) { // Clear the object's flags. objLabels[i].unFlags = 0; // See if the object is valid (i.e. it is in a valid position and has sensibel // sizes. if ( IsObjectValid( objLabels[i] ) ) { // The object is valid. m_nNumObjectsClassified++; m_nNumObjectsClassifier_last++; m_nNumFramesWithoutObjects = 0; // Classify the object. Int nClass = ClassifiyColor( objColors[i].Color.unHue, objColors[i].Color.unSat, objColors[i].Color.unLum ); // Increment count for that class. if ( nClass != -1 ) m_aryColorClasses[nClass].nCount++; // Mark the object as due for ejection if the class is valid and scheduled for ejection. if ( (nClass != -1) && ( m_aryColorClasses[nClass].nEject != 0 ) ) objLabels[i].unFlags |= FLF_EJECT; else objLabels[i].unFlags &= ~FLF_EJECT; } // if object valid } // for all objects // Resolve critical ejections //ResolveCriticalEjections( objLabels ); // Generate ejection commands for ( i=1; i<objLabels[0].unNumObjects; i++) { if ( (objLabels[i].unFlags & FLF_EJECT) != 0 ) EjectObject( objLabels[i] ); } #ifndef _WINDOWS // See if we've seen no objects for a while and turn of the jets if that's the case Uint32 unTime = timeGetHighResTime() + timeFromMs( 10 ); if ( m_nNumFramesWithoutObjects > 25 ) { for ( int i=0; i<m_pModel->GetNumJets(); i++ ) COutputDispatcher::Instance()->Channel( i ).AddCommand( unTime , false ); } #endif }
int main (int argc, char **argv) { eventlist.setEndtime (timeFromSec (200)); Clock c (timeFromSec (50 / 100.), eventlist); int algo = COUPLED_EPSILON; double epsilon = 1; int param = 0; stringstream filename (ios_base::out); uint64_t pktperflow = 1048576LL/1000 + 1; if (argc > 1) { int i = 1; if (!strcmp (argv[1], "-o")) { filename << argv[2]; i += 2; } else { filename << "logout.dat"; } if (argc > i && !strcmp (argv[i], "-sub")) { subflow_count = atoi (argv[i + 1]); i += 2; } if (argc > i && !strcmp (argv[i], "-flowM")) { pktperflow = atoi (argv[i + 1])*1048576LL/1000; i += 2; cout << "Using subflow count " << subflow_count << endl; } if (argc > i && !strcmp (argv[i], "-param")) { param = atoi (argv[i + 1]); i += 2; cout << "Using subflow count " << subflow_count << endl; } if (argc > i) { epsilon = -1; if (!strcmp (argv[i], "UNCOUPLED")) { algo = UNCOUPLED; } else if (!strcmp (argv[i], "COUPLED_INC")) { algo = COUPLED_INC; } else if (!strcmp (argv[i], "FULLY_COUPLED")) { algo = FULLY_COUPLED; } else if (!strcmp (argv[i], "COUPLED_TCP")) { algo = COUPLED_TCP; } else if (!strcmp (argv[i], "COUPLED_SCALABLE_TCP")) { algo = COUPLED_SCALABLE_TCP; } else if (!strcmp (argv[i], "COUPLED_EPSILON")) { algo = COUPLED_EPSILON; if (argc > i + 1) { epsilon = atof (argv[i + 1]); } printf ("Using epsilon %f\n", epsilon); } else { exit_error (argv[0]); } } } srand (time (NULL)); cout << "Using algo=" << algo << " epsilon=" << epsilon << endl; // prepare the loggers cout << "Logging to " << filename.str () << endl; //Logfile Logfile logfile (filename.str (), eventlist); #if PRINT_PATHS filename << ".paths"; cout << "Logging path choices to " << filename.str () << endl; std::ofstream paths (filename.str ().c_str ()); if (!paths) { cout << "Can't open for writing paths file!" << endl; exit (1); } #endif int tot_subs = 0; int cnt_con = 0; lg = &logfile; logfile.setStartTime (timeFromSec (0)); SinkLoggerSampling sinkLogger = SinkLoggerSampling (timeFromMs (1000), eventlist); logfile.addLogger (sinkLogger); //TcpLoggerSimple logTcp;logfile.addLogger(logTcp); TcpSrc *tcpSrc; TcpSink *tcpSnk; //CbrSrc* cbrSrc; //CbrSink* cbrSnk; route_t *routeout, *routein; double extrastarttime; TcpRtxTimerScanner tcpRtxScanner (timeFromMs (10), eventlist); MultipathTcpSrc *mtcp; vector<MultipathTcpSrc*> mptcpVector; int dest; #if USE_FIRST_FIT if (subflow_count == 1) { ff = new FirstFit (timeFromMs (FIRST_FIT_INTERVAL), eventlist); } #endif #ifdef FAT_TREE FatTreeTopology *top = new FatTreeTopology (&logfile, &eventlist, ff); #endif #ifdef OV_FAT_TREE OversubscribedFatTreeTopology *top = new OversubscribedFatTreeTopology (&logfile, &eventlist, ff); #endif #ifdef MH_FAT_TREE MultihomedFatTreeTopology *top = new MultihomedFatTreeTopology (&logfile, &eventlist, ff); #endif #ifdef STAR StarTopology *top = new StarTopology (&logfile, &eventlist, ff); #endif #ifdef BCUBE BCubeTopology *top = new BCubeTopology (&logfile, &eventlist, ff); cout << "BCUBE " << K << endl; #endif #ifdef VL2 VL2Topology *top = new VL2Topology (&logfile, &eventlist, ff); #endif vector < route_t * >***net_paths; net_paths = new vector < route_t * >**[N]; int *is_dest = new int[N]; for (int i = 0; i < N; i++) { is_dest[i] = 0; net_paths[i] = new vector < route_t * >*[N]; for (int j = 0; j < N; j++) { net_paths[i][j] = NULL; } } if (ff) { ff->net_paths = net_paths; } vector < int >*destinations; // Permutation connections ConnectionMatrix *conns = new ConnectionMatrix (N); //conns->setLocalTraffic(top); //cout << "Running perm with " << param << " connections" << endl; //conns->setPermutation(param); //conns->setStaggeredPermutation(top,(double)param/100.0); //conns->setStaggeredRandom(top,512,1); // conns->setHotspot(param,512/param); conns->setStride (3,0); //conns->setManytoMany(128); //conns->setVL2(); //conns->setRandom(param); map < int, vector < int >*>::iterator it; int connID = 0; for (it = conns->connections.begin (); it != conns->connections.end (); it++) { int src = (*it).first; destinations = (vector < int >*) (*it).second; vector < int >subflows_chosen; for (unsigned int dst_id = 0; dst_id < destinations->size (); dst_id++) { connID++; dest = destinations->at (dst_id); if (!net_paths[src][dest]) { net_paths[src][dest] = top->get_paths (src, dest); } /*bool cbr = 1; if (cbr){ cbrSrc = new CbrSrc(eventlist,speedFromPktps(7999),timeFromMs(0),timeFromMs(0)); cbrSnk = new CbrSink(); cbrSrc->setName("cbr_" + ntoa(src) + "_" + ntoa(dest)+"_"+ntoa(dst_id)); logfile.writeName(*cbrSrc); cbrSnk->setName("cbr_sink_" + ntoa(src) + "_" + ntoa(dest)+"_"+ntoa(dst_id)); logfile.writeName(*cbrSnk); // tell it the route if (net_paths[src][dest]->size()==1){ choice = 0; } else { choice = rand()%net_paths[src][dest]->size(); } routeout = new route_t(*(net_paths[src][dest]->at(choice))); routeout->push_back(cbrSnk); cbrSrc->connect(*routeout, *cbrSnk, timeFromMs(0)); } */ { //we should create multiple connections. How many? //if (connID%3!=0) //continue; for (int connection = 0; connection < 1; connection++) { if (algo == COUPLED_EPSILON) { mtcp = new MultipathTcpSrc (algo, eventlist, NULL, epsilon); } else { mtcp = new MultipathTcpSrc (algo, eventlist, NULL); } mptcpVector.push_back(mtcp); //uint64_t bb = generateFlowSize(); // if (subflow_control) //subflow_control->add_flow(src,dest,mtcp); subflows_chosen.clear (); int it_sub; int crt_subflow_count = subflow_count; tot_subs += crt_subflow_count; cnt_con++; it_sub = crt_subflow_count > net_paths[src][dest]-> size ()? net_paths[src][dest]->size () : crt_subflow_count; int use_all = it_sub == net_paths[src][dest]->size (); //if (connID%10!=0) //it_sub = 1; uint64_t pktpersubflow = pktperflow / it_sub; for (int inter = 0; inter < it_sub; inter++) { // if (connID%10==0){ tcpSrc = new TcpSrc (NULL, NULL, eventlist); tcpSrc->set_max_packets(pktpersubflow); tcpSnk = new TcpSink (); /*} else { tcpSrc = new TcpSrcTransfer(NULL,NULL,eventlist,bb,net_paths[src][dest]); tcpSnk = new TcpSinkTransfer(); } */ //if (connection==1) //tcpSrc->set_app_limit(9000); tcpSrc->setName ("mtcp_" + ntoa (src) + "_" + ntoa (inter) + "_" + ntoa (dest) + "(" + ntoa (connection) + ")"); logfile.writeName (*tcpSrc); tcpSnk->setName ("mtcp_sink_" + ntoa (src) + "_" + ntoa (inter) + "_" + ntoa (dest) + "(" + ntoa (connection) + ")"); logfile.writeName (*tcpSnk); tcpRtxScanner.registerTcp (*tcpSrc); /*int found; do { found = 0; //if (net_paths[src][dest]->size()==K*K/4 && it_sub <= K/2) //choice = rand()%(K/2); //else choice = rand()%net_paths[src][dest]->size(); for (unsigned int cnt = 0;cnt<subflows_chosen.size();cnt++){ if (subflows_chosen.at(cnt)==choice){ found = 1; break; } } }while(found); // */ int choice = 0; #ifdef FAT_TREE choice = rand () % net_paths[src][dest]->size (); #endif #ifdef OV_FAT_TREE choice = rand () % net_paths[src][dest]->size (); #endif #ifdef MH_FAT_TREE if (use_all) { choice = inter; } else { choice = rand () % net_paths[src][dest]->size (); } #endif #ifdef VL2 choice = rand () % net_paths[src][dest]->size (); #endif #ifdef STAR choice = 0; #endif #ifdef BCUBE //choice = inter; int min = -1, max = -1, minDist = 1000, maxDist = 0; if (subflow_count == 1) { //find shortest and longest path for (int dd = 0; dd < net_paths[src][dest]->size (); dd++) { if (net_paths[src][dest]->at (dd)->size () < minDist) { minDist = net_paths[src][dest]->at (dd)->size (); min = dd; } if (net_paths[src][dest]->at (dd)->size () > maxDist) { maxDist = net_paths[src][dest]->at (dd)->size (); max = dd; } } choice = min; } else { choice = rand () % net_paths[src][dest]->size (); } #endif //cout << "Choice "<<choice<<" out of "<<net_paths[src][dest]->size(); subflows_chosen.push_back (choice); /*if (net_paths[src][dest]->size()==K*K/4 && it_sub<=K/2){ int choice2 = rand()%(K/2); */ if (choice >= net_paths[src][dest]->size ()) { printf ("Weird path choice %d out of %u\n", choice, net_paths[src][dest]->size ()); exit (1); } #if PRINT_PATHS paths << "Route from " << ntoa (src) << " to " << ntoa (dest) << " (" << choice << ") -> "; print_path (paths, net_paths[src][dest]->at (choice)); #endif routeout = new route_t (*(net_paths[src][dest]->at (choice))); routeout->push_back (tcpSnk); routein = new route_t (); routein->push_back (tcpSrc); extrastarttime = 50 * drand (); //join multipath connection mtcp->addSubflow (tcpSrc); if (inter == 0) { mtcp->setName ("multipath" + ntoa (src) + "_" + ntoa (dest) + "(" + ntoa (connection) + ")"); logfile.writeName (*mtcp); } tcpSrc->connect (*routeout, *routein, *tcpSnk, timeFromMs (extrastarttime)); #ifdef PACKET_SCATTER tcpSrc->set_paths (net_paths[src][dest]); cout << "Using PACKET SCATTER!!!!" << endl << end; #endif if (ff && !inter) { ff->add_flow (src, dest, tcpSrc); } sinkLogger.monitorSink (tcpSnk); } } } } } //ShortFlows* sf = new ShortFlows(2560, eventlist, net_paths,conns,lg, &tcpRtxScanner); cout << "Mean number of subflows " << ntoa ((double) tot_subs / cnt_con) << endl; // Record the setup int pktsize = TcpPacket::DEFAULTDATASIZE; logfile.write ("# pktsize=" + ntoa (pktsize) + " bytes"); logfile.write ("# subflows=" + ntoa (subflow_count)); logfile.write ("# hostnicrate = " + ntoa (HOST_NIC) + " pkt/sec"); logfile.write ("# corelinkrate = " + ntoa (HOST_NIC * CORE_TO_HOST) + " pkt/sec"); //logfile.write("# buffer = " + ntoa((double) (queues_na_ni[0][1]->_maxsize) / ((double) pktsize)) + " pkt"); double rtt = timeAsSec (timeFromUs (RTT)); logfile.write ("# rtt =" + ntoa (rtt)); // GO! double last = 0.0; while (eventlist.doNextEvent ()) { if (timeAsMs(eventlist.now())>last+10.0) { cout << (last = timeAsMs(eventlist.now())) << endl; for (vector<MultipathTcpSrc*>::iterator iA = mptcpVector.begin(); iA!=mptcpVector.end(); iA++) { cout << (*iA)->compute_total_bytes()*0.001*0.001 <<" "; } cout << endl; } } }