def paperOneTestDA(): factory = GridNetworkFactory(makeSimpleNode(),Queues) resultBP = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3) factory = GridNetworkFactory(SPNode,SPQueues) resultLQ2 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3) factory = GridNetworkFactory(makeMNode(4),Queues) resultLQ3 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3) labels = {'aveDelay':'Average end-to-end delay',\ 'aveDRate':'Delivery rate',\ 'aveHop':'Average hop count',\ 'aveBacklog':'Per-node queue lengths'} for item in ['aveDelay','aveDRate','aveHop','aveBacklog']: entry = [resultBP[key][item] for key in gobalRateList] py.plot(gobalRateList,entry,'-o',label ='bp') entry = [resultLQ2[key][item] for key in gobalRateList] py.plot(gobalRateList,entry,'-x',label ='K=10') entry = [resultLQ3[key][item] for key in gobalRateList] py.plot(gobalRateList,entry,'-p',label ='M=4') py.xlabel("$\lambda$") py.ylabel(labels[item]) py.grid py.legend(loc=0) py.savefig('PaperOneTest_differentAlgorithms_other_'+labels[item]) py.close()
def rateVsDelayTest(): for m in [0,2,6,10]: factory = GridNetworkFactory(makeMNode(m),Queues) result = mainProcessCtrl(factory=factory,rateList = gobalRateList,threadNum=3) py.plot(gobalRateList,result,label = 'm=%d'%m) py.legend(loc=0) py.show()
def paperOneTestSA(): factory = GridNetworkFactory(makeSimpleNode(), Queues) resultBP = mainProcessCtrl(factory=factory, rateList=gobalRateList, threadNum=3) factory = GridNetworkFactory(makeMNode(2), Queues) resultLQ3 = mainProcessCtrl(factory=factory, rateList=gobalRateList, threadNum=3) factory = GridNetworkFactory(makeMNode(4), Queues) resultLQ4 = mainProcessCtrl(factory=factory, rateList=gobalRateList, threadNum=3) factory = GridNetworkFactory(makeMNode(6), Queues) resultLQ5 = mainProcessCtrl(factory=factory, rateList=gobalRateList, threadNum=3) labels = {'aveDelay':'Average end-to-end delay',\ 'aveDRate':'Delivery rate',\ 'aveHop':'Average hop count',\ 'aveBacklog':'Per-node queue lengths'} for item in ['aveDelay', 'aveDRate', 'aveHop', 'aveBacklog']: entry = [resultBP[key][item] for key in gobalRateList] py.plot(gobalRateList, entry, '-o', label='bp') entry = [resultLQ3[key][item] for key in gobalRateList] py.plot(gobalRateList, entry, '-p', label='M=2') entry = [resultLQ4[key][item] for key in gobalRateList] py.plot(gobalRateList, entry, '-x', label='M=4') entry = [resultLQ5[key][item] for key in gobalRateList] py.plot(gobalRateList, entry, '-x', label='M=6') py.xlabel("$\lambda$") py.ylabel(labels[item]) py.legend(loc=0) py.savefig('PaperOneTest_sameAlgorithms_' + labels[item]) py.close()
def rateVsDelayTest(): for m in [0, 2, 6, 10]: factory = GridNetworkFactory(makeMNode(m), Queues) result = mainProcessCtrl(factory=factory, rateList=gobalRateList, threadNum=3) py.plot(gobalRateList, result, label='m=%d' % m) py.legend(loc=0) py.show()
def oneRoundDelay(step = 10000): injectRate = 0.9 factory = GridNetworkFactory(makeSimpleNode(),Queues) factory.constructNetwork(6,6)\ .setFlow(Flow((0,0),(0,5),injectRate))\ .setFlow(Flow((5,0),(5,5),injectRate))\ .setFlow(Flow((2,0),(3,5),injectRate)) network = factory.getNetwork() packetFactory = PacketFactory() simulator = \ Simulator(network,step,ConstLinkRateGenerator(1),packetFactory) simulator.run() #simulator.printNetwork() stat = simulator.getStaticsInfo() print stat['aveDelay'] packetPool = sorted(stat['packetPool'],key=lambda p: p.getID) py.subplot(211) py.vlines([p.getCreateTime() for p in packetPool],[1],[p.getDelay() for p in packetPool],'r') py.xlabel('Packet create time(bp with $\lambda$ = 0.9)') py.ylabel('delay') py.grid(True) injectRate = 0.9 factory = GridNetworkFactory(makeMNode(2),Queues) factory.constructNetwork(6,6)\ .setFlow(Flow((0,0),(0,5),injectRate))\ .setFlow(Flow((5,0),(5,5),injectRate))\ .setFlow(Flow((2,0),(3,5),injectRate)) network = factory.getNetwork() packetFactory = PacketFactory() simulator = \ Simulator(network,step,ConstLinkRateGenerator(1),packetFactory) simulator.run() #simulator.printNetwork() stat = simulator.getStaticsInfo() print stat['aveDelay'] packetPool = sorted(stat['packetPool'],key=lambda p: p.getID) py.subplot(212) py.vlines([p.getCreateTime() for p in packetPool],[1],[p.getDelay() for p in packetPool],'b') py.xlabel('Packet create time (m=2 with $\lambda$ = 0.9)') py.ylabel('delay') py.grid(True) py.savefig('packetDelayInOneRound_09') py.show()
def oneRoundDelay(step=10000): injectRate = 0.9 factory = GridNetworkFactory(makeSimpleNode(), Queues) factory.constructNetwork(6,6)\ .setFlow(Flow((0,0),(0,5),injectRate))\ .setFlow(Flow((5,0),(5,5),injectRate))\ .setFlow(Flow((2,0),(3,5),injectRate)) network = factory.getNetwork() packetFactory = PacketFactory() simulator = \ Simulator(network,step,ConstLinkRateGenerator(1),packetFactory) simulator.run() #simulator.printNetwork() stat = simulator.getStaticsInfo() print stat['aveDelay'] packetPool = sorted(stat['packetPool'], key=lambda p: p.getID) py.subplot(211) py.vlines([p.getCreateTime() for p in packetPool], [1], [p.getDelay() for p in packetPool], 'r') py.xlabel('Packet create time(bp with $\lambda$ = 0.9)') py.ylabel('delay') py.grid(True) injectRate = 0.9 factory = GridNetworkFactory(makeMNode(2), Queues) factory.constructNetwork(6,6)\ .setFlow(Flow((0,0),(0,5),injectRate))\ .setFlow(Flow((5,0),(5,5),injectRate))\ .setFlow(Flow((2,0),(3,5),injectRate)) network = factory.getNetwork() packetFactory = PacketFactory() simulator = \ Simulator(network,step,ConstLinkRateGenerator(1),packetFactory) simulator.run() #simulator.printNetwork() stat = simulator.getStaticsInfo() print stat['aveDelay'] packetPool = sorted(stat['packetPool'], key=lambda p: p.getID) py.subplot(212) py.vlines([p.getCreateTime() for p in packetPool], [1], [p.getDelay() for p in packetPool], 'b') py.xlabel('Packet create time (m=2 with $\lambda$ = 0.9)') py.ylabel('delay') py.grid(True) py.savefig('packetDelayInOneRound_09') py.show()
def OMNodeVSMNodeTest(): factory = GridNetworkFactory(makeOMNode(0),Queues) result = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3) py.plot(gobalRateList,result,label ='bp') for m in [2,4]: factory = GridNetworkFactory(makeOMNode(m),Queues) result = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3) py.plot(gobalRateList,result,'--',label ='om=%d'%m) factory = GridNetworkFactory(makeMNode(m),Queues) result = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3) py.plot(gobalRateList,result,label ='m=%d'%m) py.legend(loc=0) py.show()
def OrdTest(): injectRate = 0.5 factory = GridNetworkFactory(makeMNode(1), ShadowQueues) factory.constructNetwork(8,8)\ .setFlow(Flow((2,0),(2,7),injectRate),Flow((4,0),(4,7),injectRate),\ Flow((0,2),(7,2),injectRate),Flow((0,4),(7,4),injectRate),\ Flow((1,1),(5,1),injectRate),Flow((6,1),(6,6),injectRate),\ Flow((5,6),(1,6),injectRate),Flow((1,5),(1,2),injectRate)) network = factory.getNetwork() packetFactory = PacketFactory() simulator = \ Simulator(network,gobalMaxStep,ConstLinkRateGenerator(1),packetFactory) simulator.run() stat = simulator.getStaticsInfo() print stat
def OrdTest(): injectRate = 0.5 factory = GridNetworkFactory(makeMNode(1),ShadowQueues) factory.constructNetwork(8,8)\ .setFlow(Flow((2,0),(2,7),injectRate),Flow((4,0),(4,7),injectRate),\ Flow((0,2),(7,2),injectRate),Flow((0,4),(7,4),injectRate),\ Flow((1,1),(5,1),injectRate),Flow((6,1),(6,6),injectRate),\ Flow((5,6),(1,6),injectRate),Flow((1,5),(1,2),injectRate)) network = factory.getNetwork() packetFactory = PacketFactory() simulator = \ Simulator(network,gobalMaxStep,ConstLinkRateGenerator(1),packetFactory) simulator.run() stat = simulator.getStaticsInfo() print stat
def CounterTest(step=10000): injectRate = 0.9 factory = GridNetworkFactory(makeMNode(4), Queues) factory.constructNetwork(6,6)\ .setFlow(Flow((0,0),(0,5),injectRate))\ .setFlow(Flow((5,0),(5,5),injectRate))\ .setFlow(Flow((2,0),(3,5),injectRate)) network = factory.getNetwork() packetFactory = PacketFactory() simulator = \ Simulator(network,step,ConstLinkRateGenerator(1),packetFactory) simulator.run() #simulator.printNetwork() stat = simulator.getStaticsInfo() print stat
def CounterTest(step = 10000): injectRate = 0.9 factory = GridNetworkFactory(makeMNode(4),Queues) factory.constructNetwork(6,6)\ .setFlow(Flow((0,0),(0,5),injectRate))\ .setFlow(Flow((5,0),(5,5),injectRate))\ .setFlow(Flow((2,0),(3,5),injectRate)) network = factory.getNetwork() packetFactory = PacketFactory() simulator = \ Simulator(network,step,ConstLinkRateGenerator(1),packetFactory) simulator.run() #simulator.printNetwork() stat = simulator.getStaticsInfo() print stat
def newTest(): factory = GridNetworkFactory(makeSimpleNode(), Queues) resultBP = mainProcessCtrl(factory=factory, rateList=gobalRateList, threadNum=3) factory = GridNetworkFactory(makePNode(0.5), Queues) resultLQ = mainProcessCtrl(factory=factory, rateList=gobalRateList, threadNum=3) factory = GridNetworkFactory(SPNode, SPQueues) resultLQ2 = mainProcessCtrl(factory=factory, rateList=gobalRateList, threadNum=3) factory = GridNetworkFactory(makeMNode(2), Queues) resultLQ3 = mainProcessCtrl(factory=factory, rateList=gobalRateList, threadNum=3) #factory = GridNetworkFactory(makeCNode(1),Queues) #resultLQ4 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3) for item in ['aveDelay', 'aveDRate']: entry = [resultBP[key][item] for key in gobalRateList] py.plot(gobalRateList, entry, '-o', label='bp') entry = [resultLQ[key][item] for key in gobalRateList] py.plot(gobalRateList, entry, '-v', label='pl=0.5') entry = [resultLQ2[key][item] for key in gobalRateList] py.plot(gobalRateList, entry, '-x', label='sp=1') entry = [resultLQ3[key][item] for key in gobalRateList] py.plot(gobalRateList, entry, '-p', label='mm=2') #entry = [resultLQ4[key][item] for key in gobalRateList] #py.plot(gobalRateList,entry,'-+',label ='ol=1') py.legend(loc=0) py.savefig('newTest_' + item) py.close()
def OMNodeVSMNodeTest(): factory = GridNetworkFactory(makeOMNode(0), Queues) result = mainProcessCtrl(factory=factory, rateList=gobalRateList, threadNum=3) py.plot(gobalRateList, result, label='bp') for m in [2, 4]: factory = GridNetworkFactory(makeOMNode(m), Queues) result = mainProcessCtrl(factory=factory, rateList=gobalRateList, threadNum=3) py.plot(gobalRateList, result, '--', label='om=%d' % m) factory = GridNetworkFactory(makeMNode(m), Queues) result = mainProcessCtrl(factory=factory, rateList=gobalRateList, threadNum=3) py.plot(gobalRateList, result, label='m=%d' % m) py.legend(loc=0) py.show()
def newTest(): factory = GridNetworkFactory(makeSimpleNode(),Queues) resultBP = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3) factory = GridNetworkFactory(makePNode(0.5),Queues) resultLQ = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3) factory = GridNetworkFactory(SPNode,SPQueues) resultLQ2 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3) factory = GridNetworkFactory(makeMNode(2),Queues) resultLQ3 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3) #factory = GridNetworkFactory(makeCNode(1),Queues) #resultLQ4 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3) for item in ['aveDelay','aveDRate']: entry = [resultBP[key][item] for key in gobalRateList] py.plot(gobalRateList,entry,'-o',label ='bp') entry = [resultLQ[key][item] for key in gobalRateList] py.plot(gobalRateList,entry,'-v',label ='pl=0.5') entry = [resultLQ2[key][item] for key in gobalRateList] py.plot(gobalRateList,entry,'-x',label ='sp=1') entry = [resultLQ3[key][item] for key in gobalRateList] py.plot(gobalRateList,entry,'-p',label ='mm=2') #entry = [resultLQ4[key][item] for key in gobalRateList] #py.plot(gobalRateList,entry,'-+',label ='ol=1') py.legend(loc=0) py.savefig('newTest_'+item) py.close()
__metaclass__ = type import pylab as py from Flow import Flow from Simulator import Simulator from Packet import PacketFactory from Queues import Queues, ShadowQueues, SPQueues, NewQueues, TestQueues, TestSquareQueues from NetworkFactory import GridNetworkFactory from LinkRateGenerator import ConstLinkRateGenerator from Node import makeSimpleNode, makeMNode, makeOMNode, makeCNode, makePNode, SPNode, makeNewNode gobalRateList = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1] gobalGridNetworkFactory = GridNetworkFactory(makeMNode(1), Queues) gobalMaxStep = 10000 gobalFlow = 'Flow((2,0),(2,7),injectRate),Flow((4,0),(4,7),injectRate),\ Flow((0,2),(7,2),injectRate),Flow((0,4),(7,4),injectRate),\ Flow((1,1),(5,1),injectRate),Flow((6,1),(6,6),injectRate),\ Flow((5,6),(1,6),injectRate),Flow((1,5),(1,2),injectRate)' class DifferentInjectRateTest: def __init__(self,linkRate=1,maxStep=gobalMaxStep,injectRate=0.5,\ factory=gobalGridNetworkFactory): factory.constructNetwork(8,8)\ .setFlow(Flow((2,0),(2,7),injectRate),Flow((4,0),(4,7),injectRate), Flow((0,2),(7,2),injectRate),Flow((0,4),(7,4),injectRate), Flow((1,1),(5,1),injectRate),Flow((6,1),(6,6),injectRate) ,Flow((5,6),(1,6),injectRate),Flow((1,5),(1,2),injectRate)) network = factory.getNetwork() self.packetFactory = PacketFactory()
__metaclass__ = type import pylab as py from Flow import Flow from Simulator import Simulator from Packet import PacketFactory from Queues import Queues,ShadowQueues,SPQueues,NewQueues,TestQueues,TestSquareQueues from NetworkFactory import GridNetworkFactory from LinkRateGenerator import ConstLinkRateGenerator from Node import makeSimpleNode,makeMNode,makeOMNode,makeCNode,makePNode,SPNode,makeNewNode gobalRateList = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1] gobalGridNetworkFactory = GridNetworkFactory(makeMNode(1),Queues) gobalMaxStep = 10000 gobalFlow = 'Flow((2,0),(2,7),injectRate),Flow((4,0),(4,7),injectRate),\ Flow((0,2),(7,2),injectRate),Flow((0,4),(7,4),injectRate),\ Flow((1,1),(5,1),injectRate),Flow((6,1),(6,6),injectRate),\ Flow((5,6),(1,6),injectRate),Flow((1,5),(1,2),injectRate)' class DifferentInjectRateTest: def __init__(self,linkRate=1,maxStep=gobalMaxStep,injectRate=0.5,\ factory=gobalGridNetworkFactory): factory.constructNetwork(6,6)\ .setFlow(Flow((0,0),(0,5),injectRate))\ .setFlow(Flow((5,0),(5,5),injectRate))\ .setFlow(Flow((2,0),(3,5),injectRate)) network = factory.getNetwork() self.packetFactory = PacketFactory()