-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcycle_simulator.cpp
More file actions
32 lines (27 loc) · 881 Bytes
/
cycle_simulator.cpp
File metadata and controls
32 lines (27 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// Created by Mayank Parasar on 2020-04-12.
//
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main() {
srand(time(0));
pair<int, int> router_cycle; // { '--routers--'; '--cycle number--' }
int num_bufferless_router = 1;
router_cycle.first = num_bufferless_router; // allowing at most 5 routers to make packet bufferless
router_cycle.second = 0; // Cycle ID
for(int ii=0; ii < 1000; ii += (rand()%10)) {
cout << "Cycle: " << ii << "\t";
if ((router_cycle.second == ii) && (router_cycle.first > 0)) {
router_cycle.first--;
}
else {
// refill
router_cycle.first = num_bufferless_router;
router_cycle.second = ii;
}
cout << "{ " << router_cycle.first << " : " << router_cycle.second << " }" << endl;
}
return 0;
}