Program5/Sender.cpp
bool Sender::runner(vector<FCFS*> **items, int simTime){
	//Runs while the list is not empty
	//We know that Lab5 and Program5 both use simulation times of 1 sim. However, transmission time varies.
	int transmissionQueueLength = getTransmissionQueue().getLength();
	//Add packets if the queue is empty and there are still packets to be sent.
	if (transmissionQueueLength == 0){
		transmissionQueueLength += addPackets(simTime);
	}
	//Check to see if we have packets now.
	if(transmissionQueueLength != 0){
		cout << "Sender " << getID() << ":" << endl;
		if(DEBUG){
			cout << "Sender " << getID() << " is about to work on a packet at time " << simTime << endl;
		}
		//we decrement the current transmissionTime
		setCTT(getCTT() - 1);
		if (DEBUG){
			cout << "Current transmission time is " << getCTT() << endl;
		}
		//if the current transmission time is 0, bring to the back of the simulated propogation
		if(getCTT() <= 0){
			Link tempPtr = getNextInTQ();
			int nextInListToMove = tempPtr->getNextFCFS(); /*Gets the item where the packet is intended to move to.*/
			int distance = getDistanceFrom(nextInListToMove, items);
			tempPtr->setNextLoc(nextInListToMove);
			if(DEBUG){
				cout << tempPtr->getPacketID() << " has distance from its objective " << nextInListToMove << " " << distance << endl;
			}
			tempPtr->setPropogationTime(distance + 1); 
			tempPtr->setFinishTime(simTime + distance);
			sendToPQ(tempPtr);
			if (DEBUG){
				cout << "Moving " << tempPtr->getPacketID() <<" to Propogation Queue" << endl;
			}
			propogationSimulation(items, simTime);
		}
		//We have not reached the end of transmission.
		else if (getTransmissionQueue().getLength() != 0){
			propogationSimulation(items, simTime);
		}
		//only transmitting in the last case, whereupon nothing is done.
	}
	//Everything has been transmitted from the Sender, but not everything has yet arrived at the Mule/Receiver
	else if(getPropogationQueue().getLength() != 0){
			propogationSimulation(items, simTime);	
	}
	//The sender has no more packets to send. It sits idle for the remainder of the simulation.
	else {
		return false;
	}
	return true;
}
//Runs through one sim of a sender activity, provided the simulation time and a pointer to all of the objects for the sender.
Runs through one sim of a sender activity, provided the simulation time and a pointer to all of the objects for the sender.
Runs through one sim of a sender activity provided the simulation time and a pointer to all of the objects for the sender .
bool Sender::runner(vector<FCFS*> **items, int simTime){
	int transmissionQueueLength = getTransmissionQueue().getLength();
	if (transmissionQueueLength == 0){
		transmissionQueueLength += addPackets(simTime);
	}
	if(transmissionQueueLength != 0){
		cout << "Sender " << getID() << ":" << endl;
		if(DEBUG){
			cout << "Sender " << getID() << " is about to work on a packet at time " << simTime << endl;
		}
		setCTT(getCTT() - 1);
		if (DEBUG){
			cout << "Current transmission time is " << getCTT() << endl;
		}
		if(getCTT() <= 0){
			Link tempPtr = getNextInTQ();
			int nextInListToMove = tempPtr->getNextFCFS(); 
			int distance = getDistanceFrom(nextInListToMove, items);
			tempPtr->setNextLoc(nextInListToMove);
			if(DEBUG){
				cout << tempPtr->getPacketID() << " has distance from its objective " << nextInListToMove << " " << distance << endl;
			}
			tempPtr->setPropogationTime(distance + 1); 
			tempPtr->setFinishTime(simTime + distance);
			sendToPQ(tempPtr);
			if (DEBUG){
				cout << "Moving " << tempPtr->getPacketID() <<" to Propogation Queue" << endl;
			}
			propogationSimulation(items, simTime);
		}
		else if (getTransmissionQueue().getLength() != 0){
			propogationSimulation(items, simTime);
		}
	}
	else if(getPropogationQueue().getLength() != 0){
			propogationSimulation(items, simTime);	
	}
	else {
		return false;
	}
	return true;
}
bool Sender :: runner ( vector < FCFS * > * * items , int simTime ) { int transmissionQueueLength = getTransmissionQueue ( ) . getLength ( ) ; if ( transmissionQueueLength == 0 ) { transmissionQueueLength += addPackets ( simTime ) ; } if ( transmissionQueueLength != 0 ) { cout << " " << getID ( ) << " " << endl ; if ( DEBUG ) { cout << " " << getID ( ) << " " << simTime << endl ; } setCTT ( getCTT ( ) - 1 ) ; if ( DEBUG ) { cout << " " << getCTT ( ) << endl ; } if ( getCTT ( ) <= 0 ) { Link tempPtr = getNextInTQ ( ) ; int nextInListToMove = tempPtr -> getNextFCFS ( ) ; int distance = getDistanceFrom ( nextInListToMove , items ) ; tempPtr -> setNextLoc ( nextInListToMove ) ; if ( DEBUG ) { cout << tempPtr -> getPacketID ( ) << " " << nextInListToMove << " " << distance << endl ; } tempPtr -> setPropogationTime ( distance + 1 ) ; tempPtr -> setFinishTime ( simTime + distance ) ; sendToPQ ( tempPtr ) ; if ( DEBUG ) { cout << " " << tempPtr -> getPacketID ( ) << " " << endl ; } propogationSimulation ( items , simTime ) ; } else if ( getTransmissionQueue ( ) . getLength ( ) != 0 ) { propogationSimulation ( items , simTime ) ; } } else if ( getPropogationQueue ( ) . getLength ( ) != 0 ) { propogationSimulation ( items , simTime ) ; } else { return false ; } return true ; }
Runs through one sim of a sender activity, provided the simulation time and a pointer to all of the objects for the sender.
Runs through one sim of a sender activity provided the simulation time and a pointer to all of the objects for the sender .
//Runs while the list is not empty //We know that Lab5 and Program5 both use simulation times of 1 sim. However, transmission time varies. //Add packets if the queue is empty and there are still packets to be sent. //Check to see if we have packets now. //we decrement the current transmissionTime //if the current transmission time is 0, bring to the back of the simulated propogation /*Gets the item where the packet is intended to move to.*/ //We have not reached the end of transmission. //only transmitting in the last case, whereupon nothing is done. //Everything has been transmitted from the Sender, but not everything has yet arrived at the Mule/Receiver //The sender has no more packets to send. It sits idle for the remainder of the simulation.