├── .cproject ├── .gitignore ├── .nedexclusions ├── .nedfolders ├── .oppbuildspec ├── .project ├── .settings └── language.settings.xml ├── Makefile ├── README.md ├── simulations ├── .qtenvrc ├── omnetpp.ini ├── package.ned └── run └── src ├── ECSNeTpp ├── Makefile ├── builder ├── ECSBuilder.cc ├── ECSBuilder.h ├── ECSBuilder.ned ├── TaskBuilder.cc ├── TaskBuilder.h ├── package.ned └── taskbuilder.ned ├── common ├── SimulationController.cc ├── SimulationController.h ├── SimulationController.ned └── package.ned ├── configs ├── 1.xml ├── ec_sim_mirror.xml ├── etl_app_topology.txt ├── example-plan.xml ├── package.ned └── placement-plan-schema.xsd ├── cpu ├── CPUCore.cc ├── CPUCore.h ├── CPUCore.ned ├── package.ned └── scheduling │ ├── ICpuCoreScheduler.cc │ ├── ICpuCoreScheduler.h │ ├── ICpuCoreScheduler.ned │ ├── RoundRobinCpuCoreScheduler.cc │ ├── RoundRobinCpuCoreScheduler.h │ └── RoundRobinCpuCoreScheduler.ned ├── global ├── GlobalStreamingSupervisor.cc ├── GlobalStreamingSupervisor.h ├── GlobalStreamingSupervisor.ned └── package.ned ├── host ├── CloudNodeA.ned ├── RaspberryPiModel2B.ned ├── RaspberryPiModel3B.ned └── package.ned ├── model ├── operator │ ├── productivity │ │ ├── FixedProductivityDistribution.cc │ │ ├── FixedProductivityDistribution.h │ │ ├── FixedProductivityDistribution.ned │ │ ├── IOperatorProductivityDistribution.cc │ │ ├── IOperatorProductivityDistribution.h │ │ └── IOperatorProductivityDistribution.ned │ └── selectivity │ │ ├── FixedSelectivityDistribution.cc │ │ ├── FixedSelectivityDistribution.h │ │ ├── FixedSelectivityDistribution.ned │ │ ├── IOperatorSelectivityDistribution.cc │ │ ├── IOperatorSelectivityDistribution.h │ │ └── IOperatorSelectivityDistribution.ned ├── package.ned └── source │ ├── eventrate │ ├── FixedSourceEventRateDistribution.cc │ ├── FixedSourceEventRateDistribution.h │ ├── FixedSourceEventRateDistribution.ned │ ├── ISourceEventRateDistribution.cc │ ├── ISourceEventRateDistribution.h │ ├── ISourceEventRateDistribution.ned │ ├── NormallyDistributedSourceEventRate.cc │ ├── NormallyDistributedSourceEventRate.h │ ├── NormallyDistributedSourceEventRate.ned │ ├── UniformSourceEventRateDistribution.cc │ ├── UniformSourceEventRateDistribution.h │ └── UniformSourceEventRateDistribution.ned │ └── msgsize │ ├── FixedMessageSizeDistribution.cc │ ├── FixedMessageSizeDistribution.h │ ├── FixedMessageSizeDistribution.ned │ ├── IMessageSizeDistribution.cc │ ├── IMessageSizeDistribution.h │ └── IMessageSizeDistribution.ned ├── msg ├── Ack.msg ├── Ack_m.cc ├── Ack_m.h ├── StreamingMessage.msg ├── StreamingMessage_m.cc ├── StreamingMessage_m.h └── package.ned ├── networks ├── .qtenvrc ├── package.ned └── simpleedgecloudenvironment.ned ├── package.ned ├── power ├── States.h ├── consumer │ ├── CPUPowerConsumer.cc │ ├── CPUPowerConsumer.h │ ├── CPUPowerConsumer.ned │ ├── NetworkPowerConsumer.cc │ ├── NetworkPowerConsumer.h │ ├── NetworkPowerConsumer.ned │ └── package.ned ├── package.ned └── storage │ ├── IdealNodeEnergyStorage.cc │ ├── IdealNodeEnergyStorage.h │ └── IdealNodeEnergyStorage.ned └── stask ├── Acker.cc ├── Acker.ned ├── ISTask.cc ├── ISTask.h ├── ISTask.ned ├── StreamingOperator.cc ├── StreamingOperator.h ├── StreamingOperator.ned ├── StreamingSink.cc ├── StreamingSink.h ├── StreamingSink.ned ├── StreamingSource.cc ├── StreamingSource.h ├── StreamingSource.ned ├── StreamingSupervisor.cc ├── StreamingSupervisor.h ├── StreamingSupervisor.ned └── package.ned /.cproject: -------------------------------------------------------------------------------- 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 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.[oa] 2 | *~ 3 | *.swp 4 | out/ 5 | simulations/runexpr.sh 6 | simulations/Makefile* 7 | src/ECSNeT 8 | simulations/*.csv 9 | simulations/results/ 10 | simulations/results/export/ 11 | *.anf 12 | TestEdgeCloud 13 | -------------------------------------------------------------------------------- /.nedexclusions: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sedgecloud/ECSNeTpp/edcd614b722ab77f1854ecf2901c53d81a59664d/.nedexclusions -------------------------------------------------------------------------------- /.nedfolders: -------------------------------------------------------------------------------- 1 | src 2 | simulations 3 | -------------------------------------------------------------------------------- /.oppbuildspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ECSNeTpp 4 | 5 | 6 | inet 7 | 8 | 9 | 10 | org.omnetpp.cdt.MakefileBuilder 11 | 12 | 13 | 14 | 15 | org.omnetpp.scave.builder.vectorfileindexer 16 | 17 | 18 | 19 | 20 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 21 | clean,full,incremental, 22 | 23 | 24 | 25 | 26 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 27 | full,incremental, 28 | 29 | 30 | 31 | 32 | 33 | org.eclipse.cdt.core.cnature 34 | org.eclipse.cdt.core.ccnature 35 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 36 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 37 | org.omnetpp.main.omnetppnature 38 | 39 | 40 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: checkmakefiles 2 | cd src && $(MAKE) 3 | 4 | clean: checkmakefiles 5 | cd src && $(MAKE) clean 6 | 7 | cleanall: checkmakefiles 8 | cd src && $(MAKE) MODE=release clean 9 | cd src && $(MAKE) MODE=debug clean 10 | rm -f src/Makefile 11 | 12 | makefiles: 13 | cd src && opp_makemake -f --deep 14 | 15 | checkmakefiles: 16 | @if [ ! -f src/Makefile ]; then \ 17 | echo; \ 18 | echo '======================================================================='; \ 19 | echo 'src/Makefile does not exist. Please use "make makefiles" to generate it!'; \ 20 | echo '======================================================================='; \ 21 | echo; \ 22 | exit 1; \ 23 | fi 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ECSNeT++ 2 | ECSNeT++ is a simulation toolkit for simulating the execution of 3 | Distributed Stream Processing applications on Edge anc Cloud Computing environments. 4 | ECSNeT++ is implemented using the [OMNeT++](https://omnetpp.org/) and the [INET framework](https://inet.omnetpp.org/). 5 | 6 | For more information please contact [gamarasinghe@student.unimelb.edu.au](mailto:gamarasinghe@student.unimelb.edu.au). 7 | 8 | # Dependencies 9 | * [INET Framework 3.6.0](https://inet.omnetpp.org/) 10 | * [TinyXML2](http://www.grinninglizard.com/tinyxml2/) 11 | 12 | # Building the project 13 | 14 | After cloning the repository run ```make makefiles``` followed by ```make```. 15 | 16 | # Running the example 17 | 18 | 1. Set up OMNeT++ as instructed in [installation guide](https://doc.omnetpp.org/omnetpp/InstallGuide.pdf). 19 | 2. Set up the [INET framework](https://inet.omnetpp.org/Installation.html). 20 | 3. Import ECSNeT++ to the OMNeT++ IDE. 21 | 4. Browse to ```Project Properties -> Project References``` and add ```inet``` project as reference. 22 | 5. Build the project. 23 | 6. Run ```omnetpp.ini``` file as an OMNeT++ simulation. 24 | 7. Select ```ETL-Pi3B-1-Plan``` and run the simulation and observe the ```simulation/results``` directory for simulation measurements. 25 | 26 | # Extending the project 27 | 28 | ## Host devices 29 | 30 | ```WirelessHost``` module or the ```StandardHost``` module of the INET framework can be extended to build either a IEEE 802.11 wireless enabled device or a Ethernet enabled host device respectively. 31 | See ```src/host``` package for examples. 32 | 33 | ### Network Support 34 | We have created a [LTE plugin](https://github.com/sedgecloud/ECSNeT-LTE-Plugin) for ECSNeT++ to add LTE User Plane connectivity to the networking model using the [SimuLTE simulation tool](http://simulte.com/index.html). 35 | An example is available in the github project of the plugin. 36 | 37 | Similarly, other network models can also be adopted in to ECSNeT++ by creating hosts that use the network model. 38 | 39 | ## Distributed Stream Processing application 40 | 41 | ```StreamingSource```, ```StreamingOperator```, ```StreamingSink``` module are represent each Source, Operator and Sink in the topology. ECSNeT++ 42 | expects an adjacency matrix of the application topology (See ```configs/etl_app_topology.txt```) and a placement plan 43 | (See ```configs/1.xml```). 44 | 45 | An example placement plan is shown below. The XML schema for generating the placement plan is available [here](https://github.com/sedgecloud/ECSNeTpp/blob/master/src/configs/placement-plan-schema.xsd). 46 | 47 | ```xml 48 | 49 | 50 | 51 | danio-2 52 | 0..49 53 | 54 | 55 | source 56 | source 57 | ecsnetpp.stask.StreamingSource 58 | 59 | 33406899 60 | 61 | 6880 62 | 63 | FixedSourceEventRateDistribution 64 | ecsnetpp.model.source.eventrate.FixedSourceEventRateDistribution 65 | 66 | 67 | 68 | parser 69 | operator 70 | ecsnetpp.stask.StreamingOperator 71 | 72 | FixedSelectivityDistribution 73 | ecsnetpp.model.operator.selectivity.FixedSelectivityDistribution 74 | 75 | 2 76 | 77 | 78 | . 79 | . 80 | . 81 | 82 | 83 | 84 | 85 | stargazer3 86 | 0 87 | 88 | . 89 | . 90 | . 91 | 92 | 93 | 94 | ``` 95 | 96 | ### Source Characteristics 97 | 98 | ##### Source Event Rate 99 | The `ecsnetpp.model.source.eventrate.ISourceEventRateDistribution` interface should be extended to implement different source event rate distributions. 100 | See `ecsnetpp.model.source.eventrate.FixedSourceEventRateDistribution` module for an example. 101 | 102 | #### Source Message Size 103 | The `ecsnetpp.model.source.msgsize.IMessageSizeDistribution` interface should be extended to implement different source message size distributions. 104 | See `ecsnetpp.model.source.msgsize.FixedMessageSizeDistribution` module for an example. 105 | 106 | ### Operator Characteristics 107 | 108 | #### Operator Selectivity Ratio 109 | The `ecsnetpp.model.operator.selectivity.IOperatorSelectivityDistribution` interface should be extended to implement different operator selectivity ratio distributions. 110 | See `ecsnetpp.model.operator.selectivity.FixedSelectivityDistribution` module for an example. 111 | 112 | #### Operator Productivity Ratio 113 | The `ecsnetpp.model.operator.productivity.IOperatorProductivityDistribution` interface should be extended to implement different operator productivity ratio distributions. 114 | See `ecsnetpp.model.operator.productivity.FixedProductivityDistribution` module for an example. 115 | 116 | ## CPU Scheduling 117 | 118 | ### Changing the behaviour of the CPU scheduler 119 | We have implemented a Round Robin Scheduler for selecting the CPU core for processing a streaming event at any task. It is possible to implement other scheduling strategies by implementing the `ecsnetpp.cpu.scheduling.ICpuCoreScheduler` interface. 120 | The scheduler can be set at the host using the `cpuCoreSchedulerType` configuration (See one of the host devices for an example use of `ecsnetpp.cpu.scheduling.RoundRobinCpuCoreScheduler` as the core scheduler). 121 | -------------------------------------------------------------------------------- /simulations/.qtenvrc: -------------------------------------------------------------------------------- 1 | [General] 2 | last-configname=ETL-Pi3B-1-Plan 3 | last-runnumber=0 4 | -------------------------------------------------------------------------------- /simulations/omnetpp.ini: -------------------------------------------------------------------------------- 1 | [General] 2 | #debug-on-errors=true 3 | #result-dir = /mnt/results/ 4 | print-undisposed = false 5 | 6 | [Config defaultplan] 7 | description = Mirror of the real setup on the simulator 8 | #sim-time-limit = 200s 9 | warmup-period = 5s 10 | repeat = 10 11 | seed-set = ${repetition} 12 | #record-eventlog = true 13 | 14 | **.result-recording-modes = all 15 | **.vector-record-eventnumbers = false 16 | **.endToEndDelay:vector.vector-recording = true 17 | **.endToEndDelay:stats.scalar-recording = true 18 | **.processingLatency:vector.vector-recording = true 19 | **.transmissionLatency:vector.vector-recording = true 20 | **.totalLatency:vector.vector-recording = true 21 | #**.rcvdStreamingMsgsStat:vector.vector-recording = true 22 | **.throughput:vector.vector-recording = true 23 | **.rcvdStreamingMsgsCount:vector.vector-recording = true 24 | #**.receivedStreamingMsgsSeqNo:vector.vector-recording = true 25 | #**.energyConsumption:vector.vector-recording = true 26 | **.energyConsumption:last.scalar-recording = true 27 | #**.powerConsumption:vector.vector-recording = true 28 | **.powerConsumption:last.scalar-recording = true 29 | **.idleEnergyConsumption:last.scalar-recording = true 30 | #**.idlePowerConsumption:last.scalar-recording = true 31 | **.cpuEnergyConsumption:last.scalar-recording = true 32 | **.networkEnergyConsumption:last.scalar-recording = true 33 | **.residualCapacity:last.vector-recording = true 34 | #**.cpuPowerConsumption:vector.vector-recording = true 35 | #**.networkPowerConsumption:vector.vector-recording = true 36 | #**.*.vector-recording = false 37 | **.scalar-recording = false 38 | **.vector-recording = false 39 | 40 | **.hasStatus = true 41 | 42 | *.stargazer3.perCoreFreq = ${freq=1200000000}Hz 43 | #*.stargazer3.cores = ${cores=2 ! freq} 44 | *.stargazer3.cores = 1 45 | *.stargazer3.threadsPerCore = 1 46 | *.pi3Bs[*].cores = 1 47 | *.pi3Bs[*].cpuCore[*].parallelisationFactor = 1 48 | *.pi2Bs[*].cores = 1 49 | 50 | # if enabled stop event generation after "packetCountLimit" events 51 | #*.simController.enableLimitFromSource = true 52 | #*.simController.packetCountLimit = ${pktcnt=100000, 1000000} 53 | 54 | # bitrates should be compatible with Ieee80211ModeSet 55 | # "inet/physicallayer/ieee80211/mode/Ieee80211ModeSet.h" 56 | #*.area1AP1.wlan[*].bitrate = 6Mbps 57 | #*.pi2Bs[*].wlan[*].bitrate = 6Mbps 58 | #*.pi3Bs[*].wlan[*].bitrate = 6Mbps 59 | **.wlan*.opMode = "b" 60 | **.wlan*.bitrate = 5.5Mbps 61 | 62 | *.pi3Bs[*].wlan[*].mgmtType = "Ieee80211MgmtSTA" 63 | *.pi3Bs[*].wlan[*].mac.mtu = 1500B 64 | **.wlan[*].radioType = "Ieee80211ScalarRadio" 65 | **.wlan[*].macType = "Ieee80211CompatibleMac" 66 | **.mac.address = "auto" 67 | **.mac.maxQueueSize = 1000 68 | **.mac.rtsThresholdBytes = 3000B 69 | **.wlan[*].mac.retryLimit = 7 70 | **.wlan[*].mac.cwMinData = 31 71 | **.wlan[*].mac.rateControlType = "AARFRateControl" 72 | 73 | #*.*.wlan[*].bitrate = 54Mbps 74 | #*.*.wlan[*].radio.transmitter.power = 10mW 75 | #*.area1AP1.numRadios = 50 76 | 77 | **.wlan[*].radio.transmitter.power = 300mW 78 | #**.wlan[*].radio.transmitter.bitrate = 6Mbps 79 | #**.wlan[*].radio.transmitter.headerBitLength = 100b 80 | #**.wlan[*].radio.transmitter.carrierFrequency = 2.4GHz 81 | #**.wlan[*].radio.transmitter.bandwidth = 2MHz 82 | **.wlan[*].radio.receiver.sensitivity = -65dBm 83 | **.wlan[*].radio.receiver.snirThreshold = 4dB 84 | 85 | **.wlan[*].radio.carrierFrequency = 2.4GHz 86 | #**.wlan[*].radio.receiver.energyDetection = -40dBm 87 | #**.wlan[*].radio.receiver.channelSpacing = 20MHz 88 | **.wlan[*].radio.bandwidth = 20MHz 89 | 90 | #*.albacore5.multicastForwarding = true 91 | # wifi accesspoint setup 92 | *.area1AP1.wlan[*].mgmt.ssid = "rpi-network" 93 | *.pi2Bs[0..24].wlan[*].agent.default_ssid = "rpi-network" 94 | *.pi3Bs[0..24].wlan[*].agent.default_ssid = "rpi-network" 95 | # enable UDP 96 | #*.pi3Bs[*].hasUdp = true 97 | #*.pi2Bs[*].hasUdp = true 98 | #*.piBs[*].hasUdp = true 99 | #*.cloudAs[*].hasUdp = true 100 | #*.globalSupervisorNode.hasUdp = true 101 | #*.globalSupervisorNode.udpType = "UDP" 102 | #*.pi3Bs[*].udpType = "UDP" 103 | #*.pi2Bs[*].udpType = "UDP" 104 | #*.piBs[*].udpType = "UDP" 105 | #*.cloudAs[*].udpType = "UDP" 106 | 107 | # enable or disable a apache-storm-nimbus like global supervisor for routing messages 108 | *.hasGlobalSupervisor = false 109 | 110 | # enable TCP 111 | *.pi3Bs[*].hasTcp = true 112 | *.pi2Bs[*].hasTcp = true 113 | *.stargazer3.hasTcp = true 114 | *.pi3Bs[*].tcpType = "TCP" 115 | *.pi2Bs[*].tcpType = "TCP" 116 | *.stargazer3.tcpType = "TCP" 117 | 118 | #*.piBs[*].wlan[*].typename = "IdealWirelessNic" 119 | #*.piBs[*].wlan[*].mac.useAck = false 120 | #*.piBs[*].wlan[*].mac.fullDuplex = false 121 | #*.piBs[*].wlan[*].radio.transmitter.communicationRange = 500m 122 | *.pi2Bs[*].wlan[*].macType = "Ieee80211Mac" 123 | *.pi3Bs[*].wlan[*].macType = "Ieee80211Mac" 124 | 125 | #Task builder parameters 126 | #*.taskbuilder.allocationPlanFile = "../src/configs/placement/test.xml" 127 | #*.taskbuilder.dspTopologyFile = "../src/configs/linear/linear_2.txt" 128 | 129 | # mobility parameters 130 | *.pi3Bs[*].mobilityType = "StationaryMobility" 131 | *.pi3Bs[*].mobility.constraintAreaMinX = 300m 132 | *.pi3Bs[*].mobility.constraintAreaMinY = 400m 133 | *.pi3Bs[*].mobility.constraintAreaMinZ = 0m 134 | *.pi3Bs[*].mobility.constraintAreaMaxX = 350m 135 | *.pi3Bs[*].mobility.constraintAreaMaxY = 450m 136 | *.pi3Bs[*].mobility.constraintAreaMaxZ = 0m 137 | 138 | *.pi2Bs[*].mobilityType = "StationaryMobility" 139 | *.pi2Bs[*].mobility.constraintAreaMinX = 350m 140 | *.pi2Bs[*].mobility.constraintAreaMinY = 400m 141 | *.pi2Bs[*].mobility.constraintAreaMinZ = 0m 142 | *.pi2Bs[*].mobility.constraintAreaMaxX = 400m 143 | *.pi2Bs[*].mobility.constraintAreaMaxY = 450m 144 | *.pi2Bs[*].mobility.constraintAreaMaxZ = 0m 145 | 146 | # Network Configurator settings 147 | *.configurator.config = xmldoc("../src/configs/ec_sim_mirror.xml") 148 | *.configurator.dumpAddresses = true 149 | *.configurator.dumpTopology = true 150 | *.configurator.dumpLinks = true 151 | *.configurator.dumpRoutes = true 152 | # configure the cloud multicast address which will be used by all the edge 153 | # devices to multicast the events to the cloud. 154 | #*.cloudMulticastAddress = "225.0.0.1" 155 | *.stargazer3.supervisor.joinMulticastGroup = false 156 | *.cloudAddress = "10.0.3.1" 157 | 158 | # Power parameters - rpi 2 159 | *.pi2Bs[*].energyStore.idlePowerConsumption = 1316mW 160 | *.pi2Bs[*].networkPowerConsumer.offPowerConsumption = 0W 161 | *.pi2Bs[*].networkPowerConsumer.sleepPowerConsumption = 899mW 162 | *.pi2Bs[*].networkPowerConsumer.switchingPowerConsumption = uniform(10mW, 100mW) 163 | *.pi2Bs[*].networkPowerConsumer.receiverIdlePowerConsumption = 899mW 164 | *.pi2Bs[*].networkPowerConsumer.receiverReceivingPowerConsumption = 516.16mW + this.receiverIdlePowerConsumption 165 | *.pi2Bs[*].networkPowerConsumer.transmitterIdlePowerConsumption = 899mW 166 | *.pi2Bs[*].networkPowerConsumer.transmitterTransmittingPowerConsumption = 7906.4mW + this.receiverIdlePowerConsumption 167 | #*.pi2Bs[*].energyConsumerType = "CPUEpEnergyConsumer" 168 | *.pi2Bs[*].cpuPowerConsumer.cpuPowerConsumptionScalar = 0.409 169 | *.pi2Bs[*].cpuPowerConsumer.idlePowerConsumption = uniform(0mW, 100mW) 170 | *.pi2Bs[*].cpuPowerConsumer.cpuBusyUtilisation = 0.95 171 | *.pi2Bs[*].cpuPowerConsumer.cpuIdleUtilisation = 0.05 172 | 173 | # Power parameters - rpi 3 174 | *.pi3Bs[*].energyStore.idlePowerConsumption = 1488mW 175 | *.pi3Bs[*].networkPowerConsumer.offPowerConsumption = 0W 176 | *.pi3Bs[*].networkPowerConsumer.sleepPowerConsumption = 764.5mW 177 | *.pi3Bs[*].networkPowerConsumer.switchingPowerConsumption = uniform(10mW, 100mW) 178 | *.pi3Bs[*].networkPowerConsumer.receiverIdlePowerConsumption = 764.5mW 179 | *.pi3Bs[*].networkPowerConsumer.receiverReceivingPowerConsumption = 57.6mW + this.receiverIdlePowerConsumption 180 | *.pi3Bs[*].networkPowerConsumer.transmitterIdlePowerConsumption = 764.5mW 181 | *.pi3Bs[*].networkPowerConsumer.transmitterTransmittingPowerConsumption = -60.069mW + this.receiverIdlePowerConsumption 182 | #*.pi3Bs[*].energyConsumerType = "CPUEpEnergyConsumer" 183 | *.pi3Bs[*].cpuPowerConsumer.cpuPowerConsumptionScalar = 0.6191 184 | *.pi3Bs[*].cpuPowerConsumer.idlePowerConsumption = uniform(0mW, 100mW) 185 | *.pi3Bs[*].cpuPowerConsumer.cpuBusyUtilisation = 0.95 186 | *.pi3Bs[*].cpuPowerConsumer.cpuIdleUtilisation = 0.05 187 | 188 | # Energy storage parameters 189 | *.pi2Bs[*].energyStore.nominalCapacity = 1080J 190 | *.pi2Bs[*].energyStore.initialCapacity = 1080J 191 | *.pi3Bs[*].energyStore.nominalCapacity = 1080J 192 | *.pi3Bs[*].energyStore.initialCapacity = 1080J 193 | 194 | # Visualizer settings 195 | *.visualizer.interfaceTableVisualizer.displayInterfaceTables = true 196 | *.visualizer.interfaceTableVisualizer.nodeFilter = "not (*switch* or *Switch* or *AP*)" 197 | *.visualizer.mediumVisualizer.displayCommunicationRanges = true 198 | 199 | # Set up the acker 200 | *.ackersEnabled = false 201 | *.stargazer3.hasAcker = false 202 | *.stargazer3.ackerAddress = "10.0.2.1" 203 | *.pi3Bs[*].ackerAddress = "10.0.2.1" 204 | *.pi2Bs[*].ackerAddress = "10.0.2.1" 205 | 206 | *.pi2Bs[*].networkLayer.arpType = "GlobalARP" 207 | *.pi3Bs[*].networkLayer.arpType = "GlobalARP" 208 | *.stargazer3.networkLayer.arpType = "GlobalARP" 209 | *.albacore5.networkLayer.arpType = "GlobalARP" 210 | 211 | *.pi3Bs[*].fixedSourceEventRate = 30 212 | *.simController.packetCountLimit = 100000 213 | ###################################################################################### 214 | 215 | [Config ETL-Pi3B-1-Plan] 216 | description = Cloud-only execution - Linear topology 217 | network = ecsnetpp.networks.SimpleEdgeCloudEnvironment 218 | extends = defaultplan 219 | 220 | **.numPiModel3Bs = 1 221 | **.numPiModel2Bs = 0 222 | 223 | *.eToCDatarate = 1Gbps 224 | #*.eToCDelayMean = 8.5599382104ms 225 | *.eToCDelayMean = 8.5599382104ms 226 | 227 | *.simController.enableLimitFromSource = false 228 | #*.simController.packetCountLimit = 100000 229 | *.taskbuilder.allocationPlanFile = "../src/configs/1.xml" 230 | *.taskbuilder.dspTopologyFile = "../src/configs/etl_app_topology.txt" 231 | 232 | ###################################################################################### 233 | -------------------------------------------------------------------------------- /simulations/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp.simulations; 2 | 3 | @license(LGPL); 4 | -------------------------------------------------------------------------------- /simulations/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd `dirname $0` 3 | ../src/ecsnetpp -n .:../src $* 4 | # for shared lib, use: opp_run -l ../src/ecsnetpp -n .:../src $* 5 | -------------------------------------------------------------------------------- /src/ECSNeTpp: -------------------------------------------------------------------------------- 1 | ../out/gcc-debug/src/ECSNeTpp -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # OMNeT++/OMNEST Makefile for ECSNeTpp 3 | # 4 | # This file was generated with the command: 5 | # opp_makemake -f --deep -KINET_PROJ=/home/gayashan/projects/research/omnetpp/inet -DINET_IMPORT -I$$\(INET_PROJ\)/src -L$$\(INET_PROJ\)/out/$$\(CONFIGNAME\)/src -lINET 6 | # 7 | 8 | # Name of target to be created (-o option) 9 | TARGET = ECSNeTpp$(EXE_SUFFIX) 10 | 11 | # User interface (uncomment one) (-u option) 12 | USERIF_LIBS = $(ALL_ENV_LIBS) # that is, $(TKENV_LIBS) $(QTENV_LIBS) $(CMDENV_LIBS) 13 | #USERIF_LIBS = $(CMDENV_LIBS) 14 | #USERIF_LIBS = $(TKENV_LIBS) 15 | #USERIF_LIBS = $(QTENV_LIBS) 16 | 17 | # C++ include paths (with -I) 18 | INCLUDE_PATH = -I$(INET_PROJ)/src 19 | 20 | # Additional object and library files to link with 21 | EXTRA_OBJS = 22 | 23 | # Additional libraries (-L, -l options) 24 | LIBS = $(LDFLAG_LIBPATH)$(INET_PROJ)/out/$(CONFIGNAME)/src -lINET 25 | 26 | # Output directory 27 | PROJECT_OUTPUT_DIR = ../out 28 | PROJECTRELATIVE_PATH = src 29 | O = $(PROJECT_OUTPUT_DIR)/$(CONFIGNAME)/$(PROJECTRELATIVE_PATH) 30 | 31 | # Object files for local .cc, .msg and .sm files 32 | OBJS = \ 33 | $O/builder/ECSBuilder.o \ 34 | $O/builder/TaskBuilder.o \ 35 | $O/common/SimulationController.o \ 36 | $O/cpu/CPUCore.o \ 37 | $O/cpu/scheduling/ICpuCoreScheduler.o \ 38 | $O/cpu/scheduling/RoundRobinCpuCoreScheduler.o \ 39 | $O/global/GlobalStreamingSupervisor.o \ 40 | $O/model/operator/productivity/FixedProductivityDistribution.o \ 41 | $O/model/operator/productivity/IOperatorProductivityDistribution.o \ 42 | $O/model/operator/selectivity/FixedSelectivityDistribution.o \ 43 | $O/model/operator/selectivity/IOperatorSelectivityDistribution.o \ 44 | $O/model/source/eventrate/FixedSourceEventRateDistribution.o \ 45 | $O/model/source/eventrate/ISourceEventRateDistribution.o \ 46 | $O/model/source/eventrate/NormallyDistributedSourceEventRate.o \ 47 | $O/model/source/eventrate/UniformSourceEventRateDistribution.o \ 48 | $O/model/source/msgsize/FixedMessageSizeDistribution.o \ 49 | $O/model/source/msgsize/IMessageSizeDistribution.o \ 50 | $O/power/consumer/CPUPowerConsumer.o \ 51 | $O/power/consumer/NetworkPowerConsumer.o \ 52 | $O/power/storage/IdealNodeEnergyStorage.o \ 53 | $O/stask/Acker.o \ 54 | $O/stask/ISTask.o \ 55 | $O/stask/StreamingOperator.o \ 56 | $O/stask/StreamingSink.o \ 57 | $O/stask/StreamingSource.o \ 58 | $O/stask/StreamingSupervisor.o \ 59 | $O/msg/Ack_m.o \ 60 | $O/msg/StreamingMessage_m.o 61 | 62 | # Message files 63 | MSGFILES = \ 64 | msg/Ack.msg \ 65 | msg/StreamingMessage.msg 66 | 67 | # SM files 68 | SMFILES = 69 | 70 | # Other makefile variables (-K) 71 | INET_PROJ=/home/gayashan/projects/research/omnetpp/inet 72 | 73 | #------------------------------------------------------------------------------ 74 | 75 | # Pull in OMNeT++ configuration (Makefile.inc) 76 | 77 | ifneq ("$(OMNETPP_CONFIGFILE)","") 78 | CONFIGFILE = $(OMNETPP_CONFIGFILE) 79 | else 80 | ifneq ("$(OMNETPP_ROOT)","") 81 | CONFIGFILE = $(OMNETPP_ROOT)/Makefile.inc 82 | else 83 | CONFIGFILE = $(shell opp_configfilepath) 84 | endif 85 | endif 86 | 87 | ifeq ("$(wildcard $(CONFIGFILE))","") 88 | $(error Config file '$(CONFIGFILE)' does not exist -- add the OMNeT++ bin directory to the path so that opp_configfilepath can be found, or set the OMNETPP_CONFIGFILE variable to point to Makefile.inc) 89 | endif 90 | 91 | include $(CONFIGFILE) 92 | 93 | # Simulation kernel and user interface libraries 94 | OMNETPP_LIBS = $(OPPMAIN_LIB) $(USERIF_LIBS) $(KERNEL_LIBS) $(SYS_LIBS) 95 | ifneq ($(TOOLCHAIN_NAME),clangc2) 96 | LIBS += -Wl,-rpath,$(abspath $(INET_PROJ)/out/$(CONFIGNAME)/src) 97 | endif 98 | 99 | COPTS = $(CFLAGS) $(IMPORT_DEFINES) -DINET_IMPORT $(INCLUDE_PATH) -I$(OMNETPP_INCL_DIR) 100 | MSGCOPTS = $(INCLUDE_PATH) 101 | SMCOPTS = 102 | 103 | # we want to recompile everything if COPTS changes, 104 | # so we store COPTS into $COPTS_FILE and have object 105 | # files depend on it (except when "make depend" was called) 106 | COPTS_FILE = $O/.last-copts 107 | ifneq ("$(COPTS)","$(shell cat $(COPTS_FILE) 2>/dev/null || echo '')") 108 | $(shell $(MKPATH) "$O" && echo "$(COPTS)" >$(COPTS_FILE)) 109 | endif 110 | 111 | #------------------------------------------------------------------------------ 112 | # User-supplied makefile fragment(s) 113 | # >>> 114 | # <<< 115 | #------------------------------------------------------------------------------ 116 | 117 | # Main target 118 | all: $O/$(TARGET) 119 | $(Q)$(LN) $O/$(TARGET) . 120 | 121 | $O/$(TARGET): $(OBJS) $(wildcard $(EXTRA_OBJS)) Makefile $(CONFIGFILE) 122 | @$(MKPATH) $O 123 | @echo Creating executable: $@ 124 | $(Q)$(CXX) $(LDFLAGS) -o $O/$(TARGET) $(OBJS) $(EXTRA_OBJS) $(AS_NEEDED_OFF) $(WHOLE_ARCHIVE_ON) $(LIBS) $(WHOLE_ARCHIVE_OFF) $(OMNETPP_LIBS) 125 | 126 | .PHONY: all clean cleanall depend msgheaders smheaders 127 | 128 | .SUFFIXES: .cc 129 | 130 | $O/%.o: %.cc $(COPTS_FILE) | msgheaders smheaders 131 | @$(MKPATH) $(dir $@) 132 | $(qecho) "$<" 133 | $(Q)$(CXX) -c $(CXXFLAGS) $(COPTS) -o $@ $< 134 | 135 | %_m.cc %_m.h: %.msg 136 | $(qecho) MSGC: $< 137 | $(Q)$(MSGC) -s _m.cc $(MSGCOPTS) $? 138 | 139 | %_sm.cc %_sm.h: %.sm 140 | $(qecho) SMC: $< 141 | $(Q)$(SMC) -c++ -suffix cc $(SMCOPTS) $? 142 | 143 | msgheaders: $(MSGFILES:.msg=_m.h) 144 | 145 | smheaders: $(SMFILES:.sm=_sm.h) 146 | 147 | clean: 148 | $(qecho) Cleaning... 149 | $(Q)-rm -rf $O 150 | $(Q)-rm -f $(TARGET) 151 | $(Q)-rm -f $(call opp_rwildcard, . , *_m.cc *_m.h *_sm.cc *_sm.h) 152 | 153 | cleanall: clean 154 | $(Q)-rm -rf $(PROJECT_OUTPUT_DIR) 155 | 156 | # include all dependencies 157 | -include $(OBJS:%.o=%.d) 158 | -------------------------------------------------------------------------------- /src/builder/ECSBuilder.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef BUILDER_ECSBUILDER_H_ 17 | #define BUILDER_ECSBUILDER_H_ 18 | 19 | #include 20 | #include "tinyxml2.h" 21 | #include "tinyxml2.cpp" 22 | #include "../global/GlobalStreamingSupervisor.h" 23 | #include "../stask/StreamingSupervisor.h" 24 | 25 | using namespace tinyxml2; 26 | 27 | namespace ecsnetpp { 28 | 29 | class ECSBuilder : public cSimpleModule { 30 | //public: 31 | // ECSBuilder(); 32 | // virtual ~ECSBuilder(); 33 | protected: 34 | GlobalStreamingSupervisor *globalSupervisor; 35 | bool ackersEnabled; 36 | bool hasGlobalSupervisor; 37 | protected: 38 | virtual void initialize() override; 39 | virtual void handleMessage(cMessage *msg) override; 40 | void connect(cGate *src, cGate *dest, double delay, double ber, double datarate); 41 | void executeAllocationPlan(cModule *parent); 42 | void setupDistribution(XMLElement* task, const char* taskDistributionXmlElementName, const char* isDistributionEnabledBoolVarName, 43 | const char* distributionModuleName, cModule* stask, cModule* _parent, const char* nonDistributedValueXmlElementName, 44 | const char* nonDistributedValueVarName); 45 | }; 46 | 47 | } /* namespace ecsnetpp */ 48 | 49 | #endif /* BUILDER_ECSBUILDER_H_ */ 50 | -------------------------------------------------------------------------------- /src/builder/ECSBuilder.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.builder; 17 | // 18 | // Dynamically allocates tasks to the host network, 19 | // with the allocation plan coming from a xml file. 20 | // 21 | simple ECSBuilder 22 | { 23 | parameters: 24 | @display("i=block/cogwheel_s"); 25 | string allocationPlanFile; 26 | string dspTopologyFile; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/builder/TaskBuilder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TaskBuilder.h 3 | * 4 | * Created on: Oct 24, 2017 5 | * Author: gayashan 6 | */ 7 | 8 | #ifndef BUILDER_TASKBUILDER_H_ 9 | #define BUILDER_TASKBUILDER_H_ 10 | 11 | #include 12 | #include "../global/GlobalStreamingSupervisor.h" 13 | #include "../stask/StreamingSupervisor.h" 14 | 15 | using namespace omnetpp; 16 | /** 17 | * Builds a network dynamically, with the topology coming from a 18 | * text file. 19 | */ 20 | namespace ecsnetpp { 21 | 22 | class TaskBuilder: public cSimpleModule { 23 | protected: 24 | GlobalStreamingSupervisor *globalSupervisor; 25 | bool ackersEnabled; 26 | bool hasGlobalSupervisor; 27 | protected: 28 | void connect(cGate *src, cGate *dest, double delay, double ber, 29 | double datarate); 30 | void executeAllocationPlan(cModule *parent); 31 | virtual void initialize() override; 32 | virtual void handleMessage(cMessage *msg) override; 33 | 34 | private: 35 | void setStaskBoolPar(omnetpp::cModule* stask, const char* name, bool value); 36 | }; 37 | 38 | } 39 | #endif /* BUILDER_TASKBUILDER_H_ */ 40 | -------------------------------------------------------------------------------- /src/builder/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp.builder; 2 | 3 | @namespace(ecsnetpp); 4 | @license(LGPL); 5 | -------------------------------------------------------------------------------- /src/builder/taskbuilder.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.builder; 17 | // 18 | // Dynamically allocates tasks to the host network, 19 | // with the allocation plan coming from text files. 20 | // 21 | simple TaskBuilder 22 | { 23 | parameters: 24 | @display("i=block/cogwheel_s"); 25 | string allocationPlanFile; 26 | string dspTopologyFile; 27 | } -------------------------------------------------------------------------------- /src/common/SimulationController.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "SimulationController.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | simsignal_t SimulationController::totalSimTimeChangedSignal = registerSignal("totalSimTimeChanged"); 21 | 22 | Define_Module(SimulationController); 23 | 24 | void SimulationController::initialize() { 25 | packetCountLimit = par("packetCountLimit").longValue(); 26 | enableLimitFromSource = par("enableLimitFromSource").boolValue(); 27 | packetCount = 0; 28 | sourcePacketCount = 0; 29 | stopEventGeneration = false; 30 | stopEdgeIdleEnergyRecording = false; 31 | cModule *parent = getParentModule(); 32 | // if (enableLimitFromSource) { 33 | parent->subscribe(ISTask::packetGeneratedSignal, this); 34 | // } else { 35 | parent->subscribe(ISTask::receivedStreamingMsgsSignal, this); 36 | // } 37 | startTime = simTime(); 38 | } 39 | 40 | void SimulationController::handleMessage(cMessage *msg) { 41 | if (!msg->isSelfMessage()) 42 | throw cRuntimeError("This module does not process messages."); 43 | 44 | delete msg; 45 | } 46 | 47 | void SimulationController::receiveSignal(cComponent *source, simsignal_t signalID, cObject *obj, cObject *details){ 48 | if (signalID == ISTask::receivedStreamingMsgsSignal){ 49 | if (simTime() >= getSimulation()->getWarmupPeriod()) { 50 | packetCount++; 51 | if (packetCountLimit >= 0) { // if the packetCountLimit = -1 then run simulation until manually stopped. 52 | if (packetCount >= packetCountLimit) { 53 | std::cout << "Packet count limit of " << packetCountLimit 54 | << " reached. Ending simulation..." << endl; 55 | 56 | const omnetpp::simtime_t _totalSimTime = simTime() - startTime; 57 | emit(totalSimTimeChangedSignal, _totalSimTime.dbl()); 58 | endSimulation(); 59 | } 60 | } 61 | if (packetCount % 1000 == 0) { 62 | std::cout << "Sink PKT COUNT=" << packetCount << endl; 63 | } 64 | } 65 | } 66 | } 67 | 68 | void SimulationController::receiveSignal(cComponent *source, simsignal_t signalID, long value, cObject *details){ 69 | if (signalID == ISTask::packetGeneratedSignal){ 70 | if (simTime() >= getSimulation()->getWarmupPeriod()) { 71 | sourcePacketCount++; 72 | if (packetCountLimit >= 0) { // if the packetCountLimit = -1 then run simulation until manually stopped. 73 | if (sourcePacketCount >= packetCountLimit) { 74 | // EV << "Packet count limit of " << packetCountLimit 75 | // << " reached. Ending simulation..." << endl; 76 | // endSimulation(); 77 | if (enableLimitFromSource) { 78 | stopEventGeneration = true; 79 | } 80 | stopEdgeIdleEnergyRecording = true; 81 | std::cout << "Stopping event generation now. Source PKT COUNT=" << sourcePacketCount << endl; 82 | } 83 | } 84 | if (sourcePacketCount % 1000 == 0) { 85 | std::cout << "Source PKT COUNT=" << sourcePacketCount << endl; 86 | } 87 | } 88 | } 89 | } 90 | 91 | bool SimulationController::getStopEventGeneration(){ 92 | return stopEventGeneration; 93 | } 94 | 95 | bool SimulationController::getStopEdgeIdleEnergyRecording(){ 96 | return stopEdgeIdleEnergyRecording; 97 | } 98 | //SimulationController::SimulationController() { 99 | // // TODO Auto-generated constructor stub 100 | // 101 | //} 102 | // 103 | //SimulationController::~SimulationController() { 104 | // // TODO Auto-generated destructor stub 105 | //} 106 | 107 | } /* namespace ecsnetpp */ 108 | -------------------------------------------------------------------------------- /src/common/SimulationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef COMMON_SIMULATIONCONTROLLER_H_ 17 | #define COMMON_SIMULATIONCONTROLLER_H_ 18 | 19 | #include "omnetpp.h" 20 | #include "../stask/ISTask.h" 21 | 22 | using namespace omnetpp; 23 | 24 | namespace ecsnetpp{ 25 | 26 | class SimulationController : public cSimpleModule, public cListener{ 27 | protected: 28 | long packetCountLimit; 29 | long packetCount = 0; 30 | long sourcePacketCount = 0; 31 | bool enableLimitFromSource; 32 | bool stopEventGeneration; 33 | bool stopEdgeIdleEnergyRecording; 34 | simtime_t startTime = -1; 35 | public: 36 | static simsignal_t totalSimTimeChangedSignal; 37 | public: 38 | virtual void initialize() override; 39 | virtual void handleMessage(cMessage *msg) override; 40 | virtual bool getStopEventGeneration(); 41 | virtual bool getStopEdgeIdleEnergyRecording(); 42 | // SimulationController(); 43 | // virtual ~SimulationController(); 44 | virtual void receiveSignal(cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override; 45 | virtual void receiveSignal(cComponent *source, simsignal_t signalID, long value, cObject *details) override; 46 | }; 47 | 48 | } /* namespace ecsnetpp */ 49 | 50 | #endif /* COMMON_SIMULATIONCONTROLLER_H_ */ 51 | -------------------------------------------------------------------------------- /src/common/SimulationController.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.common; 17 | 18 | simple SimulationController { 19 | parameters: 20 | @signal[totalSimTimeChanged](type=double); 21 | @statistic[totalSimTime](title="Total sim time"; source=totalSimTimeChanged; record=last; interpolationmode=sample-hold); 22 | bool enableLimitFromSource = default(false); 23 | int packetCountLimit = default(0); 24 | } -------------------------------------------------------------------------------- /src/common/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp.common; 2 | 3 | @namespace(ecsnetpp); 4 | @license(LGPL); 5 | -------------------------------------------------------------------------------- /src/configs/1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | pi3Bs 5 | 0..5 6 | 7 | 8 | so 9 | so 10 | ecsnetpp.stask.StreamingSource 11 | 12 | 1000602044 13 | 14 | 6880 15 | 16 | FixedSourceEventRateDistribution 17 | ecsnetpp.model.source.eventrate.FixedSourceEventRateDistribution 18 | 19 | 20 | 21 | pa 22 | pa 23 | ecsnetpp.stask.StreamingOperator 24 | 25 | 748722 26 | 27 | 5 28 | 0.33 29 | 30 | 31 | 32 | 33 | stargazer3 34 | 0 35 | 36 | 37 | rf 38 | rf 39 | ecsnetpp.stask.StreamingOperator 40 | 41 | 5391 42 | 43 | 1 44 | 1 45 | 46 | 47 | bf 48 | bf 49 | ecsnetpp.stask.StreamingOperator 50 | 51 | 92 52 | 53 | 1 54 | 1 55 | 56 | 57 | ip 58 | ip 59 | ecsnetpp.stask.StreamingOperator 60 | 61 | 10735 62 | 63 | 1 64 | 1 65 | 66 | 67 | jo 68 | jo 69 | ecsnetpp.stask.StreamingOperator 70 | 71 | 4384 72 | 73 | 0.2 74 | 1.3 75 | 76 | 77 | an 78 | an 79 | ecsnetpp.stask.StreamingOperator 80 | 81 | 13367 82 | 83 | 1 84 | 1 85 | 86 | 87 | csv 88 | csv 89 | ecsnetpp.stask.StreamingOperator 90 | 91 | 78706 92 | 93 | 1 94 | 2 95 | 96 | 97 | si 98 | si 99 | ecsnetpp.stask.StreamingSink 100 | 101 | 195424 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /src/configs/ec_sim_mirror.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 18 | -------------------------------------------------------------------------------- /src/configs/etl_app_topology.txt: -------------------------------------------------------------------------------- 1 | # adjacency matrix of the DSP topology 2 | # src dest connection 3 | so pa 1 4 | pa rf 1 5 | rf bf 1 6 | bf ip 1 7 | ip jo 1 8 | jo an 1 9 | an csv 1 10 | csv si 1 -------------------------------------------------------------------------------- /src/configs/example-plan.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | phone 5 | 0..5 6 | 7 | 8 | so 9 | so 10 | ecsnetpp.stask.StreamingSource 11 | 12 | 10431109 13 | 14 | 15 | FixedMessageSizeDistribution 16 | ecsnetpp.model.source.msgsize.FixedMessageSizeDistribution 17 | 18 | 1024 19 | 20 | 21 | 22 | UniformSourceEventRateDistribution 23 | ecsnetpp.model.source.eventrate.UniformSourceEventRateDistribution 24 | 25 | 0 26 | 0.01 27 | 28 | 29 | 30 | 31 | pa 32 | pa 33 | ecsnetpp.stask.StreamingOperator 34 | 35 | 576632 36 | 37 | 38 | FSD2 39 | ecsnetpp.model.operator.selectivity.FixedSelectivityDistribution 40 | 41 | 2 42 | 43 | 44 | 45 | FPD2 46 | ecsnetpp.model.operator.productivity.FixedProductivityDistribution 47 | 48 | 1 49 | 50 | 51 | 52 | 53 | 54 | 55 | region1 56 | 0..10 57 | 58 | 59 | so 60 | so 61 | ecsnetpp.stask.StreamingSource 62 | 63 | 10395199 64 | 65 | 6880 66 | 67 | FixedSourceEventRateDistribution 68 | ecsnetpp.model.source.eventrate.FixedSourceEventRateDistribution 69 | 70 | 71 | 72 | pa 73 | pa 74 | ecsnetpp.stask.StreamingOperator 75 | 76 | 2505545 77 | 78 | 5 79 | 0.33 80 | 81 | 82 | 83 | 84 | server 85 | 0 86 | 87 | 88 | rf 89 | rf 90 | ecsnetpp.stask.StreamingOperator 91 | 92 | 5397 93 | 94 | 1 95 | 1 96 | 97 | 98 | bf 99 | bf 100 | ecsnetpp.stask.StreamingOperator 101 | 102 | 109 103 | 104 | 1 105 | 1 106 | 107 | 108 | ip 109 | ip 110 | ecsnetpp.stask.StreamingOperator 111 | 112 | 10525 113 | 114 | 1 115 | 1 116 | 117 | 118 | jo 119 | jo 120 | ecsnetpp.stask.StreamingOperator 121 | 122 | 3054 123 | 124 | 125 | FSD1 126 | ecsnetpp.model.operator.selectivity.FixedSelectivityDistribution 127 | 128 | 0.2 129 | 130 | 131 | 132 | FPD1 133 | ecsnetpp.model.operator.productivity.FixedProductivityDistribution 134 | 135 | 2.5 136 | 137 | 138 | 139 | 140 | an 141 | an 142 | ecsnetpp.stask.StreamingOperator 143 | 144 | 10191 145 | 146 | 1 147 | 1 148 | 149 | 150 | csv 151 | csv 152 | ecsnetpp.stask.StreamingOperator 153 | 154 | 86948 155 | 156 | 1 157 | 2 158 | 159 | 160 | si 161 | si 162 | ecsnetpp.stask.StreamingSink 163 | 164 | 140415 165 | 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /src/configs/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp.configs; 2 | 3 | @namespace(ecsnetpp); 4 | @license(LGPL); -------------------------------------------------------------------------------- /src/configs/placement-plan-schema.xsd: -------------------------------------------------------------------------------- 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 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /src/cpu/CPUCore.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "CPUCore.h" 17 | #include "../stask/ISTask.h" 18 | #include "../power/States.h" 19 | 20 | namespace ecsnetpp { 21 | 22 | Define_Module(CPUCore); 23 | 24 | void CPUCore::finish() { 25 | // cancelAndDelete(timerMsg); 26 | std::map::iterator it; 27 | for (it = processingQueueMap.begin(); it != processingQueueMap.end(); 28 | ++it) { 29 | cQueue _q = it->second; 30 | if (!_q.isEmpty()) { 31 | _q.clear(); 32 | } 33 | } 34 | } 35 | 36 | void CPUCore::initialize() { 37 | ackersEnabled = getAncestorPar("ackersEnabled").boolValue(); 38 | perCoreFreq = getAncestorPar("perCoreFreq").doubleValue(); 39 | parallelisationFactor = par("parallelisationFactor").doubleValue(); 40 | threadsPerCore = getAncestorPar("threadsPerCore").longValue(); 41 | totalCores = getAncestorPar("cores").longValue(); 42 | isOnEdgeDevice = getAncestorPar("isEdgeDevice").boolValue(); 43 | std::cout<< "Cores: " << getParentModule()->getFullPath() << " : " << totalCores << endl; 44 | // timerMsg = new cMessage(); 45 | // timerMsg->setKind(2); 46 | } 47 | 48 | omnetpp::SimTime CPUCore::calculateDelay(bool isProcessingDelayInCpuCycles, double processingDelay, long threads) { 49 | // * normal(1, 0.02) 50 | if (!isProcessingDelayInCpuCycles) { 51 | return omnetpp::SimTime(processingDelay * parallelisationFactor / (totalCores * 1000000000)); // convert processing delay to seconds from nanoseconds 52 | } 53 | delay = 0; 54 | double cyclesPerEvent = processingDelay; 55 | if (perCoreFreq != 0) { 56 | delay = cyclesPerEvent / perCoreFreq; 57 | } 58 | if (delay < 0) { 59 | // std::cout << "LT 0 CPE=" << cyclesPerEvent << " PCF=" << perCoreFreq 60 | // << " D=" << delay << endl; 61 | delay = 0; 62 | } 63 | double _delay = threads > 0 ? (delay * threads / threadsPerCore) : delay; 64 | // std::cout << "DELAY= " << _delay << " CPE=" << cyclesPerEvent << " PCF=" 65 | // << perCoreFreq << " T=" << threads << endl; 66 | return omnetpp::SimTime(_delay); 67 | } 68 | 69 | void CPUCore::handleMessage(cMessage *msg) { 70 | if (!msg->isSelfMessage()) { 71 | emit(ISTask::cpuStateChangedSignal, States::CPU_BUSY); 72 | StreamingMessage *msgToProcess = check_and_cast(msg); 73 | msgToProcess->setOperatorIngressTime(simTime()); 74 | bool isProcessingDelayInCpuCycles = msgToProcess->getIsProcessingDelayInCyclesPerEvent(); 75 | double processingDelay = msgToProcess->getProcessingDelayPerEvent(); 76 | // double cyclesPerEvent = msgToProcess->getCyclesPerEvent(); 77 | int senderModuleId = msgToProcess->getSenderModuleId(); 78 | const omnetpp::SimTime delay = calculateDelay(isProcessingDelayInCpuCycles, processingDelay, processingQueueMap.size()); 79 | // msgToProcess->setProcessingDelay(msgToProcess->getProcessingDelay() + delay.dbl()); 80 | processingQueueMap[senderModuleId].insert(msgToProcess); 81 | cMessage *timerMsg = new cMessage(); 82 | timerMsg->setKind(senderModuleId); 83 | scheduleAt(simTime() + delay, timerMsg); 84 | } else { 85 | StreamingMessage *msgToProcess = check_and_cast( 86 | processingQueueMap[msg->getKind()].pop()); 87 | 88 | const omnetpp::SimTime _processingTime = simTime() - msgToProcess->getOperatorIngressTime(); 89 | double _procdelay = msgToProcess->getProcessingDelay() + _processingTime.dbl(); 90 | // std::cout << " CPU proc delay: " << msgToProcess->getSender() << _procdelay << endl; 91 | msgToProcess->setProcessingDelay(_procdelay); 92 | if (isOnEdgeDevice) { 93 | msgToProcess->setEdgeProcessingDelay(msgToProcess->getEdgeProcessingDelay() + _processingTime.dbl()); 94 | } 95 | // std::cout << "Queue length: " << msg->getKind() << " : " << processingQueueMap[msg->getKind()].length() << endl; 96 | if (processingQueueMap[msg->getKind()].isEmpty()) { 97 | processingQueueMap.erase(msg->getKind()); 98 | } 99 | cModule *senderModule = msgToProcess->getSenderModule(); 100 | double selectivityRatio = msgToProcess->getSelectivityRatio(); 101 | if (selectivityRatio > 1) { 102 | int _sratio = std::lround(selectivityRatio); // get the rounded value of the selectivity 103 | for (int j = 0; j < _sratio; j++) { // send a msg for each incoming msg 104 | sendDirect(msgToProcess->dup(), senderModule, "fromCPU"); 105 | } 106 | } else { 107 | sendDirect(msgToProcess, senderModule, "fromCPU"); 108 | } 109 | emit(ISTask::cpuStateChangedSignal, States::CPU_IDLE); 110 | } 111 | } 112 | 113 | } /* namespace ecsnetpp */ 114 | -------------------------------------------------------------------------------- /src/cpu/CPUCore.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef CPU_CPUCORE_H_ 17 | #define CPU_CPUCORE_H_ 18 | 19 | #include "omnetpp.h" 20 | #include "../msg/StreamingMessage_m.h" 21 | 22 | using namespace omnetpp; 23 | 24 | namespace ecsnetpp { 25 | 26 | class CPUCore : public cSimpleModule{ 27 | protected: 28 | std::map processingQueueMap; 29 | // cMessage *timerMsg = nullptr; 30 | cMessage *index; 31 | double perCoreFreq; 32 | double parallelisationFactor; 33 | long threadsPerCore; 34 | long totalCores; 35 | double delay; 36 | bool ackersEnabled; 37 | bool isOnEdgeDevice; 38 | protected: 39 | virtual void initialize() override; 40 | virtual void handleMessage(cMessage *msg) override; 41 | virtual void finish() override; 42 | virtual omnetpp::SimTime calculateDelay(bool isProcessingDelayInCpuCycles, double processingDelay, long threads); 43 | }; 44 | 45 | } /* namespace ecsnetpp */ 46 | 47 | #endif /* CPU_CPUCORE_H_ */ 48 | -------------------------------------------------------------------------------- /src/cpu/CPUCore.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.cpu; 17 | 18 | simple CPUCore { 19 | parameters: 20 | string name = default("CPUCore"); 21 | double parallelisationFactor = default(1); 22 | @signal[cpuStateChanged](type=long); 23 | gates: 24 | input incomingBus; 25 | output outgoingBus; 26 | } 27 | -------------------------------------------------------------------------------- /src/cpu/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp.cpu; 2 | 3 | @namespace(ecsnetpp); 4 | @license(LGPL); 5 | -------------------------------------------------------------------------------- /src/cpu/scheduling/ICpuCoreScheduler.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "ICpuCoreScheduler.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(ICpuCoreScheduler) 21 | 22 | long ICpuCoreScheduler::getNextCPUCoreIndex(){ 23 | throw new cRuntimeError("A CPU scheduler is not assigned to get the next CPU core index."); 24 | } 25 | 26 | } /* namespace ecsnetpp */ 27 | -------------------------------------------------------------------------------- /src/cpu/scheduling/ICpuCoreScheduler.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef CPU_SCHEDULING_ICPUCORESCHEDULER_H_ 17 | #define CPU_SCHEDULING_ICPUCORESCHEDULER_H_ 18 | #include 19 | 20 | using namespace omnetpp; 21 | 22 | namespace ecsnetpp { 23 | 24 | class ICpuCoreScheduler : public cSimpleModule { 25 | protected: 26 | virtual void initialize() {}; 27 | public: 28 | virtual long getNextCPUCoreIndex(); 29 | }; 30 | 31 | } /* namespace ecsnetpp */ 32 | 33 | #endif /* CPU_SCHEDULING_ICPUCORESCHEDULER_H_ */ 34 | -------------------------------------------------------------------------------- /src/cpu/scheduling/ICpuCoreScheduler.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.cpu.scheduling; 17 | 18 | moduleinterface ICpuCoreScheduler 19 | { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/cpu/scheduling/RoundRobinCpuCoreScheduler.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "RoundRobinCpuCoreScheduler.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(RoundRobinCpuCoreScheduler); 21 | 22 | void RoundRobinCpuCoreScheduler::initialize() { 23 | cpuCores = getAncestorPar("cores").longValue(); 24 | } 25 | 26 | long RoundRobinCpuCoreScheduler::getNextCPUCoreIndex() { 27 | lastCPUIndex = ((lastCPUIndex + 1) % cpuCores); 28 | // std::cout << "Selecting the core: " << lastCPUIndex << " at : " << getParentModule()->getFullPath() << endl; 29 | return lastCPUIndex; 30 | } 31 | 32 | } /* namespace ecsnetpp */ 33 | -------------------------------------------------------------------------------- /src/cpu/scheduling/RoundRobinCpuCoreScheduler.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef CPU_SCHEDULING_ROUNDROBINCPUCORESCHEDULER_H_ 17 | #define CPU_SCHEDULING_ROUNDROBINCPUCORESCHEDULER_H_ 18 | 19 | #include 20 | #include "ICpuCoreScheduler.h" 21 | 22 | using namespace omnetpp; 23 | 24 | namespace ecsnetpp { 25 | 26 | class RoundRobinCpuCoreScheduler : public ICpuCoreScheduler{ 27 | private: 28 | long cpuCores; 29 | long lastCPUIndex = 0; 30 | protected: 31 | virtual void initialize() override; 32 | public: 33 | virtual long getNextCPUCoreIndex() override; 34 | }; 35 | 36 | } /* namespace ecsnetpp */ 37 | 38 | #endif /* CPU_SCHEDULING_ROUNDROBINCPUCORESCHEDULER_H_ */ 39 | -------------------------------------------------------------------------------- /src/cpu/scheduling/RoundRobinCpuCoreScheduler.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.cpu.scheduling; 17 | 18 | import ecsnetpp.cpu.scheduling.ICpuCoreScheduler; 19 | 20 | simple RoundRobinCpuCoreScheduler like ICpuCoreScheduler { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/global/GlobalStreamingSupervisor.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "GlobalStreamingSupervisor.h" 17 | #include "inet/networklayer/common/L3AddressResolver.h" 18 | 19 | namespace ecsnetpp { 20 | 21 | Define_Module(GlobalStreamingSupervisor); 22 | 23 | void GlobalStreamingSupervisor::initialize() { 24 | socket.setOutputGate(gate("udpOut")); 25 | bindMsg = new cMessage("UDP_C_BIND", inet::UDP_C_BIND); 26 | inet::UDPBindCommand *ctrl2 = new inet::UDPBindCommand(); 27 | int socketId = inet::UDPSocket::generateSocketId(); 28 | ctrl2->setSockId(socketId); 29 | ctrl2->setLocalPort(1000); 30 | bindMsg->setControlInfo(ctrl2); 31 | send(bindMsg, "udpOut"); 32 | } 33 | 34 | void GlobalStreamingSupervisor::handleMessage(cMessage *msg) { 35 | if (!msg->isSelfMessage()) { 36 | StreamingMessage *msgToSend = check_and_cast(msg); 37 | std::string sender = msgToSend->getSender(); 38 | std::vector _downstreamNodes = 39 | senderStaskCategoryToDownstreamNodeIPMap[sender]; 40 | for (size_t i = 0; i < _downstreamNodes.size(); i++) { 41 | socket.connect(_downstreamNodes[i], 1000); 42 | 43 | socket.send(msgToSend->dup()); 44 | socket.close(); 45 | } 46 | delete msgToSend; 47 | } 48 | } 49 | 50 | void GlobalStreamingSupervisor::addSTaskCategoryToDownstreamNodeMapping( 51 | std::string senderSTaskCategory, std::string downstreamNodeFullPath) { 52 | senderStaskCategoryToDownstreamNodeMap[senderSTaskCategory].push_back( 53 | downstreamNodeFullPath); 54 | } 55 | 56 | void GlobalStreamingSupervisor::addSTaskCategoryToDownstreamNodeMapping( 57 | std::string senderSTaskCategory, 58 | std::vector downstreamNodeFullPaths) { 59 | senderStaskCategoryToDownstreamNodeMap[senderSTaskCategory].insert( 60 | senderStaskCategoryToDownstreamNodeMap[senderSTaskCategory].end(), 61 | downstreamNodeFullPaths.begin(), downstreamNodeFullPaths.end()); 62 | } 63 | 64 | void GlobalStreamingSupervisor::resolveDownstreamNodeIPs() { 65 | std::map>::iterator it; 66 | for (it = senderStaskCategoryToDownstreamNodeMap.begin(); 67 | it != senderStaskCategoryToDownstreamNodeMap.end(); ++it) { 68 | std::vector _downstreamNodes = it->second; 69 | std::string _staskCategory = it->first; 70 | senderStaskCategoryToDownstreamNodeIPMap[_staskCategory] = 71 | inet::L3AddressResolver().resolve(_downstreamNodes); 72 | } 73 | } 74 | 75 | } /* namespace ecsnetpp */ 76 | -------------------------------------------------------------------------------- /src/global/GlobalStreamingSupervisor.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef GLOBAL_GLOBALSTREAMINGSUPERVISOR_H_ 17 | #define GLOBAL_GLOBALSTREAMINGSUPERVISOR_H_ 18 | 19 | #include "omnetpp.h" 20 | #include "../msg/StreamingMessage_m.h" 21 | #include "inet/networklayer/common/L3Address.h" 22 | #include "inet/networklayer/common/L3AddressResolver.h" 23 | #include "inet/transportlayer/contract/udp/UDPSocket.h" 24 | 25 | //using namespace inet; 26 | using namespace omnetpp; 27 | 28 | namespace ecsnetpp { 29 | 30 | class GlobalStreamingSupervisor: public cSimpleModule { 31 | private: 32 | inet::UDPSocket socket; 33 | cMessage *bindMsg = nullptr; 34 | std::map> senderStaskCategoryToDownstreamNodeMap; 35 | std::map> senderStaskCategoryToDownstreamNodeIPMap; 36 | protected: 37 | virtual void initialize(); 38 | virtual void handleMessage(cMessage *msg); 39 | public: 40 | virtual void addSTaskCategoryToDownstreamNodeMapping( 41 | std::string senderSTaskCategory, 42 | std::string downstreamNodeFullPath); 43 | virtual void addSTaskCategoryToDownstreamNodeMapping( 44 | std::string senderSTaskCategory, 45 | std::vector downstreamNodeFullPaths); 46 | virtual void resolveDownstreamNodeIPs(); 47 | // GlobalStreamingSupervisor(); 48 | // virtual ~GlobalStreamingSupervisor(); 49 | }; 50 | 51 | } /* namespace ecsnetpp */ 52 | 53 | #endif /* GLOBAL_GLOBALSTREAMINGSUPERVISOR_H_ */ 54 | -------------------------------------------------------------------------------- /src/global/GlobalStreamingSupervisor.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.global; 17 | 18 | simple GlobalStreamingSupervisor 19 | { 20 | parameters: 21 | string name = default("Supervisor"); 22 | bool joinMulticastGroup = default(false); 23 | // @class(Supervisor); 24 | gates: 25 | // input supIn[]; 26 | // output supOut[]; 27 | input udpIn @labels(UDPControlInfo/up); 28 | output udpOut @labels(UDPControlInfo/down); 29 | inout supInOut[]; 30 | input streamingPortIn[]; 31 | output streamingPortOut[]; 32 | input sendToAcker[]; 33 | output ackerOut[]; 34 | } 35 | -------------------------------------------------------------------------------- /src/global/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp.global; 2 | 3 | @namespace(ecsnetpp); 4 | @license(LGPL); 5 | -------------------------------------------------------------------------------- /src/host/CloudNodeA.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.host; 17 | import ecsnetpp.stask.ISTask; 18 | import ecsnetpp.stask.StreamingSupervisor; 19 | import ecsnetpp.stask.Acker; 20 | import ecsnetpp.cpu.CPUCore; 21 | import ecsnetpp.cpu.scheduling.ICpuCoreScheduler; 22 | import ecsnetpp.cpu.scheduling.RoundRobinCpuCoreScheduler; 23 | import inet.node.inet.StandardHost; 24 | import inet.node.inet.WirelessHost; 25 | import inet.node.inet.NodeBase; 26 | 27 | module CloudNodeA extends StandardHost 28 | { 29 | parameters: 30 | // Intel Xeon Gold 6140, 2.30GHz 31 | int cores = default(1); 32 | double perCoreFreq @unit(Hz) = default(700000000Hz); 33 | int threadsPerCore = default(1); 34 | double totalMemory @unit(Mb) = default(16384Mb); 35 | double fixedSourceEventRate = default(0); 36 | bool hasAcker = default(false); 37 | string ackerAddress = default(""); 38 | bool isEdgeDevice = false; 39 | string cpuCoreSchedulerType = default("RoundRobinCpuCoreScheduler"); 40 | @display("bgb=728.91003,656.82"); 41 | @statistic[processingLatency](title="processingLatency"; source=processingTime; record=vector); 42 | @statistic[transmissionLatency](title="Transmission Latency"; source=transmissionTime; record=vector); 43 | @statistic[totalLatency](title="Total Latency"; source=latency; record=vector); 44 | gates: 45 | inout hostport[]; 46 | submodules: 47 | cpuCore[cores]: CPUCore { 48 | @display("p=673.2,39.6"); 49 | } 50 | supervisor: StreamingSupervisor; 51 | cpuCoreScheduler : like ICpuCoreScheduler if cpuCoreSchedulerType != ""; 52 | acker: Acker if hasAcker; 53 | connections allowunconnected: 54 | supervisor.udpIn <-- udp.appOut++ if hasUdp; 55 | supervisor.udpOut --> udp.appIn++ if hasUdp; 56 | supervisor.tcpIn <-- tcp.appOut++ if hasTcp; 57 | supervisor.tcpOut --> tcp.appIn++ if hasTcp; 58 | // connect supervisor to acker 59 | // only if the acker is placed in this node 60 | supervisor.ackerOut++ --> acker.ackerIn if hasAcker; 61 | } 62 | -------------------------------------------------------------------------------- /src/host/RaspberryPiModel2B.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.host; 17 | import ecsnetpp.stask.ISTask; 18 | import ecsnetpp.stask.StreamingSupervisor; 19 | import ecsnetpp.stask.Acker; 20 | import ecsnetpp.cpu.CPUCore; 21 | import inet.node.inet.StandardHost; 22 | import inet.node.inet.AdhocHost; 23 | import inet.node.inet.WirelessHost; 24 | import inet.node.inet.NodeBase; 25 | import inet.power.contract.IEnergyConsumer; 26 | import ecsnetpp.power.consumer.CPUPowerConsumer; 27 | import ecsnetpp.power.consumer.NetworkPowerConsumer; 28 | import ecsnetpp.power.storage.IdealNodeEnergyStorage; 29 | import ecsnetpp.cpu.scheduling.ICpuCoreScheduler; 30 | import ecsnetpp.cpu.scheduling.RoundRobinCpuCoreScheduler; 31 | import inet.power.contract.IEpEnergyConsumer; 32 | 33 | module RaspberryPiModel2B extends WirelessHost 34 | { 35 | parameters: 36 | int cores = default(4); 37 | double perCoreFreq @unit(Hz) = 900000000Hz; 38 | int threadsPerCore = 1; 39 | double totalMemory @unit(Mb) = 1024Mb; 40 | double fixedSourceEventRate = default(0); 41 | bool hasAcker = default(false); 42 | string ackerAddress = default(""); 43 | bool isEdgeDevice = true; 44 | string cpuCoreSchedulerType = default("RoundRobinCpuCoreScheduler"); 45 | string energyConsumerType = default(""); // NED type of the energy consumer model 46 | @display("bgb=728.91003,656.82"); 47 | @statistic[residualEnergyConsumption](title="Residual energy consumption"; source=residualEnergyCapacityChanged; record=last); 48 | gates: 49 | inout hostport[]; 50 | submodules: 51 | cpuCore[cores]: CPUCore { 52 | @display("p=674.52,39.6,c"); 53 | } 54 | supervisor: StreamingSupervisor; 55 | cpuCoreScheduler : like ICpuCoreScheduler if cpuCoreSchedulerType != ""; 56 | acker: Acker if hasAcker; 57 | cpuPowerConsumer: CPUPowerConsumer; 58 | networkPowerConsumer: NetworkPowerConsumer; 59 | energyStore: IdealNodeEnergyStorage; 60 | connections allowunconnected: 61 | supervisor.udpIn <-- udp.appOut++ if hasUdp; 62 | supervisor.udpOut --> udp.appIn++ if hasUdp; 63 | supervisor.tcpIn <-- tcp.appOut++ if hasTcp; 64 | supervisor.tcpOut --> tcp.appIn++ if hasTcp; 65 | // connect supervisor to acker 66 | // only if the acker is placed in this node 67 | supervisor.ackerOut++ --> acker.ackerIn if hasAcker; 68 | } 69 | -------------------------------------------------------------------------------- /src/host/RaspberryPiModel3B.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.host; 17 | import ecsnetpp.stask.ISTask; 18 | import ecsnetpp.stask.StreamingSupervisor; 19 | import ecsnetpp.stask.Acker; 20 | import ecsnetpp.cpu.CPUCore; 21 | import inet.node.inet.StandardHost; 22 | import inet.node.inet.AdhocHost; 23 | import inet.node.inet.WirelessHost; 24 | import inet.node.inet.NodeBase; 25 | import inet.power.contract.IEnergyConsumer; 26 | import ecsnetpp.power.consumer.CPUPowerConsumer; 27 | import ecsnetpp.power.consumer.NetworkPowerConsumer; 28 | import ecsnetpp.power.storage.IdealNodeEnergyStorage; 29 | import ecsnetpp.cpu.scheduling.ICpuCoreScheduler; 30 | import ecsnetpp.cpu.scheduling.RoundRobinCpuCoreScheduler; 31 | import inet.power.contract.IEpEnergyConsumer; 32 | 33 | module RaspberryPiModel3B extends WirelessHost 34 | { 35 | parameters: 36 | int cores = default(4); 37 | double perCoreFreq @unit(Hz) = 1200000000Hz; 38 | int threadsPerCore = 1; 39 | double totalMemory @unit(Mb) = 1024Mb; 40 | double fixedSourceEventRate = default(0); 41 | bool hasAcker = default(false); 42 | bool isEdgeDevice = true; 43 | string ackerAddress = default(""); 44 | string cpuCoreSchedulerType = default("RoundRobinCpuCoreScheduler"); 45 | string energyConsumerType = default(""); // NED type of the energy consumer model 46 | @display("bgb=728.91003,656.82"); 47 | @statistic[residualEnergyConsumption](title="Residual energy consumption"; source=residualEnergyCapacityChanged; record=last); 48 | gates: 49 | inout hostport[]; 50 | submodules: 51 | cpuCore[cores]: CPUCore { 52 | @display("p=674.52,39.6,c"); 53 | } 54 | supervisor: StreamingSupervisor; 55 | cpuCoreScheduler : like ICpuCoreScheduler if cpuCoreSchedulerType != ""; 56 | acker: Acker if hasAcker; 57 | cpuPowerConsumer: CPUPowerConsumer; 58 | networkPowerConsumer: NetworkPowerConsumer; 59 | energyStore: IdealNodeEnergyStorage; 60 | connections allowunconnected: 61 | supervisor.udpIn <-- udp.appOut++ if hasUdp; 62 | supervisor.udpOut --> udp.appIn++ if hasUdp; 63 | supervisor.tcpIn <-- tcp.appOut++ if hasTcp; 64 | supervisor.tcpOut --> tcp.appIn++ if hasTcp; 65 | // connect supervisor to acker 66 | // only if the acker is placed in this node 67 | supervisor.ackerOut++ --> acker.ackerIn if hasAcker; 68 | } 69 | -------------------------------------------------------------------------------- /src/host/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp.host; 2 | 3 | @namespace(ecsnetpp); 4 | @license(LGPL); 5 | -------------------------------------------------------------------------------- /src/model/operator/productivity/FixedProductivityDistribution.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "FixedProductivityDistribution.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(FixedProductivityDistribution); 21 | 22 | void FixedProductivityDistribution::initialize() 23 | { 24 | productivityRatio = par("productivityratio").doubleValue(); 25 | } 26 | 27 | double FixedProductivityDistribution::getProductivityRatio() 28 | { 29 | return productivityRatio; 30 | } 31 | 32 | } //namespace 33 | -------------------------------------------------------------------------------- /src/model/operator/productivity/FixedProductivityDistribution.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef __EDGECLOUDSTREAMINGSIMULATOR_FIXEDPRODUCTIVITYDISTRIBUTION_H_ 17 | #define __EDGECLOUDSTREAMINGSIMULATOR_FIXEDPRODUCTIVITYDISTRIBUTION_H_ 18 | 19 | #include 20 | #include "IOperatorProductivityDistribution.h" 21 | 22 | using namespace omnetpp; 23 | 24 | namespace ecsnetpp { 25 | 26 | /** 27 | * TODO - Generated class 28 | */ 29 | class FixedProductivityDistribution : public IOperatorProductivityDistribution 30 | { 31 | protected: 32 | double productivityRatio; 33 | protected: 34 | virtual void initialize() override; 35 | public: 36 | virtual double getProductivityRatio() override; 37 | }; 38 | 39 | } //namespace 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/model/operator/productivity/FixedProductivityDistribution.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.model.operator.productivity; 17 | 18 | // 19 | // TODO auto-generated module 20 | // 21 | simple FixedProductivityDistribution like IOperatorProductivityDistribution 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /src/model/operator/productivity/IOperatorProductivityDistribution.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "IOperatorProductivityDistribution.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(IOperatorProductivityDistribution); 21 | 22 | double IOperatorProductivityDistribution::getProductivityRatio() 23 | { 24 | throw new cRuntimeError("Operator productivity distribution function is not implemented."); 25 | } 26 | 27 | } //namespace 28 | -------------------------------------------------------------------------------- /src/model/operator/productivity/IOperatorProductivityDistribution.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef __EDGECLOUDSTREAMINGSIMULATOR_IOPERATORPRODUCTIVITYDISTRIBUTION_H_ 17 | #define __EDGECLOUDSTREAMINGSIMULATOR_IOPERATORPRODUCTIVITYDISTRIBUTION_H_ 18 | 19 | #include 20 | 21 | using namespace omnetpp; 22 | 23 | namespace ecsnetpp { 24 | 25 | /** 26 | * TODO - Generated class 27 | */ 28 | class IOperatorProductivityDistribution : public cSimpleModule 29 | { 30 | protected: 31 | virtual void initialize(){}; 32 | public: 33 | virtual double getProductivityRatio(); 34 | }; 35 | 36 | } //namespace 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/model/operator/productivity/IOperatorProductivityDistribution.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.model.operator.productivity; 17 | 18 | // 19 | // TODO auto-generated module 20 | // 21 | moduleinterface IOperatorProductivityDistribution 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /src/model/operator/selectivity/FixedSelectivityDistribution.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "FixedSelectivityDistribution.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(FixedSelectivityDistribution); 21 | 22 | void FixedSelectivityDistribution::initialize() 23 | { 24 | selectivityRatio = par("selectivityratio").doubleValue(); 25 | selectivityWindowLength = std::lround(1 / selectivityRatio); 26 | } 27 | 28 | double FixedSelectivityDistribution::getSelectivityRatio() 29 | { 30 | return selectivityRatio; 31 | } 32 | 33 | double FixedSelectivityDistribution::getSelectivityWindowLength() 34 | { 35 | return selectivityWindowLength; 36 | } 37 | 38 | } //namespace 39 | -------------------------------------------------------------------------------- /src/model/operator/selectivity/FixedSelectivityDistribution.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef __EDGECLOUDSTREAMINGSIMULATOR_FIXEDSELECTIVITYDISTRIBUTION_H_ 17 | #define __EDGECLOUDSTREAMINGSIMULATOR_FIXEDSELECTIVITYDISTRIBUTION_H_ 18 | 19 | #include 20 | #include "IOperatorSelectivityDistribution.h" 21 | 22 | using namespace omnetpp; 23 | 24 | namespace ecsnetpp { 25 | 26 | /** 27 | * TODO - Generated class 28 | */ 29 | class FixedSelectivityDistribution : public IOperatorSelectivityDistribution 30 | { 31 | protected: 32 | double selectivityRatio = 0; 33 | long selectivityWindowLength; 34 | protected: 35 | virtual void initialize() override; 36 | public: 37 | virtual double getSelectivityRatio() override; 38 | virtual double getSelectivityWindowLength() override; 39 | }; 40 | 41 | } //namespace 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/model/operator/selectivity/FixedSelectivityDistribution.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.model.operator.selectivity; 17 | 18 | // 19 | // TODO auto-generated module 20 | // 21 | simple FixedSelectivityDistribution like IOperatorSelectivityDistribution 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /src/model/operator/selectivity/IOperatorSelectivityDistribution.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "IOperatorSelectivityDistribution.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(IOperatorSelectivityDistribution); 21 | 22 | double IOperatorSelectivityDistribution::getSelectivityRatio() 23 | { 24 | throw new cRuntimeError("Operator selectivity distribution function is not implemented."); 25 | } 26 | 27 | double IOperatorSelectivityDistribution::getSelectivityWindowLength() 28 | { 29 | throw new cRuntimeError("Operator selectivity distribution window length function is not implemented."); 30 | } 31 | } //namespace 32 | -------------------------------------------------------------------------------- /src/model/operator/selectivity/IOperatorSelectivityDistribution.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef __EDGECLOUDSTREAMINGSIMULATOR_IOPERATORSELECTIVITYDISTRIBUTION_H_ 17 | #define __EDGECLOUDSTREAMINGSIMULATOR_IOPERATORSELECTIVITYDISTRIBUTION_H_ 18 | 19 | #include 20 | 21 | using namespace omnetpp; 22 | 23 | namespace ecsnetpp { 24 | 25 | /** 26 | * TODO - Generated class 27 | */ 28 | class IOperatorSelectivityDistribution : public cSimpleModule 29 | { 30 | protected: 31 | virtual void initialize(){}; 32 | public: 33 | virtual double getSelectivityRatio(); 34 | virtual double getSelectivityWindowLength(); 35 | }; 36 | 37 | } //namespace 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/model/operator/selectivity/IOperatorSelectivityDistribution.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.model.operator.selectivity; 17 | 18 | // 19 | // TODO auto-generated module 20 | // 21 | moduleinterface IOperatorSelectivityDistribution 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /src/model/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp.model; 2 | 3 | @namespace(ecsnetpp); 4 | @license(LGPL); 5 | -------------------------------------------------------------------------------- /src/model/source/eventrate/FixedSourceEventRateDistribution.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "FixedSourceEventRateDistribution.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(FixedSourceEventRateDistribution); 21 | 22 | void FixedSourceEventRateDistribution::initialize() { 23 | rate = getAncestorPar("fixedSourceEventRate").doubleValue(); 24 | if (rate > 0) { 25 | messageDelay = 1 / rate; 26 | } else { 27 | throw cRuntimeError("Event rate is not set for the source : %s", getFullPath().c_str()); 28 | } 29 | } 30 | 31 | double FixedSourceEventRateDistribution::getMessageDelay() { 32 | return messageDelay; 33 | } 34 | 35 | } //namespace 36 | -------------------------------------------------------------------------------- /src/model/source/eventrate/FixedSourceEventRateDistribution.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef __EDGECLOUDSTREAMINGSIMULATOR_FIXEDSOURCEEVENTRATEDISTRIBUTION_H_ 17 | #define __EDGECLOUDSTREAMINGSIMULATOR_FIXEDSOURCEEVENTRATEDISTRIBUTION_H_ 18 | 19 | #include 20 | 21 | #include "ISourceEventRateDistribution.h" 22 | 23 | using namespace omnetpp; 24 | 25 | namespace ecsnetpp { 26 | 27 | /** 28 | * TODO - Generated class 29 | */ 30 | class FixedSourceEventRateDistribution : public ISourceEventRateDistribution 31 | { 32 | protected: 33 | double rate; 34 | double messageDelay; 35 | protected: 36 | virtual void initialize() override; 37 | public: 38 | virtual double getMessageDelay() override; 39 | }; 40 | 41 | } //namespace 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/model/source/eventrate/FixedSourceEventRateDistribution.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.model.source.eventrate; 17 | 18 | // 19 | // TODO auto-generated module 20 | // 21 | simple FixedSourceEventRateDistribution like ISourceEventRateDistribution 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /src/model/source/eventrate/ISourceEventRateDistribution.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "ISourceEventRateDistribution.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | double ISourceEventRateDistribution::getMessageDelay(){ 21 | throw new cRuntimeError("Source event rate distribution function is not implemented."); 22 | } 23 | } /* namespace ecsnetpp */ 24 | -------------------------------------------------------------------------------- /src/model/source/eventrate/ISourceEventRateDistribution.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef MODEL_SOURCE_EVENTRATE_ISOURCEEVENTRATEDISTRIBUTION_H_ 17 | #define MODEL_SOURCE_EVENTRATE_ISOURCEEVENTRATEDISTRIBUTION_H_ 18 | #include "omnetpp.h" 19 | 20 | using namespace omnetpp; 21 | 22 | namespace ecsnetpp { 23 | 24 | class ISourceEventRateDistribution: public cSimpleModule 25 | { 26 | protected: 27 | virtual void initialize() { 28 | } 29 | ; 30 | public: 31 | virtual double getMessageDelay(); 32 | }; 33 | 34 | } /* namespace ecsnetpp */ 35 | 36 | #endif /* MODEL_SOURCE_EVENTRATE_ISOURCEEVENTRATEDISTRIBUTION_H_ */ 37 | -------------------------------------------------------------------------------- /src/model/source/eventrate/ISourceEventRateDistribution.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.model.source.eventrate; 17 | 18 | moduleinterface ISourceEventRateDistribution 19 | { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/model/source/eventrate/NormallyDistributedSourceEventRate.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "NormallyDistributedSourceEventRate.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(NormallyDistributedSourceEventRate); 21 | 22 | void NormallyDistributedSourceEventRate::initialize() { 23 | mean = par("mean").doubleValue(); 24 | stddev = par("stddev").doubleValue(); 25 | } 26 | 27 | double NormallyDistributedSourceEventRate::getMessageDelay(){ 28 | double val = truncnormal(mean, stddev); 29 | std::cout << val << endl; 30 | return val; 31 | } 32 | 33 | } /* namespace ecsnetpp */ 34 | -------------------------------------------------------------------------------- /src/model/source/eventrate/NormallyDistributedSourceEventRate.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef MODEL_SOURCE_EVENTRATE_NORMALLYDISTRIBUTEDSOURCEEVENTRATE_H_ 17 | #define MODEL_SOURCE_EVENTRATE_NORMALLYDISTRIBUTEDSOURCEEVENTRATE_H_ 18 | 19 | #include "omnetpp.h" 20 | 21 | #include "ISourceEventRateDistribution.h" 22 | 23 | using namespace omnetpp; 24 | 25 | namespace ecsnetpp { 26 | 27 | class NormallyDistributedSourceEventRate: public ISourceEventRateDistribution { 28 | protected: 29 | double mean; 30 | double stddev; 31 | protected: 32 | virtual void initialize() override; 33 | public: 34 | virtual double getMessageDelay() override; 35 | }; 36 | 37 | } /* namespace ecsnetpp */ 38 | 39 | #endif /* MODEL_SOURCE_EVENTRATE_NORMALLYDISTRIBUTEDSOURCEEVENTRATE_H_ */ 40 | -------------------------------------------------------------------------------- /src/model/source/eventrate/NormallyDistributedSourceEventRate.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.model.source.eventrate; 17 | 18 | simple NormallyDistributedSourceEventRate like ISourceEventRateDistribution 19 | { 20 | parameters: 21 | // double mean; 22 | // double stddev; 23 | } 24 | -------------------------------------------------------------------------------- /src/model/source/eventrate/UniformSourceEventRateDistribution.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "UniformSourceEventRateDistribution.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(UniformSourceEventRateDistribution); 21 | 22 | void UniformSourceEventRateDistribution::initialize() 23 | { 24 | begin = par("begin").doubleValue(); 25 | end = par("end").doubleValue(); 26 | } 27 | 28 | double UniformSourceEventRateDistribution::getMessageDelay(){ 29 | return uniform(begin, end); 30 | } 31 | 32 | } //namespace 33 | -------------------------------------------------------------------------------- /src/model/source/eventrate/UniformSourceEventRateDistribution.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef __EDGECLOUDSTREAMINGSIMULATOR_UNIFORMSOURCEEVENTRATEDISTRIBUTION_H_ 17 | #define __EDGECLOUDSTREAMINGSIMULATOR_UNIFORMSOURCEEVENTRATEDISTRIBUTION_H_ 18 | 19 | #include 20 | 21 | #include "ISourceEventRateDistribution.h" 22 | 23 | using namespace omnetpp; 24 | 25 | namespace ecsnetpp { 26 | 27 | /** 28 | * TODO - Generated class 29 | */ 30 | class UniformSourceEventRateDistribution : public ISourceEventRateDistribution 31 | { 32 | protected: 33 | double begin; 34 | double end; 35 | protected: 36 | virtual void initialize() override; 37 | public: 38 | virtual double getMessageDelay() override; 39 | }; 40 | 41 | } //namespace 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/model/source/eventrate/UniformSourceEventRateDistribution.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.model.source.eventrate; 17 | 18 | // 19 | // TODO auto-generated module 20 | // 21 | simple UniformSourceEventRateDistribution like ISourceEventRateDistribution 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /src/model/source/msgsize/FixedMessageSizeDistribution.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "FixedMessageSizeDistribution.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(FixedMessageSizeDistribution); 21 | 22 | void FixedMessageSizeDistribution::initialize() 23 | { 24 | msgSize = par("msgsize").doubleValue(); 25 | } 26 | 27 | double FixedMessageSizeDistribution::getMsgSize() 28 | { 29 | return msgSize; 30 | } 31 | 32 | } //namespace 33 | -------------------------------------------------------------------------------- /src/model/source/msgsize/FixedMessageSizeDistribution.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef __EDGECLOUDSTREAMINGSIMULATOR_FIXEDMESSAGESIZEDISTRIBUTION_H_ 17 | #define __EDGECLOUDSTREAMINGSIMULATOR_FIXEDMESSAGESIZEDISTRIBUTION_H_ 18 | 19 | #include 20 | #include "IMessageSizeDistribution.h" 21 | 22 | using namespace omnetpp; 23 | 24 | namespace ecsnetpp { 25 | 26 | /** 27 | * TODO - Generated class 28 | */ 29 | class FixedMessageSizeDistribution : public IMessageSizeDistribution 30 | { 31 | protected: 32 | double msgSize; 33 | protected: 34 | virtual void initialize() override; 35 | public: 36 | virtual double getMsgSize() override; 37 | }; 38 | 39 | } //namespace 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/model/source/msgsize/FixedMessageSizeDistribution.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.model.source.msgsize; 17 | 18 | // 19 | // TODO auto-generated module 20 | // 21 | simple FixedMessageSizeDistribution like IMessageSizeDistribution 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /src/model/source/msgsize/IMessageSizeDistribution.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "IMessageSizeDistribution.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(IMessageSizeDistribution); 21 | 22 | double IMessageSizeDistribution::getMsgSize() 23 | { 24 | throw new cRuntimeError("Source message size distribution function is not implemented."); 25 | } 26 | 27 | } //namespace 28 | -------------------------------------------------------------------------------- /src/model/source/msgsize/IMessageSizeDistribution.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef __EDGECLOUDSTREAMINGSIMULATOR_IMESSAGESIZEDISTRIBUTION_H_ 17 | #define __EDGECLOUDSTREAMINGSIMULATOR_IMESSAGESIZEDISTRIBUTION_H_ 18 | 19 | #include 20 | 21 | using namespace omnetpp; 22 | 23 | namespace ecsnetpp { 24 | 25 | /** 26 | * TODO - Generated class 27 | */ 28 | class IMessageSizeDistribution : public cSimpleModule 29 | { 30 | protected: 31 | virtual void initialize() { 32 | } 33 | ; 34 | public: 35 | virtual double getMsgSize(); 36 | }; 37 | 38 | } //namespace 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/model/source/msgsize/IMessageSizeDistribution.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.model.source.msgsize; 17 | 18 | // 19 | // TODO auto-generated module 20 | // 21 | moduleinterface IMessageSizeDistribution 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /src/msg/Ack.msg: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | namespace ecsnetpp; 17 | 18 | // 19 | // TODO generated message class 20 | // 21 | packet Ack { 22 | int ackedMessageId; 23 | string sender; 24 | } 25 | -------------------------------------------------------------------------------- /src/msg/Ack_m.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file, do not edit! Created by nedtool 5.1 from msg/Ack.msg. 3 | // 4 | 5 | #if defined(__clang__) 6 | # pragma clang diagnostic ignored "-Wreserved-id-macro" 7 | #endif 8 | #ifndef __ECSNETPP_ACK_M_H 9 | #define __ECSNETPP_ACK_M_H 10 | 11 | #include 12 | 13 | // nedtool version check 14 | #define MSGC_VERSION 0x0501 15 | #if (MSGC_VERSION!=OMNETPP_VERSION) 16 | # error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. 17 | #endif 18 | 19 | 20 | namespace ecsnetpp { 21 | 22 | /** 23 | * Class generated from msg/Ack.msg:21 by nedtool. 24 | *
25 |  * //
26 |  * // TODO generated message class
27 |  * //
28 |  * packet Ack
29 |  * {
30 |  *     int ackedMessageId;
31 |  *     string sender;
32 |  * }
33 |  * 
34 | */ 35 | class Ack : public ::omnetpp::cPacket 36 | { 37 | protected: 38 | int ackedMessageId; 39 | ::omnetpp::opp_string sender; 40 | 41 | private: 42 | void copy(const Ack& other); 43 | 44 | protected: 45 | // protected and unimplemented operator==(), to prevent accidental usage 46 | bool operator==(const Ack&); 47 | 48 | public: 49 | Ack(const char *name=nullptr, short kind=0); 50 | Ack(const Ack& other); 51 | virtual ~Ack(); 52 | Ack& operator=(const Ack& other); 53 | virtual Ack *dup() const override {return new Ack(*this);} 54 | virtual void parsimPack(omnetpp::cCommBuffer *b) const override; 55 | virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; 56 | 57 | // field getter/setter methods 58 | virtual int getAckedMessageId() const; 59 | virtual void setAckedMessageId(int ackedMessageId); 60 | virtual const char * getSender() const; 61 | virtual void setSender(const char * sender); 62 | }; 63 | 64 | inline void doParsimPacking(omnetpp::cCommBuffer *b, const Ack& obj) {obj.parsimPack(b);} 65 | inline void doParsimUnpacking(omnetpp::cCommBuffer *b, Ack& obj) {obj.parsimUnpack(b);} 66 | 67 | } // namespace ecsnetpp 68 | 69 | #endif // ifndef __ECSNETPP_ACK_M_H 70 | 71 | -------------------------------------------------------------------------------- /src/msg/StreamingMessage.msg: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | namespace ecsnetpp; 17 | 18 | cplusplus {{ 19 | #include "omnetpp.h" 20 | }} 21 | //class noncobject SomeType; 22 | 23 | //cplusplus {{ 24 | //#include 25 | //typedef OtherType std::map; 26 | //}} 27 | //class noncobject OtherType; 28 | 29 | // 30 | // TODO generated message class 31 | // 32 | packet StreamingMessage { 33 | int messageId; 34 | string sender; 35 | // int size; 36 | string content; 37 | bool isProcessingDelayInCyclesPerEvent; 38 | // double cyclesPerEvent; 39 | double processingDelayPerEvent; 40 | double selectivityRatio; 41 | simtime_t startTime; 42 | simtime_t operatorIngressTime; 43 | simtime_t channelIngressTime; 44 | double networkDelay; 45 | double processingDelay; 46 | double edgeProcessingDelay; 47 | } 48 | -------------------------------------------------------------------------------- /src/msg/StreamingMessage_m.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file, do not edit! Created by nedtool 5.1 from msg/StreamingMessage.msg. 3 | // 4 | 5 | #if defined(__clang__) 6 | # pragma clang diagnostic ignored "-Wreserved-id-macro" 7 | #endif 8 | #ifndef __ECSNET_STREAMINGMESSAGE_M_H 9 | #define __ECSNET_STREAMINGMESSAGE_M_H 10 | 11 | #include 12 | 13 | // nedtool version check 14 | #define MSGC_VERSION 0x0501 15 | #if (MSGC_VERSION!=OMNETPP_VERSION) 16 | # error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. 17 | #endif 18 | 19 | 20 | namespace ecsnetpp { 21 | 22 | // cplusplus {{ 23 | #include "omnetpp.h" 24 | // }} 25 | 26 | /** 27 | * Class generated from msg/StreamingMessage.msg:32 by nedtool. 28 | *
 29 |  * //
 30 |  * // TODO generated message class
 31 |  * //
 32 |  * packet StreamingMessage
 33 |  * {
 34 |  *     int messageId;
 35 |  *     string sender;
 36 |  *     //	int size;
 37 |  *     string content;
 38 |  *     bool isProcessingDelayInCyclesPerEvent;
 39 |  *     //	double cyclesPerEvent;
 40 |  *     double processingDelayPerEvent;
 41 |  *     double selectivityRatio;
 42 |  *     simtime_t startTime;
 43 |  *     simtime_t operatorIngressTime;
 44 |  *     simtime_t channelIngressTime;
 45 |  *     double networkDelay;
 46 |  *     double processingDelay;
 47 |  *     double edgeProcessingDelay;
 48 |  * }
 49 |  * 
50 | */ 51 | class StreamingMessage : public ::omnetpp::cPacket 52 | { 53 | protected: 54 | int messageId; 55 | ::omnetpp::opp_string sender; 56 | ::omnetpp::opp_string content; 57 | bool isProcessingDelayInCyclesPerEvent; 58 | double processingDelayPerEvent; 59 | double selectivityRatio; 60 | ::omnetpp::simtime_t startTime; 61 | ::omnetpp::simtime_t operatorIngressTime; 62 | ::omnetpp::simtime_t channelIngressTime; 63 | double networkDelay; 64 | double processingDelay; 65 | double edgeProcessingDelay; 66 | 67 | private: 68 | void copy(const StreamingMessage& other); 69 | 70 | protected: 71 | // protected and unimplemented operator==(), to prevent accidental usage 72 | bool operator==(const StreamingMessage&); 73 | 74 | public: 75 | StreamingMessage(const char *name=nullptr, short kind=0); 76 | StreamingMessage(const StreamingMessage& other); 77 | virtual ~StreamingMessage(); 78 | StreamingMessage& operator=(const StreamingMessage& other); 79 | virtual StreamingMessage *dup() const override {return new StreamingMessage(*this);} 80 | virtual void parsimPack(omnetpp::cCommBuffer *b) const override; 81 | virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; 82 | 83 | // field getter/setter methods 84 | virtual int getMessageId() const; 85 | virtual void setMessageId(int messageId); 86 | virtual const char * getSender() const; 87 | virtual void setSender(const char * sender); 88 | virtual const char * getContent() const; 89 | virtual void setContent(const char * content); 90 | virtual bool getIsProcessingDelayInCyclesPerEvent() const; 91 | virtual void setIsProcessingDelayInCyclesPerEvent(bool isProcessingDelayInCyclesPerEvent); 92 | virtual double getProcessingDelayPerEvent() const; 93 | virtual void setProcessingDelayPerEvent(double processingDelayPerEvent); 94 | virtual double getSelectivityRatio() const; 95 | virtual void setSelectivityRatio(double selectivityRatio); 96 | virtual ::omnetpp::simtime_t getStartTime() const; 97 | virtual void setStartTime(::omnetpp::simtime_t startTime); 98 | virtual ::omnetpp::simtime_t getOperatorIngressTime() const; 99 | virtual void setOperatorIngressTime(::omnetpp::simtime_t operatorIngressTime); 100 | virtual ::omnetpp::simtime_t getChannelIngressTime() const; 101 | virtual void setChannelIngressTime(::omnetpp::simtime_t channelIngressTime); 102 | virtual double getNetworkDelay() const; 103 | virtual void setNetworkDelay(double networkDelay); 104 | virtual double getProcessingDelay() const; 105 | virtual void setProcessingDelay(double processingDelay); 106 | virtual double getEdgeProcessingDelay() const; 107 | virtual void setEdgeProcessingDelay(double edgeProcessingDelay); 108 | }; 109 | 110 | inline void doParsimPacking(omnetpp::cCommBuffer *b, const StreamingMessage& obj) {obj.parsimPack(b);} 111 | inline void doParsimUnpacking(omnetpp::cCommBuffer *b, StreamingMessage& obj) {obj.parsimUnpack(b);} 112 | 113 | } // namespace ecsnetpp 114 | 115 | #endif // ifndef __ECSNET_STREAMINGMESSAGE_M_H 116 | 117 | -------------------------------------------------------------------------------- /src/msg/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp.msg; 2 | 3 | @namespace(ecsnetpp); 4 | @license(LGPL); 5 | -------------------------------------------------------------------------------- /src/networks/.qtenvrc: -------------------------------------------------------------------------------- 1 | [General] 2 | last-configname=General 3 | last-runnumber=0 4 | -------------------------------------------------------------------------------- /src/networks/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp.networks; 2 | 3 | @namespace(ecsnetpp); 4 | @license(LGPL); 5 | -------------------------------------------------------------------------------- /src/networks/simpleedgecloudenvironment.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.networks; 17 | 18 | import ecsnetpp.host.RaspberryPiModel2B; 19 | import ecsnetpp.host.RaspberryPiModel3B; 20 | import ecsnetpp.host.CloudNodeA; 21 | import ecsnetpp.builder.TaskBuilder; 22 | import ecsnetpp.builder.ECSBuilder; 23 | import ecsnetpp.common.SimulationController; 24 | import inet.visualizer.integrated.IntegratedCanvasVisualizer; 25 | import inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator; 26 | import inet.physicallayer.ieee80211.packetlevel.Ieee80211ScalarRadioMedium; 27 | import inet.common.lifecycle.LifecycleController; 28 | import inet.common.figures.DelegateSignalConfigurator; 29 | import inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator; 30 | import inet.node.inet.INetworkNode; 31 | import inet.physicallayer.contract.packetlevel.IRadioMedium; 32 | import inet.visualizer.contract.IIntegratedVisualizer; 33 | import inet.node.ethernet.Eth100M; 34 | import inet.node.ethernet.Eth10M; 35 | import inet.node.ethernet.Eth100G; 36 | import inet.node.ethernet.Eth1G; 37 | import inet.node.ethernet.EtherLink; 38 | import inet.node.ethernet.EtherSwitch; 39 | import inet.node.inet.Router; 40 | import inet.node.internetcloud.InternetCloud; 41 | import inet.node.wireless.AccessPoint; 42 | import ned.DatarateChannel; 43 | 44 | network SimpleEdgeCloudEnvironment 45 | { 46 | parameters: 47 | double eToCDelayMean @unit(ms) = default(0ms); 48 | double eToCDelayStdev @unit(ms) = default(0ms); 49 | double eToCDatarate @unit(bps) = default(1Gbps); 50 | bool ackersEnabled = default(false); 51 | bool hasGlobalSupervisor = default(true); 52 | int numPiModel2Bs = default(4); 53 | int numPiModel3Bs = default(4); 54 | string mediumType = default("IdealRadioMedium"); 55 | string cloudAddress = default(""); 56 | @display("bgb=884.304,707.72797"); 57 | types: 58 | channel E2C_low extends DatarateChannel 59 | { 60 | delay = 0; 61 | datarate = eToCDatarate; 62 | } 63 | 64 | channel E2C_high extends DatarateChannel 65 | { 66 | delay = eToCDelayMean; 67 | datarate = eToCDatarate; 68 | } 69 | submodules: 70 | pi2Bs[numPiModel2Bs]: RaspberryPiModel2B; 71 | pi3Bs[numPiModel3Bs]: RaspberryPiModel3B; 72 | stargazer3: CloudNodeA { 73 | @display("p=246.35199,131.008,r"); 74 | } 75 | albacore5: Router { 76 | @display("p=331.792,263.44"); 77 | } 78 | // switch1: EtherSwitch { 79 | // @display("p=371.664,226.416"); 80 | // } 81 | area1AP1: AccessPoint { 82 | @display("p=357.42398,380.208"); 83 | } 84 | taskbuilder: ECSBuilder { 85 | @display("p=492.70398,39.871998"); 86 | } 87 | simController: SimulationController { 88 | @display("p=783.2,39.871998"); 89 | } 90 | radioMedium: Ieee80211ScalarRadioMedium { 91 | @display("p=344.608,38.447998"); 92 | } 93 | configurator: IPv4NetworkConfigurator { 94 | @display("p=193.664,38.447998"); 95 | } 96 | visualizer: IntegratedCanvasVisualizer { 97 | @display("p=629.408,38.447998"); 98 | } 99 | lifecycleController: LifecycleController { 100 | @display("p=24.208,41.295998"); 101 | } 102 | connections: 103 | stargazer3.ethg++ <--> E2C_high <--> albacore5.ethg++; 104 | albacore5.ethg++ <--> E2C_low <--> area1AP1.ethg++; 105 | 106 | } 107 | -------------------------------------------------------------------------------- /src/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp; 2 | 3 | @license(LGPL); 4 | -------------------------------------------------------------------------------- /src/power/States.h: -------------------------------------------------------------------------------- 1 | /* 2 | * States.h 3 | * 4 | * Created on: Nov 4, 2017 5 | * Author: gayashan 6 | */ 7 | 8 | #ifndef POWER_STATES_H_ 9 | #define POWER_STATES_H_ 10 | 11 | class States { 12 | public: 13 | enum CPUState{ 14 | CPU_IDLE, 15 | CPU_BUSY 16 | }; 17 | }; 18 | 19 | 20 | 21 | #endif /* POWER_STATES_H_ */ 22 | -------------------------------------------------------------------------------- /src/power/consumer/CPUPowerConsumer.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "CPUPowerConsumer.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | simsignal_t CPUPowerConsumer::cpuPowerConsumptionChangedSignal = registerSignal("cpuPowerConsumptionChanged"); 21 | 22 | Define_Module(CPUPowerConsumer); 23 | 24 | void CPUPowerConsumer::initialize(int stage) { 25 | cSimpleModule::initialize(stage); 26 | if (stage == inet::INITSTAGE_LOCAL) { 27 | cpuBusyUtilisation = par("cpuBusyUtilisation").doubleValue(); 28 | cpuIdleUtilisation = par("cpuIdleUtilisation").doubleValue(); 29 | cpuPowerConsumptionScalar = 30 | par("cpuPowerConsumptionScalar").doubleValue(); 31 | idlePowerConsumption = W(par("idlePowerConsumption")); 32 | 33 | prevState = States::CPU_IDLE; 34 | cModule *host = findContainingNode(this); 35 | host->subscribe(ISTask::cpuStateChangedSignal, this); 36 | powerConsumption = W(0); 37 | WATCH(powerConsumption); 38 | } 39 | } 40 | 41 | W CPUPowerConsumer::computeCPUPowerConsumption(double value) const { 42 | W _powerConsumption = W(0); 43 | if (value == States::CPU_BUSY) { 44 | if (prevState == States::CPU_BUSY) { 45 | _powerConsumption = W( 46 | cpuPowerConsumptionScalar * cpuBusyUtilisation); 47 | } else if (prevState == States::CPU_IDLE) { 48 | _powerConsumption = W( 49 | cpuPowerConsumptionScalar * cpuIdleUtilisation); 50 | } 51 | prevState = States::CPU_BUSY; 52 | } else if (value == States::CPU_IDLE) { 53 | if (prevState == States::CPU_BUSY) { 54 | _powerConsumption = W( 55 | cpuPowerConsumptionScalar * cpuBusyUtilisation); 56 | } else if (prevState == States::CPU_IDLE) { 57 | _powerConsumption = W( 58 | cpuPowerConsumptionScalar * cpuIdleUtilisation); 59 | } 60 | prevState = States::CPU_IDLE; 61 | } else { 62 | _powerConsumption = W(0); 63 | } 64 | // EV << "CPU Power consumption=" << _powerConsumption << endl; 65 | return _powerConsumption; 66 | } 67 | 68 | void CPUPowerConsumer::receiveSignal(cComponent *source, simsignal_t signal, 69 | long value, cObject *details) { 70 | 71 | if (simTime() >= getSimulation()->getWarmupPeriod()) { 72 | if (signal == ISTask::cpuStateChangedSignal) { 73 | powerConsumption = computeCPUPowerConsumption(value); 74 | emit(cpuPowerConsumptionChangedSignal, powerConsumption.get()); 75 | } else 76 | throw cRuntimeError("Unknown signal"); 77 | } 78 | } 79 | 80 | } /* namespace ecsnetpp */ 81 | -------------------------------------------------------------------------------- /src/power/consumer/CPUPowerConsumer.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef POWER_CONSUMER_CPUPOWERCONSUMER_H_ 17 | #define POWER_CONSUMER_CPUPOWERCONSUMER_H_ 18 | 19 | #include "inet/power/contract/IEpEnergySource.h" 20 | #include "inet/power/contract/IEpEnergyConsumer.h" 21 | #include "inet/common/ModuleAccess.h" 22 | #include "../../stask/ISTask.h" 23 | 24 | using namespace inet; 25 | using namespace inet::power; 26 | 27 | namespace ecsnetpp { 28 | 29 | class CPUPowerConsumer : public cSimpleModule, public cListener { 30 | protected: 31 | double cpuPowerConsumptionScalar = NaN; 32 | double cpuBusyUtilisation; 33 | double cpuIdleUtilisation; 34 | W idlePowerConsumption = W(NaN); 35 | IEpEnergySource *energySource = nullptr; 36 | 37 | // state 38 | mutable States::CPUState prevState; 39 | W powerConsumption = W(NaN); 40 | public: 41 | static simsignal_t cpuPowerConsumptionChangedSignal; 42 | 43 | protected: 44 | virtual int numInitStages() const override { return NUM_INIT_STAGES; } 45 | virtual void initialize(int stage) override; 46 | virtual W computeCPUPowerConsumption(double value) const; 47 | public: 48 | virtual IEnergySource *getEnergySource() const { return energySource; } 49 | virtual W getPowerConsumption() const {return powerConsumption;} 50 | 51 | virtual void receiveSignal(cComponent *source, simsignal_t signal, long value, cObject *details) override; 52 | }; 53 | 54 | } /* namespace ecsnetpp */ 55 | 56 | #endif /* POWER_CONSUMER_CPUEPENERGYCONSUMER_H_ */ 57 | -------------------------------------------------------------------------------- /src/power/consumer/CPUPowerConsumer.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.power.consumer; 17 | 18 | simple CPUPowerConsumer 19 | { 20 | parameters: 21 | string energySourceModule; 22 | double cpuPowerConsumptionScalar = default(0); 23 | double cpuBusyUtilisation = default(1); 24 | double cpuIdleUtilisation = default(0); 25 | double idlePowerConsumption @unit(W) = default(0mW); 26 | @display("i=block/cogwheel"); 27 | @signal[cpuPowerConsumptionChanged](type=double); 28 | @statistic[cpuPowerConsumption](title="CPU Power consumption"; source=cpuPowerConsumptionChanged; record=vector; interpolationmode=sample-hold); 29 | 30 | @class(CPUPowerConsumer); 31 | } 32 | -------------------------------------------------------------------------------- /src/power/consumer/NetworkPowerConsumer.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "NetworkPowerConsumer.h" 17 | 18 | #include "inet/common/ModuleAccess.h" 19 | #include "../../stask/ISTask.h" 20 | 21 | namespace ecsnetpp { 22 | 23 | simsignal_t NetworkPowerConsumer::networkPowerConsumptionChangedSignal = registerSignal("networkPowerConsumptionChanged"); 24 | 25 | Define_Module(NetworkPowerConsumer); 26 | 27 | void NetworkPowerConsumer::initialize(int stage) { 28 | cSimpleModule::initialize(stage); 29 | if (stage == inet::INITSTAGE_LOCAL) { 30 | offPowerConsumption = W(par("offPowerConsumption")); 31 | sleepPowerConsumption = W(par("sleepPowerConsumption")); 32 | switchingPowerConsumption = W(par("switchingPowerConsumption")); 33 | receiverIdlePowerConsumption = W(par("receiverIdlePowerConsumption")); 34 | receiverBusyPowerConsumption = W(par("receiverBusyPowerConsumption")); 35 | receiverReceivingPowerConsumption = W( 36 | par("receiverReceivingPowerConsumption")); 37 | receiverReceivingPreamblePowerConsumption = W( 38 | par("receiverReceivingPreamblePowerConsumption")); 39 | receiverReceivingHeaderPowerConsumption = W( 40 | par("receiverReceivingHeaderPowerConsumption")); 41 | receiverReceivingDataPowerConsumption = W( 42 | par("receiverReceivingDataPowerConsumption")); 43 | transmitterIdlePowerConsumption = W( 44 | par("transmitterIdlePowerConsumption")); 45 | transmitterTransmittingPowerConsumption = W( 46 | par("transmitterTransmittingPowerConsumption")); 47 | transmitterTransmittingPreamblePowerConsumption = W( 48 | par("transmitterTransmittingPreamblePowerConsumption")); 49 | transmitterTransmittingHeaderPowerConsumption = W( 50 | par("transmitterTransmittingHeaderPowerConsumption")); 51 | transmitterTransmittingDataPowerConsumption = W( 52 | par("transmitterTransmittingDataPowerConsumption")); 53 | cpuPowerConsumptionScalar = 54 | par("cpuPowerConsumptionScalar").doubleValue(); 55 | cModule *parent = getParentModule(); 56 | parent->subscribe(IRadio::radioModeChangedSignal, this); 57 | parent->subscribe(IRadio::receptionStateChangedSignal, this); 58 | parent->subscribe(IRadio::transmissionStateChangedSignal, this); 59 | parent->subscribe(IRadio::receivedSignalPartChangedSignal, this); 60 | parent->subscribe(IRadio::transmittedSignalPartChangedSignal, 61 | this); 62 | 63 | cModule *radioModule = parent->getSubmodule("wlan", 0)->getSubmodule("radio"); 64 | radio = check_and_cast(radioModule); 65 | powerConsumption = W(0); 66 | WATCH(powerConsumption); 67 | } 68 | } 69 | 70 | W NetworkPowerConsumer::computePowerConsumption() const 71 | { 72 | IRadio::RadioMode radioMode = radio->getRadioMode(); 73 | if (radioMode == IRadio::RADIO_MODE_OFF) 74 | return offPowerConsumption; 75 | else if (radioMode == IRadio::RADIO_MODE_SLEEP) 76 | return sleepPowerConsumption; 77 | else if (radioMode == IRadio::RADIO_MODE_SWITCHING) 78 | return switchingPowerConsumption; 79 | W _powerConsumption = W(0); 80 | IRadio::ReceptionState receptionState = radio->getReceptionState(); 81 | IRadio::TransmissionState transmissionState = radio->getTransmissionState(); 82 | if (radioMode == IRadio::RADIO_MODE_RECEIVER || radioMode == IRadio::RADIO_MODE_TRANSCEIVER) { 83 | // std::cout << "RCV " << _powerConsumption << endl; 84 | if (receptionState == IRadio::RECEPTION_STATE_IDLE){ 85 | _powerConsumption += receiverIdlePowerConsumption; 86 | // std::cout << "RCV receiverIdlePowerConsumption " << _powerConsumption << endl; 87 | } else if (receptionState == IRadio::RECEPTION_STATE_BUSY){ 88 | _powerConsumption += receiverBusyPowerConsumption; 89 | // std::cout << "RCV receiverBusyPowerConsumption " << _powerConsumption << endl; 90 | } else if (receptionState == IRadio::RECEPTION_STATE_RECEIVING) { 91 | auto part = radio->getReceivedSignalPart(); 92 | if (part == IRadioSignal::SIGNAL_PART_NONE) 93 | ; 94 | else if (part == IRadioSignal::SIGNAL_PART_WHOLE){ 95 | _powerConsumption += receiverReceivingPowerConsumption; 96 | // std::cout << "RCV receiverReceivingPowerConsumption " << _powerConsumption << endl; 97 | }else if (part == IRadioSignal::SIGNAL_PART_PREAMBLE){ 98 | _powerConsumption += receiverReceivingPreamblePowerConsumption; 99 | // std::cout << "RCV receiverReceivingPreamblePowerConsumption " << _powerConsumption << endl; 100 | }else if (part == IRadioSignal::SIGNAL_PART_HEADER){ 101 | _powerConsumption += receiverReceivingHeaderPowerConsumption; 102 | // std::cout << "RCV receiverReceivingHeaderPowerConsumption " << _powerConsumption << endl; 103 | }else if (part == IRadioSignal::SIGNAL_PART_DATA){ 104 | _powerConsumption += receiverReceivingDataPowerConsumption; 105 | // std::cout << "RCV receiverReceivingDataPowerConsumption " << _powerConsumption << endl; 106 | }else{ 107 | throw cRuntimeError("Unknown received signal part"); 108 | // std::cout << "RCV unknown " << _powerConsumption << endl; 109 | } 110 | } 111 | else if (receptionState != IRadio::RECEPTION_STATE_UNDEFINED) 112 | throw cRuntimeError("Unknown radio reception state"); 113 | } 114 | if (radioMode == IRadio::RADIO_MODE_TRANSMITTER || radioMode == IRadio::RADIO_MODE_TRANSCEIVER) { 115 | // std::cout << "TRS " << _powerConsumption << endl; 116 | if (transmissionState == IRadio::TRANSMISSION_STATE_IDLE){ 117 | _powerConsumption += transmitterIdlePowerConsumption; 118 | // std::cout << "TRS transmitterIdlePowerConsumption " << _powerConsumption << endl; 119 | } else if (transmissionState == IRadio::TRANSMISSION_STATE_TRANSMITTING) { 120 | // TODO: add transmission power? 121 | auto part = radio->getTransmittedSignalPart(); 122 | if (part == IRadioSignal::SIGNAL_PART_NONE) 123 | ; 124 | else if (part == IRadioSignal::SIGNAL_PART_WHOLE){ 125 | _powerConsumption += transmitterTransmittingPowerConsumption; 126 | // std::cout << "TRS transmitterTransmittingPowerConsumption " << _powerConsumption << endl; 127 | } else if (part == IRadioSignal::SIGNAL_PART_PREAMBLE){ 128 | _powerConsumption += transmitterTransmittingPreamblePowerConsumption; 129 | // std::cout << "TRS transmitterTransmittingPreamblePowerConsumption " << _powerConsumption << endl; 130 | } else if (part == IRadioSignal::SIGNAL_PART_HEADER){ 131 | _powerConsumption += transmitterTransmittingHeaderPowerConsumption; 132 | // std::cout << "TRS transmitterTransmittingHeaderPowerConsumption " << _powerConsumption << endl; 133 | } else if (part == IRadioSignal::SIGNAL_PART_DATA){ 134 | _powerConsumption += transmitterTransmittingDataPowerConsumption; 135 | // std::cout << "TRS transmitterTransmittingDataPowerConsumption " << _powerConsumption << endl; 136 | } else{ 137 | throw cRuntimeError("Unknown transmitted signal part"); 138 | // std::cout << "TRS unknown " << _powerConsumption << endl; 139 | } 140 | } 141 | else if (transmissionState != IRadio::TRANSMISSION_STATE_UNDEFINED) 142 | throw cRuntimeError("Unknown radio transmission state"); 143 | } 144 | // std::cout << "Network Power consumption=" << _powerConsumption << endl; 145 | return _powerConsumption; 146 | } 147 | 148 | void NetworkPowerConsumer::receiveSignal(cComponent *source, 149 | simsignal_t signal, long value, cObject *details) { 150 | 151 | if (simTime() >= getSimulation()->getWarmupPeriod()) { 152 | if (signal == IRadio::radioModeChangedSignal 153 | || signal == IRadio::receptionStateChangedSignal 154 | || signal == IRadio::transmissionStateChangedSignal 155 | || signal == IRadio::receivedSignalPartChangedSignal 156 | || signal == IRadio::transmittedSignalPartChangedSignal) { 157 | powerConsumption = computePowerConsumption(); 158 | emit(networkPowerConsumptionChangedSignal, powerConsumption.get()); 159 | } else 160 | throw cRuntimeError("Unknown signal"); 161 | } 162 | } 163 | 164 | } /* namespace ecsnetpp */ 165 | -------------------------------------------------------------------------------- /src/power/consumer/NetworkPowerConsumer.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef POWER_CONSUMER_NETWORKPOWERCONSUMER_H_ 17 | #define POWER_CONSUMER_NETWORKPOWERCONSUMER_H_ 18 | 19 | #include "inet/physicallayer/contract/packetlevel/IRadio.h" 20 | #include "inet/power/contract/IEpEnergyConsumer.h" 21 | #include "inet/power/contract/IEpEnergySource.h" 22 | 23 | using namespace inet; 24 | using namespace inet::power; 25 | using namespace inet::physicallayer; 26 | 27 | namespace ecsnetpp { 28 | 29 | class NetworkPowerConsumer: public cSimpleModule, public cListener { 30 | 31 | protected: 32 | double cpuPowerConsumptionScalar = NaN; 33 | // parameters 34 | W offPowerConsumption = W(NaN); 35 | W sleepPowerConsumption = W(NaN); 36 | W switchingPowerConsumption = W(NaN); 37 | W receiverIdlePowerConsumption = W(NaN); 38 | W receiverBusyPowerConsumption = W(NaN); 39 | W receiverReceivingPowerConsumption = W(NaN); 40 | W receiverReceivingPreamblePowerConsumption = W(NaN); 41 | W receiverReceivingHeaderPowerConsumption = W(NaN); 42 | W receiverReceivingDataPowerConsumption = W(NaN); 43 | W transmitterIdlePowerConsumption = W(NaN); 44 | W transmitterTransmittingPowerConsumption = W(NaN); 45 | W transmitterTransmittingPreamblePowerConsumption = W(NaN); 46 | W transmitterTransmittingHeaderPowerConsumption = W(NaN); 47 | W transmitterTransmittingDataPowerConsumption = W(NaN); 48 | 49 | // environment 50 | IRadio *radio = nullptr; // TODO handle multiple ethernet interfaces 51 | 52 | // state 53 | W powerConsumption = W(NaN); 54 | 55 | public: 56 | static simsignal_t networkPowerConsumptionChangedSignal; 57 | 58 | protected: 59 | virtual int numInitStages() const override { return NUM_INIT_STAGES; } 60 | virtual W computePowerConsumption() const; 61 | virtual void initialize(int stage) override; 62 | 63 | public: 64 | virtual W getPowerConsumption() const {return powerConsumption;} 65 | virtual void receiveSignal(cComponent *source, simsignal_t signal, long value, cObject *details) override; 66 | }; 67 | 68 | } 69 | /* namespace ecsnetpp */ 70 | 71 | #endif /* POWER_CONSUMER_STREAMINGENERGYCONSUMER_H_ */ 72 | -------------------------------------------------------------------------------- /src/power/consumer/NetworkPowerConsumer.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.power.consumer; 17 | 18 | simple NetworkPowerConsumer 19 | { 20 | parameters: 21 | string energySourceModule; 22 | double cpuPowerConsumptionScalar = default(0); 23 | double offPowerConsumption @unit(W) = default(0mW); 24 | double sleepPowerConsumption @unit(W) = default(1mW); 25 | double switchingPowerConsumption @unit(W) = default(1mW); 26 | double receiverIdlePowerConsumption @unit(W) = default(2mW); 27 | double receiverBusyPowerConsumption @unit(W) = default(5mW); 28 | double receiverReceivingPowerConsumption @unit(W) = default(10mW); 29 | double receiverReceivingPreamblePowerConsumption @unit(W) = default(receiverReceivingPowerConsumption); 30 | double receiverReceivingHeaderPowerConsumption @unit(W) = default(receiverReceivingPowerConsumption); 31 | double receiverReceivingDataPowerConsumption @unit(W) = default(receiverReceivingPowerConsumption); 32 | double transmitterIdlePowerConsumption @unit(W) = default(2mW); 33 | double transmitterTransmittingPowerConsumption @unit(W) = default(100mW); 34 | double transmitterTransmittingPreamblePowerConsumption @unit(W) = default(transmitterTransmittingPowerConsumption); 35 | double transmitterTransmittingHeaderPowerConsumption @unit(W) = default(transmitterTransmittingPowerConsumption); 36 | double transmitterTransmittingDataPowerConsumption @unit(W) = default(transmitterTransmittingPowerConsumption); 37 | @display("i=block/cogwheel"); 38 | @signal[networkPowerConsumptionChanged](type=double); 39 | @statistic[networkPowerConsumption](title="Wireless Power consumption"; source=networkPowerConsumptionChanged; record=vector; interpolationmode=sample-hold); 40 | @class(NetworkPowerConsumer); 41 | } 42 | -------------------------------------------------------------------------------- /src/power/consumer/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp.power.consumer; 2 | 3 | @namespace(ecsnetpp); 4 | @license(LGPL); 5 | -------------------------------------------------------------------------------- /src/power/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp.power; 2 | 3 | @namespace(ecsnetpp); 4 | @license(LGPL); 5 | -------------------------------------------------------------------------------- /src/power/storage/IdealNodeEnergyStorage.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) OpenSim Ltd. 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU Lesser General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with this program; if not, see . 16 | // 17 | 18 | #ifndef POWER_STORAGE_IDEALNODEENERGYSTORAGE_H 19 | #define POWER_STORAGE_IDEALNODEENERGYSTORAGE_H 20 | 21 | #include "inet/common/Units.h" 22 | #include "inet/common/Units.h" 23 | #include "inet/common/INETMath.h" 24 | #include "omnetpp.h" 25 | #include "../../common/SimulationController.h" 26 | 27 | using namespace inet; 28 | using namespace inet::math; 29 | using namespace inet::units::values; 30 | using namespace omnetpp; 31 | 32 | namespace ecsnetpp { 33 | 34 | 35 | class IdealNodeEnergyStorage : public cSimpleModule, public cListener 36 | { 37 | protected: 38 | /** 39 | * The nominal capacity is in the range [0, +infinity). 40 | */ 41 | W idlePowerConsumption = W(0); 42 | J nominalCapacity = J(NaN); 43 | long cores = 1; 44 | 45 | /** 46 | * The residual capacity is in the range [0, nominalCapacity]. 47 | */ 48 | J residualCapacity = J(NaN); 49 | J energyBalance = J(NaN); 50 | J cpuEnergyConsumption = J(NAN); 51 | J networkEnergyConsumption = J(NAN); 52 | J totalEnergyConsumption = J(0); 53 | W totalPowerConsumption = W(0); 54 | W totalIdlePowerConsumption = W(0); 55 | // J _energyConsumption = J(0); 56 | cModule *networkNode = nullptr; 57 | std::map lastCPUEnergyBalanceUpdateMap; 58 | simtime_t lastCPUEnergyBalanceUpdate = -1; 59 | simtime_t lastWirelessEnergyBalanceUpdate = -1; 60 | simtime_t lastlastWirelessEnergyBalanceUpdate = -1; 61 | simtime_t startTime = -1; 62 | simtime_t firstCpuUse = -1; 63 | simtime_t lastCpuUse = -1; 64 | simtime_t edgeProcessingTime = 0; 65 | SimulationController *commonSimController; 66 | 67 | public: 68 | static simsignal_t energyConsumptionChangedSignal; 69 | static simsignal_t idleEnergyConsumptionChangedSignal; 70 | static simsignal_t powerConsumptionChangedSignal; 71 | // static simsignal_t idlePowerConsumptionChangedSignal; 72 | static simsignal_t cpuEnergyConsumptionChangedSignal; 73 | static simsignal_t networkEnergyConsumptionChangedSignal; 74 | static simsignal_t residualCapacityChangedSignal; 75 | static simsignal_t totalEnergySimTimeChangedSignal; 76 | 77 | protected: 78 | virtual void initialize(int stage) override; 79 | 80 | // virtual void updateTotalPowerConsumption(); 81 | // virtual void updateTotalPowerGeneration(); 82 | // virtual void updateEnergyBalance(); 83 | virtual void updateCPUEnergyBalance(W totalPowerConsumption, long index); 84 | virtual void updateWirelessEnergyBalance(W totalPowerConsumption, simtime_t currentTime); 85 | virtual J getTotalEnergy(); 86 | 87 | public: 88 | virtual double getNominalEnergyCapacity() const { return double(INFINITY); } 89 | virtual double getResidualEnergyCapacity() const { return double(INFINITY); } 90 | virtual void receiveSignal(cComponent *source, simsignal_t signal, double value, cObject *details) override; 91 | 92 | }; 93 | 94 | } 95 | 96 | #endif // ifndef __INET_IDEALEPENERGYSTORAGE_H 97 | 98 | -------------------------------------------------------------------------------- /src/power/storage/IdealNodeEnergyStorage.ned: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) OpenSim Ltd. 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, see . 16 | // 17 | 18 | package ecsnetpp.power.storage; 19 | 20 | import inet.power.base.EpEnergyStorageBase; 21 | 22 | // 23 | // This energy storage model stores an infinite amount of energy. It can provide 24 | // energy for any number of consumers, and it can absorb energy from any number 25 | // of generators. The ideal energy storage never gets completely charged or 26 | // depleted. This module is primarily useful for testing energy consumer and 27 | // energy generator models. See the base module for signals and statistics. 28 | // 29 | // @author Levente Meszaros 30 | // 31 | simple IdealNodeEnergyStorage 32 | { 33 | parameters: 34 | double idlePowerConsumption @unit(W) = default(0W); 35 | double nominalCapacity @unit(J); // the maximum amount of energy stored 36 | double initialCapacity @unit(J) = default(nominalCapacity); // the initially stored amount of energy 37 | @signal[energyConsumptionChanged](type=double); 38 | @signal[powerConsumptionChanged](type=double); 39 | @signal[idleEnergyConsumptionChanged](type=double); 40 | // @signal[idlePowerConsumptionChanged](type=double); 41 | @signal[cpuEnergyConsumptionChanged](type=double); 42 | @signal[networkEnergyConsumptionChanged](type=double); 43 | @signal[residualCapacityChanged](type=double); 44 | @signal[totalEnergySimTimeChanged](type=double); 45 | @statistic[energyConsumption](title="Total energy consumption"; unit=J; source=energyConsumptionChanged; record=last; interpolationmode=sample-hold); 46 | @statistic[powerConsumption](title="Total power consumption"; unit=W; source=powerConsumptionChanged; record=last; interpolationmode=sample-hold); 47 | @statistic[idleEnergyConsumption](title="Idle energy consumption"; unit=J; source=idleEnergyConsumptionChanged; record=last; interpolationmode=sample-hold); 48 | // @statistic[idlePowerConsumption](title="Idle power consumption"; unit=W; source=idlePowerConsumptionChanged; record=last; interpolationmode=sample-hold); 49 | @statistic[cpuEnergyConsumption](title="CPU energy consumption"; source=cpuEnergyConsumptionChanged; record=vector,last; interpolationmode=sample-hold); 50 | @statistic[networkEnergyConsumption](title="Network energy consumption"; source=networkEnergyConsumptionChanged; record=vector,last; interpolationmode=sample-hold); 51 | @statistic[residualCapacity](title="Residual Capacity"; source=residualCapacityChanged; record=vector; interpolationmode=sample-hold); 52 | @statistic[totalEnergySimTime](title="Total Energy sim time"; source=totalEnergySimTimeChanged; record=last; interpolationmode=sample-hold); 53 | 54 | @class(IdealNodeEnergyStorage); 55 | } 56 | -------------------------------------------------------------------------------- /src/stask/Acker.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ConsoleSink.cc 3 | * 4 | * Created on: Sep 26, 2017 5 | * Author: gayashan 6 | */ 7 | 8 | #include "omnetpp.h" 9 | #include "../msg/Ack_m.h" 10 | 11 | using namespace omnetpp; 12 | 13 | namespace ecsnetpp { 14 | 15 | class Acker: public cSimpleModule { 16 | 17 | protected: 18 | static simsignal_t rcvdAckSignal; 19 | 20 | protected: 21 | virtual void initialize() override; 22 | virtual void handleMessage(cMessage *msg) override; 23 | }; 24 | 25 | Define_Module(Acker); 26 | 27 | simsignal_t Acker::rcvdAckSignal = registerSignal("rcvdAck"); 28 | 29 | void Acker::initialize() { 30 | // cMessage *msg = new cMessage("Random Number"); 31 | // scheduleAt(simTime() + 1, msg); 32 | } 33 | 34 | void Acker::handleMessage(cMessage *msg) { 35 | Ack *pk = check_and_cast(msg); 36 | EV << "ACK RCVD from=" << pk->getSender() << " for MSG=" << pk->getAckedMessageId() 37 | << endl; 38 | emit(rcvdAckSignal, pk); 39 | delete msg; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/stask/Acker.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.stask; 17 | 18 | simple Acker 19 | { 20 | parameters: 21 | string name = default("Acker"); 22 | 23 | @signal[rcvdAck](type=cPacket); 24 | gates: 25 | input ackerIn; 26 | } -------------------------------------------------------------------------------- /src/stask/ISTask.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "ISTask.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | simsignal_t ISTask::receivedStreamingMsgsSignal = registerSignal("receivedStreamingMsgs"); 21 | simsignal_t ISTask::cpuUtilisationSignal = registerSignal("cpuUtilisationSignal"); 22 | simsignal_t ISTask::cpuStateChangedSignal = registerSignal("cpuStateChanged"); 23 | simsignal_t ISTask::latencySignal = registerSignal("latency"); 24 | simsignal_t ISTask::transmissionTimeSignal = registerSignal("transmissionTime"); 25 | simsignal_t ISTask::processingTimeSignal = registerSignal("processingTime"); 26 | simsignal_t ISTask::edgeProcessingTimeSignal = registerSignal("edgeProcessingTime"); 27 | 28 | void ISTask::sendAck(cMessage* msg) { 29 | // send ack 30 | if(ackersEnabled){ 31 | Ack* ack = new Ack(); 32 | ack->setAckedMessageId(msg->getId()); 33 | ack->setSender(getFullPath().c_str()); 34 | send(ack, "ackerOut"); 35 | } 36 | } 37 | 38 | void ISTask::publishCpuStateChanged(States::CPUState state){ 39 | emit(cpuStateChangedSignal, state); 40 | } 41 | 42 | long ISTask::getNextProcessorCoreIndex() { 43 | return myCpuCoreScheduler->getNextCPUCoreIndex(); 44 | } 45 | 46 | } /* namespace ecsnetpp */ 47 | -------------------------------------------------------------------------------- /src/stask/ISTask.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef STASK_ISTASK_H_ 17 | #define STASK_ISTASK_H_ 18 | 19 | #include "omnetpp.h" 20 | #include "../msg/StreamingMessage_m.h" 21 | #include "../msg/Ack_m.h" 22 | #include "../power/States.h" 23 | #include "../cpu/scheduling/ICpuCoreScheduler.h" 24 | 25 | using namespace omnetpp; 26 | 27 | namespace ecsnetpp { 28 | 29 | class ISTask: public cSimpleModule { 30 | public: 31 | static simsignal_t receivedStreamingMsgsSignal; 32 | static simsignal_t cpuUtilisationSignal; 33 | static simsignal_t cpuStateChangedSignal; 34 | static simsignal_t packetGeneratedSignal; 35 | static simsignal_t latencySignal; 36 | static simsignal_t transmissionTimeSignal; 37 | static simsignal_t processingTimeSignal; 38 | static simsignal_t edgeProcessingTimeSignal; 39 | 40 | protected: 41 | const char* mySenders; 42 | const char* mySTaskCategory; 43 | std::vector mySendersList; 44 | long cpuCores; 45 | long lastCPUIndex = 0; 46 | double perCoreFreq; 47 | double processingDelayPerEvent; 48 | double delay; 49 | bool ackersEnabled; 50 | bool isProcessingDelayInCpuCycles; 51 | ICpuCoreScheduler* myCpuCoreScheduler; 52 | protected: 53 | virtual void initialize() { 54 | } 55 | ; 56 | virtual void handleMessage(cMessage *msg) { 57 | } 58 | ; 59 | virtual long getNextProcessorCoreIndex(); 60 | virtual void sendAck(cMessage* msg); 61 | virtual void publishCpuStateChanged(States::CPUState state); 62 | }; 63 | 64 | } /* namespace ecsnetpp */ 65 | 66 | #endif /* STASK_ISTASK_H_ */ 67 | -------------------------------------------------------------------------------- /src/stask/ISTask.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.stask; 17 | 18 | moduleinterface ISTask 19 | { 20 | gates: 21 | inout port[]; 22 | output ackerOut; 23 | } 24 | -------------------------------------------------------------------------------- /src/stask/StreamingOperator.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "StreamingOperator.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(StreamingOperator); 21 | 22 | void StreamingOperator::finish() { 23 | cancelAndDelete(timerMsg); 24 | if (!outgoingQueue.isEmpty()) { 25 | outgoingQueue.clear(); 26 | } 27 | } 28 | 29 | void StreamingOperator::initialize() { 30 | omnetpp::cModule* submodule = getParentModule()->getSubmodule("cpuCoreScheduler"); 31 | myCpuCoreScheduler = check_and_cast(submodule); 32 | ackersEnabled = getAncestorPar("ackersEnabled").boolValue(); 33 | perCoreFreq = getAncestorPar("perCoreFreq").doubleValue(); 34 | isProcessingDelayInCpuCycles = par("isProcessingDelayInCpuCycles").boolValue(); 35 | // if (isProcessingDelayInCpuCycles) { 36 | // cyclesPerEvent = par("cyclesPerEvent").doubleValue(); 37 | // } else { 38 | processingDelayPerEvent = par("processingDelayPerEvent").doubleValue(); 39 | // } 40 | 41 | cpuCores = getAncestorPar("cores").longValue(); 42 | if (cpuCores < 1) { 43 | throw new cRuntimeError("Number of CPU Cores is not set."); 44 | } 45 | 46 | isOperatorSelectivityDistributed = par("isOperatorSelectivityDistributed").boolValue(); 47 | if(!isOperatorSelectivityDistributed){ 48 | selectivityRatio = par("selectivityRatio").doubleValue(); 49 | selectivityWindowLength = 0; 50 | if (selectivityRatio > 0) { 51 | selectivityWindowLength = std::lround(1 / selectivityRatio); 52 | } 53 | } else { 54 | myOperatorSelectivityDistributionModuleName = par("myOperatorSelectivityDistributionModuleName").stringValue(); 55 | cModule* submodule = getParentModule()->getSubmodule(myOperatorSelectivityDistributionModuleName); 56 | 57 | myOperatorSelectivityDistributionModule = check_and_cast(submodule); 58 | } 59 | 60 | isOperatorProductivityDistributed = par("isOperatorProductivityDistributed").boolValue(); 61 | if (!isOperatorProductivityDistributed) { 62 | productivityRatio = par("productivityRatio").doubleValue(); 63 | } else { 64 | myOperatorProductivityDistributionModuleName = par("myOperatorProductivityDistributionModuleName").stringValue(); 65 | cModule* submodule = getParentModule()->getSubmodule(myOperatorProductivityDistributionModuleName); 66 | 67 | myOperatorProductivityDistributionModule = check_and_cast(submodule); 68 | } 69 | 70 | mySenders = par("mySenders").stringValue(); 71 | mySTaskCategory = par("mySTaskCategory").stringValue(); 72 | lastCPUIndex = 0; 73 | selectivityWindowCount = 0; 74 | 75 | timerMsg = new cMessage(); 76 | timerMsg->setKind(2); 77 | // calculateDelay(); 78 | } 79 | 80 | void StreamingOperator::handleMessage(cMessage *msg) { 81 | if (msg->arrivedOn("fromCPU")) { 82 | nextToSend = check_and_cast(msg); 83 | for (int i = 0; i < gateSize("outgoingStream"); i++) { 84 | send(nextToSend->dup(), "outgoingStream", i); 85 | } 86 | // sendAck(nextToSend); 87 | delete nextToSend; 88 | } else if (msg->arrivedOn("incomingStream")) { 89 | StreamingMessage *msgToSend = check_and_cast(msg); 90 | double outgoingMsgSize = msgToSend->getBitLength() * getProductivityRatio(); 91 | msgToSend->setBitLength(outgoingMsgSize); 92 | msgToSend->setSender(mySTaskCategory); 93 | 94 | msgToSend->setIsProcessingDelayInCyclesPerEvent(isProcessingDelayInCpuCycles); 95 | msgToSend->setProcessingDelayPerEvent(processingDelayPerEvent); 96 | 97 | double _selectivityRatio = getSelectivityRatio(); 98 | msgToSend->setSelectivityRatio(_selectivityRatio); 99 | double _selectivityWindowLength = getSelectivityWindowLength(); 100 | long nextInLine = getNextProcessorCoreIndex(); 101 | cModule *cpuCore = getParentModule()->getSubmodule("cpuCore", nextInLine); 102 | if(_selectivityRatio < 1) { 103 | selectivityWindow.insert(msgToSend); 104 | if (selectivityWindow.getLength() >= _selectivityWindowLength) { 105 | nextToSend = check_and_cast( 106 | selectivityWindow.pop()); 107 | sendDirect(nextToSend, cpuCore, "incomingBus"); 108 | if (!selectivityWindow.isEmpty()) { 109 | if (selectivityWindow.getLength() < _selectivityWindowLength) { 110 | selectivityWindow.clear(); 111 | } else { 112 | for (int i = 0; i < _selectivityWindowLength - 1; i++) { 113 | selectivityWindow.pop(); 114 | } 115 | } 116 | } 117 | } 118 | } else{ 119 | sendDirect(msgToSend, cpuCore, "incomingBus"); 120 | } 121 | } 122 | // if (msg->isSelfMessage()) { 123 | // if (msg->getKind() == 2) { 124 | //// std::cout << "sending new msg" << endl; 125 | // nextToSend = check_and_cast( 126 | // outgoingQueue.pop()); 127 | // if (selectivityRatio >= 1) { 128 | // int _sratio = std::lround(selectivityRatio); // get the rounded value of the selectivity 129 | // for (int j = 0; j < _sratio; j++) { // send a msg for each incoming msg 130 | // for (int i = 0; i < gateSize("outgoingStream"); i++) { 131 | // send(nextToSend->dup(), "outgoingStream", i); 132 | // } 133 | // sendAck(nextToSend); 134 | // } 135 | // delete nextToSend; 136 | // } else { 137 | // // If selectivity < 1, then hold the message in a queue 138 | // // until the queue length = 1/selectivity. Then pop the first 139 | // // msg in the queue and send it to the downstream. 140 | // // Clear the queue afterwards and wait for the next event. 141 | // selectivityWindow.insert(nextToSend); 142 | // if(selectivityWindow.getLength() >= selectivityWindowLength){ 143 | // nextToSend = check_and_cast(selectivityWindow.pop()); 144 | // for (int i = 0; i < gateSize("outgoingStream"); i++) { 145 | // send(nextToSend->dup(), "outgoingStream", i); 146 | // } 147 | // if (!selectivityWindow.isEmpty()) { 148 | // selectivityWindow.clear(); 149 | // } 150 | // sendAck(nextToSend); 151 | // delete nextToSend; 152 | // } 153 | // } 154 | // } else { 155 | // // unknown msg 156 | // delete msg; 157 | // } 158 | // publishCpuStateChanged(States::CPU_IDLE); 159 | // } else { // not self message 160 | // StreamingMessage *msgToSend = check_and_cast(msg); 161 | // const char* sender = msgToSend->getSender(); 162 | // if (strstr(mySenders, sender) == NULL) { // check if the intended receiver is the current node 163 | // delete msg; 164 | // } else { 165 | // publishCpuStateChanged(States::CPU_BUSY); 166 | // double outgoingMsgSize = msgToSend->getSize() * sizeIncreaseRatio; 167 | // msgToSend->setSize(outgoingMsgSize); 168 | // msgToSend->setSender(mySTaskCategory); 169 | // msgToSend->setCyclesPerEvent(cyclesPerEvent); 170 | // outgoingQueue.insert(msgToSend); 171 | // 172 | // if (!timerMsg->isScheduled()) { 173 | // cancelAndDelete(timerMsg); 174 | // } 175 | // 176 | // timerMsg = new cMessage(); 177 | // timerMsg->setKind(2); 178 | // scheduleAt(simTime() + delay, timerMsg); 179 | // } 180 | // } 181 | } 182 | 183 | double StreamingOperator::getSelectivityRatio(){ 184 | if (isOperatorSelectivityDistributed) { 185 | return myOperatorSelectivityDistributionModule->getSelectivityRatio(); 186 | } 187 | return selectivityRatio; 188 | } 189 | 190 | double StreamingOperator::getSelectivityWindowLength(){ 191 | if (isOperatorSelectivityDistributed) { 192 | return myOperatorSelectivityDistributionModule->getSelectivityWindowLength(); 193 | } 194 | return selectivityWindowLength; 195 | } 196 | 197 | double StreamingOperator::getProductivityRatio(){ 198 | if (isOperatorProductivityDistributed) { 199 | return myOperatorProductivityDistributionModule->getProductivityRatio(); 200 | } 201 | return productivityRatio; 202 | } 203 | 204 | } /* namespace ecsnetpp */ 205 | -------------------------------------------------------------------------------- /src/stask/StreamingOperator.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef STASK_STREAMINGOPERATOR_H_ 17 | #define STASK_STREAMINGOPERATOR_H_ 18 | 19 | #include "omnetpp.h" 20 | #include "../msg/StreamingMessage_m.h" 21 | #include "ISTask.h" 22 | #include "../model/operator/selectivity/IOperatorSelectivityDistribution.h" 23 | #include "../model/operator/productivity/IOperatorProductivityDistribution.h" 24 | 25 | using namespace omnetpp; 26 | 27 | namespace ecsnetpp { 28 | 29 | class StreamingOperator : public ISTask{ 30 | private: 31 | int selectivityWindowLength; 32 | int selectivityWindowCount; 33 | protected: 34 | cQueue outgoingQueue; 35 | cQueue selectivityWindow; 36 | cMessage *timerMsg = nullptr; 37 | StreamingMessage* nextToSend; 38 | double selectivityRatio = 0; // number of outgoing messages to be generated per each incoming message 39 | double productivityRatio = 0; // sizeof(outgoing msg)/sizeof(incoming msg) 40 | const char* myOperatorSelectivityDistributionModuleName; 41 | const char* myOperatorProductivityDistributionModuleName; 42 | bool isOperatorSelectivityDistributed = false; 43 | bool isOperatorProductivityDistributed = false; 44 | IOperatorSelectivityDistribution* myOperatorSelectivityDistributionModule; 45 | IOperatorProductivityDistribution* myOperatorProductivityDistributionModule; 46 | public: 47 | //// StreamingTask(); 48 | // virtual ~StreamingOperator(); 49 | protected: 50 | virtual void initialize() override; 51 | virtual void handleMessage(cMessage *msg) override; 52 | virtual void finish() override; 53 | virtual double getSelectivityRatio(); 54 | virtual double getSelectivityWindowLength(); 55 | virtual double getProductivityRatio(); 56 | }; 57 | 58 | } /* namespace ecsnetpp */ 59 | 60 | #endif /* STASK_STREAMINGOPERATOR_H_ */ 61 | -------------------------------------------------------------------------------- /src/stask/StreamingOperator.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.stask; 17 | 18 | simple StreamingOperator like ISTask 19 | { 20 | parameters: 21 | string name = default("StreamingTask"); 22 | @signal[cpuStateChanged](type=long); 23 | gates: 24 | inout port[]; 25 | input incomingStream[]; 26 | output outgoingStream[]; 27 | input fromCPU; 28 | output toCPU; 29 | output ackerOut; 30 | } 31 | -------------------------------------------------------------------------------- /src/stask/StreamingSink.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "StreamingSink.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(StreamingSink); 21 | 22 | void StreamingSink::initialize() { 23 | omnetpp::cModule* submodule = getParentModule()->getSubmodule("cpuCoreScheduler"); 24 | myCpuCoreScheduler = check_and_cast(submodule); 25 | ackersEnabled = getAncestorPar("ackersEnabled").boolValue(); 26 | perCoreFreq = getAncestorPar("perCoreFreq").doubleValue(); 27 | // if (isProcessingDelayInCpuCycles) { 28 | // cyclesPerEvent = par("cyclesPerEvent").doubleValue(); 29 | // } else { 30 | processingDelayPerEvent = par("processingDelayPerEvent").doubleValue(); 31 | // } 32 | mySenders = par("mySenders").stringValue(); 33 | mySTaskCategory = par("mySTaskCategory").stringValue(); 34 | lastCPUIndex = 0; 35 | cpuCores = getAncestorPar("cores").longValue(); 36 | if (cpuCores < 1) { 37 | throw new cRuntimeError("Number of CPU Cores is not set."); 38 | } 39 | // calculateDelay(); 40 | } 41 | 42 | void StreamingSink::handleMessage(cMessage *msg) { 43 | if (msg->arrivedOn("fromCPU")) { 44 | StreamingMessage *pk = check_and_cast(msg); 45 | double _networkDelay = pk->getNetworkDelay(); 46 | double _processingDelay = pk->getProcessingDelay(); 47 | emit(transmissionTimeSignal, _networkDelay); 48 | emit(processingTimeSignal, _processingDelay); 49 | // const omnetpp::SimTime _latency = simTime() - pk->getStartTime(); 50 | emit(latencySignal, _networkDelay + _processingDelay); 51 | emit(edgeProcessingTimeSignal, pk->getEdgeProcessingDelay()); 52 | emit(receivedStreamingMsgsSignal, pk); 53 | // std::cout << " CPU proc delay: " << pk->getEdgeProcessingDelay() << " : " << pk->getProcessingDelay() << endl; 54 | // std::cout << "##Finished Processing. Msg size (Bytes): " << pk->getByteLength() << " (Bits): " << pk->getBitLength() << endl; 55 | 56 | // sendAck(msg); 57 | delete msg; 58 | } else if (msg->arrivedOn("incomingStream")) { 59 | StreamingMessage *msgToSend = check_and_cast(msg); 60 | msgToSend->setSender(mySTaskCategory); 61 | 62 | msgToSend->setIsProcessingDelayInCyclesPerEvent(isProcessingDelayInCpuCycles); 63 | msgToSend->setProcessingDelayPerEvent(processingDelayPerEvent); 64 | 65 | msgToSend->setSelectivityRatio(1); 66 | long nextInLine = getNextProcessorCoreIndex(); 67 | cModule *cpuCore = getParentModule()->getSubmodule("cpuCore", nextInLine); 68 | sendDirect(msgToSend, cpuCore, "incomingBus"); 69 | } 70 | // StreamingMessage *pk = check_and_cast(msg); 71 | // const char* sender = pk->getSender(); 72 | // if (strstr(mySenders, sender) == NULL) { 73 | // delete msg; 74 | // } else { 75 | // publishCpuStateChanged(States::CPU_BUSY); 76 | // emit(rcvdPkSignal, pk); 77 | // sendAck(msg); 78 | // delete msg; 79 | // 80 | // publishCpuStateChanged(States::CPU_IDLE); 81 | // } 82 | } 83 | } /* namespace ecsnetpp */ 84 | -------------------------------------------------------------------------------- /src/stask/StreamingSink.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef STASK_STREAMINGSINK_H_ 17 | #define STASK_STREAMINGSINK_H_ 18 | 19 | #include "omnetpp.h" 20 | #include "../msg/StreamingMessage_m.h" 21 | #include "ISTask.h" 22 | 23 | using namespace omnetpp; 24 | 25 | namespace ecsnetpp { 26 | 27 | class StreamingSink : public ISTask{ 28 | protected: 29 | virtual void initialize() override; 30 | virtual void handleMessage(cMessage *msg) override; 31 | 32 | }; 33 | 34 | } /* namespace ecsnetpp */ 35 | 36 | #endif /* STASK_STREAMINGSINK_H_ */ 37 | -------------------------------------------------------------------------------- /src/stask/StreamingSink.ned: -------------------------------------------------------------------------------- 1 | // This program is free software: you can redistribute it and/or modify 2 | // it under the terms of the GNU Lesser General Public License as published by 3 | // the Free Software Foundation, either version 3 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU Lesser General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU Lesser General Public License 12 | // along with this program. If not, see http://www.gnu.org/licenses/. 13 | // 14 | 15 | package ecsnetpp.stask; 16 | 17 | simple StreamingSink like ISTask 18 | { 19 | parameters: 20 | string name = default("StreamingSink"); 21 | @signal[cpuStateChanged](type=long); 22 | @signal[receivedStreamingMsgs](type=cPacket); 23 | @signal[latency](type=double); 24 | @signal[transmissionTime](type=double); 25 | @signal[processingTime](type=double); 26 | @signal[edgeProcessingTime](type=double); 27 | @statistic[rcvdStreamingMsgsStat](title="packets received"; source=receivedStreamingMsgs; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none); 28 | @statistic[throughput](title="throughput"; unit=bps; source="throughput(receivedStreamingMsgs)"; record=vector); 29 | @statistic[rcvdStreamingMsgsCount](title="Streaming Msg Count"; source=receivedStreamingMsgs; record=count); 30 | @statistic[endToEndDelay](title="end-to-end delay"; source="messageAge(receivedStreamingMsgs)"; unit=s; record=min,max,mean,stats,histogram,vector; interpolationmode=sample-hold); 31 | @statistic[receivedStreamingMsgsSeqNo](title="received packet sequence number"; source="appPkSeqNo(receivedStreamingMsgs)"; record=vector; interpolationmode=none); 32 | 33 | gates: 34 | inout port[]; 35 | input incomingStream[]; 36 | output outgoingStream[]; 37 | input fromCPU; 38 | output toCPU; 39 | output ackerOut; 40 | } 41 | -------------------------------------------------------------------------------- /src/stask/StreamingSource.cc: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #include "StreamingSource.h" 17 | 18 | namespace ecsnetpp { 19 | 20 | Define_Module(StreamingSource); 21 | 22 | simsignal_t ISTask::packetGeneratedSignal = registerSignal("packetGenerated"); 23 | 24 | StreamingSource::~StreamingSource() { 25 | cancelAndDelete(timerMsg); 26 | } 27 | 28 | void StreamingSource::initialize() { 29 | perCoreFreq = getAncestorPar("perCoreFreq").doubleValue(); 30 | omnetpp::cModule* submodule = getParentModule()->getSubmodule("cpuCoreScheduler"); 31 | myCpuCoreScheduler = check_and_cast(submodule); 32 | // if (isProcessingDelayInCpuCycles) { 33 | // cyclesPerEvent = par("cyclesPerEvent").doubleValue(); 34 | // } else { 35 | processingDelayPerEvent = par("processingDelayPerEvent").doubleValue(); 36 | // } 37 | // calculateDelay(); 38 | lastCPUIndex = 0; 39 | cpuCores = getAncestorPar("cores").longValue(); 40 | if (cpuCores < 1) { 41 | throw new cRuntimeError("Number of CPU Cores is not set."); 42 | } 43 | mySTaskCategory = par("mySTaskCategory").stringValue(); 44 | 45 | isSourceMsgSizeDistributed = par("isSourceMsgSizeDistributed").boolValue(); 46 | if (!isSourceMsgSizeDistributed) { 47 | msgSize = par("msgSize").doubleValue(); 48 | } else { 49 | mySourceMsgSizeDistributionModuleName = par("mySourceMsgSizeDistributionModuleName").stringValue(); 50 | omnetpp::cModule* submodule = getParentModule()->getSubmodule(mySourceMsgSizeDistributionModuleName); 51 | 52 | mySourceMsgSizeDistributionModule = check_and_cast(submodule); 53 | } 54 | 55 | isSourceEvRateDistributed = par("isSourceEvRateDistributed").boolValue(); 56 | if (!isSourceEvRateDistributed) { 57 | eventRate = par("eventRate").doubleValue(); //evs per second 58 | if (eventRate != 0) { 59 | msgDelay = 1 / eventRate; 60 | } else { 61 | throw cRuntimeError("Event rate is not set for the source : %s", 62 | getFullPath().c_str()); 63 | } 64 | } else { 65 | mySourceEvRateDistributionModuleName = par("mySourceEvRateDistributionModuleName").stringValue(); 66 | omnetpp::cModule* submodule = getParentModule()->getSubmodule(mySourceEvRateDistributionModuleName); 67 | 68 | mySourceEvRateDistributionModule = check_and_cast(submodule); 69 | } 70 | 71 | timerMsg = new cMessage("BEGIN"); 72 | commonSimController = check_and_cast( 73 | getParentModule()->getParentModule()->getModuleByPath( 74 | ".simController")); 75 | scheduleAt(simTime() + getMessageDelay(), timerMsg); 76 | } 77 | 78 | void StreamingSource::handleMessage(cMessage *msg) { 79 | // publishCpuStateChanged(States::CPU_BUSY); 80 | 81 | if (msg->isSelfMessage()) { 82 | if (!commonSimController->getStopEventGeneration()) { 83 | StreamingMessage *sourceMsg = new StreamingMessage(); 84 | sourceMsg->setBitLength(getMessageSize()); 85 | 86 | sourceMsg->setIsProcessingDelayInCyclesPerEvent(isProcessingDelayInCpuCycles); 87 | sourceMsg->setProcessingDelayPerEvent(processingDelayPerEvent); 88 | 89 | // if (isProcessingDelayInCpuCycles){ 90 | // sourceMsg->setIsProcessingDelayInCyclesPerEvent(true); 91 | // sourceMsg->setProcessingDelayPerEvent(cyclesPerEvent); 92 | // } else { 93 | // sourceMsg->setIsProcessingDelayInCyclesPerEvent(false); 94 | // sourceMsg->setProcessingDelayPerEvent(processingDelayPerEvent); 95 | // } 96 | sourceMsg->setStartTime(simTime()); 97 | sourceMsg->setSender(mySTaskCategory); 98 | sourceMsg->setSelectivityRatio(1); 99 | sourceMsg->setNetworkDelay(0); 100 | sourceMsg->setProcessingDelay(0); 101 | sourceMsg->setEdgeProcessingDelay(0); 102 | long nextInLine = getNextProcessorCoreIndex(); 103 | cModule *cpuCore = getParentModule()->getSubmodule("cpuCore", 104 | nextInLine); 105 | // send(sourceMsg,"toCPU"); 106 | sendDirect(sourceMsg, cpuCore, "incomingBus"); 107 | cancelEvent(timerMsg); 108 | scheduleAt(simTime() + getMessageDelay(), timerMsg); 109 | } 110 | } else if (msg->arrivedOn("fromCPU")) { 111 | StreamingMessage *sourceMsg = check_and_cast(msg); 112 | emit(packetGeneratedSignal, 1, getParentModule()); 113 | for (int i = 0; i < gateSize("outgoingStream"); i++) { 114 | send(sourceMsg->dup(), "outgoingStream", i); 115 | } 116 | } else { 117 | delete msg; 118 | } 119 | 120 | // publishCpuStateChanged(States::CPU_IDLE); 121 | } 122 | 123 | double StreamingSource::getMessageDelay() { 124 | if (isSourceEvRateDistributed) { 125 | return mySourceEvRateDistributionModule->getMessageDelay(); 126 | } 127 | return msgDelay; 128 | } 129 | 130 | double StreamingSource::getMessageSize() { 131 | if (isSourceMsgSizeDistributed) { 132 | return mySourceMsgSizeDistributionModule->getMsgSize(); 133 | } 134 | return msgSize; 135 | } 136 | } /* namespace ecsnetpp */ 137 | -------------------------------------------------------------------------------- /src/stask/StreamingSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | #ifndef STASK_STREAMINGSOURCE_H_ 17 | #define STASK_STREAMINGSOURCE_H_ 18 | 19 | #include "omnetpp.h" 20 | #include "../msg/StreamingMessage_m.h" 21 | #include "ISTask.h" 22 | #include "../common/SimulationController.h" 23 | #include "../model/source/eventrate/ISourceEventRateDistribution.h" 24 | #include "../model/source/msgsize/IMessageSizeDistribution.h" 25 | 26 | using namespace omnetpp; 27 | 28 | namespace ecsnetpp { 29 | 30 | class StreamingSource: public ISTask { 31 | protected: 32 | cQueue outgoingQueue; 33 | cMessage *timerMsg = nullptr; 34 | double msgSize = 0; 35 | double eventRate = 0; 36 | double msgDelay = 0; 37 | bool isSourceEvRateDistributed = false; 38 | bool isSourceMsgSizeDistributed = false; 39 | const char* mySourceEvRateDistributionModuleName; 40 | const char* mySourceMsgSizeDistributionModuleName; 41 | SimulationController *commonSimController; 42 | ISourceEventRateDistribution* mySourceEvRateDistributionModule; 43 | IMessageSizeDistribution* mySourceMsgSizeDistributionModule; 44 | public: 45 | virtual ~StreamingSource(); 46 | protected: 47 | virtual void initialize() override; 48 | virtual void handleMessage(cMessage *msg) override; 49 | virtual double getMessageDelay(); 50 | virtual double getMessageSize(); 51 | }; 52 | 53 | } /* namespace ecsnetpp */ 54 | 55 | #endif /* STASK_STREAMINGSOURCE_H_ */ 56 | -------------------------------------------------------------------------------- /src/stask/StreamingSource.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.stask; 17 | 18 | simple StreamingSource like ISTask 19 | { 20 | parameters: 21 | string name = default("StreamingSource"); 22 | @signal[cpuStateChanged](type=long); 23 | @signal[packetGenerated](type=long); 24 | gates: 25 | inout port[]; 26 | input incomingStream[]; 27 | output outgoingStream[]; 28 | input fromCPU; 29 | output toCPU; 30 | output ackerOut; 31 | } -------------------------------------------------------------------------------- /src/stask/StreamingSupervisor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Supervisor.h 3 | * 4 | * Created on: Oct 24, 2017 5 | * Author: gayashan 6 | */ 7 | 8 | #ifndef STASK_STREAMINGSUPERVISOR_H_ 9 | #define STASK_STREAMINGSUPERVISOR_H_ 10 | 11 | #include "omnetpp.h" 12 | #include "inet/transportlayer/contract/udp/UDPSocket.h" 13 | #include "inet/transportlayer/contract/tcp/TCPSocket.h" 14 | #include "inet/transportlayer/contract/tcp/TCPSocketMap.h" 15 | 16 | using namespace omnetpp; 17 | 18 | namespace ecsnetpp { 19 | 20 | class StreamingSupervisor: public cSimpleModule , public inet::TCPSocket::CallbackInterface{ 21 | 22 | private: 23 | const char* cloudAddress; 24 | bool joinMulticastGroup; 25 | bool ackersEnabled; 26 | bool checkpointsEnabled; 27 | bool hasUdp; 28 | bool hasTcp; 29 | inet::UDPSocket udpSocket; 30 | inet::TCPSocket tcpSocket; 31 | inet::TCPSocket serverSocket; 32 | inet::TCPSocketMap tcpSocketMap; 33 | cMessage *selfMsg = nullptr; 34 | cMessage *bindMsg = nullptr; 35 | cMessage *joinMCastMsg = nullptr; 36 | std::map destinationSocketMap; 37 | std::map> senderStaskCategoryToDownstreamNodeMap; 38 | std::map> senderStaskCategoryToDownstreamNodeIPMap; 39 | 40 | simtime_t startTime = -1; 41 | int count = 0; 42 | void processSelfMessage(); 43 | void processUDPMessage(omnetpp::cMessage* msg); 44 | void processTCPMessage(omnetpp::cMessage* msg); 45 | 46 | public: 47 | static simsignal_t sentPkSize; 48 | static simsignal_t completedMIPS; 49 | protected: 50 | virtual void initialize() override; 51 | virtual void handleMessage(cMessage *msg) override; 52 | void processUDPPacket(cMessage *msg); 53 | void processUDPError(cMessage *error); 54 | public: 55 | virtual ~StreamingSupervisor(); 56 | virtual void addSTaskCategoryToDownstreamNodeMapping( 57 | std::string senderSTaskCategory, 58 | std::string downstreamNodeFullPath); 59 | virtual void addSTaskCategoryToDownstreamNodeMapping( 60 | std::string senderSTaskCategory, 61 | std::vector downstreamNodeFullPaths); 62 | virtual void resolveDownstreamNodeIPs(); 63 | virtual void socketDataArrived(int connId, void *yourPtr, cPacket *msg, bool urgent) override; 64 | virtual void socketFailure(int connId, void *yourPtr, int code) override; 65 | }; 66 | 67 | } 68 | 69 | #endif /* STASK_STREAMINGSUPERVISOR_H_ */ 70 | -------------------------------------------------------------------------------- /src/stask/StreamingSupervisor.ned: -------------------------------------------------------------------------------- 1 | // 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Lesser General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Lesser General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Lesser General Public License 13 | // along with this program. If not, see http://www.gnu.org/licenses/. 14 | // 15 | 16 | package ecsnetpp.stask; 17 | 18 | simple StreamingSupervisor 19 | { 20 | parameters: 21 | string name = default("Supervisor"); 22 | bool joinMulticastGroup = default(false); 23 | string dataTransferMode @enum("bytecount","object","bytestream") = default("object"); 24 | gates: 25 | input udpIn @labels(UDPControlInfo/up); 26 | output udpOut @labels(UDPControlInfo/down); 27 | input tcpIn @labels(TCPCommand/up); 28 | output tcpOut @labels(TCPCommand/down); 29 | inout supInOut[]; 30 | input streamingPortIn[]; 31 | output streamingPortOut[]; 32 | input sendToAcker[]; 33 | output ackerOut[]; 34 | input fromCheckpointManager[]; 35 | output toCheckpointManager[]; 36 | } 37 | -------------------------------------------------------------------------------- /src/stask/package.ned: -------------------------------------------------------------------------------- 1 | package ecsnetpp.stask; 2 | 3 | @namespace(ecsnetpp); 4 | @license(LGPL); 5 | --------------------------------------------------------------------------------