bool ProcessingElement::canShot(Packet & packet) { bool shot; double threshold; double now = sc_time_stamp().to_double() / GlobalParams::clock_period_ps; if (GlobalParams::traffic_distribution != TRAFFIC_TABLE_BASED) { if (!transmittedAtPreviousCycle) threshold = GlobalParams::packet_injection_rate; else threshold = GlobalParams::probability_of_retransmission; double prob_rand = ((double) rand()) / RAND_MAX; shot = (prob_rand < threshold); if (shot) { if (GlobalParams::traffic_distribution == TRAFFIC_RANDOM) packet = trafficRandom(); else if (GlobalParams::traffic_distribution == TRAFFIC_TRANSPOSE1) packet = trafficTranspose1(); else if (GlobalParams::traffic_distribution == TRAFFIC_TRANSPOSE2) packet = trafficTranspose2(); else if (GlobalParams::traffic_distribution == TRAFFIC_BIT_REVERSAL) packet = trafficBitReversal(); else if (GlobalParams::traffic_distribution == TRAFFIC_SHUFFLE) packet = trafficShuffle(); else if (GlobalParams::traffic_distribution == TRAFFIC_BUTTERFLY) packet = trafficButterfly(); else if (GlobalParams::traffic_distribution == TRAFFIC_LOCAL) packet = trafficLocal(); else assert(false); } } else { // Table based communication traffic if (never_transmit) return false; bool use_pir = (transmittedAtPreviousCycle == false); vector < pair < int, double > > dst_prob; double threshold = traffic_table->getCumulativePirPor(local_id, (int) now, use_pir, dst_prob); double prob = (double) rand() / RAND_MAX; shot = (prob < threshold); if (shot) { for (unsigned int i = 0; i < dst_prob.size(); i++) { if (prob < dst_prob[i].second) { packet.make(local_id, dst_prob[i].first, now, getRandomSize()); break; } } } } return shot; }
bool NoximProcessingElement::canShot(NoximPacket & packet) { bool shot; double threshold; if (NoximGlobalParams::traffic_distribution != TRAFFIC_TABLE_BASED) { if (!transmittedAtPreviousCycle) threshold = NoximGlobalParams::packet_injection_rate; else threshold = NoximGlobalParams::probability_of_retransmission; shot = (((double) rand()) / RAND_MAX < threshold); if (shot) { switch (NoximGlobalParams::traffic_distribution) { case TRAFFIC_OneDest: //New Traffic: all to one (dest_id=20) packet = trafficOneDest(); break; case TRAFFIC_RANDOM: packet = trafficRandom(); break; case TRAFFIC_TRANSPOSE1: packet = trafficTranspose1(); break; case TRAFFIC_TRANSPOSE2: packet = trafficTranspose2(); break; case TRAFFIC_BIT_REVERSAL: packet = trafficBitReversal(); break; case TRAFFIC_SHUFFLE: packet = trafficShuffle(); break; case TRAFFIC_BUTTERFLY: packet = trafficButterfly(); break; default: assert(false); } } } else { // Table based communication traffic if (never_transmit) return false; double now = sc_time_stamp().to_double() / 1000; bool use_pir = (transmittedAtPreviousCycle == false); vector < pair < int, double > > dst_prob; double threshold = traffic_table->getCumulativePirPor(local_id, (int) now, use_pir, dst_prob); double prob = (double) rand() / RAND_MAX; shot = (prob < threshold); if (shot) { for (unsigned int i = 0; i < dst_prob.size(); i++) { if (prob < dst_prob[i].second) { // generate a new packet packet.make(local_id, dst_prob[i].first, 0, now, //vinu: i_d_i = 0 ; fixed getRandomSize()); break; } } } } return shot; }