cpu: Fix bug when reading in TrafficGen state transitions

This patch fixes a bug with the traffic generator which occured when
reading in the state transitions from the configuration
file. Previously, the size of the vector which stored the transitions
was used to get the size of the transitions matrix, rather than using
the number of states. Therefore, if there were more transitions than
states, i.e. some transitions has a probability of less than 1, then
the traffic generator would fatal when trying to check the
transitions.

This issue has been addressed by using the number of input states,
rather then the number of transitions.
This commit is contained in:
Sascha Bischoff
2013-05-30 12:54:07 -04:00
parent fc09bc8678
commit 04ccc79134

View File

@@ -315,9 +315,9 @@ TrafficGen::parseConfig()
}
// resize and populate state transition matrix
transitionMatrix.resize(transitions.size());
for (size_t i = 0; i < transitions.size(); i++) {
transitionMatrix[i].resize(transitions.size());
transitionMatrix.resize(states.size());
for (size_t i = 0; i < states.size(); i++) {
transitionMatrix[i].resize(states.size());
}
for (vector<Transition>::iterator t = transitions.begin();
@@ -327,9 +327,9 @@ TrafficGen::parseConfig()
// ensure the egress edges do not have a probability larger than
// one
for (size_t i = 0; i < transitions.size(); i++) {
for (size_t i = 0; i < states.size(); i++) {
double sum = 0;
for (size_t j = 0; j < transitions.size(); j++) {
for (size_t j = 0; j < states.size(); j++) {
sum += transitionMatrix[i][j];
}