├── Database ├── 1_Node_255_Houses │ ├── marketname │ ├── nodeNamePrefixes │ ├── numberofnodes │ ├── LinkModelGLDNS3.txt │ ├── firstN │ ├── run_ns-3 │ ├── GridLab-D.dot.pdf │ ├── max_capacity_reference_bid_quantity.glm │ ├── env.sh │ ├── run.sh │ ├── compile-ns3.sh │ ├── creat_rout_and_subscribe.py │ ├── creat_zpl_file.py │ ├── attack_schedule.glm │ ├── ns-3.cc │ ├── run_ns-3.cc │ └── firstN.cc ├── 4_Nodes_1_House │ ├── LinkModelGLDNS3.txt │ ├── firstN │ ├── ns-3 │ ├── run_ns-3 │ ├── append_to_main_file.py │ ├── fncs_msg.txt │ ├── run.sh │ ├── compile-ns3.sh │ ├── fncs.zpl │ ├── creat_rout_and_subscribe.py │ ├── light_schedule.glm │ ├── creat_zpl_file.py │ ├── attack_schedule.glm │ ├── GridLab-D.glm │ ├── run_GridLab-D.glm │ ├── ns-3.cc │ └── run_ns-3.cc ├── 13_Nodes_15_Houses │ ├── LinkModelGLDNS3.txt │ ├── ns-3 │ ├── run_ns-3 │ ├── run.sh │ ├── compile-ns3.sh │ ├── creat_rout_and_subscribe.py │ ├── light_schedule.glm │ ├── creat_zpl_file.py │ ├── attack_schedule.glm │ ├── ns-3.cc │ └── run_ns-3.cc ├── 13_Nodes_73_Houses │ ├── LinkModelGLDNS3.txt │ ├── ns-3 │ ├── run_ns-3 │ ├── run.sh │ ├── compile-ns3.sh │ ├── creat_rout_and_subscribe.py │ ├── creat_zpl_file.py │ ├── light_schedule.glm │ ├── attack_schedule.glm │ ├── ns-3.cc │ └── run_ns-3.cc └── 4_Nodes_492_Houses │ ├── LinkModelGLDNS3.txt │ ├── ns-3 │ ├── run_ns-3 │ ├── run.sh │ ├── compile-ns3.sh │ ├── README.txt │ ├── attack_schedule.glm │ ├── Test_Feeder_Line_Configurations.glm │ ├── appliance_schedules.glm │ ├── ns-3.cc │ └── run_ns-3.cc ├── Figures ├── attack_types.png ├── gui_screenshot.png ├── use_overview.png └── framework_architecture.png ├── CONTRIBUTORS ├── CHANGES ├── LICENSE ├── attack_broker.py ├── plot_result.py ├── installation_guide.md ├── README.md ├── glmMap.py ├── developer_guide.md └── GridAttackSim.py /Database/1_Node_255_Houses/marketname: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/nodeNamePrefixes: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/numberofnodes: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/LinkModelGLDNS3.txt: -------------------------------------------------------------------------------- 1 | 1 Market_1 HOUSE_ 2 | -------------------------------------------------------------------------------- /Database/13_Nodes_15_Houses/LinkModelGLDNS3.txt: -------------------------------------------------------------------------------- 1 | 15 Market_1 HOUSE_ 2 | -------------------------------------------------------------------------------- /Database/13_Nodes_73_Houses/LinkModelGLDNS3.txt: -------------------------------------------------------------------------------- 1 | 73 Market_1 HOUSE_ 2 | -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/LinkModelGLDNS3.txt: -------------------------------------------------------------------------------- 1 | 250 Market2 C250_ 2 | -------------------------------------------------------------------------------- /Database/4_Nodes_492_Houses/LinkModelGLDNS3.txt: -------------------------------------------------------------------------------- 1 | 492 Market_1 HOUSE_ 2 | -------------------------------------------------------------------------------- /Figures/attack_types.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Figures/attack_types.png -------------------------------------------------------------------------------- /Figures/gui_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Figures/gui_screenshot.png -------------------------------------------------------------------------------- /Figures/use_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Figures/use_overview.png -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/firstN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Database/4_Nodes_1_House/firstN -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/ns-3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Database/4_Nodes_1_House/ns-3 -------------------------------------------------------------------------------- /Database/13_Nodes_15_Houses/ns-3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Database/13_Nodes_15_Houses/ns-3 -------------------------------------------------------------------------------- /Database/13_Nodes_73_Houses/ns-3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Database/13_Nodes_73_Houses/ns-3 -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/firstN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Database/1_Node_255_Houses/firstN -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/run_ns-3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Database/4_Nodes_1_House/run_ns-3 -------------------------------------------------------------------------------- /Database/4_Nodes_492_Houses/ns-3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Database/4_Nodes_492_Houses/ns-3 -------------------------------------------------------------------------------- /Database/13_Nodes_15_Houses/run_ns-3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Database/13_Nodes_15_Houses/run_ns-3 -------------------------------------------------------------------------------- /Database/13_Nodes_73_Houses/run_ns-3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Database/13_Nodes_73_Houses/run_ns-3 -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/run_ns-3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Database/1_Node_255_Houses/run_ns-3 -------------------------------------------------------------------------------- /Database/4_Nodes_492_Houses/run_ns-3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Database/4_Nodes_492_Houses/run_ns-3 -------------------------------------------------------------------------------- /Figures/framework_architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Figures/framework_architecture.png -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/GridLab-D.dot.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crond-jaist/GridAttackSim/HEAD/Database/1_Node_255_Houses/GridLab-D.dot.pdf -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | This file includes the main contributors to the GridAttackSim project. 2 | 3 | Initial implementation: 4 | Tan Duy Le 5 | 6 | Current maintainers: 7 | Razvan Beuran 8 | -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/max_capacity_reference_bid_quantity.glm: -------------------------------------------------------------------------------- 1 | schedule max_capacity_reference_bid_quantity_attack { 2 | //* 0-7 * * * 1125 3 | //* 8-14 * * * 500 4 | //* 15-23 * * * 1125 5 | * 0-13 * * * 1125 6 | * 14-20 * * * 1125 7 | * 21-23 * * * 1125 8 | } 9 | 10 | -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- 1 | 2 | GridAttackSim v1.0 3 | ------------------ 4 | * First public release of GridAttackSim, the smart grid attack 5 | simulation framework that makes it possible to simulate various 6 | cyber-attacks on the smart grid infrastructure and visualize their 7 | consequences. The framework is extensible by end users, and the 8 | current release includes five smart grid topologies, two smart grid 9 | applications, and an attack library with four types of attacks. 10 | -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export FNCS_INSTALL="$HOME/FNCS-install" 4 | 5 | # update LD_LIBRARY_PATH 6 | if test "x$LD_LIBRARY_PATH" = x 7 | then 8 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib" 9 | else 10 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib:$LD_LIBRARY_PATH" 11 | fi 12 | 13 | # update PATH 14 | if test "x$PATH" = x 15 | then 16 | export PATH="$FNCS_INSTALL/bin" 17 | else 18 | export PATH="$FNCS_INSTALL/bin:$PATH" 19 | fi 20 | 21 | export FNCS_FATAL=yes 22 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/append_to_main_file.py: -------------------------------------------------------------------------------- 1 | filepath = 'GridLab-D_old.glm' 2 | outF = open("GridLab-D.glm", "w") 3 | with open(filepath) as fp: 4 | line = fp.readline() 5 | cnt = 0 6 | index = 1 7 | while line: 8 | #print("Line {}: {}".format(cnt, line.strip())) 9 | line = fp.readline() 10 | if line.strip() == 'object controller {': 11 | line = line + "\n \t name HOUSE_"+str(index)+";\n" 12 | line = line + "\t proxy_average 0.042676;\n" 13 | line = line + "\t proxy_standard_deviation 0.020000;\n" 14 | line = line + "\t proxy_market_id 1;\n" 15 | line = line + "\t proxy_clear_price 0.042676;\n" 16 | line = line + "\t proxy_price_cap 3.78;\n" 17 | index +=1 18 | outF.write(line) 19 | cnt += 1 20 | print("Finished") 21 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/fncs_msg.txt: -------------------------------------------------------------------------------- 1 | route "commit:Market_1.current_market.clearing_price -> HOUSE_1/clearPrice; 0"; 2 | route "commit:Market_1.market_id -> HOUSE_1/mktID; 0"; 3 | route "commit:Market_1.current_price_mean_24h -> HOUSE_1/avgPrice; 0"; 4 | route "commit:Market_1.current_price_mean_24h -> HOUSE_1/avgPrice; 0"; 5 | route "commit:Market_1.current_price_stdev_24h -> HOUSE_1/stdevPrice; 0"; 6 | subscribe "function:auction/submit_bid_state <- ns3_1/fncs_msg/HOUSE_1@Market_1/submit_bid_state"; 7 | subscribe "precommit:HOUSE_1.proxy_clear_price <- ns3_1/fncs_msg/Market_1@HOUSE_1/clearPrice"; 8 | subscribe "precommit:HOUSE_1.proxy_market_id <- ns3_1/fncs_msg/Market_1@HOUSE_1/mktID"; 9 | subscribe "precommit:HOUSE_1.proxy_average <- ns3_1/fncs_msg/Market_1@HOUSE_1/avgPrice"; 10 | subscribe "precommit:HOUSE_1.proxy_standard_deviation <- ns3_1/fncs_msg/Market_1@HOUSE_1/stdevPrice"; 11 | -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # use a fresh custom loader path 4 | unset LD_LIBRARY_PATH 5 | 6 | # shortcut 7 | export FNCS_INSTALL="$HOME/FNCS-install" 8 | 9 | # update LD_LIBRARY_PATH 10 | if test "x$LD_LIBRARY_PATH" = x 11 | then 12 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib" 13 | else 14 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib:$LD_LIBRARY_PATH" 15 | fi 16 | 17 | # update PATH 18 | if test "x$PATH" = x 19 | then 20 | export PATH="$FNCS_INSTALL/bin" 21 | else 22 | export PATH="$FNCS_INSTALL/bin:$PATH" 23 | fi 24 | 25 | export FNCS_LOG_STDOUT=no 26 | export FNCS_LOG_FILE=yes 27 | 28 | # run ns3 in separate window 29 | xterm -e ./run_ns-3 LinkModelGLDNS3.txt & 30 | 31 | # run gld in separate window 32 | xterm -e gridlabd run_GridLab-D.glm & 33 | 34 | # run fncs_broker in separate window 35 | xterm -e fncs_broker 2 & 36 | 37 | echo "running" 38 | -------------------------------------------------------------------------------- /Database/13_Nodes_15_Houses/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # use a fresh custom loader path 4 | unset LD_LIBRARY_PATH 5 | 6 | # shortcut 7 | export FNCS_INSTALL="$HOME/FNCS-install" 8 | 9 | # update LD_LIBRARY_PATH 10 | if test "x$LD_LIBRARY_PATH" = x 11 | then 12 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib" 13 | else 14 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib:$LD_LIBRARY_PATH" 15 | fi 16 | 17 | # update PATH 18 | if test "x$PATH" = x 19 | then 20 | export PATH="$FNCS_INSTALL/bin" 21 | else 22 | export PATH="$FNCS_INSTALL/bin:$PATH" 23 | fi 24 | 25 | export FNCS_LOG_STDOUT=no 26 | export FNCS_LOG_FILE=yes 27 | 28 | # run ns3 in separate window 29 | xterm -e ./run_ns-3 LinkModelGLDNS3.txt & 30 | 31 | # run gld in separate window 32 | xterm -e gridlabd run_GridLab-D.glm & 33 | 34 | # run fncs_broker in separate window 35 | xterm -e fncs_broker 2 & 36 | 37 | echo "running" 38 | -------------------------------------------------------------------------------- /Database/13_Nodes_73_Houses/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # use a fresh custom loader path 4 | unset LD_LIBRARY_PATH 5 | 6 | # shortcut 7 | export FNCS_INSTALL="$HOME/FNCS-install" 8 | 9 | # update LD_LIBRARY_PATH 10 | if test "x$LD_LIBRARY_PATH" = x 11 | then 12 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib" 13 | else 14 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib:$LD_LIBRARY_PATH" 15 | fi 16 | 17 | # update PATH 18 | if test "x$PATH" = x 19 | then 20 | export PATH="$FNCS_INSTALL/bin" 21 | else 22 | export PATH="$FNCS_INSTALL/bin:$PATH" 23 | fi 24 | 25 | export FNCS_LOG_STDOUT=no 26 | export FNCS_LOG_FILE=yes 27 | 28 | # run ns3 in separate window 29 | xterm -e ./run_ns-3 LinkModelGLDNS3.txt & 30 | 31 | # run gld in separate window 32 | xterm -e gridlabd run_GridLab-D.glm & 33 | 34 | # run fncs_broker in separate window 35 | xterm -e fncs_broker 2 & 36 | 37 | echo "running" 38 | -------------------------------------------------------------------------------- /Database/4_Nodes_492_Houses/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # use a fresh custom loader path 4 | unset LD_LIBRARY_PATH 5 | 6 | # shortcut 7 | export FNCS_INSTALL="$HOME/FNCS-install" 8 | 9 | # update LD_LIBRARY_PATH 10 | if test "x$LD_LIBRARY_PATH" = x 11 | then 12 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib" 13 | else 14 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib:$LD_LIBRARY_PATH" 15 | fi 16 | 17 | # update PATH 18 | if test "x$PATH" = x 19 | then 20 | export PATH="$FNCS_INSTALL/bin" 21 | else 22 | export PATH="$FNCS_INSTALL/bin:$PATH" 23 | fi 24 | 25 | export FNCS_LOG_STDOUT=no 26 | export FNCS_LOG_FILE=yes 27 | 28 | # run ns3 in separate window 29 | xterm -e ./run_ns-3 LinkModelGLDNS3.txt & 30 | 31 | # run gld in separate window 32 | xterm -e gridlabd run_GridLab-D.glm & 33 | 34 | # run fncs_broker in separate window 35 | xterm -e fncs_broker 2 & 36 | 37 | echo "running" 38 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # use a fresh custom loader path 4 | unset LD_LIBRARY_PATH 5 | 6 | # shortcut 7 | export FNCS_INSTALL="$HOME/FNCS-install" 8 | 9 | # update LD_LIBRARY_PATH 10 | if test "x$LD_LIBRARY_PATH" = x 11 | then 12 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib" 13 | else 14 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib:$LD_LIBRARY_PATH" 15 | fi 16 | 17 | # update PATH 18 | if test "x$PATH" = x 19 | then 20 | export PATH="$FNCS_INSTALL/bin" 21 | else 22 | export PATH="$FNCS_INSTALL/bin:$PATH" 23 | fi 24 | 25 | export FNCS_LOG_STDOUT=no 26 | export FNCS_LOG_FILE=yes 27 | 28 | # run ns3 in separate window 29 | xterm -e ./run_ns-3 LinkModelGLDNS3.txt & 30 | 31 | # run gld in separate window 32 | xterm -e gridlabd run_GridLab-D.glm & 33 | 34 | # run fncs_broker in separate window 35 | xterm -e fncs_broker 2 & 36 | 37 | #Get Process ID 38 | 39 | #processId_2=$(ps -ef | grep run_GridLab-D | grep -v 'grep' | awk '{ printf $2 }') 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Database/13_Nodes_15_Houses/compile-ns3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | g++ \ 4 | -g \ 5 | -o run_ns-3 \ 6 | run_ns-3.cc \ 7 | -I$FNCS_INSTALL/include \ 8 | -I$FNCS_INSTALL/include/fncs \ 9 | -I$FNCS_INSTALL/include/ns3.26 \ 10 | -L$FNCS_INSTALL/lib \ 11 | -lns3.26-applications-debug \ 12 | -lns3.26-fncs-debug \ 13 | -lns3.26-nix-vector-routing-debug \ 14 | -lns3.26-internet-debug \ 15 | -lns3.26-bridge-debug \ 16 | -lns3.26-csma-debug \ 17 | -lns3.26-point-to-point-debug \ 18 | -lns3.26-mpi-debug \ 19 | -lns3.26-stats-debug \ 20 | -lns3.26-network-debug \ 21 | -lns3.26-core-debug \ 22 | -lfncs \ 23 | -lczmq \ 24 | -lzmq 25 | 26 | #g++ \ 27 | #-g \ 28 | #-o firstN \ 29 | #firstN.cc \ 30 | #-I$FNCS_INSTALL/include/fncs \ 31 | #-I$FNCS_INSTALL/include/ns3.19 \ 32 | #-L$FNCS_INSTALL/lib \ 33 | #-lns3.19-fncs-debug \ 34 | #-lfncs \ 35 | #-lzmq \ 36 | #-lns3.19-point-to-point-debug \ 37 | #-lns3.19-applications-debug \ 38 | #-lns3.19-nix-vector-routing-debug \ 39 | #-lns3.19-csma-debug \ 40 | #-lns3.19-point-to-point-layout-debug \ 41 | #-lns3.19-wifi-debug \ 42 | #-lns3.19-netanim-debug \ 43 | #-lns3.19-wimax-debug \ 44 | #-lns3.19-core-debug 45 | -------------------------------------------------------------------------------- /Database/13_Nodes_73_Houses/compile-ns3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | g++ \ 4 | -g \ 5 | -o run_ns-3 \ 6 | run_ns-3.cc \ 7 | -I$FNCS_INSTALL/include \ 8 | -I$FNCS_INSTALL/include/fncs \ 9 | -I$FNCS_INSTALL/include/ns3.26 \ 10 | -L$FNCS_INSTALL/lib \ 11 | -lns3.26-applications-debug \ 12 | -lns3.26-fncs-debug \ 13 | -lns3.26-nix-vector-routing-debug \ 14 | -lns3.26-internet-debug \ 15 | -lns3.26-bridge-debug \ 16 | -lns3.26-csma-debug \ 17 | -lns3.26-point-to-point-debug \ 18 | -lns3.26-mpi-debug \ 19 | -lns3.26-stats-debug \ 20 | -lns3.26-network-debug \ 21 | -lns3.26-core-debug \ 22 | -lfncs \ 23 | -lczmq \ 24 | -lzmq 25 | 26 | #g++ \ 27 | #-g \ 28 | #-o firstN \ 29 | #firstN.cc \ 30 | #-I$FNCS_INSTALL/include/fncs \ 31 | #-I$FNCS_INSTALL/include/ns3.19 \ 32 | #-L$FNCS_INSTALL/lib \ 33 | #-lns3.19-fncs-debug \ 34 | #-lfncs \ 35 | #-lzmq \ 36 | #-lns3.19-point-to-point-debug \ 37 | #-lns3.19-applications-debug \ 38 | #-lns3.19-nix-vector-routing-debug \ 39 | #-lns3.19-csma-debug \ 40 | #-lns3.19-point-to-point-layout-debug \ 41 | #-lns3.19-wifi-debug \ 42 | #-lns3.19-netanim-debug \ 43 | #-lns3.19-wimax-debug \ 44 | #-lns3.19-core-debug 45 | -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/compile-ns3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | g++ \ 4 | -g \ 5 | -o run_ns-3 \ 6 | run_ns-3.cc \ 7 | -I$FNCS_INSTALL/include \ 8 | -I$FNCS_INSTALL/include/fncs \ 9 | -I$FNCS_INSTALL/include/ns3.26 \ 10 | -L$FNCS_INSTALL/lib \ 11 | -lns3.26-applications-debug \ 12 | -lns3.26-fncs-debug \ 13 | -lns3.26-nix-vector-routing-debug \ 14 | -lns3.26-internet-debug \ 15 | -lns3.26-bridge-debug \ 16 | -lns3.26-csma-debug \ 17 | -lns3.26-point-to-point-debug \ 18 | -lns3.26-mpi-debug \ 19 | -lns3.26-stats-debug \ 20 | -lns3.26-network-debug \ 21 | -lns3.26-core-debug \ 22 | -lfncs \ 23 | -lczmq \ 24 | -lzmq 25 | 26 | #g++ \ 27 | #-g \ 28 | #-o firstN \ 29 | #firstN.cc \ 30 | #-I$FNCS_INSTALL/include/fncs \ 31 | #-I$FNCS_INSTALL/include/ns3.19 \ 32 | #-L$FNCS_INSTALL/lib \ 33 | #-lns3.19-fncs-debug \ 34 | #-lfncs \ 35 | #-lzmq \ 36 | #-lns3.19-point-to-point-debug \ 37 | #-lns3.19-applications-debug \ 38 | #-lns3.19-nix-vector-routing-debug \ 39 | #-lns3.19-csma-debug \ 40 | #-lns3.19-point-to-point-layout-debug \ 41 | #-lns3.19-wifi-debug \ 42 | #-lns3.19-netanim-debug \ 43 | #-lns3.19-wimax-debug \ 44 | #-lns3.19-core-debug 45 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/compile-ns3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | g++ \ 4 | -g \ 5 | -o run_ns-3 \ 6 | run_ns-3.cc \ 7 | -I$FNCS_INSTALL/include \ 8 | -I$FNCS_INSTALL/include/fncs \ 9 | -I$FNCS_INSTALL/include/ns3.26 \ 10 | -L$FNCS_INSTALL/lib \ 11 | -lns3.26-applications-debug \ 12 | -lns3.26-fncs-debug \ 13 | -lns3.26-nix-vector-routing-debug \ 14 | -lns3.26-internet-debug \ 15 | -lns3.26-bridge-debug \ 16 | -lns3.26-csma-debug \ 17 | -lns3.26-point-to-point-debug \ 18 | -lns3.26-mpi-debug \ 19 | -lns3.26-stats-debug \ 20 | -lns3.26-network-debug \ 21 | -lns3.26-core-debug \ 22 | -lfncs \ 23 | -lczmq \ 24 | -lzmq 25 | 26 | #g++ \ 27 | #-g \ 28 | #-o firstN \ 29 | #firstN.cc \ 30 | #-I$FNCS_INSTALL/include/fncs \ 31 | #-I$FNCS_INSTALL/include/ns3.19 \ 32 | #-L$FNCS_INSTALL/lib \ 33 | #-lns3.19-fncs-debug \ 34 | #-lfncs \ 35 | #-lzmq \ 36 | #-lns3.19-point-to-point-debug \ 37 | #-lns3.19-applications-debug \ 38 | #-lns3.19-nix-vector-routing-debug \ 39 | #-lns3.19-csma-debug \ 40 | #-lns3.19-point-to-point-layout-debug \ 41 | #-lns3.19-wifi-debug \ 42 | #-lns3.19-netanim-debug \ 43 | #-lns3.19-wimax-debug \ 44 | #-lns3.19-core-debug 45 | -------------------------------------------------------------------------------- /Database/4_Nodes_492_Houses/compile-ns3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | g++ \ 4 | -g \ 5 | -o run_ns-3 \ 6 | run_ns-3.cc \ 7 | -I$FNCS_INSTALL/include \ 8 | -I$FNCS_INSTALL/include/fncs \ 9 | -I$FNCS_INSTALL/include/ns3.26 \ 10 | -L$FNCS_INSTALL/lib \ 11 | -lns3.26-applications-debug \ 12 | -lns3.26-fncs-debug \ 13 | -lns3.26-nix-vector-routing-debug \ 14 | -lns3.26-internet-debug \ 15 | -lns3.26-bridge-debug \ 16 | -lns3.26-csma-debug \ 17 | -lns3.26-point-to-point-debug \ 18 | -lns3.26-mpi-debug \ 19 | -lns3.26-stats-debug \ 20 | -lns3.26-network-debug \ 21 | -lns3.26-core-debug \ 22 | -lfncs \ 23 | -lczmq \ 24 | -lzmq 25 | 26 | #g++ \ 27 | #-g \ 28 | #-o firstN \ 29 | #firstN.cc \ 30 | #-I$FNCS_INSTALL/include/fncs \ 31 | #-I$FNCS_INSTALL/include/ns3.19 \ 32 | #-L$FNCS_INSTALL/lib \ 33 | #-lns3.19-fncs-debug \ 34 | #-lfncs \ 35 | #-lzmq \ 36 | #-lns3.19-point-to-point-debug \ 37 | #-lns3.19-applications-debug \ 38 | #-lns3.19-nix-vector-routing-debug \ 39 | #-lns3.19-csma-debug \ 40 | #-lns3.19-point-to-point-layout-debug \ 41 | #-lns3.19-wifi-debug \ 42 | #-lns3.19-netanim-debug \ 43 | #-lns3.19-wimax-debug \ 44 | #-lns3.19-core-debug 45 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/fncs.zpl: -------------------------------------------------------------------------------- 1 | name = ns3_1 2 | time_delta = 1ns 3 | broker = tcp://localhost:5570 4 | values 5 | fncs_msg/HOUSE_1@Market_1/submit_bid_state 6 | topic = fncs_msg/HOUSE_1@Market_1/submit_bid_state 7 | default = "" 8 | type = string 9 | list = false 10 | fncs_msg/Market_1@HOUSE_1/clearPrice 11 | topic = fncs_msg/Market_1@HOUSE_1/clearPrice 12 | default = "" 13 | ttype = string 14 | list = false 15 | fncs_msg/Market_1@HOUSE_1/mktID 16 | topic = fncs_msg/Market_1@HOUSE_1/mktID 17 | default = "" 18 | type = string 19 | list = false 20 | fncs_msg/Market_1@HOUSE_1/avgPrice 21 | topic = fncs_msg/Market_1@HOUSE_1/avgPrice 22 | default = "" 23 | type = string 24 | list = false 25 | fncs_msg/Market_1@HOUSE_1/stdevPrice 26 | topic = fncs_msg/Market_1@HOUSE_1/stdevPrice 27 | default = "" 28 | type = string 29 | list = false 30 | fncs_msg/Market_1@HOUSE_1/clearPrice 31 | topic = fncs_msg/Market_1@HOUSE_1/clearPrice 32 | default = "" 33 | type = string 34 | list = false 35 | -------------------------------------------------------------------------------- /Database/4_Nodes_492_Houses/README.txt: -------------------------------------------------------------------------------- 1 | NOTE: These files have only been tested with version 3.2. A revision may be posted once the generator_controller object is updated. 2 | 3 | These files represent a simple example using the generator_controller bidding 4 | object attached to a very simple 4-node system. The generator_controller emulates 5 | a distributed-energy-resource (DER) generator bidding into the local market to decide 6 | when to activate or not. The control mechanism implemented is that given in the following 7 | publications: 8 | 9 | D. J. Hammerstrom, et al., "Pacific Northwest GridWise Testbed Demonstration Projects, Part I: Olympic Peninsula Project", 10 | Pacific Northwest National Laboratory Technical Report, PNNL-17167, Richland, WA, October 2007 11 | 12 | File breakdown: 13 | appliance_schedules.glm -- schedules for appliance objects in the model 14 | fun_regionalization.m -- Regionalization subfunction for main MATLAB generator 15 | Generate_Feeder_Pseudo_4_Node.m -- Main MATLAB file to generate the GLM file to run, and adjust parameters 16 | README.txt -- This file 17 | Test_Feeder_Line_Configurations.glm -- "Database" of line and transformer types for the generated GLM 18 | Test_GLM_4Node_Test.glm -- Sample GLM generated by Generate_Feeder_Pseudo_4_Node.m 19 | WA-Seattle.tmy2 -- Seattle, WA weather file needed by simulation 20 | water_and_setpoint_schedule_v5.glm -- Schedules for water use and setpoint adjustments needed for the model 21 | -------------------------------------------------------------------------------- /Database/13_Nodes_73_Houses/creat_rout_and_subscribe.py: -------------------------------------------------------------------------------- 1 | 2 | outF = open("fncs_msg.txt", "w") 3 | index = 1 4 | line = "" 5 | while (index < 74): 6 | 7 | 8 | 9 | 10 | line = line + "route \"commit:Market_1.current_market.clearing_price -> HOUSE_"+str(index)+"/clearPrice; 0\";\n"; 11 | line = line + "route \"commit:Market_1.market_id -> HOUSE_"+str(index)+"/mktID; 0\";\n"; 12 | line = line + "route \"commit:Market_1.current_price_mean_24h -> HOUSE_"+str(index)+"/avgPrice; 0\";\n"; 13 | line = line + "route \"commit:Market_1.current_price_mean_24h -> HOUSE_"+str(index)+"/avgPrice; 0\";\n"; 14 | line = line + "route \"commit:Market_1.current_price_stdev_24h -> HOUSE_"+str(index)+"/stdevPrice; 0\";\n"; 15 | 16 | 17 | 18 | line = line + "subscribe \"function:auction/submit_bid_state <- ns3_1/ONE_NODE/HOUSE_"+str(index)+"@Market_1/submit_bid_state\";\n"; 19 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_clear_price <- ns3_1/ONE_NODE/Market_1@HOUSE_"+str(index)+"/clearPrice\";\n"; 20 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_market_id <- ns3_1/ONE_NODE/Market_1@HOUSE_"+str(index)+"/mktID\";\n"; 21 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_average <- ns3_1/ONE_NODE/Market_1@HOUSE_"+str(index)+"/avgPrice\";\n"; 22 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_standard_deviation <- ns3_1/ONE_NODE/Market_1@HOUSE_"+str(index)+"/stdevPrice\";\n"; 23 | 24 | 25 | 26 | 27 | 28 | index +=1 29 | 30 | 31 | 32 | outF.write(line) 33 | print("Finished") 34 | -------------------------------------------------------------------------------- /Database/13_Nodes_15_Houses/creat_rout_and_subscribe.py: -------------------------------------------------------------------------------- 1 | 2 | outF = open("fncs_msg.txt", "w") 3 | index = 1 4 | line = "" 5 | total_houses = int(raw_input("Enter Total House(s): ")) 6 | while (index <= total_houses): 7 | 8 | 9 | 10 | 11 | line = line + "route \"commit:Market_1.current_market.clearing_price -> HOUSE_"+str(index)+"/clearPrice; 0\";\n"; 12 | line = line + "route \"commit:Market_1.market_id -> HOUSE_"+str(index)+"/mktID; 0\";\n"; 13 | line = line + "route \"commit:Market_1.current_price_mean_24h -> HOUSE_"+str(index)+"/avgPrice; 0\";\n"; 14 | line = line + "route \"commit:Market_1.current_price_mean_24h -> HOUSE_"+str(index)+"/avgPrice; 0\";\n"; 15 | line = line + "route \"commit:Market_1.current_price_stdev_24h -> HOUSE_"+str(index)+"/stdevPrice; 0\";\n"; 16 | 17 | 18 | 19 | line = line + "subscribe \"function:auction/submit_bid_state <- ns3_1/fncs_msg/HOUSE_"+str(index)+"@Market_1/submit_bid_state\";\n"; 20 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_clear_price <- ns3_1/fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice\";\n"; 21 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_market_id <- ns3_1/fncs_msg/Market_1@HOUSE_"+str(index)+"/mktID\";\n"; 22 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_average <- ns3_1/fncs_msg/Market_1@HOUSE_"+str(index)+"/avgPrice\";\n"; 23 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_standard_deviation <- ns3_1/fncs_msg/Market_1@HOUSE_"+str(index)+"/stdevPrice\";\n"; 24 | 25 | 26 | 27 | 28 | 29 | index +=1 30 | 31 | 32 | 33 | outF.write(line) 34 | print("Finished") 35 | -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/creat_rout_and_subscribe.py: -------------------------------------------------------------------------------- 1 | 2 | outF = open("fncs_msg.txt", "w") 3 | index = 1 4 | line = "" 5 | total_houses = int(raw_input("Enter Total House(s): ")) 6 | while (index <= total_houses): 7 | 8 | 9 | 10 | 11 | line = line + "route \"commit:Market_1.current_market.clearing_price -> HOUSE_"+str(index)+"/clearPrice; 0\";\n"; 12 | line = line + "route \"commit:Market_1.market_id -> HOUSE_"+str(index)+"/mktID; 0\";\n"; 13 | line = line + "route \"commit:Market_1.current_price_mean_24h -> HOUSE_"+str(index)+"/avgPrice; 0\";\n"; 14 | line = line + "route \"commit:Market_1.current_price_mean_24h -> HOUSE_"+str(index)+"/avgPrice; 0\";\n"; 15 | line = line + "route \"commit:Market_1.current_price_stdev_24h -> HOUSE_"+str(index)+"/stdevPrice; 0\";\n"; 16 | 17 | 18 | 19 | line = line + "subscribe \"function:auction/submit_bid_state <- ns3_1/fncs_msg/HOUSE_"+str(index)+"@Market_1/submit_bid_state\";\n"; 20 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_clear_price <- ns3_1/fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice\";\n"; 21 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_market_id <- ns3_1/fncs_msg/Market_1@HOUSE_"+str(index)+"/mktID\";\n"; 22 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_average <- ns3_1/fncs_msg/Market_1@HOUSE_"+str(index)+"/avgPrice\";\n"; 23 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_standard_deviation <- ns3_1/fncs_msg/Market_1@HOUSE_"+str(index)+"/stdevPrice\";\n"; 24 | 25 | 26 | 27 | 28 | 29 | index +=1 30 | 31 | 32 | 33 | outF.write(line) 34 | print("Finished") 35 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/creat_rout_and_subscribe.py: -------------------------------------------------------------------------------- 1 | 2 | outF = open("fncs_msg.txt", "w") 3 | index = 1 4 | line = "" 5 | total_houses = int(raw_input("Enter Total House(s): ")) 6 | while (index <= total_houses): 7 | 8 | 9 | 10 | 11 | line = line + "route \"commit:Market_1.current_market.clearing_price -> HOUSE_"+str(index)+"/clearPrice; 0\";\n"; 12 | line = line + "route \"commit:Market_1.market_id -> HOUSE_"+str(index)+"/mktID; 0\";\n"; 13 | line = line + "route \"commit:Market_1.current_price_mean_24h -> HOUSE_"+str(index)+"/avgPrice; 0\";\n"; 14 | line = line + "route \"commit:Market_1.current_price_mean_24h -> HOUSE_"+str(index)+"/avgPrice; 0\";\n"; 15 | line = line + "route \"commit:Market_1.current_price_stdev_24h -> HOUSE_"+str(index)+"/stdevPrice; 0\";\n"; 16 | 17 | 18 | 19 | line = line + "subscribe \"function:auction/submit_bid_state <- ns3_1/fncs_msg/HOUSE_"+str(index)+"@Market_1/submit_bid_state\";\n"; 20 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_clear_price <- ns3_1/fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice\";\n"; 21 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_market_id <- ns3_1/fncs_msg/Market_1@HOUSE_"+str(index)+"/mktID\";\n"; 22 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_average <- ns3_1/fncs_msg/Market_1@HOUSE_"+str(index)+"/avgPrice\";\n"; 23 | line = line + "subscribe \"precommit:HOUSE_"+str(index)+".proxy_standard_deviation <- ns3_1/fncs_msg/Market_1@HOUSE_"+str(index)+"/stdevPrice\";\n"; 24 | 25 | 26 | 27 | 28 | 29 | index +=1 30 | 31 | 32 | 33 | outF.write(line) 34 | print("Finished") 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2021, Japan Advanced Institute of Science and Technology 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Database/13_Nodes_73_Houses/creat_zpl_file.py: -------------------------------------------------------------------------------- 1 | 2 | outF = open("fncs.zpl", "w") 3 | index = 1 4 | space = " " 5 | line = "name = ns3_1 \n" 6 | line = line + "time_delta = 1ns \n" 7 | line = line + "broker = tcp://localhost:5570 \n" 8 | line = line + "values \n" 9 | while (index < 74): 10 | line = line + space*4 +"fncs_msg/HOUSE_"+str(index)+"@Market_1/submit_bid_state\n" 11 | line = line + space*8 +"topic = fncs_msg/HOUSE_"+str(index)+"@Market_1/submit_bid_state\n" 12 | line = line + space*8 +"default = \"\"\n" 13 | line = line + space*8 +"type = string\n" 14 | line = line + space*8 +"list = false\n" 15 | 16 | 17 | 18 | 19 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 20 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 21 | line = line + space*8 +"default = \"\" \n" 22 | line = line + space*8 +"ttype = string \n" 23 | line = line + space*8 +"list = false \n" 24 | 25 | 26 | 27 | 28 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/mktID \n" 29 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/mktID \n" 30 | line = line + space*8 +"default = \"\" \n" 31 | line = line + space*8 +"type = string \n" 32 | line = line + space*8 +"list = false \n" 33 | 34 | 35 | 36 | 37 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/avgPrice \n" 38 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/avgPrice \n" 39 | line = line + space*8 +"default = \"\" \n" 40 | line = line + space*8 +"type = string \n" 41 | line = line + space*8 +"list = false \n" 42 | 43 | 44 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/stdevPrice \n" 45 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/stdevPrice \n" 46 | line = line + space*8 +"default = \"\" \n" 47 | line = line + space*8 +"type = string \n" 48 | line = line + space*8 +"list = false \n" 49 | 50 | 51 | 52 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 53 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 54 | line = line + space*8 +"default = \"\" \n" 55 | line = line + space*8 +"type = string \n" 56 | line = line + space*8 +"list = false \n" 57 | 58 | 59 | 60 | index +=1 61 | 62 | 63 | 64 | outF.write(line) 65 | print("Finished") 66 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/light_schedule.glm: -------------------------------------------------------------------------------- 1 | schedule LIGHTS { 2 | // weekday-summer 3 | { 4 | * 0 * 4-9 1-5 0.380; * 1 * 4-9 1-5 0.340; * 2 * 4-9 1-5 0.320; * 3 * 4-9 1-5 0.320; 5 | * 4 * 4-9 1-5 0.320; * 5 * 4-9 1-5 0.350; * 6 * 4-9 1-5 0.410; * 7 * 4-9 1-5 0.450; 6 | * 8 * 4-9 1-5 0.450; * 9 * 4-9 1-5 0.450; * 10 * 4-9 1-5 0.450; * 11 * 4-9 1-5 0.450; 7 | * 12 * 4-9 1-5 0.450; * 13 * 4-9 1-5 0.440; * 14 * 4-9 1-5 0.440; * 15 * 4-9 1-5 0.450; 8 | * 16 * 4-9 1-5 0.470; * 17 * 4-9 1-5 0.510; * 18 * 4-9 1-5 0.540; * 19 * 4-9 1-5 0.560; 9 | * 20 * 4-9 1-5 0.630; * 21 * 4-9 1-5 0.710; * 22 * 4-9 1-5 0.650; * 23 * 4-9 1-5 0.490 10 | } 11 | // weekend-summer 12 | { 13 | * 0 * 4-9 6-0 0.410; * 1 * 4-9 6-0 0.360; * 2 * 4-9 6-0 0.330; * 3 * 4-9 6-0 0.320; 14 | * 4 * 4-9 6-0 0.320; * 5 * 4-9 6-0 0.320; * 6 * 4-9 6-0 0.340; * 7 * 4-9 6-0 0.390; 15 | * 8 * 4-9 6-0 0.440; * 9 * 4-9 6-0 0.470; * 10 * 4-9 6-0 0.470; * 11 * 4-9 6-0 0.470; 16 | * 12 * 4-9 6-0 0.470; * 13 * 4-9 6-0 0.460; * 14 * 4-9 6-0 0.460; * 15 * 4-9 6-0 0.460; 17 | * 16 * 4-9 6-0 0.470; * 17 * 4-9 6-0 0.490; * 18 * 4-9 6-0 0.520; * 19 * 4-9 6-0 0.540; 18 | * 20 * 4-9 6-0 0.610; * 21 * 4-9 6-0 0.680; * 22 * 4-9 6-0 0.630; * 23 * 4-9 6-0 0.500 19 | } 20 | // weekday-winter 21 | { 22 | * 0 * 10-3 1-5 0.4200; * 1 * 10-3 1-5 0.3800; * 2 * 10-3 1-5 0.3700; * 3 * 10-3 1-5 0.3600; 23 | * 4 * 10-3 1-5 0.3700; * 5 * 10-3 1-5 0.4200; * 6 * 10-3 1-5 0.5800; * 7 * 10-3 1-5 0.6900; 24 | * 8 * 10-3 1-5 0.6100; * 9 * 10-3 1-5 0.5600; * 10 * 10-3 1-5 0.5300; * 11 * 10-3 1-5 0.5100; 25 | * 12 * 10-3 1-5 0.4900; * 13 * 10-3 1-5 0.4700; * 14 * 10-3 1-5 0.4700; * 15 * 10-3 1-5 0.5100; 26 | * 16 * 10-3 1-5 0.6300; * 17 * 10-3 1-5 0.8400; * 18 * 10-3 1-5 0.9700; * 19 * 10-3 1-5 0.9800; 27 | * 20 * 10-3 1-5 0.9600; * 21 * 10-3 1-5 0.8900; * 22 * 10-3 1-5 0.7400; * 23 * 10-3 1-5 0.5500 28 | } 29 | // weekend-winter 30 | { 31 | * 0 * 10-3 6-0 0.4900; * 1 * 10-3 6-0 0.4200; * 2 * 10-3 6-0 0.3800; * 3 * 10-3 6-0 0.3800; 32 | * 4 * 10-3 6-0 0.3700; * 5 * 10-3 6-0 0.3800; * 6 * 10-3 6-0 0.4300; * 7 * 10-3 6-0 0.5100; 33 | * 8 * 10-3 6-0 0.6000; * 9 * 10-3 6-0 0.6300; * 10 * 10-3 6-0 0.6300; * 11 * 10-3 6-0 0.6100; 34 | * 12 * 10-3 6-0 0.6000; * 13 * 10-3 6-0 0.5900; * 14 * 10-3 6-0 0.5900; * 15 * 10-3 6-0 0.6100; 35 | * 16 * 10-3 6-0 0.7100; * 17 * 10-3 6-0 0.8800; * 18 * 10-3 6-0 0.9600; * 19 * 10-3 6-0 0.9700; 36 | * 20 * 10-3 6-0 0.9400; * 21 * 10-3 6-0 0.8800; * 22 * 10-3 6-0 0.7600; * 23 * 10-3 6-0 0.5800 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /Database/13_Nodes_15_Houses/light_schedule.glm: -------------------------------------------------------------------------------- 1 | schedule LIGHTS { 2 | // weekday-summer 3 | { 4 | * 0 * 4-9 1-5 0.380; * 1 * 4-9 1-5 0.340; * 2 * 4-9 1-5 0.320; * 3 * 4-9 1-5 0.320; 5 | * 4 * 4-9 1-5 0.320; * 5 * 4-9 1-5 0.350; * 6 * 4-9 1-5 0.410; * 7 * 4-9 1-5 0.450; 6 | * 8 * 4-9 1-5 0.450; * 9 * 4-9 1-5 0.450; * 10 * 4-9 1-5 0.450; * 11 * 4-9 1-5 0.450; 7 | * 12 * 4-9 1-5 0.450; * 13 * 4-9 1-5 0.440; * 14 * 4-9 1-5 0.440; * 15 * 4-9 1-5 0.450; 8 | * 16 * 4-9 1-5 0.470; * 17 * 4-9 1-5 0.510; * 18 * 4-9 1-5 0.540; * 19 * 4-9 1-5 0.560; 9 | * 20 * 4-9 1-5 0.630; * 21 * 4-9 1-5 0.710; * 22 * 4-9 1-5 0.650; * 23 * 4-9 1-5 0.490 10 | } 11 | // weekend-summer 12 | { 13 | * 0 * 4-9 6-0 0.410; * 1 * 4-9 6-0 0.360; * 2 * 4-9 6-0 0.330; * 3 * 4-9 6-0 0.320; 14 | * 4 * 4-9 6-0 0.320; * 5 * 4-9 6-0 0.320; * 6 * 4-9 6-0 0.340; * 7 * 4-9 6-0 0.390; 15 | * 8 * 4-9 6-0 0.440; * 9 * 4-9 6-0 0.470; * 10 * 4-9 6-0 0.470; * 11 * 4-9 6-0 0.470; 16 | * 12 * 4-9 6-0 0.470; * 13 * 4-9 6-0 0.460; * 14 * 4-9 6-0 0.460; * 15 * 4-9 6-0 0.460; 17 | * 16 * 4-9 6-0 0.470; * 17 * 4-9 6-0 0.490; * 18 * 4-9 6-0 0.520; * 19 * 4-9 6-0 0.540; 18 | * 20 * 4-9 6-0 0.610; * 21 * 4-9 6-0 0.680; * 22 * 4-9 6-0 0.630; * 23 * 4-9 6-0 0.500 19 | } 20 | // weekday-winter 21 | { 22 | * 0 * 10-3 1-5 0.4200; * 1 * 10-3 1-5 0.3800; * 2 * 10-3 1-5 0.3700; * 3 * 10-3 1-5 0.3600; 23 | * 4 * 10-3 1-5 0.3700; * 5 * 10-3 1-5 0.4200; * 6 * 10-3 1-5 0.5800; * 7 * 10-3 1-5 0.6900; 24 | * 8 * 10-3 1-5 0.6100; * 9 * 10-3 1-5 0.5600; * 10 * 10-3 1-5 0.5300; * 11 * 10-3 1-5 0.5100; 25 | * 12 * 10-3 1-5 0.4900; * 13 * 10-3 1-5 0.4700; * 14 * 10-3 1-5 0.4700; * 15 * 10-3 1-5 0.5100; 26 | * 16 * 10-3 1-5 0.6300; * 17 * 10-3 1-5 0.8400; * 18 * 10-3 1-5 0.9700; * 19 * 10-3 1-5 0.9800; 27 | * 20 * 10-3 1-5 0.9600; * 21 * 10-3 1-5 0.8900; * 22 * 10-3 1-5 0.7400; * 23 * 10-3 1-5 0.5500 28 | } 29 | // weekend-winter 30 | { 31 | * 0 * 10-3 6-0 0.4900; * 1 * 10-3 6-0 0.4200; * 2 * 10-3 6-0 0.3800; * 3 * 10-3 6-0 0.3800; 32 | * 4 * 10-3 6-0 0.3700; * 5 * 10-3 6-0 0.3800; * 6 * 10-3 6-0 0.4300; * 7 * 10-3 6-0 0.5100; 33 | * 8 * 10-3 6-0 0.6000; * 9 * 10-3 6-0 0.6300; * 10 * 10-3 6-0 0.6300; * 11 * 10-3 6-0 0.6100; 34 | * 12 * 10-3 6-0 0.6000; * 13 * 10-3 6-0 0.5900; * 14 * 10-3 6-0 0.5900; * 15 * 10-3 6-0 0.6100; 35 | * 16 * 10-3 6-0 0.7100; * 17 * 10-3 6-0 0.8800; * 18 * 10-3 6-0 0.9600; * 19 * 10-3 6-0 0.9700; 36 | * 20 * 10-3 6-0 0.9400; * 21 * 10-3 6-0 0.8800; * 22 * 10-3 6-0 0.7600; * 23 * 10-3 6-0 0.5800 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /Database/13_Nodes_73_Houses/light_schedule.glm: -------------------------------------------------------------------------------- 1 | schedule LIGHTS { 2 | // weekday-summer 3 | { 4 | * 0 * 4-9 1-5 0.380; * 1 * 4-9 1-5 0.340; * 2 * 4-9 1-5 0.320; * 3 * 4-9 1-5 0.320; 5 | * 4 * 4-9 1-5 0.320; * 5 * 4-9 1-5 0.350; * 6 * 4-9 1-5 0.410; * 7 * 4-9 1-5 0.450; 6 | * 8 * 4-9 1-5 0.450; * 9 * 4-9 1-5 0.450; * 10 * 4-9 1-5 0.450; * 11 * 4-9 1-5 0.450; 7 | * 12 * 4-9 1-5 0.450; * 13 * 4-9 1-5 0.440; * 14 * 4-9 1-5 0.440; * 15 * 4-9 1-5 0.450; 8 | * 16 * 4-9 1-5 0.470; * 17 * 4-9 1-5 0.510; * 18 * 4-9 1-5 0.540; * 19 * 4-9 1-5 0.560; 9 | * 20 * 4-9 1-5 0.630; * 21 * 4-9 1-5 0.710; * 22 * 4-9 1-5 0.650; * 23 * 4-9 1-5 0.490 10 | } 11 | // weekend-summer 12 | { 13 | * 0 * 4-9 6-0 0.410; * 1 * 4-9 6-0 0.360; * 2 * 4-9 6-0 0.330; * 3 * 4-9 6-0 0.320; 14 | * 4 * 4-9 6-0 0.320; * 5 * 4-9 6-0 0.320; * 6 * 4-9 6-0 0.340; * 7 * 4-9 6-0 0.390; 15 | * 8 * 4-9 6-0 0.440; * 9 * 4-9 6-0 0.470; * 10 * 4-9 6-0 0.470; * 11 * 4-9 6-0 0.470; 16 | * 12 * 4-9 6-0 0.470; * 13 * 4-9 6-0 0.460; * 14 * 4-9 6-0 0.460; * 15 * 4-9 6-0 0.460; 17 | * 16 * 4-9 6-0 0.470; * 17 * 4-9 6-0 0.490; * 18 * 4-9 6-0 0.520; * 19 * 4-9 6-0 0.540; 18 | * 20 * 4-9 6-0 0.610; * 21 * 4-9 6-0 0.680; * 22 * 4-9 6-0 0.630; * 23 * 4-9 6-0 0.500 19 | } 20 | // weekday-winter 21 | { 22 | * 0 * 10-3 1-5 0.4200; * 1 * 10-3 1-5 0.3800; * 2 * 10-3 1-5 0.3700; * 3 * 10-3 1-5 0.3600; 23 | * 4 * 10-3 1-5 0.3700; * 5 * 10-3 1-5 0.4200; * 6 * 10-3 1-5 0.5800; * 7 * 10-3 1-5 0.6900; 24 | * 8 * 10-3 1-5 0.6100; * 9 * 10-3 1-5 0.5600; * 10 * 10-3 1-5 0.5300; * 11 * 10-3 1-5 0.5100; 25 | * 12 * 10-3 1-5 0.4900; * 13 * 10-3 1-5 0.4700; * 14 * 10-3 1-5 0.4700; * 15 * 10-3 1-5 0.5100; 26 | * 16 * 10-3 1-5 0.6300; * 17 * 10-3 1-5 0.8400; * 18 * 10-3 1-5 0.9700; * 19 * 10-3 1-5 0.9800; 27 | * 20 * 10-3 1-5 0.9600; * 21 * 10-3 1-5 0.8900; * 22 * 10-3 1-5 0.7400; * 23 * 10-3 1-5 0.5500 28 | } 29 | // weekend-winter 30 | { 31 | * 0 * 10-3 6-0 0.4900; * 1 * 10-3 6-0 0.4200; * 2 * 10-3 6-0 0.3800; * 3 * 10-3 6-0 0.3800; 32 | * 4 * 10-3 6-0 0.3700; * 5 * 10-3 6-0 0.3800; * 6 * 10-3 6-0 0.4300; * 7 * 10-3 6-0 0.5100; 33 | * 8 * 10-3 6-0 0.6000; * 9 * 10-3 6-0 0.6300; * 10 * 10-3 6-0 0.6300; * 11 * 10-3 6-0 0.6100; 34 | * 12 * 10-3 6-0 0.6000; * 13 * 10-3 6-0 0.5900; * 14 * 10-3 6-0 0.5900; * 15 * 10-3 6-0 0.6100; 35 | * 16 * 10-3 6-0 0.7100; * 17 * 10-3 6-0 0.8800; * 18 * 10-3 6-0 0.9600; * 19 * 10-3 6-0 0.9700; 36 | * 20 * 10-3 6-0 0.9400; * 21 * 10-3 6-0 0.8800; * 22 * 10-3 6-0 0.7600; * 23 * 10-3 6-0 0.5800 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /Database/13_Nodes_15_Houses/creat_zpl_file.py: -------------------------------------------------------------------------------- 1 | 2 | def main(): 3 | outF = open("fncs.zpl", "w") 4 | index = 1 5 | total_houses = int(raw_input("Enter Total Houses: ")) 6 | space = " " 7 | line = "name = ns3_1 \n" 8 | line = line + "time_delta = 1ns \n" 9 | line = line + "broker = tcp://localhost:5570 \n" 10 | line = line + "values \n" 11 | while (index <= total_houses): 12 | line = line + space*4 +"fncs_msg/HOUSE_"+str(index)+"@Market_1/submit_bid_state\n" 13 | line = line + space*8 +"topic = fncs_msg/HOUSE_"+str(index)+"@Market_1/submit_bid_state\n" 14 | line = line + space*8 +"default = \"\"\n" 15 | line = line + space*8 +"type = string\n" 16 | line = line + space*8 +"list = false\n" 17 | 18 | 19 | 20 | 21 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 22 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 23 | line = line + space*8 +"default = \"\" \n" 24 | line = line + space*8 +"ttype = string \n" 25 | line = line + space*8 +"list = false \n" 26 | 27 | 28 | 29 | 30 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/mktID \n" 31 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/mktID \n" 32 | line = line + space*8 +"default = \"\" \n" 33 | line = line + space*8 +"type = string \n" 34 | line = line + space*8 +"list = false \n" 35 | 36 | 37 | 38 | 39 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/avgPrice \n" 40 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/avgPrice \n" 41 | line = line + space*8 +"default = \"\" \n" 42 | line = line + space*8 +"type = string \n" 43 | line = line + space*8 +"list = false \n" 44 | 45 | 46 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/stdevPrice \n" 47 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/stdevPrice \n" 48 | line = line + space*8 +"default = \"\" \n" 49 | line = line + space*8 +"type = string \n" 50 | line = line + space*8 +"list = false \n" 51 | 52 | 53 | 54 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 55 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 56 | line = line + space*8 +"default = \"\" \n" 57 | line = line + space*8 +"type = string \n" 58 | line = line + space*8 +"list = false \n" 59 | 60 | 61 | 62 | index +=1 63 | 64 | 65 | 66 | outF.write(line) 67 | print("Finished") 68 | if __name__ == '__main__': 69 | main() 70 | -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/creat_zpl_file.py: -------------------------------------------------------------------------------- 1 | 2 | def main(): 3 | outF = open("fncs.zpl", "w") 4 | index = 1 5 | total_houses = int(raw_input("Enter Total Houses: ")) 6 | space = " " 7 | line = "name = ns3_1 \n" 8 | line = line + "time_delta = 1ns \n" 9 | line = line + "broker = tcp://localhost:5570 \n" 10 | line = line + "values \n" 11 | while (index <= total_houses): 12 | line = line + space*4 +"fncs_msg/HOUSE_"+str(index)+"@Market_1/submit_bid_state\n" 13 | line = line + space*8 +"topic = fncs_msg/HOUSE_"+str(index)+"@Market_1/submit_bid_state\n" 14 | line = line + space*8 +"default = \"\"\n" 15 | line = line + space*8 +"type = string\n" 16 | line = line + space*8 +"list = false\n" 17 | 18 | 19 | 20 | 21 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 22 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 23 | line = line + space*8 +"default = \"\" \n" 24 | line = line + space*8 +"ttype = string \n" 25 | line = line + space*8 +"list = false \n" 26 | 27 | 28 | 29 | 30 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/mktID \n" 31 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/mktID \n" 32 | line = line + space*8 +"default = \"\" \n" 33 | line = line + space*8 +"type = string \n" 34 | line = line + space*8 +"list = false \n" 35 | 36 | 37 | 38 | 39 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/avgPrice \n" 40 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/avgPrice \n" 41 | line = line + space*8 +"default = \"\" \n" 42 | line = line + space*8 +"type = string \n" 43 | line = line + space*8 +"list = false \n" 44 | 45 | 46 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/stdevPrice \n" 47 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/stdevPrice \n" 48 | line = line + space*8 +"default = \"\" \n" 49 | line = line + space*8 +"type = string \n" 50 | line = line + space*8 +"list = false \n" 51 | 52 | 53 | 54 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 55 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 56 | line = line + space*8 +"default = \"\" \n" 57 | line = line + space*8 +"type = string \n" 58 | line = line + space*8 +"list = false \n" 59 | 60 | 61 | 62 | index +=1 63 | 64 | 65 | 66 | outF.write(line) 67 | print("Finished") 68 | if __name__ == '__main__': 69 | main() 70 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/creat_zpl_file.py: -------------------------------------------------------------------------------- 1 | 2 | def main(): 3 | outF = open("fncs.zpl", "w") 4 | index = 1 5 | total_houses = int(raw_input("Enter Total Houses: ")) 6 | space = " " 7 | line = "name = ns3_1 \n" 8 | line = line + "time_delta = 1ns \n" 9 | line = line + "broker = tcp://localhost:5570 \n" 10 | line = line + "values \n" 11 | while (index <= total_houses): 12 | line = line + space*4 +"fncs_msg/HOUSE_"+str(index)+"@Market_1/submit_bid_state\n" 13 | line = line + space*8 +"topic = fncs_msg/HOUSE_"+str(index)+"@Market_1/submit_bid_state\n" 14 | line = line + space*8 +"default = \"\"\n" 15 | line = line + space*8 +"type = string\n" 16 | line = line + space*8 +"list = false\n" 17 | 18 | 19 | 20 | 21 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 22 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 23 | line = line + space*8 +"default = \"\" \n" 24 | line = line + space*8 +"ttype = string \n" 25 | line = line + space*8 +"list = false \n" 26 | 27 | 28 | 29 | 30 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/mktID \n" 31 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/mktID \n" 32 | line = line + space*8 +"default = \"\" \n" 33 | line = line + space*8 +"type = string \n" 34 | line = line + space*8 +"list = false \n" 35 | 36 | 37 | 38 | 39 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/avgPrice \n" 40 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/avgPrice \n" 41 | line = line + space*8 +"default = \"\" \n" 42 | line = line + space*8 +"type = string \n" 43 | line = line + space*8 +"list = false \n" 44 | 45 | 46 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/stdevPrice \n" 47 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/stdevPrice \n" 48 | line = line + space*8 +"default = \"\" \n" 49 | line = line + space*8 +"type = string \n" 50 | line = line + space*8 +"list = false \n" 51 | 52 | 53 | 54 | line = line + space*4 +"fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 55 | line = line + space*8 +"topic = fncs_msg/Market_1@HOUSE_"+str(index)+"/clearPrice \n" 56 | line = line + space*8 +"default = \"\" \n" 57 | line = line + space*8 +"type = string \n" 58 | line = line + space*8 +"list = false \n" 59 | 60 | 61 | 62 | index +=1 63 | 64 | 65 | 66 | outF.write(line) 67 | print("Finished") 68 | if __name__ == '__main__': 69 | main() 70 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/ attack_schedule.glm: -------------------------------------------------------------------------------- 1 | schedule schedule_1 { 2 | 0-9 0 * * * 0.00; 3 | 10-19 0 * * * 0.00; 4 | 20-29 0 * * * 0.00; 5 | 30-39 0 * * * 0.00; 6 | 40-49 0 * * * 0.00; 7 | 50-59 0 * * * 0.00; 8 | 0-9 1 * * * 0.00; 9 | 10-19 1 * * * 0.00; 10 | 20-29 1 * * * 0.00; 11 | 30-39 1 * * * 0.00; 12 | 40-49 1 * * * 0.00; 13 | 50-59 1 * * * 0.00; 14 | 0-9 2 * * * 0.00; 15 | 10-19 2 * * * 0.00; 16 | 20-29 2 * * * 0.00; 17 | 30-39 2 * * * 0.39; 18 | 40-49 2 * * * 0.00; 19 | 50-59 2 * * * 0.01; 20 | 0-9 3 * * * 0.00; 21 | 10-19 3 * * * 0.00; 22 | 20-29 3 * * * 0.00; 23 | 30-39 3 * * * 0.00; 24 | 40-49 3 * * * 0.00; 25 | 50-59 3 * * * 0.32; 26 | 0-9 4 * * * 0.00; 27 | 10-19 4 * * * 0.00; 28 | 20-29 4 * * * 0.00; 29 | 30-39 4 * * * 0.13; 30 | 40-49 4 * * * 0.00; 31 | 50-59 4 * * * 0.09; 32 | 0-9 5 * * * 0.23; 33 | 10-19 5 * * * 0.00; 34 | 20-29 5 * * * 0.00; 35 | 30-39 5 * * * 0.00; 36 | 40-49 5 * * * 0.00; 37 | 50-59 5 * * * 0.48; 38 | 0-9 6 * * * 0.88; 39 | 10-19 6 * * * 0.00; 40 | 20-29 6 * * * 0.00; 41 | 30-39 6 * * * 0.00; 42 | 40-49 6 * * * 0.00; 43 | 50-59 6 * * * 0.00; 44 | 0-9 7 * * * 0.00; 45 | 10-19 7 * * * 0.00; 46 | 20-29 7 * * * 0.00; 47 | 30-39 7 * * * 0.00; 48 | 40-49 7 * * * 0.00; 49 | 50-59 7 * * * 0.00; 50 | 0-9 8 * * * 0.00; 51 | 10-19 8 * * * 0.00; 52 | 20-29 8 * * * 0.00; 53 | 30-39 8 * * * 0.61; 54 | 40-49 8 * * * 0.00; 55 | 50-59 8 * * * 0.00; 56 | 0-9 9 * * * 0.00; 57 | 10-19 9 * * * 0.00; 58 | 20-29 9 * * * 0.00; 59 | 30-39 9 * * * 0.00; 60 | 40-49 9 * * * 0.00; 61 | 50-59 9 * * * 0.00; 62 | 0-9 10 * * * 0.00; 63 | 10-19 10 * * * 0.00; 64 | 20-29 10 * * * 0.00; 65 | 30-39 10 * * * 0.00; 66 | 40-49 10 * * * 0.00; 67 | 50-59 10 * * * 0.00; 68 | 0-9 11 * * * 0.00; 69 | 10-19 11 * * * 0.00; 70 | 20-29 11 * * * 0.00; 71 | 30-39 11 * * * 0.00; 72 | 40-49 11 * * * 0.00; 73 | 50-59 11 * * * 0.00; 74 | 0-9 12 * * * 0.00; 75 | 10-19 12 * * * 0.00; 76 | 20-29 12 * * * 0.00; 77 | 30-39 12 * * * 0.00; 78 | 40-49 12 * * * 0.00; 79 | 50-59 12 * * * 0.00; 80 | 0-9 13 * * * 0.00; 81 | 10-19 13 * * * 0.00; 82 | 20-29 13 * * * 0.00; 83 | 30-39 13 * * * 0.00; 84 | 40-49 13 * * * 0.00; 85 | 50-59 13 * * * 0.41; 86 | 0-9 14 * * * 0.00; 87 | 10-19 14 * * * 0.12; 88 | 20-29 14 * * * 0.00; 89 | 30-39 14 * * * 0.92; 90 | 40-49 14 * * * 0.30; 91 | 50-59 14 * * * 0.00; 92 | 0-9 15 * * * 0.78; 93 | 10-19 15 * * * 0.00; 94 | 20-29 15 * * * 0.00; 95 | 30-39 15 * * * 0.00; 96 | 40-49 15 * * * 0.00; 97 | 50-59 15 * * * 0.00; 98 | 0-9 16 * * * 0.00; 99 | 10-19 16 * * * 0.00; 100 | 20-29 16 * * * 0.00; 101 | 30-39 16 * * * 0.00; 102 | 40-49 16 * * * 0.00; 103 | 50-59 16 * * * 0.25; 104 | 0-9 17 * * * 0.00; 105 | 10-19 17 * * * 0.00; 106 | 20-29 17 * * * 0.00; 107 | 30-39 17 * * * 0.00; 108 | 40-49 17 * * * 0.00; 109 | 50-59 17 * * * 0.00; 110 | 0-9 18 * * * 0.00; 111 | 10-19 18 * * * 0.16; 112 | 20-29 18 * * * 0.00; 113 | 30-39 18 * * * 0.00; 114 | 40-49 18 * * * 0.00; 115 | 50-59 18 * * * 0.00; 116 | 0-9 19 * * * 0.00; 117 | 10-19 19 * * * 0.00; 118 | 20-29 19 * * * 0.00; 119 | 30-39 19 * * * 0.00; 120 | 40-49 19 * * * 0.00; 121 | 50-59 19 * * * 0.00; 122 | 0-9 20 * * * 0.00; 123 | 10-19 20 * * * 0.00; 124 | 20-29 20 * * * 0.00; 125 | 30-39 20 * * * 0.00; 126 | 40-49 20 * * * 0.00; 127 | 50-59 20 * * * 0.00; 128 | 0-9 21 * * * 0.00; 129 | 10-19 21 * * * 0.00; 130 | 20-29 21 * * * 0.00; 131 | 30-39 21 * * * 0.00; 132 | 40-49 21 * * * 0.00; 133 | 50-59 21 * * * 0.00; 134 | 0-9 22 * * * 0.00; 135 | 10-19 22 * * * 0.00; 136 | 20-29 22 * * * 0.00; 137 | 30-39 22 * * * 0.00; 138 | 40-49 22 * * * 0.00; 139 | 50-59 22 * * * 0.00; 140 | 0-9 23 * * * 0.00; 141 | 10-19 23 * * * 0.00; 142 | 20-29 23 * * * 0.00; 143 | 30-39 23 * * * 0.00; 144 | 40-49 23 * * * 0.00; 145 | 50-59 23 * * * 0.00; 146 | } 147 | -------------------------------------------------------------------------------- /Database/13_Nodes_15_Houses/ attack_schedule.glm: -------------------------------------------------------------------------------- 1 | schedule schedule_1 { 2 | 0-9 0 * * * 0.00; 3 | 10-19 0 * * * 0.00; 4 | 20-29 0 * * * 0.00; 5 | 30-39 0 * * * 0.00; 6 | 40-49 0 * * * 0.00; 7 | 50-59 0 * * * 0.00; 8 | 0-9 1 * * * 0.00; 9 | 10-19 1 * * * 0.00; 10 | 20-29 1 * * * 0.00; 11 | 30-39 1 * * * 0.00; 12 | 40-49 1 * * * 0.00; 13 | 50-59 1 * * * 0.00; 14 | 0-9 2 * * * 0.00; 15 | 10-19 2 * * * 0.00; 16 | 20-29 2 * * * 0.00; 17 | 30-39 2 * * * 0.39; 18 | 40-49 2 * * * 0.00; 19 | 50-59 2 * * * 0.01; 20 | 0-9 3 * * * 0.00; 21 | 10-19 3 * * * 0.00; 22 | 20-29 3 * * * 0.00; 23 | 30-39 3 * * * 0.00; 24 | 40-49 3 * * * 0.00; 25 | 50-59 3 * * * 0.32; 26 | 0-9 4 * * * 0.00; 27 | 10-19 4 * * * 0.00; 28 | 20-29 4 * * * 0.00; 29 | 30-39 4 * * * 0.13; 30 | 40-49 4 * * * 0.00; 31 | 50-59 4 * * * 0.09; 32 | 0-9 5 * * * 0.23; 33 | 10-19 5 * * * 0.00; 34 | 20-29 5 * * * 0.00; 35 | 30-39 5 * * * 0.00; 36 | 40-49 5 * * * 0.00; 37 | 50-59 5 * * * 0.48; 38 | 0-9 6 * * * 0.88; 39 | 10-19 6 * * * 0.00; 40 | 20-29 6 * * * 0.00; 41 | 30-39 6 * * * 0.00; 42 | 40-49 6 * * * 0.00; 43 | 50-59 6 * * * 0.00; 44 | 0-9 7 * * * 0.00; 45 | 10-19 7 * * * 0.00; 46 | 20-29 7 * * * 0.00; 47 | 30-39 7 * * * 0.00; 48 | 40-49 7 * * * 0.00; 49 | 50-59 7 * * * 0.00; 50 | 0-9 8 * * * 0.00; 51 | 10-19 8 * * * 0.00; 52 | 20-29 8 * * * 0.00; 53 | 30-39 8 * * * 0.61; 54 | 40-49 8 * * * 0.00; 55 | 50-59 8 * * * 0.00; 56 | 0-9 9 * * * 0.00; 57 | 10-19 9 * * * 0.00; 58 | 20-29 9 * * * 0.00; 59 | 30-39 9 * * * 0.00; 60 | 40-49 9 * * * 0.00; 61 | 50-59 9 * * * 0.00; 62 | 0-9 10 * * * 0.00; 63 | 10-19 10 * * * 0.00; 64 | 20-29 10 * * * 0.00; 65 | 30-39 10 * * * 0.00; 66 | 40-49 10 * * * 0.00; 67 | 50-59 10 * * * 0.00; 68 | 0-9 11 * * * 0.00; 69 | 10-19 11 * * * 0.00; 70 | 20-29 11 * * * 0.00; 71 | 30-39 11 * * * 0.00; 72 | 40-49 11 * * * 0.00; 73 | 50-59 11 * * * 0.00; 74 | 0-9 12 * * * 0.00; 75 | 10-19 12 * * * 0.00; 76 | 20-29 12 * * * 0.00; 77 | 30-39 12 * * * 0.00; 78 | 40-49 12 * * * 0.00; 79 | 50-59 12 * * * 0.00; 80 | 0-9 13 * * * 0.00; 81 | 10-19 13 * * * 0.00; 82 | 20-29 13 * * * 0.00; 83 | 30-39 13 * * * 0.00; 84 | 40-49 13 * * * 0.00; 85 | 50-59 13 * * * 0.41; 86 | 0-9 14 * * * 0.00; 87 | 10-19 14 * * * 0.12; 88 | 20-29 14 * * * 0.00; 89 | 30-39 14 * * * 0.92; 90 | 40-49 14 * * * 0.30; 91 | 50-59 14 * * * 0.00; 92 | 0-9 15 * * * 0.78; 93 | 10-19 15 * * * 0.00; 94 | 20-29 15 * * * 0.00; 95 | 30-39 15 * * * 0.00; 96 | 40-49 15 * * * 0.00; 97 | 50-59 15 * * * 0.00; 98 | 0-9 16 * * * 0.00; 99 | 10-19 16 * * * 0.00; 100 | 20-29 16 * * * 0.00; 101 | 30-39 16 * * * 0.00; 102 | 40-49 16 * * * 0.00; 103 | 50-59 16 * * * 0.25; 104 | 0-9 17 * * * 0.00; 105 | 10-19 17 * * * 0.00; 106 | 20-29 17 * * * 0.00; 107 | 30-39 17 * * * 0.00; 108 | 40-49 17 * * * 0.00; 109 | 50-59 17 * * * 0.00; 110 | 0-9 18 * * * 0.00; 111 | 10-19 18 * * * 0.16; 112 | 20-29 18 * * * 0.00; 113 | 30-39 18 * * * 0.00; 114 | 40-49 18 * * * 0.00; 115 | 50-59 18 * * * 0.00; 116 | 0-9 19 * * * 0.00; 117 | 10-19 19 * * * 0.00; 118 | 20-29 19 * * * 0.00; 119 | 30-39 19 * * * 0.00; 120 | 40-49 19 * * * 0.00; 121 | 50-59 19 * * * 0.00; 122 | 0-9 20 * * * 0.00; 123 | 10-19 20 * * * 0.00; 124 | 20-29 20 * * * 0.00; 125 | 30-39 20 * * * 0.00; 126 | 40-49 20 * * * 0.00; 127 | 50-59 20 * * * 0.00; 128 | 0-9 21 * * * 0.00; 129 | 10-19 21 * * * 0.00; 130 | 20-29 21 * * * 0.00; 131 | 30-39 21 * * * 0.00; 132 | 40-49 21 * * * 0.00; 133 | 50-59 21 * * * 0.00; 134 | 0-9 22 * * * 0.00; 135 | 10-19 22 * * * 0.00; 136 | 20-29 22 * * * 0.00; 137 | 30-39 22 * * * 0.00; 138 | 40-49 22 * * * 0.00; 139 | 50-59 22 * * * 0.00; 140 | 0-9 23 * * * 0.00; 141 | 10-19 23 * * * 0.00; 142 | 20-29 23 * * * 0.00; 143 | 30-39 23 * * * 0.00; 144 | 40-49 23 * * * 0.00; 145 | 50-59 23 * * * 0.00; 146 | } 147 | -------------------------------------------------------------------------------- /Database/13_Nodes_73_Houses/ attack_schedule.glm: -------------------------------------------------------------------------------- 1 | schedule schedule_1 { 2 | 0-9 0 * * * 0.00; 3 | 10-19 0 * * * 0.00; 4 | 20-29 0 * * * 0.00; 5 | 30-39 0 * * * 0.00; 6 | 40-49 0 * * * 0.00; 7 | 50-59 0 * * * 0.00; 8 | 0-9 1 * * * 0.00; 9 | 10-19 1 * * * 0.00; 10 | 20-29 1 * * * 0.00; 11 | 30-39 1 * * * 0.00; 12 | 40-49 1 * * * 0.00; 13 | 50-59 1 * * * 0.00; 14 | 0-9 2 * * * 0.00; 15 | 10-19 2 * * * 0.00; 16 | 20-29 2 * * * 0.00; 17 | 30-39 2 * * * 0.39; 18 | 40-49 2 * * * 0.00; 19 | 50-59 2 * * * 0.01; 20 | 0-9 3 * * * 0.00; 21 | 10-19 3 * * * 0.00; 22 | 20-29 3 * * * 0.00; 23 | 30-39 3 * * * 0.00; 24 | 40-49 3 * * * 0.00; 25 | 50-59 3 * * * 0.32; 26 | 0-9 4 * * * 0.00; 27 | 10-19 4 * * * 0.00; 28 | 20-29 4 * * * 0.00; 29 | 30-39 4 * * * 0.13; 30 | 40-49 4 * * * 0.00; 31 | 50-59 4 * * * 0.09; 32 | 0-9 5 * * * 0.23; 33 | 10-19 5 * * * 0.00; 34 | 20-29 5 * * * 0.00; 35 | 30-39 5 * * * 0.00; 36 | 40-49 5 * * * 0.00; 37 | 50-59 5 * * * 0.48; 38 | 0-9 6 * * * 0.88; 39 | 10-19 6 * * * 0.00; 40 | 20-29 6 * * * 0.00; 41 | 30-39 6 * * * 0.00; 42 | 40-49 6 * * * 0.00; 43 | 50-59 6 * * * 0.00; 44 | 0-9 7 * * * 0.00; 45 | 10-19 7 * * * 0.00; 46 | 20-29 7 * * * 0.00; 47 | 30-39 7 * * * 0.00; 48 | 40-49 7 * * * 0.00; 49 | 50-59 7 * * * 0.00; 50 | 0-9 8 * * * 0.00; 51 | 10-19 8 * * * 0.00; 52 | 20-29 8 * * * 0.00; 53 | 30-39 8 * * * 0.61; 54 | 40-49 8 * * * 0.00; 55 | 50-59 8 * * * 0.00; 56 | 0-9 9 * * * 0.00; 57 | 10-19 9 * * * 0.00; 58 | 20-29 9 * * * 0.00; 59 | 30-39 9 * * * 0.00; 60 | 40-49 9 * * * 0.00; 61 | 50-59 9 * * * 0.00; 62 | 0-9 10 * * * 0.00; 63 | 10-19 10 * * * 0.00; 64 | 20-29 10 * * * 0.00; 65 | 30-39 10 * * * 0.00; 66 | 40-49 10 * * * 0.00; 67 | 50-59 10 * * * 0.00; 68 | 0-9 11 * * * 0.00; 69 | 10-19 11 * * * 0.00; 70 | 20-29 11 * * * 0.00; 71 | 30-39 11 * * * 0.00; 72 | 40-49 11 * * * 0.00; 73 | 50-59 11 * * * 0.00; 74 | 0-9 12 * * * 0.00; 75 | 10-19 12 * * * 0.00; 76 | 20-29 12 * * * 0.00; 77 | 30-39 12 * * * 0.00; 78 | 40-49 12 * * * 0.00; 79 | 50-59 12 * * * 0.00; 80 | 0-9 13 * * * 0.00; 81 | 10-19 13 * * * 0.00; 82 | 20-29 13 * * * 0.00; 83 | 30-39 13 * * * 0.00; 84 | 40-49 13 * * * 0.00; 85 | 50-59 13 * * * 0.41; 86 | 0-9 14 * * * 0.00; 87 | 10-19 14 * * * 0.12; 88 | 20-29 14 * * * 0.00; 89 | 30-39 14 * * * 0.92; 90 | 40-49 14 * * * 0.30; 91 | 50-59 14 * * * 0.00; 92 | 0-9 15 * * * 0.78; 93 | 10-19 15 * * * 0.00; 94 | 20-29 15 * * * 0.00; 95 | 30-39 15 * * * 0.00; 96 | 40-49 15 * * * 0.00; 97 | 50-59 15 * * * 0.00; 98 | 0-9 16 * * * 0.00; 99 | 10-19 16 * * * 0.00; 100 | 20-29 16 * * * 0.00; 101 | 30-39 16 * * * 0.00; 102 | 40-49 16 * * * 0.00; 103 | 50-59 16 * * * 0.25; 104 | 0-9 17 * * * 0.00; 105 | 10-19 17 * * * 0.00; 106 | 20-29 17 * * * 0.00; 107 | 30-39 17 * * * 0.00; 108 | 40-49 17 * * * 0.00; 109 | 50-59 17 * * * 0.00; 110 | 0-9 18 * * * 0.00; 111 | 10-19 18 * * * 0.16; 112 | 20-29 18 * * * 0.00; 113 | 30-39 18 * * * 0.00; 114 | 40-49 18 * * * 0.00; 115 | 50-59 18 * * * 0.00; 116 | 0-9 19 * * * 0.00; 117 | 10-19 19 * * * 0.00; 118 | 20-29 19 * * * 0.00; 119 | 30-39 19 * * * 0.00; 120 | 40-49 19 * * * 0.00; 121 | 50-59 19 * * * 0.00; 122 | 0-9 20 * * * 0.00; 123 | 10-19 20 * * * 0.00; 124 | 20-29 20 * * * 0.00; 125 | 30-39 20 * * * 0.00; 126 | 40-49 20 * * * 0.00; 127 | 50-59 20 * * * 0.00; 128 | 0-9 21 * * * 0.00; 129 | 10-19 21 * * * 0.00; 130 | 20-29 21 * * * 0.00; 131 | 30-39 21 * * * 0.00; 132 | 40-49 21 * * * 0.00; 133 | 50-59 21 * * * 0.00; 134 | 0-9 22 * * * 0.00; 135 | 10-19 22 * * * 0.00; 136 | 20-29 22 * * * 0.00; 137 | 30-39 22 * * * 0.00; 138 | 40-49 22 * * * 0.00; 139 | 50-59 22 * * * 0.00; 140 | 0-9 23 * * * 0.00; 141 | 10-19 23 * * * 0.00; 142 | 20-29 23 * * * 0.00; 143 | 30-39 23 * * * 0.00; 144 | 40-49 23 * * * 0.00; 145 | 50-59 23 * * * 0.00; 146 | } 147 | -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/ attack_schedule.glm: -------------------------------------------------------------------------------- 1 | schedule schedule_1 { 2 | 0-9 0 * * * 0.00; 3 | 10-19 0 * * * 0.00; 4 | 20-29 0 * * * 0.00; 5 | 30-39 0 * * * 0.00; 6 | 40-49 0 * * * 0.00; 7 | 50-59 0 * * * 0.00; 8 | 0-9 1 * * * 0.00; 9 | 10-19 1 * * * 0.00; 10 | 20-29 1 * * * 0.00; 11 | 30-39 1 * * * 0.00; 12 | 40-49 1 * * * 0.00; 13 | 50-59 1 * * * 0.00; 14 | 0-9 2 * * * 0.00; 15 | 10-19 2 * * * 0.00; 16 | 20-29 2 * * * 0.00; 17 | 30-39 2 * * * 0.39; 18 | 40-49 2 * * * 0.00; 19 | 50-59 2 * * * 0.01; 20 | 0-9 3 * * * 0.00; 21 | 10-19 3 * * * 0.00; 22 | 20-29 3 * * * 0.00; 23 | 30-39 3 * * * 0.00; 24 | 40-49 3 * * * 0.00; 25 | 50-59 3 * * * 0.32; 26 | 0-9 4 * * * 0.00; 27 | 10-19 4 * * * 0.00; 28 | 20-29 4 * * * 0.00; 29 | 30-39 4 * * * 0.13; 30 | 40-49 4 * * * 0.00; 31 | 50-59 4 * * * 0.09; 32 | 0-9 5 * * * 0.23; 33 | 10-19 5 * * * 0.00; 34 | 20-29 5 * * * 0.00; 35 | 30-39 5 * * * 0.00; 36 | 40-49 5 * * * 0.00; 37 | 50-59 5 * * * 0.48; 38 | 0-9 6 * * * 0.88; 39 | 10-19 6 * * * 0.00; 40 | 20-29 6 * * * 0.00; 41 | 30-39 6 * * * 0.00; 42 | 40-49 6 * * * 0.00; 43 | 50-59 6 * * * 0.00; 44 | 0-9 7 * * * 0.00; 45 | 10-19 7 * * * 0.00; 46 | 20-29 7 * * * 0.00; 47 | 30-39 7 * * * 0.00; 48 | 40-49 7 * * * 0.00; 49 | 50-59 7 * * * 0.00; 50 | 0-9 8 * * * 0.00; 51 | 10-19 8 * * * 0.00; 52 | 20-29 8 * * * 0.00; 53 | 30-39 8 * * * 0.61; 54 | 40-49 8 * * * 0.00; 55 | 50-59 8 * * * 0.00; 56 | 0-9 9 * * * 0.00; 57 | 10-19 9 * * * 0.00; 58 | 20-29 9 * * * 0.00; 59 | 30-39 9 * * * 0.00; 60 | 40-49 9 * * * 0.00; 61 | 50-59 9 * * * 0.00; 62 | 0-9 10 * * * 0.00; 63 | 10-19 10 * * * 0.00; 64 | 20-29 10 * * * 0.00; 65 | 30-39 10 * * * 0.00; 66 | 40-49 10 * * * 0.00; 67 | 50-59 10 * * * 0.00; 68 | 0-9 11 * * * 0.00; 69 | 10-19 11 * * * 0.00; 70 | 20-29 11 * * * 0.00; 71 | 30-39 11 * * * 0.00; 72 | 40-49 11 * * * 0.00; 73 | 50-59 11 * * * 0.00; 74 | 0-9 12 * * * 0.00; 75 | 10-19 12 * * * 0.00; 76 | 20-29 12 * * * 0.00; 77 | 30-39 12 * * * 0.00; 78 | 40-49 12 * * * 0.00; 79 | 50-59 12 * * * 0.00; 80 | 0-9 13 * * * 0.00; 81 | 10-19 13 * * * 0.00; 82 | 20-29 13 * * * 0.00; 83 | 30-39 13 * * * 0.00; 84 | 40-49 13 * * * 0.00; 85 | 50-59 13 * * * 0.41; 86 | 0-9 14 * * * 0.00; 87 | 10-19 14 * * * 0.12; 88 | 20-29 14 * * * 0.00; 89 | 30-39 14 * * * 0.92; 90 | 40-49 14 * * * 0.30; 91 | 50-59 14 * * * 0.00; 92 | 0-9 15 * * * 0.78; 93 | 10-19 15 * * * 0.00; 94 | 20-29 15 * * * 0.00; 95 | 30-39 15 * * * 0.00; 96 | 40-49 15 * * * 0.00; 97 | 50-59 15 * * * 0.00; 98 | 0-9 16 * * * 0.00; 99 | 10-19 16 * * * 0.00; 100 | 20-29 16 * * * 0.00; 101 | 30-39 16 * * * 0.00; 102 | 40-49 16 * * * 0.00; 103 | 50-59 16 * * * 0.25; 104 | 0-9 17 * * * 0.00; 105 | 10-19 17 * * * 0.00; 106 | 20-29 17 * * * 0.00; 107 | 30-39 17 * * * 0.00; 108 | 40-49 17 * * * 0.00; 109 | 50-59 17 * * * 0.00; 110 | 0-9 18 * * * 0.00; 111 | 10-19 18 * * * 0.16; 112 | 20-29 18 * * * 0.00; 113 | 30-39 18 * * * 0.00; 114 | 40-49 18 * * * 0.00; 115 | 50-59 18 * * * 0.00; 116 | 0-9 19 * * * 0.00; 117 | 10-19 19 * * * 0.00; 118 | 20-29 19 * * * 0.00; 119 | 30-39 19 * * * 0.00; 120 | 40-49 19 * * * 0.00; 121 | 50-59 19 * * * 0.00; 122 | 0-9 20 * * * 0.00; 123 | 10-19 20 * * * 0.00; 124 | 20-29 20 * * * 0.00; 125 | 30-39 20 * * * 0.00; 126 | 40-49 20 * * * 0.00; 127 | 50-59 20 * * * 0.00; 128 | 0-9 21 * * * 0.00; 129 | 10-19 21 * * * 0.00; 130 | 20-29 21 * * * 0.00; 131 | 30-39 21 * * * 0.00; 132 | 40-49 21 * * * 0.00; 133 | 50-59 21 * * * 0.00; 134 | 0-9 22 * * * 0.00; 135 | 10-19 22 * * * 0.00; 136 | 20-29 22 * * * 0.00; 137 | 30-39 22 * * * 0.00; 138 | 40-49 22 * * * 0.00; 139 | 50-59 22 * * * 0.00; 140 | 0-9 23 * * * 0.00; 141 | 10-19 23 * * * 0.00; 142 | 20-29 23 * * * 0.00; 143 | 30-39 23 * * * 0.00; 144 | 40-49 23 * * * 0.00; 145 | 50-59 23 * * * 0.00; 146 | } 147 | -------------------------------------------------------------------------------- /Database/4_Nodes_492_Houses/ attack_schedule.glm: -------------------------------------------------------------------------------- 1 | schedule schedule_1 { 2 | 0-9 0 * * * 0.00; 3 | 10-19 0 * * * 0.00; 4 | 20-29 0 * * * 0.00; 5 | 30-39 0 * * * 0.00; 6 | 40-49 0 * * * 0.00; 7 | 50-59 0 * * * 0.00; 8 | 0-9 1 * * * 0.00; 9 | 10-19 1 * * * 0.00; 10 | 20-29 1 * * * 0.00; 11 | 30-39 1 * * * 0.00; 12 | 40-49 1 * * * 0.00; 13 | 50-59 1 * * * 0.00; 14 | 0-9 2 * * * 0.00; 15 | 10-19 2 * * * 0.00; 16 | 20-29 2 * * * 0.00; 17 | 30-39 2 * * * 0.39; 18 | 40-49 2 * * * 0.00; 19 | 50-59 2 * * * 0.01; 20 | 0-9 3 * * * 0.00; 21 | 10-19 3 * * * 0.00; 22 | 20-29 3 * * * 0.00; 23 | 30-39 3 * * * 0.00; 24 | 40-49 3 * * * 0.00; 25 | 50-59 3 * * * 0.32; 26 | 0-9 4 * * * 0.00; 27 | 10-19 4 * * * 0.00; 28 | 20-29 4 * * * 0.00; 29 | 30-39 4 * * * 0.13; 30 | 40-49 4 * * * 0.00; 31 | 50-59 4 * * * 0.09; 32 | 0-9 5 * * * 0.23; 33 | 10-19 5 * * * 0.00; 34 | 20-29 5 * * * 0.00; 35 | 30-39 5 * * * 0.00; 36 | 40-49 5 * * * 0.00; 37 | 50-59 5 * * * 0.48; 38 | 0-9 6 * * * 0.88; 39 | 10-19 6 * * * 0.00; 40 | 20-29 6 * * * 0.00; 41 | 30-39 6 * * * 0.00; 42 | 40-49 6 * * * 0.00; 43 | 50-59 6 * * * 0.00; 44 | 0-9 7 * * * 0.00; 45 | 10-19 7 * * * 0.00; 46 | 20-29 7 * * * 0.00; 47 | 30-39 7 * * * 0.00; 48 | 40-49 7 * * * 0.00; 49 | 50-59 7 * * * 0.00; 50 | 0-9 8 * * * 0.00; 51 | 10-19 8 * * * 0.00; 52 | 20-29 8 * * * 0.00; 53 | 30-39 8 * * * 0.61; 54 | 40-49 8 * * * 0.00; 55 | 50-59 8 * * * 0.00; 56 | 0-9 9 * * * 0.00; 57 | 10-19 9 * * * 0.00; 58 | 20-29 9 * * * 0.00; 59 | 30-39 9 * * * 0.00; 60 | 40-49 9 * * * 0.00; 61 | 50-59 9 * * * 0.00; 62 | 0-9 10 * * * 0.00; 63 | 10-19 10 * * * 0.00; 64 | 20-29 10 * * * 0.00; 65 | 30-39 10 * * * 0.00; 66 | 40-49 10 * * * 0.00; 67 | 50-59 10 * * * 0.00; 68 | 0-9 11 * * * 0.00; 69 | 10-19 11 * * * 0.00; 70 | 20-29 11 * * * 0.00; 71 | 30-39 11 * * * 0.00; 72 | 40-49 11 * * * 0.00; 73 | 50-59 11 * * * 0.00; 74 | 0-9 12 * * * 0.00; 75 | 10-19 12 * * * 0.00; 76 | 20-29 12 * * * 0.00; 77 | 30-39 12 * * * 0.00; 78 | 40-49 12 * * * 0.00; 79 | 50-59 12 * * * 0.00; 80 | 0-9 13 * * * 0.00; 81 | 10-19 13 * * * 0.00; 82 | 20-29 13 * * * 0.00; 83 | 30-39 13 * * * 0.00; 84 | 40-49 13 * * * 0.00; 85 | 50-59 13 * * * 0.41; 86 | 0-9 14 * * * 0.00; 87 | 10-19 14 * * * 0.12; 88 | 20-29 14 * * * 0.00; 89 | 30-39 14 * * * 0.92; 90 | 40-49 14 * * * 0.30; 91 | 50-59 14 * * * 0.00; 92 | 0-9 15 * * * 0.78; 93 | 10-19 15 * * * 0.00; 94 | 20-29 15 * * * 0.00; 95 | 30-39 15 * * * 0.00; 96 | 40-49 15 * * * 0.00; 97 | 50-59 15 * * * 0.00; 98 | 0-9 16 * * * 0.00; 99 | 10-19 16 * * * 0.00; 100 | 20-29 16 * * * 0.00; 101 | 30-39 16 * * * 0.00; 102 | 40-49 16 * * * 0.00; 103 | 50-59 16 * * * 0.25; 104 | 0-9 17 * * * 0.00; 105 | 10-19 17 * * * 0.00; 106 | 20-29 17 * * * 0.00; 107 | 30-39 17 * * * 0.00; 108 | 40-49 17 * * * 0.00; 109 | 50-59 17 * * * 0.00; 110 | 0-9 18 * * * 0.00; 111 | 10-19 18 * * * 0.16; 112 | 20-29 18 * * * 0.00; 113 | 30-39 18 * * * 0.00; 114 | 40-49 18 * * * 0.00; 115 | 50-59 18 * * * 0.00; 116 | 0-9 19 * * * 0.00; 117 | 10-19 19 * * * 0.00; 118 | 20-29 19 * * * 0.00; 119 | 30-39 19 * * * 0.00; 120 | 40-49 19 * * * 0.00; 121 | 50-59 19 * * * 0.00; 122 | 0-9 20 * * * 0.00; 123 | 10-19 20 * * * 0.00; 124 | 20-29 20 * * * 0.00; 125 | 30-39 20 * * * 0.00; 126 | 40-49 20 * * * 0.00; 127 | 50-59 20 * * * 0.00; 128 | 0-9 21 * * * 0.00; 129 | 10-19 21 * * * 0.00; 130 | 20-29 21 * * * 0.00; 131 | 30-39 21 * * * 0.00; 132 | 40-49 21 * * * 0.00; 133 | 50-59 21 * * * 0.00; 134 | 0-9 22 * * * 0.00; 135 | 10-19 22 * * * 0.00; 136 | 20-29 22 * * * 0.00; 137 | 30-39 22 * * * 0.00; 138 | 40-49 22 * * * 0.00; 139 | 50-59 22 * * * 0.00; 140 | 0-9 23 * * * 0.00; 141 | 10-19 23 * * * 0.00; 142 | 20-29 23 * * * 0.00; 143 | 30-39 23 * * * 0.00; 144 | 40-49 23 * * * 0.00; 145 | 50-59 23 * * * 0.00; 146 | } 147 | -------------------------------------------------------------------------------- /attack_broker.py: -------------------------------------------------------------------------------- 1 | import json 2 | import shutil 3 | import os 4 | import sys 5 | import fileinput 6 | import matplotlib 7 | import matplotlib.pyplot as plt 8 | import numpy as np 9 | import pandas as pd 10 | import subprocess 11 | import sys 12 | from subprocess import check_output 13 | import time 14 | 15 | 16 | filter = "JSON file (*.json)|*.json|All Files (*.*)|*.*||" 17 | with open('attack_library.json', 'r') as f: 18 | distros_dict = json.load(f) 19 | 20 | path = "Database/" 21 | 22 | 23 | def print_function(): 24 | print("------------------------------------------") 25 | print("Welcome to Smart Grid Simulation System!") 26 | print("------------------------------------------") 27 | print("Please select Attack ID from: ") 28 | for x in range(len(distros_dict['object'])): 29 | print("------------------------------------------") 30 | print('Attack ID: ' + str(distros_dict['object'][x]["attack_id"])) 31 | print('Category Name: ' + str(distros_dict['object'][x]["category_name"])) 32 | 33 | print('Attack Type: ' + str(distros_dict['object'][x]["name"])) 34 | 35 | print("------------------------------------------") 36 | 37 | 38 | 39 | def readfile(index): 40 | for x in range(len(distros_dict['object'])): 41 | if distros_dict['object'][x]["attack_id"]==str(index): 42 | print("\n \n------------------------------------------") 43 | print("You selected Attack ID: " + str(distros_dict['object'][x]["attack_id"])) 44 | print('- Category Name: ' + str(distros_dict['object'][x]["category_name"])) 45 | print('- Attack Type: ' + str(distros_dict['object'][x]["name"])) 46 | print('- Description: ' + str(distros_dict['object'][x]["attack_type"][0]["description"])) 47 | print('- Attack Component: ' + str(distros_dict['object'][x]["attack_component"][0]["component_name"])) 48 | print('- Start Time: ' + str(distros_dict['object'][x]["attack_schedule"][0]["start_time"])) 49 | print('- End Time: ' + str(distros_dict['object'][x]["attack_schedule"][0]["end_time"])) 50 | 51 | filepath = str(distros_dict['object'][x]["attack_component"][0]["file"]) 52 | file_out = str("run_" + filepath) 53 | affected_value = distros_dict['object'][x]["attack_type"][0]["affected_value"][0] 54 | print('- Affected Value: ') 55 | for key, value in affected_value.items(): 56 | print('\t- ' + str(key) + " = " + str(value)) 57 | config(filepath, file_out, key, value) 58 | 59 | 60 | def config(filepath, file_out, key, value): 61 | f = open(file_out,'r') 62 | filedata = f.read() 63 | f.close() 64 | if filepath == "ns-3.cc": 65 | newdata = filedata.replace("//Flag", "//Flag"+ "\n \t" + key + " = " + str(value) + ";//") 66 | else: 67 | newdata = filedata.replace(key,key + " " + str(value) + ";//") 68 | f = open(file_out,'w') 69 | f.write(newdata) 70 | f.close() 71 | 72 | 73 | 74 | #Check Process is running or not 75 | def is_running(pid): 76 | try: 77 | os.kill(pid, 0) 78 | except OSError: 79 | return False 80 | 81 | return True 82 | 83 | def main(): 84 | os.system('clear') 85 | os.chdir(sys.argv[1]) 86 | os.remove("run_ns-3.cc") 87 | os.remove("run_GridLab-D.glm") 88 | time.sleep(1) 89 | shutil.copyfile("ns-3.cc", "run_ns-3.cc") 90 | shutil.copyfile("GridLab-D.glm", "run_GridLab-D.glm") 91 | print_function() 92 | 93 | readfile(sys.argv[2]) 94 | 95 | 96 | p1 = subprocess.Popen('./compile-ns3.sh run_ns-3.cc', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, executable='/bin/bash') 97 | 98 | p1.wait() 99 | time.sleep(2) 100 | p2 = subprocess.Popen('./run.sh', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, executable='/bin/bash') 101 | time.sleep(2) 102 | child = subprocess.Popen('pgrep xterm', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, executable='/bin/bash') 103 | pid = int(child.communicate()[0].split('\n')[0]) 104 | print("The Simulation is running!") 105 | print("Process PID: "+str(pid)) 106 | while is_running(pid): 107 | time.sleep(1) 108 | print("Finished!") 109 | 110 | 111 | if __name__ == '__main__': 112 | main() 113 | -------------------------------------------------------------------------------- /plot_result.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | from tkinter.ttk import * 3 | from tkinter import ttk 4 | from pandas import DataFrame 5 | import matplotlib.pyplot as plt 6 | from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg 7 | import os 8 | import sys 9 | import matplotlib 10 | import numpy as np 11 | import pandas as pd 12 | from matplotlib import interactive 13 | import matplotlib.ticker as plticker 14 | 15 | 16 | os.chdir(sys.argv[1]) 17 | print("Plot Result") 18 | print(sys.argv[2].split(':')) #Price 19 | print(sys.argv[3].split(':')) #Total Load 20 | print(len(sys.argv[2].split(':'))) 21 | print(len(sys.argv[3].split(':'))) 22 | 23 | root_name = sys.argv[1].replace("/", " ").replace("_", " ")[8:] + " Simulation Result" 24 | 25 | root= tk.Tk() 26 | root.title(root_name) 27 | 28 | lbl = Label(root, text=root_name, font=("Times", 18), foreground="#000280") 29 | lbl.pack() 30 | 31 | def plot_price(file_list): 32 | 33 | figure1 = plt.Figure(figsize=(6,5), dpi=100) 34 | ax1 = figure1.add_subplot(111) 35 | bar1 = FigureCanvasTkAgg(figure1, root) 36 | bar1.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand=True) 37 | legend_list = [] 38 | 39 | 40 | figure2 = plt.Figure(figsize=(6,5), dpi=100) 41 | ax2 = figure2.add_subplot(111) 42 | bar2 = FigureCanvasTkAgg(figure2, root) 43 | bar2.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand=True) 44 | 45 | 46 | 47 | 48 | 49 | 50 | for i in range(1, len(file_list)-1): 51 | data_loading= pd.read_csv(str(file_list[i]), delimiter=',', skiprows=9,names=["timestamp","capacity_reference_bid_price","current_market.clearing_price","current_market.clearing_quantity"]) 52 | data_loading.head(5) 53 | #print(data_loading) 54 | if i == 1: 55 | my_xticks = data_loading["timestamp"] 56 | with open(str(file_list[i])) as f: 57 | row_count = sum(1 for line in f) - 9 58 | y_1 = [] 59 | for k in range(0, row_count): 60 | y_1.append(my_xticks.values[k][11:19]) 61 | ax1.plot(y_1, 'current_market.clearing_price', data=data_loading, linewidth = 4) 62 | ax2.plot(y_1, 'current_market.clearing_quantity', data=data_loading, linewidth = 4) 63 | legend_list.append(str(file_list[i]).replace('.csv','')) 64 | 65 | 66 | 67 | 68 | ax1.set_title('Clearing Price') 69 | 70 | plt.setp(ax1.get_xticklabels(), rotation=45, horizontalalignment='right') 71 | ax1.xaxis.set_major_locator(loc) 72 | ax1.set_xlabel('Time') 73 | ax1.set_ylabel('Price $') 74 | 75 | 76 | 77 | 78 | ax2.set_title('Clearing Quantity') 79 | 80 | plt.setp(ax2.get_xticklabels(), rotation=45, horizontalalignment='right') 81 | ax2.xaxis.set_major_locator(loc) 82 | ax2.set_xlabel('Time') 83 | ax2.set_ylabel('Price $') 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | def plot_total_load(file_list): 94 | 95 | figure2 = plt.Figure(figsize=(6,5), dpi=100) 96 | ax2 = figure2.add_subplot(111) 97 | line2 = FigureCanvasTkAgg(figure2, root) 98 | line2.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand=True) 99 | 100 | legend_list = [] 101 | 102 | for i in range(1, len(file_list)-1): 103 | data_loading= pd.read_csv(str(file_list[i]), delimiter=',', skiprows=9,names=["timestamp","power_out_real"]) 104 | data_loading.head(5) 105 | 106 | if i == 1: 107 | my_xticks = data_loading["timestamp"] 108 | with open(str(file_list[i])) as f: 109 | row_count = sum(1 for line in f) - 9 110 | y_1 = [] 111 | for k in range(0, row_count): 112 | y_1.append(my_xticks.values[k][11:19]) 113 | ax2.plot(y_1, 'power_out_real', data=data_loading, linewidth = 4) 114 | legend_list.append(str(file_list[i]).replace('.csv','')) 115 | 116 | 117 | ax2.set_title('Total Load') 118 | 119 | plt.setp(ax2.get_xticklabels(), rotation=45, horizontalalignment='right') 120 | ax2.xaxis.set_major_locator(loc) 121 | ax2.set_xlabel('Time') 122 | ax2.set_ylabel('kWh') 123 | 124 | 125 | loc = plticker.MultipleLocator(base=100) # this locator puts ticks at regular intervals 126 | if(len(sys.argv[2].split(':'))>2): 127 | plot_price(sys.argv[2].split(':')) 128 | if(len(sys.argv[3].split(':'))>2): 129 | plot_total_load(sys.argv[3].split(':')) 130 | 131 | root.mainloop() -------------------------------------------------------------------------------- /installation_guide.md: -------------------------------------------------------------------------------- 1 | 2 | # Installation Guide 3 | 4 | GridAttackSim was developed and tested exclusively using the Ubuntu 5 | 16.04 LTS operating system; either a physical host or a virtual 6 | machine installation can be used. Other Linux OSes may work, but have 7 | not been tested, nor has this software been tested on Windows. 8 | 9 | To run GridAttackSim, you have to first install and configure the 10 | three external components it uses: FNCS, ns-3, and GridLAB-D. To do 11 | this, please follow the official [FNCS 12 | tutorial](https://github.com/FNCS/FNCS-Tutorial/tree/master/demo-gld-ns3). In 13 | case you encounter any difficulties, see the notes below about the 14 | installation process. 15 | 16 | 17 | ## Set up environment variables 18 | 19 | In order to configure FNCS, you _must_ set up the related environment 20 | variables, for example by adding the code shown next to the file 21 | `~/.bashrc`: 22 | 23 | ```shell 24 | export FNCS_INSTALL="$HOME/FNCS-install" 25 | # update LD_LIBRARY_PATH 26 | if test "x$LD_LIBRARY_PATH" = x 27 | then 28 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib:$FNCS_INSTALL/lib/gridlabd" 29 | else 30 | export LD_LIBRARY_PATH="$FNCS_INSTALL/lib:$FNCS_INSTALL/lib/gridlabd:$LD_LIBRARY_PATH" 31 | fi 32 | # update PATH 33 | if test "x$PATH" = x 34 | then 35 | export PATH="$FNCS_INSTALL/bin:$FNCS_INSTALL/share/gridlabd" 36 | else 37 | export PATH="$FNCS_INSTALL/bin:$FNCS_INSTALL/share/gridlabd:$PATH" 38 | fi 39 | export GLPATH="$FNCS_INSTALL/share/gridlabd:$FNCS_INSTALL/lib/gridlabd" 40 | ``` 41 | 42 | 43 | ## Install required packages and dependencies 44 | 45 | ```shell 46 | sudo apt install automake libtool autoconf libczmq-dev libxerces-c-dev 47 | ``` 48 | 49 | 50 | ## Download, build and install FCNS 51 | 52 | ```shell 53 | # change to the $HOME directory 54 | cd $HOME 55 | # download FNCS 56 | git clone https://github.com/FNCS/fncs 57 | # change to FNCS directory 58 | cd FNCS 59 | # configure, make, and make install 60 | ./configure --prefix=$FNCS_INSTALL --with-zmq=$FNCS_INSTALL 61 | make 62 | make install 63 | ``` 64 | 65 | 66 | ## Download, build and install ns-3 67 | 68 | ```shell 69 | # change to the $HOME directory 70 | cd $HOME 71 | # download our FNCS version of ns-3 72 | git clone https://github.com/FNCS/ns-3.26 73 | # change to ns-3.26 directory 74 | cd ns-3.26 75 | # the ns-3 install typically uses the compiler flag for 76 | # warnings-as-errors which often broke our ability to build and install 77 | # it, so we recommend the following configure of ns-3 78 | CFLAGS="-g -O2" CXXFLAGS="-g -O2" ./waf configure --prefix=$FNCS_INSTALL --with-fncs=$FNCS_INSTALL --with-zmq=$FNCS_INSTALL --disable-python 79 | # 'make' 80 | ./waf build 81 | # install 82 | ./waf install 83 | ``` 84 | 85 | 86 | ## Download, build and install GridLAB-D 87 | 88 | ```shell 89 | # change to the $HOME directory 90 | cd $HOME 91 | # download our FNCS-capable version of GridLAB-D 92 | git clone https://github.com/gridlab-d/gridlab-d 93 | # change to the FNCS-gridlab-d directory 94 | cd gridlab-d 95 | # checkout the develop branch 96 | git checkout -b develop origin/develop 97 | # generate the configure script and Makefile.in templates 98 | # minimum required versions: 99 | # autoconf 2.63 100 | # automake 1.11 101 | # libtool 2.2.6b 102 | autoreconf -fi 103 | # configure, make, and make install 104 | ./configure --prefix=$FNCS_INSTALL --with-xerces=$FNCS_INSTALL --with- fncs=$FNCS_INSTALL --enable-silent-rules 'CFLAGS=-g -O0 -w' 'CXXFLAGS=-g -O0 -w' 'LDFLAGS=-g -O0 -w' 105 | make 106 | make install 107 | ``` 108 | 109 | **NOTE**: At this stage we suggest you restart the operating system to 110 | make sure that all the changes are taken into account. 111 | 112 | 113 | ## Fix issue with GridLAB-D 114 | 115 | We have encountered an issue when compiling GridLAB-D. To solve it you 116 | need to edit the file `climate/climate.cpp` in the GridLAB-D 117 | distribution, and change the math library as shown below: 118 | 119 | _ORIGINAL CODE:_ 120 | ``` 121 | #include 122 | ``` 123 | 124 | _NEW CODE:_ 125 | ``` 126 | #include 127 | ``` 128 | 129 | 130 | ## Run co-simulation experiment 131 | 132 | In order to run a co-simulation using FNCS, you can use the `run.sh` 133 | file included in the [source 134 | code](https://github.com/FNCS/FNCS-Tutorial/tree/master/demo-gld-ns3) 135 | of the FNCS tutorial. 136 | 137 | 138 | ## Reset installation 139 | 140 | If you encounter an error while installing any of the above tools, you 141 | can use the following command to reset the installation, then try again: 142 | 143 | ``` 144 | Make 145 | ``` 146 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # GridAttackSim: Smart Grid Attack Simulation Framework 3 | 4 | GridAttackSim is a framework that makes it possible to simulate 5 | various cyber-attacks on the smart grid infrastructure and visualize 6 | their consequences. GridAttackSim uses a co-simulation approach, and 7 | it is based on a combination of [GridLAB-D](https://www.gridlabd.org), 8 | [ns-3](https://www.nsnam.org), and 9 | [FNCS](https://github.com/FNCS). The framework is extensible by end 10 | users, and the current release includes five smart grid topologies, 11 | two smart grid applications (demand response and dynamic pricing), and 12 | an attack library with four types of attacks (channel jamming, 13 | malicious code, injection attacks, and message replay). GridAttackSim 14 | is being developed by the Cyber Range Organization and Design 15 | ([CROND](https://www.jaist.ac.jp/misc/crond/index-en.html)) 16 | NEC-endowed chair at the Japan Advanced Institute of Science and 17 | Technology ([JAIST](https://www.jaist.ac.jp/english/)) in Ishikawa, 18 | Japan. 19 | 20 | GridAttackSim is intended as a tool that helps researchers investigate 21 | smart grid security issues and develop technologies for improving 22 | smart grid security. An overview of how GridAttackSim can be used to 23 | visualize the consequences of a smart grid cyber-attack is shown 24 | below. 25 | 26 | ![GridAttackSim Use](Figures/use_overview.png?raw=true "Overview of the GridAttackSim use") 27 | 28 | The architecture of GridAttackSim comprises six main modules, as 29 | illustrated below: 30 | * **Preprocessing Module**: Prepare the files needed to run the 31 | GridLAB-D simulation and to configure the FNCS broker 32 | * **Attack Pattern Library**: Store information about the attack type, 33 | target and schedule that will be used for the cyber-attack 34 | simulation 35 | * **Model Manager**: Core component of GridAttackSim that coordinates 36 | the entire smart grid attack simulation framework 37 | * **Ns-3**: Discrete-event network simulator 38 | * **GridLAB-D**: Power distribution system simulation and analysis tool 39 | * **FNCS Broker**: Component of the FNCS co-simulation framework that 40 | mediates the communication between ns-3 and GridLAB-D 41 | 42 | ![GridAttackSim Architecture](Figures/framework_architecture.png?raw=true "Architecture of the GridAttackSim framework") 43 | 44 | GridAttackSim can be extended, and end users can add new smart grid 45 | topologies or new types of attacks. Please consult the [Developer 46 | Guide](/developer_guide.md) for more information on how to extend the 47 | framework. 48 | 49 | 50 | ## Installation 51 | 52 | GridAttackSim was developed and tested exclusively using the Ubuntu 53 | 16.04 LTS operating system; either a physical host or a virtual 54 | machine installation can be used. Other Linux OSes may work, but have 55 | not been tested, nor has this software been tested on Windows. 56 | 57 | To run GridAttackSim, you have to first install and configure the 58 | three external components, FNCS, ns-3, and GridLAB-D. For details, 59 | please consult our [Installation Guide](/installation_guide.md). 60 | 61 | Once the external components are installed, use the 62 | [releases](https://github.com/crond-jaist/GridAttackSim/releases) page 63 | to download the latest version of GridAttackSim, and extract the 64 | source code archive into a directory of your choice. 65 | 66 | 67 | ## Quick Start 68 | 69 | 1. Use a terminal window to navigate to the GridAttackSim directory 70 | 71 | 2. Start the GridAttackSim GUI 72 | 73 | ```$ python3 GridAttackSim.py``` 74 | 75 | ![GridAttackSim GUI](Figures/gui_screenshot.png?raw=true "GridAttackSim GUI") 76 | 77 | 3. Once the GUI is displayed, as shown above, follow the next steps to 78 | configure and run a simulation: 79 | 1. Select the simulation parameters: Smart Grid Model, Application, 80 | Attack Category, Attack Type 81 | 2. Click on the "Run Simulation" button to start the simulation 82 | 3. When the simulation process finishes, click on "Load Results" to 83 | display the output files 84 | 4. Select the output files of interest, then click on "Show Charts" to 85 | visualize the results 86 | 87 | 88 | ## References 89 | 90 | For a research background regarding GridAttackSim, please refer to the 91 | following papers: 92 | 1. T. D. Le, A. Anwar, S. W. Loke, R. Beuran, Y. Tan, "GridAttackSim: 93 | Cyber Attack Simulation Framework for Smart Grids", MDPI 94 | Electronics, Special Issue on Applications of IoT for Microgrids, 95 | vol. 9, no. 8, August 96 | 2020, 1218. [https://doi.org/10.3390/electronics9081218] 97 | 2. T. D. Le, A. Anwar, R. Beuran, S. W. Loke, "Smart Grid 98 | Co-Simulation Tools: Review and Cybersecurity Case Study", 7th 99 | International Conference on Smart Grid (icSmartGrid 2019), 100 | Newcastle, Australia, December 9-11, 2019, 101 | pp. 39-45. [https://ieeexplore.ieee.org/abstract/document/8990712] 102 | 103 | For a list of contributors to this project, check the file 104 | CONTRIBUTORS included with the source code. 105 | -------------------------------------------------------------------------------- /glmMap.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | #Pre-requisites software required to run this script: 4 | #Python 2.7: Modules:: sys, re, os 5 | #Graphviz 6 | ##If you just installed Graphviz, "restart" your computer for Graphviz commandline execution to work 7 | 8 | #Purpose of this script and How can a modeler use it: 9 | #Convert a GridLAB-D file (.glm) to a Graphviz file (.dot) 10 | #Use that .dot to generate .svg 11 | #Use any web browser to open the .svg file - SIMPLE 12 | 13 | #Usage: 14 | #python glmMap.py inputfile.glm outputfile.dot 15 | 16 | #Licensing: Copyright 2016; licensing falls under GridLAB-D 17 | #Email Contact: sri at pnnl dot gov 18 | #Devloped at: Pacific Northwest National Laboratory 19 | #Acknowledgements: This tool is developed using a base script provided by Philip Douglass, Technical University of Denmark in 2013 20 | 21 | #Version and Patch Notes: 22 | ##05/20/2016: Added :: line spacing; object names; object color coding 23 | ##06/02/2016: Bug Fix :: If the node names has ':' in it, grapgviz errors out. replaced ':' with '_' as well 24 | 25 | import sys; 26 | import re; 27 | import os 28 | 29 | infile = open(sys.argv[1], 'r') 30 | outfile = open(sys.argv[2], 'w') 31 | 32 | lines = infile.readlines() 33 | 34 | # .dot files begin with the 'graph' keyword. 35 | outfile.write("digraph {\n") 36 | outfile.write("node [shape=box]\n") 37 | # These are state variables. There is no error checking, so we rely on 38 | # well formatted *.GLM files. 39 | s =0 40 | state = 'start' 41 | edge_color = 'black' 42 | edge_style = 'solid' 43 | lengthVal = 'None' 44 | lineLengthIncrement = 0 45 | 46 | # Loop through each line in the input file... 47 | while s < len(lines): 48 | # Discard Comments 49 | if re.match("//", lines[s]) == None: 50 | if re.search("from", lines[s])!=None: 51 | ts = lines[s].split() 52 | #Graphvis format can't handle '-' characters, so they are converted to '_' 53 | ns = ts[1].rstrip(';').replace('-','_').replace(':','_') 54 | outfile.write(ns) 55 | state = 'after_from' 56 | elif state == 'after_from' and re.search("to ", lines[s])!=None: 57 | ts = lines[s].split() 58 | ns = ts[1].rstrip(';').replace('-','_').replace(':','_') 59 | if edge_color == 'red': 60 | outfile.write(' -> ' + ns + '[style=' + edge_style + ' color='+ edge_color + ' label="'+lengthVal+'"]\n') 61 | outfile.write("node [shape=box]\n") 62 | else: 63 | outfile.write(' -> ' + ns + '[style=' + edge_style + ' color='+ edge_color + ' label="'+lengthVal+'"]\n') 64 | lengthVal = 'None' 65 | # After an edge is added to the graph, reset the states back to default 66 | state = 'start' 67 | edge_color = 'black' 68 | edge_style = 'solid' 69 | elif (re.search("object underground_line", lines[s]) != None) or (re.search("object overhead_line", lines[s]) != None): 70 | while '}' not in lines[s+lineLengthIncrement]: 71 | if re.search("length ", lines[s+lineLengthIncrement]) != None: 72 | les = lines[s+lineLengthIncrement].split() 73 | if len(les) > 2: 74 | tsVal = les[1]+' '+les[2].strip(';') 75 | lengthVal = tsVal 76 | elif len(les)<=2: 77 | tsVal = les[1].strip(';') 78 | lengthVal = tsVal 79 | break 80 | else: 81 | lineLengthIncrement = lineLengthIncrement+1 82 | if '}' in lines[s+lineLengthIncrement]: 83 | lineLengthIncrement = 0 84 | lengthVal = 'None' 85 | break 86 | if re.search("object underground_line", lines[s]) != None: 87 | lengthVal = "UG_line\\n"+lengthVal 88 | elif re.search("object overhead_line", lines[s]) != None: 89 | lengthVal = "OH_line\\n"+lengthVal 90 | elif re.search("object transformer", lines[s]) != None: 91 | edge_color='red' 92 | lengthVal = "transformer\\n"+lengthVal 93 | outfile.write("node [shape=oval]\n") 94 | elif re.search("object triplex_line", lines[s]) != None: 95 | edge_color='green' 96 | lengthVal = "triplex_line\\n"+lengthVal 97 | elif re.search("object fuse", lines[s]) != None: 98 | edge_color='blue' 99 | lengthVal = "Fuse\\n"+lengthVal 100 | elif re.search("phases ", lines[s]) != None: 101 | ts = lines[s].split() 102 | if len(ts[1].rstrip(';')) > 3: 103 | edge_style = 'bold' 104 | elif len(ts[1].rstrip(';')) > 2: 105 | edge_style = 'dashed' 106 | 107 | s+=1 108 | 109 | 110 | outfile.write("}\n") 111 | infile.close() 112 | outfile.close() 113 | os.system("dot -Tsvg -O "+sys.argv[2]) 114 | 115 | -------------------------------------------------------------------------------- /Database/4_Nodes_492_Houses/Test_Feeder_Line_Configurations.glm: -------------------------------------------------------------------------------- 1 | //Configuration file for 4-node system with houses 2 | 3 | object overhead_line_conductor { 4 | name olc100; 5 | geometric_mean_radius 0.0244; 6 | resistance 0.306; 7 | } 8 | 9 | object overhead_line_conductor { 10 | name olc101; 11 | geometric_mean_radius 0.00814; 12 | resistance 0.592; 13 | } 14 | 15 | object line_spacing { 16 | name ls200; 17 | distance_AB 2.5; 18 | distance_BC 4.5; 19 | distance_AC 7.0; 20 | distance_AN 5.656854; 21 | distance_BN 4.272002; 22 | distance_CN 5.0; 23 | } 24 | 25 | object line_configuration { 26 | name lc300; 27 | conductor_A olc100; 28 | conductor_B olc100; 29 | conductor_C olc100; 30 | conductor_N olc101; 31 | spacing ls200; 32 | } 33 | 34 | object transformer_configuration { 35 | name tc400; 36 | connect_type WYE_WYE; 37 | power_rating 6000; 38 | powerA_rating 2000; 39 | powerB_rating 2000; 40 | powerC_rating 2000; 41 | primary_voltage 7200; 42 | secondary_voltage 2400; 43 | resistance 0.01; 44 | reactance 0.06; 45 | } 46 | 47 | object transformer_configuration { 48 | name AS_config; 49 | connect_type SINGLE_PHASE_CENTER_TAPPED; 50 | install_type POLETOP; 51 | powerA_rating 75; 52 | primary_voltage 2401; 53 | secondary_voltage 124.000; 54 | impedance 0.006+0.0136j; 55 | } 56 | 57 | object transformer_configuration { 58 | name BS_config; 59 | connect_type SINGLE_PHASE_CENTER_TAPPED; 60 | install_type POLETOP; 61 | powerB_rating 75; 62 | primary_voltage 2401; 63 | secondary_voltage 124.000; 64 | impedance 0.006+0.0136j; 65 | } 66 | 67 | object transformer_configuration { 68 | name CS_config; 69 | connect_type SINGLE_PHASE_CENTER_TAPPED; 70 | install_type POLETOP; 71 | powerC_rating 75; 72 | primary_voltage 2401; 73 | secondary_voltage 124.000; 74 | impedance 0.006+0.0136j; 75 | } 76 | 77 | object triplex_line_conductor { 78 | name tplex_line_cond; 79 | resistance 0.97; 80 | geometric_mean_radius 0.0111; 81 | } 82 | 83 | object triplex_line_configuration { 84 | name triplex_line_configuration_1; 85 | conductor_1 tplex_line_cond; 86 | conductor_2 tplex_line_cond; 87 | conductor_N tplex_line_cond; 88 | insulation_thickness 0.08; 89 | diameter 0.368; 90 | } 91 | -------------------------------------------------------------------------------- /Database/4_Nodes_492_Houses/appliance_schedules.glm: -------------------------------------------------------------------------------- 1 | schedule responsive_loads { 2 | { 3 | // Winter Weekday 4 | * 0 * 1-3,10-12 1-5 0.5365; 5 | * 1 * 1-3,10-12 1-5 0.4655; 6 | * 2 * 1-3,10-12 1-5 0.4465; 7 | * 3 * 1-3,10-12 1-5 0.4315; 8 | * 4 * 1-3,10-12 1-5 0.4455; 9 | * 5 * 1-3,10-12 1-5 0.5264; 10 | * 6 * 1-3,10-12 1-5 0.7661; 11 | * 7 * 1-3,10-12 1-5 0.9585; 12 | * 8 * 1-3,10-12 1-5 0.9022; 13 | * 9 * 1-3,10-12 1-5 0.8890; 14 | * 10 * 1-3,10-12 1-5 0.8840; 15 | * 11 * 1-3,10-12 1-5 0.8759; 16 | * 12 * 1-3,10-12 1-5 0.8348; 17 | * 13 * 1-3,10-12 1-5 0.7859; 18 | * 14 * 1-3,10-12 1-5 0.7652; 19 | * 15 * 1-3,10-12 1-5 0.8219; 20 | * 16 * 1-3,10-12 1-5 1.0241; 21 | * 17 * 1-3,10-12 1-5 1.3612; 22 | * 18 * 1-3,10-12 1-5 1.4683; 23 | * 19 * 1-3,10-12 1-5 1.4067; 24 | * 20 * 1-3,10-12 1-5 1.3512; 25 | * 21 * 1-3,10-12 1-5 1.2531; 26 | * 22 * 1-3,10-12 1-5 1.0321; 27 | * 23 * 1-3,10-12 1-5 0.7429; 28 | } 29 | { 30 | // Winter Weekend 31 | * 0 * 1-3,10-12 0,6 0.6261; 32 | * 1 * 1-3,10-12 0,6 0.5182; 33 | * 2 * 1-3,10-12 0,6 0.4606; 34 | * 3 * 1-3,10-12 0,6 0.4557; 35 | * 4 * 1-3,10-12 0,6 0.4449; 36 | * 5 * 1-3,10-12 0,6 0.4594; 37 | * 6 * 1-3,10-12 0,6 0.5304; 38 | * 7 * 1-3,10-12 0,6 0.6740; 39 | * 8 * 1-3,10-12 0,6 0.8739; 40 | * 9 * 1-3,10-12 0,6 1.0216; 41 | * 10 * 1-3,10-12 0,6 1.1140; 42 | * 11 * 1-3,10-12 0,6 1.1404; 43 | * 12 * 1-3,10-12 0,6 1.1456; 44 | * 13 * 1-3,10-12 0,6 1.1211; 45 | * 14 * 1-3,10-12 0,6 1.0878; 46 | * 15 * 1-3,10-12 0,6 1.0954; 47 | * 16 * 1-3,10-12 0,6 1.2347; 48 | * 17 * 1-3,10-12 0,6 1.4651; 49 | * 18 * 1-3,10-12 0,6 1.4991; 50 | * 19 * 1-3,10-12 0,6 1.4287; 51 | * 20 * 1-3,10-12 0,6 1.3494; 52 | * 21 * 1-3,10-12 0,6 1.2501; 53 | * 22 * 1-3,10-12 0,6 1.0660; 54 | * 23 * 1-3,10-12 0,6 0.7921; 55 | } 56 | { 57 | // Summer Weekday 58 | * 0 * 4-9 1-5 0.4897; 59 | * 1 * 4-9 1-5 0.4145; 60 | * 2 * 4-9 1-5 0.3829; 61 | * 3 * 4-9 1-5 0.3806; 62 | * 4 * 4-9 1-5 0.3817; 63 | * 5 * 4-9 1-5 0.4340; 64 | * 6 * 4-9 1-5 0.5499; 65 | * 7 * 4-9 1-5 0.6556; 66 | * 8 * 4-9 1-5 0.6961; 67 | * 9 * 4-9 1-5 0.7413; 68 | * 10 * 4-9 1-5 0.7653; 69 | * 11 * 4-9 1-5 0.7755; 70 | * 12 * 4-9 1-5 0.7631; 71 | * 13 * 4-9 1-5 0.7326; 72 | * 14 * 4-9 1-5 0.7097; 73 | * 15 * 4-9 1-5 0.7180; 74 | * 16 * 4-9 1-5 0.7711; 75 | * 17 * 4-9 1-5 0.8799; 76 | * 18 * 4-9 1-5 0.8993; 77 | * 19 * 4-9 1-5 0.8810; 78 | * 20 * 4-9 1-5 0.9447; 79 | * 21 * 4-9 1-5 1.0348; 80 | * 22 * 4-9 1-5 0.9337; 81 | * 23 * 4-9 1-5 0.6756; 82 | } 83 | { 84 | // Summer Weekend 85 | * 0 * 4-9 0,6 0.5295; 86 | * 1 * 4-9 0,6 0.4417; 87 | * 2 * 4-9 0,6 0.3954; 88 | * 3 * 4-9 0,6 0.3806; 89 | * 4 * 4-9 0,6 0.3804; 90 | * 5 * 4-9 0,6 0.3847; 91 | * 6 * 4-9 0,6 0.4273; 92 | * 7 * 4-9 0,6 0.5372; 93 | * 8 * 4-9 0,6 0.6791; 94 | * 9 * 4-9 0,6 0.8010; 95 | * 10 * 4-9 0,6 0.8423; 96 | * 11 * 4-9 0,6 0.8563; 97 | * 12 * 4-9 0,6 0.8494; 98 | * 13 * 4-9 0,6 0.8282; 99 | * 14 * 4-9 0,6 0.7962; 100 | * 15 * 4-9 0,6 0.7771; 101 | * 16 * 4-9 0,6 0.7927; 102 | * 17 * 4-9 0,6 0.8434; 103 | * 18 * 4-9 0,6 0.8635; 104 | * 19 * 4-9 0,6 0.8555; 105 | * 20 * 4-9 0,6 0.9222; 106 | * 21 * 4-9 0,6 0.9977; 107 | * 22 * 4-9 0,6 0.8988; 108 | * 23 * 4-9 0,6 0.6840; 109 | } 110 | } 111 | 112 | schedule unresponsive_loads { 113 | { 114 | // Winter Weekday 115 | * 0 * 1-3,10-12 1-5 0.2084; 116 | * 1 * 1-3,10-12 1-5 0.2056; 117 | * 2 * 1-3,10-12 1-5 0.2008; 118 | * 3 * 1-3,10-12 1-5 0.1973; 119 | * 4 * 1-3,10-12 1-5 0.1953; 120 | * 5 * 1-3,10-12 1-5 0.1967; 121 | * 6 * 1-3,10-12 1-5 0.2001; 122 | * 7 * 1-3,10-12 1-5 0.2056; 123 | * 8 * 1-3,10-12 1-5 0.2056; 124 | * 9 * 1-3,10-12 1-5 0.2063; 125 | * 10 * 1-3,10-12 1-5 0.2056; 126 | * 11 * 1-3,10-12 1-5 0.2091; 127 | * 12 * 1-3,10-12 1-5 0.2180; 128 | * 13 * 1-3,10-12 1-5 0.2180; 129 | * 14 * 1-3,10-12 1-5 0.2146; 130 | * 15 * 1-3,10-12 1-5 0.2160; 131 | * 16 * 1-3,10-12 1-5 0.2277; 132 | * 17 * 1-3,10-12 1-5 0.2477; 133 | * 18 * 1-3,10-12 1-5 0.2539; 134 | * 19 * 1-3,10-12 1-5 0.2470; 135 | * 20 * 1-3,10-12 1-5 0.2450; 136 | * 21 * 1-3,10-12 1-5 0.2381; 137 | * 22 * 1-3,10-12 1-5 0.2256; 138 | * 23 * 1-3,10-12 1-5 0.2153; 139 | } 140 | { 141 | // Winter Weekend 142 | * 0 * 1-3,10-12 0,6 0.2146; 143 | * 1 * 1-3,10-12 0,6 0.2084; 144 | * 2 * 1-3,10-12 0,6 0.2001; 145 | * 3 * 1-3,10-12 0,6 0.1960; 146 | * 4 * 1-3,10-12 0,6 0.1953; 147 | * 5 * 1-3,10-12 0,6 0.1946; 148 | * 6 * 1-3,10-12 0,6 0.1939; 149 | * 7 * 1-3,10-12 0,6 0.1994; 150 | * 8 * 1-3,10-12 0,6 0.2091; 151 | * 9 * 1-3,10-12 0,6 0.2146; 152 | * 10 * 1-3,10-12 0,6 0.2153; 153 | * 11 * 1-3,10-12 0,6 0.2201; 154 | * 12 * 1-3,10-12 0,6 0.2312; 155 | * 13 * 1-3,10-12 0,6 0.2332; 156 | * 14 * 1-3,10-12 0,6 0.2305; 157 | * 15 * 1-3,10-12 0,6 0.2318; 158 | * 16 * 1-3,10-12 0,6 0.2374; 159 | * 17 * 1-3,10-12 0,6 0.2539; 160 | * 18 * 1-3,10-12 0,6 0.2567; 161 | * 19 * 1-3,10-12 0,6 0.2512; 162 | * 20 * 1-3,10-12 0,6 0.2450; 163 | * 21 * 1-3,10-12 0,6 0.2387; 164 | * 22 * 1-3,10-12 0,6 0.2277; 165 | * 23 * 1-3,10-12 0,6 0.2146; 166 | } 167 | { 168 | // Summer Weekday 169 | * 0 * 4-9 1-5 0.2739; 170 | * 1 * 4-9 1-5 0.2726; 171 | * 2 * 4-9 1-5 0.2650; 172 | * 3 * 4-9 1-5 0.2567; 173 | * 4 * 4-9 1-5 0.2560; 174 | * 5 * 4-9 1-5 0.2525; 175 | * 6 * 4-9 1-5 0.2532; 176 | * 7 * 4-9 1-5 0.2484; 177 | * 8 * 4-9 1-5 0.2525; 178 | * 9 * 4-9 1-5 0.2581; 179 | * 10 * 4-9 1-5 0.2615; 180 | * 11 * 4-9 1-5 0.2657; 181 | * 12 * 4-9 1-5 0.2781; 182 | * 13 * 4-9 1-5 0.2801; 183 | * 14 * 4-9 1-5 0.2850; 184 | * 15 * 4-9 1-5 0.2884; 185 | * 16 * 4-9 1-5 0.3002; 186 | * 17 * 4-9 1-5 0.3071; 187 | * 18 * 4-9 1-5 0.3133; 188 | * 19 * 4-9 1-5 0.3064; 189 | * 20 * 4-9 1-5 0.3036; 190 | * 21 * 4-9 1-5 0.3015; 191 | * 22 * 4-9 1-5 0.2933; 192 | * 23 * 4-9 1-5 0.2822; 193 | } 194 | { 195 | // Summer Weekend 196 | * 0 * 4-9 0,6 0.2691; 197 | * 1 * 4-9 0,6 0.2643; 198 | * 2 * 4-9 0,6 0.2608; 199 | * 3 * 4-9 0,6 0.2498; 200 | * 4 * 4-9 0,6 0.2512; 201 | * 5 * 4-9 0,6 0.2477; 202 | * 6 * 4-9 0,6 0.2470; 203 | * 7 * 4-9 0,6 0.2429; 204 | * 8 * 4-9 0,6 0.2512; 205 | * 9 * 4-9 0,6 0.2594; 206 | * 10 * 4-9 0,6 0.2650; 207 | * 11 * 4-9 0,6 0.2684; 208 | * 12 * 4-9 0,6 0.2781; 209 | * 13 * 4-9 0,6 0.2891; 210 | * 14 * 4-9 0,6 0.2898; 211 | * 15 * 4-9 0,6 0.2953; 212 | * 16 * 4-9 0,6 0.2995; 213 | * 17 * 4-9 0,6 0.3057; 214 | * 18 * 4-9 0,6 0.3071; 215 | * 19 * 4-9 0,6 0.3036; 216 | * 20 * 4-9 0,6 0.3022; 217 | * 21 * 4-9 0,6 0.3008; 218 | * 22 * 4-9 0,6 0.2912; 219 | * 23 * 4-9 0,6 0.2795; 220 | } 221 | } 222 | schedule pool_pump_season { 223 | * * * 5-9 * 1; 224 | * * * 1-4,10-12 * 0; 225 | } 226 | -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/ns-3.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation; 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 General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "ns3/core-module.h" 18 | #include "ns3/network-module.h" 19 | #include "ns3/internet-module.h" 20 | #include "ns3/point-to-point-module.h" 21 | #include "ns3/applications-module.h" 22 | #include "ns3/nix-vector-routing-module.h" 23 | #include "ns3/mobility-module.h" 24 | #include "ns3/csma-module.h" 25 | #include "ns3/point-to-point-dumbbell.h" 26 | #include "ns3/bridge-helper.h" 27 | #include "ns3/wifi-module.h" 28 | #include "ns3/netanim-module.h" 29 | #include "ns3/wimax-helper.h" 30 | #include "ns3/lte-helper.h" 31 | #include "ns3/ipv4.h" 32 | #include "ns3/fncs-application.h" 33 | #include "ns3/fncs-application-helper.h" 34 | #include "ns3/fncs-simulator-impl.h" 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | using namespace ns3; 43 | using namespace std; 44 | 45 | struct MarketModel{ 46 | string nodeNamePrefixes; 47 | int numberofnodes; 48 | int numberofgroups; 49 | string marketname; 50 | vector csma; 51 | NodeContainer market; 52 | }; 53 | 54 | vector parseLinkModel(string name) { 55 | 56 | vector toReturn; 57 | ifstream inputFile(name.c_str()); 58 | if(!inputFile.good()) 59 | throw std::invalid_argument("Cannot open file!"); 60 | 61 | MarketModel *toAdd; 62 | while(!inputFile.eof()){ 63 | toAdd=new MarketModel(); 64 | inputFile >> toAdd->numberofnodes 65 | >> toAdd->marketname 66 | >> toAdd->nodeNamePrefixes; 67 | toAdd->numberofgroups = (toAdd->numberofnodes+19)/20; 68 | if(toAdd->numberofnodes==0) //ifstream zicti 69 | continue; 70 | toReturn.push_back(toAdd); 71 | } 72 | return toReturn; 73 | 74 | } 75 | 76 | int main (int argc, char *argv[]) 77 | { 78 | if(argc < 2){ 79 | cout << "Usage ./first " << endl; 80 | return 0; 81 | } 82 | int totalNumberOfNodes=0; 83 | 84 | /* reads the list of market models from the linkModel file*/ 85 | 86 | /* Each market model is defined by its 87 | * size (Number of HVAC/controllers) 88 | * Name of Market (MarkNIF) 89 | * Prefix of Node Names ( Prefix for controller name) 90 | * the busid of the bus, market is connected to 91 | */ 92 | /* totalNumberOfNodes is the sum of size of all market model */ 93 | vector networks = parseLinkModel(string(argv[1])); 94 | 95 | cout << "Creating " << networks.size() << " networks." << endl; 96 | for (size_t i=0; inumberofgroups << " groups of " 99 | << networks[i]->numberofnodes << " nodes total" << endl; 100 | totalNumberOfNodes += networks[i]->numberofnodes; 101 | if (networks[i]->numberofgroups > 255) { 102 | cerr << "too many groups" << endl; 103 | return EXIT_FAILURE; 104 | } 105 | } 106 | cout << "Total number of nodes is " << totalNumberOfNodes << "." << endl; 107 | 108 | FncsSimulatorImpl *hb=new FncsSimulatorImpl(); 109 | Ptr hb2(hb); 110 | hb->Unref(); 111 | Simulator::SetImplementation(hb2); 112 | 113 | LogComponentEnable ("FncsApplication", LOG_LEVEL_INFO); 114 | 115 | Ipv4NixVectorHelper nixRouting; 116 | Ipv4StaticRoutingHelper staticRouting; 117 | Ipv4AddressHelper addresses; 118 | InternetStackHelper ihelper; 119 | Ipv4ListRoutingHelper list; 120 | list.Add (staticRouting, 0); 121 | list.Add (nixRouting, 10); 122 | ihelper.SetRoutingHelper (list); 123 | 124 | CsmaHelper chelper; 125 | chelper.SetChannelAttribute ("DataRate", DataRateValue (10000000)); 126 | chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (3))); 127 | 128 | ApplicationContainer fncsaps; 129 | 130 | /* Create the various networks. */ 131 | for (size_t netIndex=0; netIndexnumberofgroups; 139 | model->csma.resize(groups); 140 | for (int csmaIndex=0; csmaIndexcsma[csmaIndex].Create(21); 142 | } 143 | model->market.Create(1); 144 | 145 | ihelper.Install(model->market); 146 | 147 | NetDeviceContainer *csmaDevices = new NetDeviceContainer[groups]; 148 | 149 | for(int i=0;icsma[i]); 154 | 155 | ihelper.Install(model->csma[i]); 156 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 157 | addresses.Assign(csmaDevices[i]); 158 | ip.str(string()); 159 | } 160 | 161 | PointToPointHelper phelper3; 162 | phelper3.SetDeviceAttribute ("DataRate", StringValue ("4Mbps")); 163 | phelper3.SetChannelAttribute ("Delay", StringValue ("3ms")); 164 | 165 | //connect market nodes to csma nodes. 166 | for(int i=0;imarket.Get(0), model->csma[i].Get(0)); 172 | 173 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 174 | addresses.Assign(csma1dbell1); 175 | 176 | ip.str(string()); 177 | } 178 | 179 | NodeContainer gldnodes; 180 | for(int i=0;icsma[i].Get(j)); 183 | } 184 | } 185 | 186 | /* the '1' below is the offset where number of nodes begins */ 187 | FncsApplicationHelper help(model->nodeNamePrefixes, 1); 188 | fncsaps.Add(help.Install(gldnodes)); 189 | fncsaps.Add(help.Install(model->market.Get(0), model->marketname)); 190 | } 191 | 192 | fncsaps.Start (Seconds (0.0)); 193 | fncsaps.Stop (Seconds (259200.0)); 194 | 195 | Simulator::Run (); 196 | Simulator::Destroy (); 197 | } 198 | -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/run_ns-3.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation; 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 General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "ns3/core-module.h" 18 | #include "ns3/network-module.h" 19 | #include "ns3/internet-module.h" 20 | #include "ns3/point-to-point-module.h" 21 | #include "ns3/applications-module.h" 22 | #include "ns3/nix-vector-routing-module.h" 23 | #include "ns3/mobility-module.h" 24 | #include "ns3/csma-module.h" 25 | #include "ns3/point-to-point-dumbbell.h" 26 | #include "ns3/bridge-helper.h" 27 | #include "ns3/wifi-module.h" 28 | #include "ns3/netanim-module.h" 29 | #include "ns3/wimax-helper.h" 30 | #include "ns3/lte-helper.h" 31 | #include "ns3/ipv4.h" 32 | #include "ns3/fncs-application.h" 33 | #include "ns3/fncs-application-helper.h" 34 | #include "ns3/fncs-simulator-impl.h" 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | using namespace ns3; 43 | using namespace std; 44 | 45 | struct MarketModel{ 46 | string nodeNamePrefixes; 47 | int numberofnodes; 48 | int numberofgroups; 49 | string marketname; 50 | vector csma; 51 | NodeContainer market; 52 | }; 53 | 54 | vector parseLinkModel(string name) { 55 | 56 | vector toReturn; 57 | ifstream inputFile(name.c_str()); 58 | if(!inputFile.good()) 59 | throw std::invalid_argument("Cannot open file!"); 60 | 61 | MarketModel *toAdd; 62 | while(!inputFile.eof()){ 63 | toAdd=new MarketModel(); 64 | inputFile >> toAdd->numberofnodes 65 | >> toAdd->marketname 66 | >> toAdd->nodeNamePrefixes; 67 | toAdd->numberofgroups = (toAdd->numberofnodes+19)/20; 68 | if(toAdd->numberofnodes==0) //ifstream zicti 69 | continue; 70 | toReturn.push_back(toAdd); 71 | } 72 | return toReturn; 73 | 74 | } 75 | 76 | int main (int argc, char *argv[]) 77 | { 78 | if(argc < 2){ 79 | cout << "Usage ./first " << endl; 80 | return 0; 81 | } 82 | int totalNumberOfNodes=0; 83 | 84 | /* reads the list of market models from the linkModel file*/ 85 | 86 | /* Each market model is defined by its 87 | * size (Number of HVAC/controllers) 88 | * Name of Market (MarkNIF) 89 | * Prefix of Node Names ( Prefix for controller name) 90 | * the busid of the bus, market is connected to 91 | */ 92 | /* totalNumberOfNodes is the sum of size of all market model */ 93 | vector networks = parseLinkModel(string(argv[1])); 94 | 95 | cout << "Creating " << networks.size() << " networks." << endl; 96 | for (size_t i=0; inumberofgroups << " groups of " 99 | << networks[i]->numberofnodes << " nodes total" << endl; 100 | totalNumberOfNodes += networks[i]->numberofnodes; 101 | if (networks[i]->numberofgroups > 255) { 102 | cerr << "too many groups" << endl; 103 | return EXIT_FAILURE; 104 | } 105 | } 106 | cout << "Total number of nodes is " << totalNumberOfNodes << "." << endl; 107 | 108 | FncsSimulatorImpl *hb=new FncsSimulatorImpl(); 109 | Ptr hb2(hb); 110 | hb->Unref(); 111 | Simulator::SetImplementation(hb2); 112 | 113 | LogComponentEnable ("FncsApplication", LOG_LEVEL_INFO); 114 | 115 | Ipv4NixVectorHelper nixRouting; 116 | Ipv4StaticRoutingHelper staticRouting; 117 | Ipv4AddressHelper addresses; 118 | InternetStackHelper ihelper; 119 | Ipv4ListRoutingHelper list; 120 | list.Add (staticRouting, 0); 121 | list.Add (nixRouting, 10); 122 | ihelper.SetRoutingHelper (list); 123 | 124 | CsmaHelper chelper; 125 | chelper.SetChannelAttribute ("DataRate", DataRateValue (10000000)); 126 | chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (3))); 127 | 128 | ApplicationContainer fncsaps; 129 | 130 | /* Create the various networks. */ 131 | for (size_t netIndex=0; netIndexnumberofgroups; 139 | model->csma.resize(groups); 140 | for (int csmaIndex=0; csmaIndexcsma[csmaIndex].Create(21); 142 | } 143 | model->market.Create(1); 144 | 145 | ihelper.Install(model->market); 146 | 147 | NetDeviceContainer *csmaDevices = new NetDeviceContainer[groups]; 148 | 149 | for(int i=0;icsma[i]); 154 | 155 | ihelper.Install(model->csma[i]); 156 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 157 | addresses.Assign(csmaDevices[i]); 158 | ip.str(string()); 159 | } 160 | 161 | PointToPointHelper phelper3; 162 | phelper3.SetDeviceAttribute ("DataRate", StringValue ("4Mbps")); 163 | phelper3.SetChannelAttribute ("Delay", StringValue ("3ms")); 164 | 165 | //connect market nodes to csma nodes. 166 | for(int i=0;imarket.Get(0), model->csma[i].Get(0)); 172 | 173 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 174 | addresses.Assign(csma1dbell1); 175 | 176 | ip.str(string()); 177 | } 178 | 179 | NodeContainer gldnodes; 180 | for(int i=0;icsma[i].Get(j)); 183 | } 184 | } 185 | 186 | /* the '1' below is the offset where number of nodes begins */ 187 | FncsApplicationHelper help(model->nodeNamePrefixes, 1); 188 | fncsaps.Add(help.Install(gldnodes)); 189 | fncsaps.Add(help.Install(model->market.Get(0), model->marketname)); 190 | } 191 | 192 | fncsaps.Start (Seconds (0.0)); 193 | fncsaps.Stop (Seconds (259200.0)); 194 | 195 | Simulator::Run (); 196 | Simulator::Destroy (); 197 | } 198 | -------------------------------------------------------------------------------- /developer_guide.md: -------------------------------------------------------------------------------- 1 | 2 | # Developer Guide 3 | 4 | In this developer guide we provide information to help those 5 | researchers interested in extending the GridAttackSim functionality, 6 | for example to add new smart grid topologies and attack types. 7 | 8 | 9 | ## File overview 10 | 11 | The GridAttackSim release contains a large number of files, and we 12 | provide an overview below to facilitate further development and 13 | extensions of the software. 14 | 15 | ``` 16 | ├── Database # Database folder 17 | │   ├── 13_Nodes_73_Houses # IEEE 13 node test feeder with 73 houses 18 | │   ├── GridLab-D.glm # GridLAB-D main file 19 | │   ├── ns-3.cc # ns-3 main file 20 | │   ├── compile-ns3.sh # Compile ns-3 network model 21 | │   ├── creat_zpl_file.py # Generate fncs.zpl 22 | │   ├── creat_rout_and_subscribe.py # Generate fncs_msg.txt 23 | │   ├── run.sh # Run ns-3, GridLab-D, and fncs_broker 24 | │   ├── fncs_msg.txt # Configure FNCS broker to ns-3 communication 25 | │   ├── fncs.zpl # Configure simulator topic subscription 26 | │   ├── LinkModelGLDNS3.txt # Define number of houses and prefix 27 | │   ├── 13_Nodes_15_Houses # IEEE 13 node test feeder with 15 houses 28 | │   ├── 1_Node_255_Houses # Simple test feeder developed by the FNCS team 29 | │   ├── 4_Nodes_1_House # IEEE 4 node test feeder with 1 house 30 | │   ├── 4_Nodes_492_Houses # IEEE 4 node test feeder with 492 houses 31 | ├── GridAttackSim.py # Main application GUI file 32 | ├── attack_broker.py # Run attack simulation 33 | ├── attack_library.json # Attack library in JSON format 34 | ├── glmMap.py # Convert GridLab-D.glm to graph 35 | ├── plot_result.py # Plot results 36 | ``` 37 | 38 | 39 | ## How to add new smart grid topologies 40 | 41 | In order to add a new smart grid topology, you need to create a 42 | directory similar to the ones existing in the `Database` folder. To 43 | set up an existing raw `GridLab-D.glm` file for use with 44 | GridAttackSim, you need to add `fncs_msg` and auction objects in it, 45 | so as to configure the GridLAB-D process connection with the FNCS 46 | broker. This can be achieved by running the two scripts shown below: 47 | 48 | ``` 49 | python3 creat_zpl_file.py 50 | python3 creat_rout_and_subscribe.py 51 | ``` 52 | 53 | The generation scripts for FNCS communication configuration files use 54 | the total number of houses, market ID, and prefix of the controller 55 | inside each house as the input. The files generated by these scripts 56 | are: 57 | * `fncs.zpl`: Configure the simulator to subscribe to the topics of 58 | interest, such as market ID, market-clearing price, submit bid state, 59 | etc.; this file uses the ZPL (ZeroMQ Property Language) format 60 | * `fncs_msg.txt`: Configure the communication between the FNCS broker 61 | and the ns-3 process 62 | 63 | 64 | ## How to add new attack types 65 | 66 | GridAttackSim makes it possible to evaluate the consequences of 67 | cyber-attacks in a simulated smart grid environment. These attacks are 68 | instantiated through the attack pattern library, which contains 69 | descriptions of each attack. 70 | 71 | To add a new attack, you need to add new objects to the attack pattern 72 | library file `attack_library.json`, which contains a representation of 73 | the nature, effects, and schedule of an attack. The attack pattern 74 | library file uses the JSON format, and for each attack the following 75 | information needs to be provided: 76 | 77 | ``` 78 | ├── "Object" # JSON object 79 | │   ├── attack_type # Type of attack to be conducted 80 | │   ├── type_id # ID of the attack 81 | │   ├── type_name # Name of the attack 82 | │   ├── description # Description of the attack 83 | │   ├── affected_value # Parameters affected by the attack and their values 84 | │   ├── attack_component # Smart grid components affected by the attack 85 | │   ├── component_id # ID of the affected component 86 | │   ├── component_name # Name of the affected component 87 | │   ├── description # Description of the affected component 88 | │   ├── file # Core system files to be over-written to conduct the attack 89 | │   ├── attack_schedule # Schedule according to which the attack should happen 90 | │   ├── schedule_id # ID of the attack schedule 91 | │   ├── description # Description of the attack schedule 92 | │   ├── start_time # Starting time of the attack 93 | │   ├── end_time # Ending time of the attack 94 | ``` 95 | 96 | ### Attack example 97 | 98 | Below we show a fragment of the `attack_library.json` file in the 99 | GridAttackSim release, which includes details for the "Channel 100 | Jamming" attack. 101 | 102 | ``` 103 | { 104 | "type": "attack_library", 105 | "version": "1.0", 106 | "created": "2020-01-01", 107 | "object": [ 108 | { 109 | "attack_category": "nefarious_activity", 110 | "attack_id": "1", 111 | "category_name": "Nefarious Activity", 112 | "name": "Channel Jamming - Cluster", 113 | "description": "Nefarious Activity", 114 | "attack_type": [ 115 | { 116 | "type_id": "1", 117 | "type_name": "channel_jamming_cluster", 118 | "description": "Since smart grid uses IP protocol and TCP/IP stack, 119 | it becomes subject to DoS attacks and to the vulnerabilities 120 | inherent in the TCP/IP stack. DoS attacks might attempt to delay, 121 | block, or corrupt information transmission in order to make smart grid 122 | resources unavailable", 123 | "affected_value": [ 124 | { 125 | "delay_cluster": 100, 126 | "data_rate_cluster": 1000000 127 | } 128 | ] 129 | } 130 | ], 131 | "attack_component": [ 132 | { 133 | "component_id": "1", 134 | "component_name": "Network", 135 | "description": "Network component is affected", 136 | "file": "ns-3.cc" 137 | } 138 | ], 139 | "attack_schedule": [ 140 | { 141 | "schedule_id": "1", 142 | "description": "Attack Schedule", 143 | "file": "schedule_1", 144 | "start_time": "12:00:00", 145 | "end_time": "18:00:00" 146 | } 147 | ] 148 | }, 149 | ... 150 | ``` 151 | 152 | ### Currently implemented attacks 153 | 154 | The simulation of smart grid cyber-attacks is conducted by altering 155 | the input of the GridLAB-D and ns-3 simulators. For each attack, the 156 | attack pattern library needs to specify the variables that need to be 157 | changed to simulate that particular attack. The table below shows the 158 | affected parameters for each of the currently implemented attack 159 | type. Note that different types of attacks might affect the same 160 | variables, yielding multiple possibilities for diagnosis. 161 | 162 | ![GridAttackSim GUI](Figures/attack_types.png?raw=true "Attack types available in GridAttackSim") 163 | 164 | If you simply want to modify the effects of one of the currently 165 | implemented attacks, you should change the values of the affected 166 | values, then run the simulation to see what are the consequences on 167 | the smart grid. 168 | -------------------------------------------------------------------------------- /Database/1_Node_255_Houses/firstN.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation; 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 General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "ns3/core-module.h" 18 | #include "ns3/network-module.h" 19 | #include "ns3/internet-module.h" 20 | #include "ns3/point-to-point-module.h" 21 | #include "ns3/applications-module.h" 22 | #include "ns3/nix-vector-routing-module.h" 23 | #include "ns3/mobility-module.h" 24 | #include "ns3/csma-module.h" 25 | #include "ns3/point-to-point-dumbbell.h" 26 | #include "ns3/bridge-helper.h" 27 | #include "ns3/wifi-module.h" 28 | #include "ns3/netanim-module.h" 29 | #include "ns3/wimax-helper.h" 30 | #include "ns3/lte-helper.h" 31 | #include "ns3/ipv4.h" 32 | #include "ns3/fncs-application.h" 33 | #include "ns3/fncs-application-helper.h" 34 | #include "ns3/fncs-simulator-impl.h" 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | using namespace ns3; 43 | using namespace std; 44 | int int_delay = 3; 45 | struct MarketModel{ 46 | string nodeNamePrefixes; 47 | int numberofnodes; 48 | int numberofgroups; 49 | string marketname; 50 | vector csma; 51 | NodeContainer market; 52 | }; 53 | 54 | vector parseLinkModel(string name) { 55 | 56 | vector toReturn; 57 | ifstream inputFile(name.c_str()); 58 | if(!inputFile.good()) 59 | throw std::invalid_argument("Cannot open file!"); 60 | 61 | MarketModel *toAdd; 62 | while(!inputFile.eof()){ 63 | toAdd=new MarketModel(); 64 | inputFile >> toAdd->numberofnodes 65 | >> toAdd->marketname 66 | >> toAdd->nodeNamePrefixes; 67 | toAdd->numberofgroups = (toAdd->numberofnodes+19)/20; 68 | //Smart meters are organized and grouped into clusters of 20 nodes forming local area networks 69 | if(toAdd->numberofnodes==0) //ifstream zicti 70 | continue; 71 | toReturn.push_back(toAdd); 72 | } 73 | return toReturn; 74 | 75 | } 76 | 77 | int main (int argc, char *argv[]) 78 | { 79 | if(argc < 2){ 80 | cout << "Usage ./first " << endl; 81 | return 0; 82 | } 83 | int totalNumberOfNodes=0; 84 | 85 | /* reads the list of market models from the linkModel file*/ 86 | 87 | /* Each market model is defined by its 88 | * size (Number of HVAC/controllers) 89 | * Name of Market (MarkNIF) 90 | * Prefix of Node Names ( Prefix for controller name) 91 | * the busid of the bus, market is connected to 92 | */ 93 | /* totalNumberOfNodes is the sum of size of all market model */ 94 | vector networks = parseLinkModel(string(argv[1])); 95 | 96 | cout << "Creating " << networks.size() << " networks." << endl; 97 | for (size_t i=0; inumberofgroups << " groups of " 100 | << networks[i]->numberofnodes << " nodes total" << endl; 101 | totalNumberOfNodes += networks[i]->numberofnodes; 102 | if (networks[i]->numberofgroups > 255) { 103 | cerr << "too many groups" << endl; 104 | return EXIT_FAILURE; 105 | } 106 | } 107 | cout << "Total number of nodes is " << totalNumberOfNodes << "." << endl; 108 | 109 | FncsSimulatorImpl *hb=new FncsSimulatorImpl(); 110 | Ptr hb2(hb); 111 | hb->Unref(); 112 | Simulator::SetImplementation(hb2); 113 | 114 | LogComponentEnable ("FncsApplication", LOG_LEVEL_INFO); 115 | 116 | Ipv4NixVectorHelper nixRouting; 117 | Ipv4StaticRoutingHelper staticRouting; 118 | Ipv4AddressHelper addresses; 119 | InternetStackHelper ihelper; 120 | Ipv4ListRoutingHelper list; 121 | list.Add (staticRouting, 0); 122 | list.Add (nixRouting, 10); 123 | ihelper.SetRoutingHelper (list); 124 | 125 | CsmaHelper chelper; 126 | //chelper.SetChannelAttribute ("DataRate", DataRateValue (10000000)); 127 | //chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (3))); 128 | 129 | 130 | 131 | chelper.SetChannelAttribute ("DataRate", DataRateValue (10000000)); 132 | chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (int_delay))); 133 | 134 | 135 | 136 | 137 | ApplicationContainer fncsaps; 138 | 139 | /* Create the various networks. */ 140 | for (size_t netIndex=0; netIndexnumberofgroups; 148 | model->csma.resize(groups); 149 | for (int csmaIndex=0; csmaIndexcsma[csmaIndex].Create(21); 151 | } 152 | model->market.Create(1); 153 | 154 | ihelper.Install(model->market); 155 | 156 | NetDeviceContainer *csmaDevices = new NetDeviceContainer[groups]; 157 | 158 | for(int i=0;icsma[i]); 163 | 164 | ihelper.Install(model->csma[i]); 165 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 166 | addresses.Assign(csmaDevices[i]); 167 | ip.str(string()); 168 | } 169 | 170 | PointToPointHelper phelper3; 171 | 172 | //phelper3.SetDeviceAttribute ("DataRate", StringValue ("4Mbps")); 173 | //phelper3.SetChannelAttribute ("Delay", StringValue ("3000000ms")); 174 | 175 | phelper3.SetDeviceAttribute ("DataRate", StringValue ("4Mbps")); 176 | phelper3.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (int_delay))); 177 | 178 | //connect market nodes to csma nodes. 179 | for(int i=0;imarket.Get(0), model->csma[i].Get(0)); 185 | 186 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 187 | addresses.Assign(csma1dbell1); 188 | 189 | ip.str(string()); 190 | } 191 | 192 | NodeContainer gldnodes; 193 | for(int i=0;icsma[i].Get(j)); 196 | } 197 | } 198 | 199 | /* the '1' below is the offset where number of nodes begins */ 200 | FncsApplicationHelper help(model->nodeNamePrefixes, 1); 201 | fncsaps.Add(help.Install(gldnodes)); 202 | fncsaps.Add(help.Install(model->market.Get(0), model->marketname)); 203 | } 204 | 205 | fncsaps.Start (Seconds (0.0)); 206 | fncsaps.Stop (Seconds (259200.0)); 207 | 208 | Simulator::Run (); 209 | Simulator::Destroy (); 210 | } 211 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/GridLab-D.glm: -------------------------------------------------------------------------------- 1 | 2 | clock { 3 | timezone EST+5EDT; 4 | starttime '2009-07-21 00:00:00'; 5 | stoptime '2009-07-22 00:00:00'; 6 | } 7 | #include "light_schedule.glm"; 8 | module powerflow { 9 | solver_method FBS; 10 | NR_iteration_limit 50; 11 | }; 12 | module market; 13 | module tape; 14 | module residential { 15 | implicit_enduses NONE; 16 | }; 17 | module climate; 18 | module connection; 19 | 20 | class auction { 21 | double current_price_mean_24h; 22 | double current_price_stdev_24h; 23 | } 24 | 25 | object auction { 26 | name Market_1; 27 | special_mode NONE; 28 | unit kW; 29 | price_cap 3.78; 30 | period 300; 31 | init_price 0.10; 32 | init_stdev 0.05; 33 | capacity_reference_object transformer23; 34 | capacity_reference_property power_out_real; 35 | object player { 36 | property capacity_reference_bid_price; 37 | file ExamplePrices2.player; 38 | loop 150; 39 | }; 40 | max_capacity_reference_bid_quantity 150; 41 | warmup 0; 42 | object recorder { 43 | property capacity_reference_bid_price, current_market.clearing_price, current_market.clearing_quantity; 44 | limit 100000000; 45 | interval 60; 46 | file baseprice_clearedprice_clearedquantity.csv; 47 | }; 48 | } 49 | 50 | 51 | 52 | 53 | object csv_reader { 54 | name CSVREADER; 55 | filename "ColumbusWeather2009_2a.csv"; 56 | } 57 | 58 | object climate { 59 | name "Minneapolis MN"; 60 | tmyfile "ColumbusWeather2009_2a.csv"; 61 | reader CSVREADER; 62 | }; 63 | 64 | object fncs_msg { 65 | name fncs_msg; 66 | parent Market_1; 67 | route "function:controller/submit_bid_state -> auction/submit_bid_state"; 68 | option "transport:hostname localhost, port 5570"; 69 | configure fncs_msg.txt; 70 | } 71 | 72 | 73 | 74 | object overhead_line_conductor { 75 | name overhead_line_conductor100; 76 | geometric_mean_radius 0.0244; 77 | resistance 0.306; 78 | } 79 | 80 | object overhead_line_conductor { 81 | name overhead_line_conductor101; 82 | geometric_mean_radius 0.00814; 83 | resistance 0.592; 84 | } 85 | 86 | object line_spacing { 87 | name line_spacing200; 88 | distance_AB 2.5; 89 | distance_BC 4.5; 90 | distance_AC 7.0; 91 | distance_AN 5.656854; 92 | distance_BN 4.272002; 93 | distance_CN 5.0; 94 | } 95 | 96 | object line_configuration { 97 | name line_configuration300; 98 | conductor_A overhead_line_conductor100; 99 | conductor_B overhead_line_conductor100; 100 | conductor_C overhead_line_conductor100; 101 | conductor_N overhead_line_conductor101; 102 | spacing line_spacing200; 103 | } 104 | 105 | object transformer_configuration { 106 | name transformer_configuration400; 107 | connect_type 1; 108 | power_rating 6000; 109 | powerA_rating 2000; 110 | powerB_rating 2000; 111 | powerC_rating 2000; 112 | primary_voltage 12470; 113 | secondary_voltage 4160; 114 | resistance 0.01; 115 | reactance 0.06; 116 | } 117 | 118 | object node { 119 | name node1; 120 | bustype SWING; 121 | phases "ABCN"; 122 | voltage_A +7199.558+0.000j; 123 | voltage_B -3599.779-6235.000j; 124 | voltage_C -3599.779+6235.000j; 125 | nominal_voltage 7200; 126 | } 127 | 128 | object overhead_line { 129 | phases "ABCN"; 130 | from node1; 131 | to node2; 132 | length 2000; 133 | configuration line_configuration300; 134 | } 135 | 136 | object node { 137 | name node2; 138 | phases "ABCN"; 139 | voltage_A +7199.558+0.000j; 140 | voltage_B -3599.779-6235.000j; 141 | voltage_C -3599.779+6235.000j; 142 | nominal_voltage 7200; 143 | } 144 | 145 | object transformer { 146 | name transformer23; 147 | phases "ABCN"; 148 | from node2; 149 | to node3; 150 | configuration transformer_configuration400; 151 | object recorder { 152 | interval 60; 153 | limit 0; 154 | property power_out_real; 155 | file totalload.csv; 156 | }; 157 | } 158 | 159 | object node { 160 | name node3; 161 | phases "ABCN"; 162 | voltage_A +2401.777+0.000j; 163 | voltage_B -1200.889-2080.000j; 164 | voltage_C -1200.889+2080.000j; 165 | nominal_voltage 2400; 166 | } 167 | 168 | object overhead_line:34 { 169 | phases "ABCN"; 170 | from node3; 171 | to node4; 172 | length 2500; 173 | configuration line_configuration300; 174 | } 175 | 176 | object node { 177 | name node4; 178 | phases ABCN; 179 | nominal_voltage 2400; 180 | } 181 | 182 | object transformer { 183 | name CTTF_A1; 184 | phases AS; 185 | from node4; 186 | to tn_A1; 187 | configuration object transformer_configuration { 188 | connect_type SINGLE_PHASE_CENTER_TAPPED; 189 | install_type POLETOP; 190 | shunt_impedance 10000+10000j; 191 | primary_voltage 2401.777; 192 | secondary_voltage 120; 193 | powerA_rating 25 kVA; 194 | impedance 0.00033+0.0022j; 195 | }; 196 | groupid Distribution_Trans; 197 | } 198 | 199 | object triplex_meter { 200 | name tn_A1; 201 | phases AS; 202 | nominal_voltage 120; 203 | } 204 | 205 | object triplex_line_configuration { 206 | name trip_line_config; 207 | conductor_1 object triplex_line_conductor { 208 | resistance 0.97; 209 | geometric_mean_radius 0.01111; 210 | }; 211 | conductor_2 object triplex_line_conductor { 212 | resistance 0.97; 213 | geometric_mean_radius 0.01111; 214 | }; 215 | conductor_N object triplex_line_conductor { 216 | resistance 0.97; 217 | geometric_mean_radius 0.01111; 218 | }; 219 | insulation_thickness 0.08; 220 | diameter 0.368; 221 | } 222 | 223 | object triplex_line { 224 | name tl_A1; 225 | phases AS; 226 | from tn_A1; 227 | to tm_A1; 228 | length 19.10; 229 | configuration trip_line_config; 230 | groupid Triplex_Line; 231 | } 232 | 233 | object triplex_meter { 234 | name tm_A1; 235 | phases AS; 236 | nominal_voltage 120; 237 | } 238 | 239 | 240 | object house { 241 | parent tm_A1; 242 | name house_A1; 243 | floor_area 1936; 244 | schedule_skew 2754; 245 | heating_system_type HEAT_PUMP; 246 | heating_COP 2.7; 247 | cooling_system_type ELECTRIC; 248 | object controller { 249 | name HOUSE_1; 250 | schedule_skew 2754; 251 | market Market_1; 252 | bid_mode ON; 253 | 254 | 255 | proxy_average 0.042676; 256 | proxy_standard_deviation 0.020000; 257 | proxy_market_id 1; 258 | proxy_clear_price 0.042676; 259 | proxy_price_cap 3.78; 260 | 261 | 262 | control_mode DOUBLE_RAMP; 263 | resolve_mode DEADBAND; 264 | slider_setting_heat 0.500; 265 | slider_setting_cool 0.500; 266 | heating_base_setpoint 68; 267 | cooling_base_setpoint 74; 268 | period 300; 269 | average_target current_price_mean_24h; 270 | standard_deviation_target current_price_stdev_24h; 271 | target air_temperature; 272 | heating_setpoint heating_setpoint; 273 | heating_demand last_heating_load; 274 | cooling_setpoint cooling_setpoint; 275 | cooling_demand last_cooling_load; 276 | deadband thermostat_deadband; 277 | total hvac_load; 278 | load hvac_load; 279 | state power_state; 280 | }; 281 | thermal_integrity_level 5; 282 | air_temperature 70; 283 | mass_temperature 70; 284 | cooling_COP 2.7; 285 | object ZIPload { 286 | base_power LIGHTS*1.33; 287 | schedule_skew -1582; 288 | heatgain_fraction 0.9; 289 | power_pf 1.000; 290 | current_pf 1.000; 291 | impedance_pf 1.000; 292 | impedance_fraction 0.300000; 293 | current_fraction 0.300000; 294 | power_fraction 0.400000; 295 | }; 296 | } 297 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/run_GridLab-D.glm: -------------------------------------------------------------------------------- 1 | 2 | clock { 3 | timezone EST+5EDT; 4 | starttime '2009-07-21 00:00:00'; 5 | stoptime '2009-07-22 00:00:00'; 6 | } 7 | #include "light_schedule.glm"; 8 | module powerflow { 9 | solver_method FBS; 10 | NR_iteration_limit 50; 11 | }; 12 | module market; 13 | module tape; 14 | module residential { 15 | implicit_enduses NONE; 16 | }; 17 | module climate; 18 | module connection; 19 | 20 | class auction { 21 | double current_price_mean_24h; 22 | double current_price_stdev_24h; 23 | } 24 | 25 | object auction { 26 | name Market_1; 27 | special_mode NONE; 28 | unit kW; 29 | price_cap 3.78; 30 | period 300; 31 | init_price 0.10; 32 | init_stdev 0.05; 33 | capacity_reference_object transformer23; 34 | capacity_reference_property power_out_real; 35 | object player { 36 | property capacity_reference_bid_price; 37 | file ExamplePrices2.player; 38 | loop 150; 39 | }; 40 | max_capacity_reference_bid_quantity 150; 41 | warmup 0; 42 | object recorder { 43 | property capacity_reference_bid_price, current_market.clearing_price, current_market.clearing_quantity; 44 | limit 100000000; 45 | interval 60; 46 | file baseprice_clearedprice_clearedquantity.csv; 47 | }; 48 | } 49 | 50 | 51 | 52 | 53 | object csv_reader { 54 | name CSVREADER; 55 | filename "ColumbusWeather2009_2a.csv"; 56 | } 57 | 58 | object climate { 59 | name "Minneapolis MN"; 60 | tmyfile "ColumbusWeather2009_2a.csv"; 61 | reader CSVREADER; 62 | }; 63 | 64 | object fncs_msg { 65 | name fncs_msg; 66 | parent Market_1; 67 | route "function:controller/submit_bid_state -> auction/submit_bid_state"; 68 | option "transport:hostname localhost, port 5570"; 69 | configure fncs_msg.txt; 70 | } 71 | 72 | 73 | 74 | object overhead_line_conductor { 75 | name overhead_line_conductor100; 76 | geometric_mean_radius 0.0244; 77 | resistance 0.306; 78 | } 79 | 80 | object overhead_line_conductor { 81 | name overhead_line_conductor101; 82 | geometric_mean_radius 0.00814; 83 | resistance 0.592; 84 | } 85 | 86 | object line_spacing { 87 | name line_spacing200; 88 | distance_AB 2.5; 89 | distance_BC 4.5; 90 | distance_AC 7.0; 91 | distance_AN 5.656854; 92 | distance_BN 4.272002; 93 | distance_CN 5.0; 94 | } 95 | 96 | object line_configuration { 97 | name line_configuration300; 98 | conductor_A overhead_line_conductor100; 99 | conductor_B overhead_line_conductor100; 100 | conductor_C overhead_line_conductor100; 101 | conductor_N overhead_line_conductor101; 102 | spacing line_spacing200; 103 | } 104 | 105 | object transformer_configuration { 106 | name transformer_configuration400; 107 | connect_type 1; 108 | power_rating 6000; 109 | powerA_rating 2000; 110 | powerB_rating 2000; 111 | powerC_rating 2000; 112 | primary_voltage 12470; 113 | secondary_voltage 4160; 114 | resistance 0.01; 115 | reactance 0.06; 116 | } 117 | 118 | object node { 119 | name node1; 120 | bustype SWING; 121 | phases "ABCN"; 122 | voltage_A +7199.558+0.000j; 123 | voltage_B -3599.779-6235.000j; 124 | voltage_C -3599.779+6235.000j; 125 | nominal_voltage 7200; 126 | } 127 | 128 | object overhead_line { 129 | phases "ABCN"; 130 | from node1; 131 | to node2; 132 | length 2000; 133 | configuration line_configuration300; 134 | } 135 | 136 | object node { 137 | name node2; 138 | phases "ABCN"; 139 | voltage_A +7199.558+0.000j; 140 | voltage_B -3599.779-6235.000j; 141 | voltage_C -3599.779+6235.000j; 142 | nominal_voltage 7200; 143 | } 144 | 145 | object transformer { 146 | name transformer23; 147 | phases "ABCN"; 148 | from node2; 149 | to node3; 150 | configuration transformer_configuration400; 151 | object recorder { 152 | interval 60; 153 | limit 0; 154 | property power_out_real; 155 | file totalload.csv; 156 | }; 157 | } 158 | 159 | object node { 160 | name node3; 161 | phases "ABCN"; 162 | voltage_A +2401.777+0.000j; 163 | voltage_B -1200.889-2080.000j; 164 | voltage_C -1200.889+2080.000j; 165 | nominal_voltage 2400; 166 | } 167 | 168 | object overhead_line:34 { 169 | phases "ABCN"; 170 | from node3; 171 | to node4; 172 | length 2500; 173 | configuration line_configuration300; 174 | } 175 | 176 | object node { 177 | name node4; 178 | phases ABCN; 179 | nominal_voltage 2400; 180 | } 181 | 182 | object transformer { 183 | name CTTF_A1; 184 | phases AS; 185 | from node4; 186 | to tn_A1; 187 | configuration object transformer_configuration { 188 | connect_type SINGLE_PHASE_CENTER_TAPPED; 189 | install_type POLETOP; 190 | shunt_impedance 10000+10000j; 191 | primary_voltage 2401.777; 192 | secondary_voltage 120; 193 | powerA_rating 25 kVA; 194 | impedance 0.00033+0.0022j; 195 | }; 196 | groupid Distribution_Trans; 197 | } 198 | 199 | object triplex_meter { 200 | name tn_A1; 201 | phases AS; 202 | nominal_voltage 120; 203 | } 204 | 205 | object triplex_line_configuration { 206 | name trip_line_config; 207 | conductor_1 object triplex_line_conductor { 208 | resistance 0.97; 209 | geometric_mean_radius 0.01111; 210 | }; 211 | conductor_2 object triplex_line_conductor { 212 | resistance 0.97; 213 | geometric_mean_radius 0.01111; 214 | }; 215 | conductor_N object triplex_line_conductor { 216 | resistance 0.97; 217 | geometric_mean_radius 0.01111; 218 | }; 219 | insulation_thickness 0.08; 220 | diameter 0.368; 221 | } 222 | 223 | object triplex_line { 224 | name tl_A1; 225 | phases AS; 226 | from tn_A1; 227 | to tm_A1; 228 | length 19.10; 229 | configuration trip_line_config; 230 | groupid Triplex_Line; 231 | } 232 | 233 | object triplex_meter { 234 | name tm_A1; 235 | phases AS; 236 | nominal_voltage 120; 237 | } 238 | 239 | 240 | object house { 241 | parent tm_A1; 242 | name house_A1; 243 | floor_area 1936; 244 | schedule_skew 2754; 245 | heating_system_type HEAT_PUMP; 246 | heating_COP 2.7; 247 | cooling_system_type ELECTRIC; 248 | object controller { 249 | name HOUSE_1; 250 | schedule_skew 2754; 251 | market Market_1; 252 | bid_mode ON; 253 | 254 | 255 | proxy_average 0.042676; 256 | proxy_standard_deviation 0.020000; 257 | proxy_market_id 1; 258 | proxy_clear_price 0.042676; 259 | proxy_price_cap 3.78; 260 | 261 | 262 | control_mode DOUBLE_RAMP; 263 | resolve_mode DEADBAND; 264 | slider_setting_heat 0.500; 265 | slider_setting_cool 0.500; 266 | heating_base_setpoint 68; 267 | cooling_base_setpoint 74; 268 | period 300; 269 | average_target current_price_mean_24h; 270 | standard_deviation_target current_price_stdev_24h; 271 | target air_temperature; 272 | heating_setpoint heating_setpoint; 273 | heating_demand last_heating_load; 274 | cooling_setpoint cooling_setpoint; 275 | cooling_demand last_cooling_load; 276 | deadband thermostat_deadband; 277 | total hvac_load; 278 | load hvac_load; 279 | state power_state; 280 | }; 281 | thermal_integrity_level 5; 282 | air_temperature 70; 283 | mass_temperature 70; 284 | cooling_COP 2.7; 285 | object ZIPload { 286 | base_power LIGHTS*1.33; 287 | schedule_skew -1582; 288 | heatgain_fraction 0.9; 289 | power_pf 1.000; 290 | current_pf 1.000; 291 | impedance_pf 1.000; 292 | impedance_fraction 0.300000; 293 | current_fraction 0.300000; 294 | power_fraction 0.400000; 295 | }; 296 | } 297 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/ns-3.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-1ile-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation; 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 General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "ns3/core-module.h" 18 | #include "ns3/network-module.h" 19 | #include "ns3/internet-module.h" 20 | #include "ns3/point-to-point-module.h" 21 | #include "ns3/applications-module.h" 22 | #include "ns3/nix-vector-routing-module.h" 23 | #include "ns3/mobility-module.h" 24 | #include "ns3/csma-module.h" 25 | #include "ns3/point-to-point-dumbbell.h" 26 | #include "ns3/bridge-helper.h" 27 | #include "ns3/wifi-module.h" 28 | #include "ns3/netanim-module.h" 29 | #include "ns3/wimax-helper.h" 30 | #include "ns3/lte-helper.h" 31 | #include "ns3/ipv4.h" 32 | #include "ns3/fncs-application.h" 33 | #include "ns3/fncs-application-helper.h" 34 | #include "ns3/fncs-simulator-impl.h" 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | using namespace ns3; 43 | using namespace std; 44 | int data_rate_peer_to_peer; 45 | int delay_peer_to_peer; 46 | int data_rate_cluster; //10000000bps = 10 Mbps 47 | int delay_cluster; //3 MilliSeconds 48 | 49 | 50 | 51 | 52 | 53 | struct MarketModel{ 54 | string nodeNamePrefixes; 55 | int numberofnodes; 56 | int numberofgroups; 57 | string marketname; 58 | vector csma; 59 | NodeContainer market; 60 | }; 61 | 62 | vector parseLinkModel(string name) { 63 | 64 | vector toReturn; 65 | ifstream inputFile(name.c_str()); 66 | if(!inputFile.good()) 67 | throw std::invalid_argument("Cannot open file!"); 68 | 69 | MarketModel *toAdd; 70 | while(!inputFile.eof()){ 71 | toAdd=new MarketModel(); 72 | inputFile >> toAdd->numberofnodes 73 | >> toAdd->marketname 74 | >> toAdd->nodeNamePrefixes; 75 | toAdd->numberofgroups = (toAdd->numberofnodes+19)/20; 76 | if(toAdd->numberofnodes==0) //ifstream zicti 77 | continue; 78 | toReturn.push_back(toAdd); 79 | } 80 | return toReturn; 81 | 82 | } 83 | 84 | int main (int argc, char *argv[]) 85 | { 86 | data_rate_peer_to_peer = 40000000;//40000000bps = 4 Mbps 87 | delay_peer_to_peer = 3; 88 | data_rate_cluster = 10000000; //10000000bps = 10 Mbps 89 | delay_cluster = 3; //3 MilliSeconds 90 | // Don't remove 91 | //Flag 92 | 93 | if(argc < 2){ 94 | cout << "Usage ./first " << endl; 95 | return 0; 96 | } 97 | int totalNumberOfNodes=0; 98 | 99 | /* reads the list of market models from the linkModel file*/ 100 | 101 | /* Each market model is defined by its 102 | * size (Number of HVAC/controllers) 103 | * Name of Market (MarkNIF) 104 | * Prefix of Node Names ( Prefix for controller name) 105 | * the busid of the bus, market is connected to 106 | */ 107 | /* totalNumberOfNodes is the sum of size of all market model */ 108 | vector networks = parseLinkModel(string(argv[1])); 109 | 110 | cout << "Creating " << networks.size() << " networks." << endl; 111 | for (size_t i=0; inumberofgroups << " groups of " 114 | << networks[i]->numberofnodes << " nodes total" << endl; 115 | totalNumberOfNodes += networks[i]->numberofnodes; 116 | if (networks[i]->numberofgroups > 255) { 117 | cerr << "too many groups" << endl; 118 | return EXIT_FAILURE; 119 | } 120 | } 121 | cout << "Total number of nodes is " << totalNumberOfNodes << "." << endl; 122 | 123 | FncsSimulatorImpl *hb=new FncsSimulatorImpl(); 124 | Ptr hb2(hb); 125 | hb->Unref(); 126 | Simulator::SetImplementation(hb2); 127 | 128 | LogComponentEnable ("FncsApplication", LOG_LEVEL_INFO); 129 | 130 | Ipv4NixVectorHelper nixRouting; 131 | Ipv4StaticRoutingHelper staticRouting; 132 | Ipv4AddressHelper addresses; 133 | InternetStackHelper ihelper; 134 | Ipv4ListRoutingHelper list; 135 | list.Add (staticRouting, 0); 136 | list.Add (nixRouting, 10); 137 | ihelper.SetRoutingHelper (list); 138 | 139 | CsmaHelper chelper; 140 | 141 | //ns3::DataRate::DataRate ( uint64_t bps ) bps bit/s value 142 | 143 | 144 | //chelper.SetChannelAttribute ("DataRate", DataRateValue (10000000)); 145 | //chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (3))); 146 | 147 | //chelper.SetChannelAttribute ("DataRate", StringValue ("4Mbps")); 148 | //chelper.SetChannelAttribute ("Delay", StringValue ("1000000ms")); 149 | 150 | chelper.SetChannelAttribute ("DataRate", DataRateValue (data_rate_cluster)); 151 | chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_cluster))); 152 | 153 | ApplicationContainer fncsaps; 154 | 155 | /* Create the various networks. */ 156 | for (size_t netIndex=0; netIndexnumberofgroups; 164 | model->csma.resize(groups); 165 | for (int csmaIndex=0; csmaIndexcsma[csmaIndex].Create(21); 167 | } 168 | model->market.Create(1); 169 | 170 | ihelper.Install(model->market); 171 | 172 | NetDeviceContainer *csmaDevices = new NetDeviceContainer[groups]; 173 | 174 | for(int i=0;icsma[i]); 179 | 180 | ihelper.Install(model->csma[i]); 181 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 182 | addresses.Assign(csmaDevices[i]); 183 | ip.str(string()); 184 | } 185 | 186 | PointToPointHelper phelper3; 187 | //phelper3.SetDeviceAttribute ("DataRate", StringValue ("4Mbps")); 188 | // phelper3.SetChannelAttribute ("Delay", StringValue ("2ms")); 189 | 190 | 191 | phelper3.SetDeviceAttribute ("DataRate", DataRateValue (data_rate_peer_to_peer)); 192 | phelper3.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_peer_to_peer))); 193 | 194 | //connect market nodes to csma nodes. 195 | for(int i=0;imarket.Get(0), model->csma[i].Get(0)); 201 | 202 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 203 | addresses.Assign(csma1dbell1); 204 | 205 | ip.str(string()); 206 | } 207 | 208 | NodeContainer gldnodes; 209 | for(int i=0;icsma[i].Get(j)); 212 | } 213 | } 214 | 215 | /* the '1' below is the offset where number of nodes begins */ 216 | FncsApplicationHelper help(model->nodeNamePrefixes, 1); 217 | fncsaps.Add(help.Install(gldnodes)); 218 | fncsaps.Add(help.Install(model->market.Get(0), model->marketname)); 219 | } 220 | 221 | fncsaps.Start (Seconds (0.0)); 222 | fncsaps.Stop (Seconds (259200.0)); 223 | 224 | Simulator::Run (); 225 | Simulator::Destroy (); 226 | } 227 | -------------------------------------------------------------------------------- /Database/13_Nodes_15_Houses/ns-3.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-1ile-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation; 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 General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "ns3/core-module.h" 18 | #include "ns3/network-module.h" 19 | #include "ns3/internet-module.h" 20 | #include "ns3/point-to-point-module.h" 21 | #include "ns3/applications-module.h" 22 | #include "ns3/nix-vector-routing-module.h" 23 | #include "ns3/mobility-module.h" 24 | #include "ns3/csma-module.h" 25 | #include "ns3/point-to-point-dumbbell.h" 26 | #include "ns3/bridge-helper.h" 27 | #include "ns3/wifi-module.h" 28 | #include "ns3/netanim-module.h" 29 | #include "ns3/wimax-helper.h" 30 | #include "ns3/lte-helper.h" 31 | #include "ns3/ipv4.h" 32 | #include "ns3/fncs-application.h" 33 | #include "ns3/fncs-application-helper.h" 34 | #include "ns3/fncs-simulator-impl.h" 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | using namespace ns3; 43 | using namespace std; 44 | int data_rate_peer_to_peer; 45 | int delay_peer_to_peer; 46 | int data_rate_cluster; //10000000bps = 10 Mbps 47 | int delay_cluster; //3 MilliSeconds 48 | 49 | 50 | 51 | 52 | 53 | struct MarketModel{ 54 | string nodeNamePrefixes; 55 | int numberofnodes; 56 | int numberofgroups; 57 | string marketname; 58 | vector csma; 59 | NodeContainer market; 60 | }; 61 | 62 | vector parseLinkModel(string name) { 63 | 64 | vector toReturn; 65 | ifstream inputFile(name.c_str()); 66 | if(!inputFile.good()) 67 | throw std::invalid_argument("Cannot open file!"); 68 | 69 | MarketModel *toAdd; 70 | while(!inputFile.eof()){ 71 | toAdd=new MarketModel(); 72 | inputFile >> toAdd->numberofnodes 73 | >> toAdd->marketname 74 | >> toAdd->nodeNamePrefixes; 75 | toAdd->numberofgroups = (toAdd->numberofnodes+19)/20; 76 | if(toAdd->numberofnodes==0) //ifstream zicti 77 | continue; 78 | toReturn.push_back(toAdd); 79 | } 80 | return toReturn; 81 | 82 | } 83 | 84 | int main (int argc, char *argv[]) 85 | { 86 | data_rate_peer_to_peer = 40000000;//40000000bps = 4 Mbps 87 | delay_peer_to_peer = 3; 88 | data_rate_cluster = 10000000; //10000000bps = 10 Mbps 89 | delay_cluster = 3; //3 MilliSeconds 90 | // Don't remove 91 | //Flag 92 | 93 | if(argc < 2){ 94 | cout << "Usage ./first " << endl; 95 | return 0; 96 | } 97 | int totalNumberOfNodes=0; 98 | 99 | /* reads the list of market models from the linkModel file*/ 100 | 101 | /* Each market model is defined by its 102 | * size (Number of HVAC/controllers) 103 | * Name of Market (MarkNIF) 104 | * Prefix of Node Names ( Prefix for controller name) 105 | * the busid of the bus, market is connected to 106 | */ 107 | /* totalNumberOfNodes is the sum of size of all market model */ 108 | vector networks = parseLinkModel(string(argv[1])); 109 | 110 | cout << "Creating " << networks.size() << " networks." << endl; 111 | for (size_t i=0; inumberofgroups << " groups of " 114 | << networks[i]->numberofnodes << " nodes total" << endl; 115 | totalNumberOfNodes += networks[i]->numberofnodes; 116 | if (networks[i]->numberofgroups > 255) { 117 | cerr << "too many groups" << endl; 118 | return EXIT_FAILURE; 119 | } 120 | } 121 | cout << "Total number of nodes is " << totalNumberOfNodes << "." << endl; 122 | 123 | FncsSimulatorImpl *hb=new FncsSimulatorImpl(); 124 | Ptr hb2(hb); 125 | hb->Unref(); 126 | Simulator::SetImplementation(hb2); 127 | 128 | LogComponentEnable ("FncsApplication", LOG_LEVEL_INFO); 129 | 130 | Ipv4NixVectorHelper nixRouting; 131 | Ipv4StaticRoutingHelper staticRouting; 132 | Ipv4AddressHelper addresses; 133 | InternetStackHelper ihelper; 134 | Ipv4ListRoutingHelper list; 135 | list.Add (staticRouting, 0); 136 | list.Add (nixRouting, 10); 137 | ihelper.SetRoutingHelper (list); 138 | 139 | CsmaHelper chelper; 140 | 141 | //ns3::DataRate::DataRate ( uint64_t bps ) bps bit/s value 142 | 143 | 144 | //chelper.SetChannelAttribute ("DataRate", DataRateValue (10000000)); 145 | //chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (3))); 146 | 147 | //chelper.SetChannelAttribute ("DataRate", StringValue ("4Mbps")); 148 | //chelper.SetChannelAttribute ("Delay", StringValue ("1000000ms")); 149 | 150 | chelper.SetChannelAttribute ("DataRate", DataRateValue (data_rate_cluster)); 151 | chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_cluster))); 152 | 153 | ApplicationContainer fncsaps; 154 | 155 | /* Create the various networks. */ 156 | for (size_t netIndex=0; netIndexnumberofgroups; 164 | model->csma.resize(groups); 165 | for (int csmaIndex=0; csmaIndexcsma[csmaIndex].Create(21); 167 | } 168 | model->market.Create(1); 169 | 170 | ihelper.Install(model->market); 171 | 172 | NetDeviceContainer *csmaDevices = new NetDeviceContainer[groups]; 173 | 174 | for(int i=0;icsma[i]); 179 | 180 | ihelper.Install(model->csma[i]); 181 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 182 | addresses.Assign(csmaDevices[i]); 183 | ip.str(string()); 184 | } 185 | 186 | PointToPointHelper phelper3; 187 | //phelper3.SetDeviceAttribute ("DataRate", StringValue ("4Mbps")); 188 | // phelper3.SetChannelAttribute ("Delay", StringValue ("2ms")); 189 | 190 | 191 | phelper3.SetDeviceAttribute ("DataRate", DataRateValue (data_rate_peer_to_peer)); 192 | phelper3.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_peer_to_peer))); 193 | 194 | //connect market nodes to csma nodes. 195 | for(int i=0;imarket.Get(0), model->csma[i].Get(0)); 201 | 202 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 203 | addresses.Assign(csma1dbell1); 204 | 205 | ip.str(string()); 206 | } 207 | 208 | NodeContainer gldnodes; 209 | for(int i=0;icsma[i].Get(j)); 212 | } 213 | } 214 | 215 | /* the '1' below is the offset where number of nodes begins */ 216 | FncsApplicationHelper help(model->nodeNamePrefixes, 1); 217 | fncsaps.Add(help.Install(gldnodes)); 218 | fncsaps.Add(help.Install(model->market.Get(0), model->marketname)); 219 | } 220 | 221 | fncsaps.Start (Seconds (0.0)); 222 | fncsaps.Stop (Seconds (259200.0)); 223 | 224 | Simulator::Run (); 225 | Simulator::Destroy (); 226 | } 227 | -------------------------------------------------------------------------------- /Database/13_Nodes_73_Houses/ns-3.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-1ile-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation; 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 General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "ns3/core-module.h" 18 | #include "ns3/network-module.h" 19 | #include "ns3/internet-module.h" 20 | #include "ns3/point-to-point-module.h" 21 | #include "ns3/applications-module.h" 22 | #include "ns3/nix-vector-routing-module.h" 23 | #include "ns3/mobility-module.h" 24 | #include "ns3/csma-module.h" 25 | #include "ns3/point-to-point-dumbbell.h" 26 | #include "ns3/bridge-helper.h" 27 | #include "ns3/wifi-module.h" 28 | #include "ns3/netanim-module.h" 29 | #include "ns3/wimax-helper.h" 30 | #include "ns3/lte-helper.h" 31 | #include "ns3/ipv4.h" 32 | #include "ns3/fncs-application.h" 33 | #include "ns3/fncs-application-helper.h" 34 | #include "ns3/fncs-simulator-impl.h" 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | using namespace ns3; 43 | using namespace std; 44 | int data_rate_peer_to_peer; 45 | int delay_peer_to_peer; 46 | int data_rate_cluster; //10000000bps = 10 Mbps 47 | int delay_cluster; //3 MilliSeconds 48 | 49 | 50 | 51 | 52 | 53 | struct MarketModel{ 54 | string nodeNamePrefixes; 55 | int numberofnodes; 56 | int numberofgroups; 57 | string marketname; 58 | vector csma; 59 | NodeContainer market; 60 | }; 61 | 62 | vector parseLinkModel(string name) { 63 | 64 | vector toReturn; 65 | ifstream inputFile(name.c_str()); 66 | if(!inputFile.good()) 67 | throw std::invalid_argument("Cannot open file!"); 68 | 69 | MarketModel *toAdd; 70 | while(!inputFile.eof()){ 71 | toAdd=new MarketModel(); 72 | inputFile >> toAdd->numberofnodes 73 | >> toAdd->marketname 74 | >> toAdd->nodeNamePrefixes; 75 | toAdd->numberofgroups = (toAdd->numberofnodes+19)/20; 76 | if(toAdd->numberofnodes==0) //ifstream zicti 77 | continue; 78 | toReturn.push_back(toAdd); 79 | } 80 | return toReturn; 81 | 82 | } 83 | 84 | int main (int argc, char *argv[]) 85 | { 86 | data_rate_peer_to_peer = 40000000;//40000000 bps = 4 Mbps 87 | delay_peer_to_peer = 3; 88 | data_rate_cluster = 10000000; //10000000 bps = 10 Mbps 89 | delay_cluster = 3; //3 MilliSeconds 90 | // Don't remove 91 | //Flag 92 | 93 | if(argc < 2){ 94 | cout << "Usage ./first " << endl; 95 | return 0; 96 | } 97 | int totalNumberOfNodes=0; 98 | 99 | /* reads the list of market models from the linkModel file*/ 100 | 101 | /* Each market model is defined by its 102 | * size (Number of HVAC/controllers) 103 | * Name of Market (MarkNIF) 104 | * Prefix of Node Names ( Prefix for controller name) 105 | * the busid of the bus, market is connected to 106 | */ 107 | /* totalNumberOfNodes is the sum of size of all market model */ 108 | vector networks = parseLinkModel(string(argv[1])); 109 | 110 | cout << "Creating " << networks.size() << " networks." << endl; 111 | for (size_t i=0; inumberofgroups << " groups of " 114 | << networks[i]->numberofnodes << " nodes total" << endl; 115 | totalNumberOfNodes += networks[i]->numberofnodes; 116 | if (networks[i]->numberofgroups > 255) { 117 | cerr << "too many groups" << endl; 118 | return EXIT_FAILURE; 119 | } 120 | } 121 | cout << "Total number of nodes is " << totalNumberOfNodes << "." << endl; 122 | 123 | FncsSimulatorImpl *hb=new FncsSimulatorImpl(); 124 | Ptr hb2(hb); 125 | hb->Unref(); 126 | Simulator::SetImplementation(hb2); 127 | 128 | LogComponentEnable ("FncsApplication", LOG_LEVEL_INFO); 129 | 130 | Ipv4NixVectorHelper nixRouting; 131 | Ipv4StaticRoutingHelper staticRouting; 132 | Ipv4AddressHelper addresses; 133 | InternetStackHelper ihelper; 134 | Ipv4ListRoutingHelper list; 135 | list.Add (staticRouting, 0); 136 | list.Add (nixRouting, 10); 137 | ihelper.SetRoutingHelper (list); 138 | 139 | CsmaHelper chelper; 140 | 141 | //ns3::DataRate::DataRate ( uint64_t bps ) bps bit/s value 142 | 143 | 144 | //chelper.SetChannelAttribute ("DataRate", DataRateValue (10000000)); 145 | //chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (3))); 146 | 147 | //chelper.SetChannelAttribute ("DataRate", StringValue ("4Mbps")); 148 | //chelper.SetChannelAttribute ("Delay", StringValue ("1000000ms")); 149 | 150 | chelper.SetChannelAttribute ("DataRate", DataRateValue (data_rate_cluster)); 151 | chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_cluster))); 152 | 153 | ApplicationContainer fncsaps; 154 | 155 | /* Create the various networks. */ 156 | for (size_t netIndex=0; netIndexnumberofgroups; 164 | model->csma.resize(groups); 165 | for (int csmaIndex=0; csmaIndexcsma[csmaIndex].Create(21); 167 | } 168 | model->market.Create(1); 169 | 170 | ihelper.Install(model->market); 171 | 172 | NetDeviceContainer *csmaDevices = new NetDeviceContainer[groups]; 173 | 174 | for(int i=0;icsma[i]); 179 | 180 | ihelper.Install(model->csma[i]); 181 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 182 | addresses.Assign(csmaDevices[i]); 183 | ip.str(string()); 184 | } 185 | 186 | PointToPointHelper phelper3; 187 | //phelper3.SetDeviceAttribute ("DataRate", StringValue ("4Mbps")); 188 | // phelper3.SetChannelAttribute ("Delay", StringValue ("2ms")); 189 | 190 | 191 | phelper3.SetDeviceAttribute ("DataRate", DataRateValue (data_rate_peer_to_peer)); 192 | phelper3.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_peer_to_peer))); 193 | 194 | //connect market nodes to csma nodes. 195 | for(int i=0;imarket.Get(0), model->csma[i].Get(0)); 201 | 202 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 203 | addresses.Assign(csma1dbell1); 204 | 205 | ip.str(string()); 206 | } 207 | 208 | NodeContainer gldnodes; 209 | for(int i=0;icsma[i].Get(j)); 212 | } 213 | } 214 | 215 | /* the '1' below is the offset where number of nodes begins */ 216 | FncsApplicationHelper help(model->nodeNamePrefixes, 1); 217 | fncsaps.Add(help.Install(gldnodes)); 218 | fncsaps.Add(help.Install(model->market.Get(0), model->marketname)); 219 | } 220 | 221 | fncsaps.Start (Seconds (0.0)); 222 | fncsaps.Stop (Seconds (259200.0)); 223 | 224 | Simulator::Run (); 225 | Simulator::Destroy (); 226 | } 227 | -------------------------------------------------------------------------------- /Database/4_Nodes_492_Houses/ns-3.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-1ile-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation; 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 General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "ns3/core-module.h" 18 | #include "ns3/network-module.h" 19 | #include "ns3/internet-module.h" 20 | #include "ns3/point-to-point-module.h" 21 | #include "ns3/applications-module.h" 22 | #include "ns3/nix-vector-routing-module.h" 23 | #include "ns3/mobility-module.h" 24 | #include "ns3/csma-module.h" 25 | #include "ns3/point-to-point-dumbbell.h" 26 | #include "ns3/bridge-helper.h" 27 | #include "ns3/wifi-module.h" 28 | #include "ns3/netanim-module.h" 29 | #include "ns3/wimax-helper.h" 30 | #include "ns3/lte-helper.h" 31 | #include "ns3/ipv4.h" 32 | #include "ns3/fncs-application.h" 33 | #include "ns3/fncs-application-helper.h" 34 | #include "ns3/fncs-simulator-impl.h" 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | using namespace ns3; 43 | using namespace std; 44 | int data_rate_peer_to_peer; 45 | int delay_peer_to_peer; 46 | int data_rate_cluster; //10000000bps = 10 Mbps 47 | int delay_cluster; //3 MilliSeconds 48 | 49 | 50 | 51 | 52 | 53 | struct MarketModel{ 54 | string nodeNamePrefixes; 55 | int numberofnodes; 56 | int numberofgroups; 57 | string marketname; 58 | vector csma; 59 | NodeContainer market; 60 | }; 61 | 62 | vector parseLinkModel(string name) { 63 | 64 | vector toReturn; 65 | ifstream inputFile(name.c_str()); 66 | if(!inputFile.good()) 67 | throw std::invalid_argument("Cannot open file!"); 68 | 69 | MarketModel *toAdd; 70 | while(!inputFile.eof()){ 71 | toAdd=new MarketModel(); 72 | inputFile >> toAdd->numberofnodes 73 | >> toAdd->marketname 74 | >> toAdd->nodeNamePrefixes; 75 | toAdd->numberofgroups = (toAdd->numberofnodes+19)/20; 76 | if(toAdd->numberofnodes==0) //ifstream zicti 77 | continue; 78 | toReturn.push_back(toAdd); 79 | } 80 | return toReturn; 81 | 82 | } 83 | 84 | int main (int argc, char *argv[]) 85 | { 86 | data_rate_peer_to_peer = 40000000;//40000000bps = 4 Mbps 87 | delay_peer_to_peer = 3; 88 | data_rate_cluster = 10000000; //10000000bps = 10 Mbps 89 | delay_cluster = 3; //3 MilliSeconds 90 | // Don't remove 91 | //Flag 92 | 93 | if(argc < 2){ 94 | cout << "Usage ./first " << endl; 95 | return 0; 96 | } 97 | int totalNumberOfNodes=0; 98 | 99 | /* reads the list of market models from the linkModel file*/ 100 | 101 | /* Each market model is defined by its 102 | * size (Number of HVAC/controllers) 103 | * Name of Market (MarkNIF) 104 | * Prefix of Node Names ( Prefix for controller name) 105 | * the busid of the bus, market is connected to 106 | */ 107 | /* totalNumberOfNodes is the sum of size of all market model */ 108 | vector networks = parseLinkModel(string(argv[1])); 109 | 110 | cout << "Creating " << networks.size() << " networks." << endl; 111 | for (size_t i=0; inumberofgroups << " groups of " 114 | << networks[i]->numberofnodes << " nodes total" << endl; 115 | totalNumberOfNodes += networks[i]->numberofnodes; 116 | if (networks[i]->numberofgroups > 255) { 117 | cerr << "too many groups" << endl; 118 | return EXIT_FAILURE; 119 | } 120 | } 121 | cout << "Total number of nodes is " << totalNumberOfNodes << "." << endl; 122 | 123 | FncsSimulatorImpl *hb=new FncsSimulatorImpl(); 124 | Ptr hb2(hb); 125 | hb->Unref(); 126 | Simulator::SetImplementation(hb2); 127 | 128 | LogComponentEnable ("FncsApplication", LOG_LEVEL_INFO); 129 | 130 | Ipv4NixVectorHelper nixRouting; 131 | Ipv4StaticRoutingHelper staticRouting; 132 | Ipv4AddressHelper addresses; 133 | InternetStackHelper ihelper; 134 | Ipv4ListRoutingHelper list; 135 | list.Add (staticRouting, 0); 136 | list.Add (nixRouting, 10); 137 | ihelper.SetRoutingHelper (list); 138 | 139 | CsmaHelper chelper; 140 | 141 | //ns3::DataRate::DataRate ( uint64_t bps ) bps bit/s value 142 | 143 | 144 | //chelper.SetChannelAttribute ("DataRate", DataRateValue (10000000)); 145 | //chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (3))); 146 | 147 | //chelper.SetChannelAttribute ("DataRate", StringValue ("4Mbps")); 148 | //chelper.SetChannelAttribute ("Delay", StringValue ("1000000ms")); 149 | 150 | chelper.SetChannelAttribute ("DataRate", DataRateValue (data_rate_cluster)); 151 | chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_cluster))); 152 | 153 | ApplicationContainer fncsaps; 154 | 155 | /* Create the various networks. */ 156 | for (size_t netIndex=0; netIndexnumberofgroups; 164 | model->csma.resize(groups); 165 | for (int csmaIndex=0; csmaIndexcsma[csmaIndex].Create(21); 167 | } 168 | model->market.Create(1); 169 | 170 | ihelper.Install(model->market); 171 | 172 | NetDeviceContainer *csmaDevices = new NetDeviceContainer[groups]; 173 | 174 | for(int i=0;icsma[i]); 179 | 180 | ihelper.Install(model->csma[i]); 181 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 182 | addresses.Assign(csmaDevices[i]); 183 | ip.str(string()); 184 | } 185 | 186 | PointToPointHelper phelper3; 187 | //phelper3.SetDeviceAttribute ("DataRate", StringValue ("4Mbps")); 188 | // phelper3.SetChannelAttribute ("Delay", StringValue ("2ms")); 189 | 190 | 191 | phelper3.SetDeviceAttribute ("DataRate", DataRateValue (data_rate_peer_to_peer)); 192 | phelper3.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_peer_to_peer))); 193 | 194 | //connect market nodes to csma nodes. 195 | for(int i=0;imarket.Get(0), model->csma[i].Get(0)); 201 | 202 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 203 | addresses.Assign(csma1dbell1); 204 | 205 | ip.str(string()); 206 | } 207 | 208 | NodeContainer gldnodes; 209 | for(int i=0;icsma[i].Get(j)); 212 | } 213 | } 214 | 215 | /* the '1' below is the offset where number of nodes begins */ 216 | FncsApplicationHelper help(model->nodeNamePrefixes, 1); 217 | fncsaps.Add(help.Install(gldnodes)); 218 | fncsaps.Add(help.Install(model->market.Get(0), model->marketname)); 219 | } 220 | 221 | fncsaps.Start (Seconds (0.0)); 222 | fncsaps.Stop (Seconds (259200.0)); 223 | 224 | Simulator::Run (); 225 | Simulator::Destroy (); 226 | } 227 | -------------------------------------------------------------------------------- /Database/13_Nodes_15_Houses/run_ns-3.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-1ile-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation; 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 General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "ns3/core-module.h" 18 | #include "ns3/network-module.h" 19 | #include "ns3/internet-module.h" 20 | #include "ns3/point-to-point-module.h" 21 | #include "ns3/applications-module.h" 22 | #include "ns3/nix-vector-routing-module.h" 23 | #include "ns3/mobility-module.h" 24 | #include "ns3/csma-module.h" 25 | #include "ns3/point-to-point-dumbbell.h" 26 | #include "ns3/bridge-helper.h" 27 | #include "ns3/wifi-module.h" 28 | #include "ns3/netanim-module.h" 29 | #include "ns3/wimax-helper.h" 30 | #include "ns3/lte-helper.h" 31 | #include "ns3/ipv4.h" 32 | #include "ns3/fncs-application.h" 33 | #include "ns3/fncs-application-helper.h" 34 | #include "ns3/fncs-simulator-impl.h" 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | using namespace ns3; 43 | using namespace std; 44 | int data_rate_peer_to_peer; 45 | int delay_peer_to_peer; 46 | int data_rate_cluster; //10000000bps = 10 Mbps 47 | int delay_cluster; //3 MilliSeconds 48 | 49 | 50 | 51 | 52 | 53 | struct MarketModel{ 54 | string nodeNamePrefixes; 55 | int numberofnodes; 56 | int numberofgroups; 57 | string marketname; 58 | vector csma; 59 | NodeContainer market; 60 | }; 61 | 62 | vector parseLinkModel(string name) { 63 | 64 | vector toReturn; 65 | ifstream inputFile(name.c_str()); 66 | if(!inputFile.good()) 67 | throw std::invalid_argument("Cannot open file!"); 68 | 69 | MarketModel *toAdd; 70 | while(!inputFile.eof()){ 71 | toAdd=new MarketModel(); 72 | inputFile >> toAdd->numberofnodes 73 | >> toAdd->marketname 74 | >> toAdd->nodeNamePrefixes; 75 | toAdd->numberofgroups = (toAdd->numberofnodes+19)/20; 76 | if(toAdd->numberofnodes==0) //ifstream zicti 77 | continue; 78 | toReturn.push_back(toAdd); 79 | } 80 | return toReturn; 81 | 82 | } 83 | 84 | int main (int argc, char *argv[]) 85 | { 86 | data_rate_peer_to_peer = 40000000;//40000000bps = 4 Mbps 87 | delay_peer_to_peer = 3; 88 | data_rate_cluster = 10000000; //10000000bps = 10 Mbps 89 | delay_cluster = 3; //3 MilliSeconds 90 | // Don't remove 91 | //Flag 92 | data_rate_cluster = 2000000;// 93 | delay_cluster = 50;// 94 | 95 | if(argc < 2){ 96 | cout << "Usage ./first " << endl; 97 | return 0; 98 | } 99 | int totalNumberOfNodes=0; 100 | 101 | /* reads the list of market models from the linkModel file*/ 102 | 103 | /* Each market model is defined by its 104 | * size (Number of HVAC/controllers) 105 | * Name of Market (MarkNIF) 106 | * Prefix of Node Names ( Prefix for controller name) 107 | * the busid of the bus, market is connected to 108 | */ 109 | /* totalNumberOfNodes is the sum of size of all market model */ 110 | vector networks = parseLinkModel(string(argv[1])); 111 | 112 | cout << "Creating " << networks.size() << " networks." << endl; 113 | for (size_t i=0; inumberofgroups << " groups of " 116 | << networks[i]->numberofnodes << " nodes total" << endl; 117 | totalNumberOfNodes += networks[i]->numberofnodes; 118 | if (networks[i]->numberofgroups > 255) { 119 | cerr << "too many groups" << endl; 120 | return EXIT_FAILURE; 121 | } 122 | } 123 | cout << "Total number of nodes is " << totalNumberOfNodes << "." << endl; 124 | 125 | FncsSimulatorImpl *hb=new FncsSimulatorImpl(); 126 | Ptr hb2(hb); 127 | hb->Unref(); 128 | Simulator::SetImplementation(hb2); 129 | 130 | LogComponentEnable ("FncsApplication", LOG_LEVEL_INFO); 131 | 132 | Ipv4NixVectorHelper nixRouting; 133 | Ipv4StaticRoutingHelper staticRouting; 134 | Ipv4AddressHelper addresses; 135 | InternetStackHelper ihelper; 136 | Ipv4ListRoutingHelper list; 137 | list.Add (staticRouting, 0); 138 | list.Add (nixRouting, 10); 139 | ihelper.SetRoutingHelper (list); 140 | 141 | CsmaHelper chelper; 142 | 143 | //ns3::DataRate::DataRate ( uint64_t bps ) bps bit/s value 144 | 145 | 146 | //chelper.SetChannelAttribute ("DataRate", DataRateValue (10000000)); 147 | //chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (3))); 148 | 149 | //chelper.SetChannelAttribute ("DataRate", StringValue ("4Mbps")); 150 | //chelper.SetChannelAttribute ("Delay", StringValue ("1000000ms")); 151 | 152 | chelper.SetChannelAttribute ("DataRate", DataRateValue (data_rate_cluster)); 153 | chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_cluster))); 154 | 155 | ApplicationContainer fncsaps; 156 | 157 | /* Create the various networks. */ 158 | for (size_t netIndex=0; netIndexnumberofgroups; 166 | model->csma.resize(groups); 167 | for (int csmaIndex=0; csmaIndexcsma[csmaIndex].Create(21); 169 | } 170 | model->market.Create(1); 171 | 172 | ihelper.Install(model->market); 173 | 174 | NetDeviceContainer *csmaDevices = new NetDeviceContainer[groups]; 175 | 176 | for(int i=0;icsma[i]); 181 | 182 | ihelper.Install(model->csma[i]); 183 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 184 | addresses.Assign(csmaDevices[i]); 185 | ip.str(string()); 186 | } 187 | 188 | PointToPointHelper phelper3; 189 | //phelper3.SetDeviceAttribute ("DataRate", StringValue ("4Mbps")); 190 | // phelper3.SetChannelAttribute ("Delay", StringValue ("2ms")); 191 | 192 | 193 | phelper3.SetDeviceAttribute ("DataRate", DataRateValue (data_rate_peer_to_peer)); 194 | phelper3.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_peer_to_peer))); 195 | 196 | //connect market nodes to csma nodes. 197 | for(int i=0;imarket.Get(0), model->csma[i].Get(0)); 203 | 204 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 205 | addresses.Assign(csma1dbell1); 206 | 207 | ip.str(string()); 208 | } 209 | 210 | NodeContainer gldnodes; 211 | for(int i=0;icsma[i].Get(j)); 214 | } 215 | } 216 | 217 | /* the '1' below is the offset where number of nodes begins */ 218 | FncsApplicationHelper help(model->nodeNamePrefixes, 1); 219 | fncsaps.Add(help.Install(gldnodes)); 220 | fncsaps.Add(help.Install(model->market.Get(0), model->marketname)); 221 | } 222 | 223 | fncsaps.Start (Seconds (0.0)); 224 | fncsaps.Stop (Seconds (259200.0)); 225 | 226 | Simulator::Run (); 227 | Simulator::Destroy (); 228 | } 229 | -------------------------------------------------------------------------------- /Database/4_Nodes_492_Houses/run_ns-3.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-1ile-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation; 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 General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "ns3/core-module.h" 18 | #include "ns3/network-module.h" 19 | #include "ns3/internet-module.h" 20 | #include "ns3/point-to-point-module.h" 21 | #include "ns3/applications-module.h" 22 | #include "ns3/nix-vector-routing-module.h" 23 | #include "ns3/mobility-module.h" 24 | #include "ns3/csma-module.h" 25 | #include "ns3/point-to-point-dumbbell.h" 26 | #include "ns3/bridge-helper.h" 27 | #include "ns3/wifi-module.h" 28 | #include "ns3/netanim-module.h" 29 | #include "ns3/wimax-helper.h" 30 | #include "ns3/lte-helper.h" 31 | #include "ns3/ipv4.h" 32 | #include "ns3/fncs-application.h" 33 | #include "ns3/fncs-application-helper.h" 34 | #include "ns3/fncs-simulator-impl.h" 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | using namespace ns3; 43 | using namespace std; 44 | int data_rate_peer_to_peer; 45 | int delay_peer_to_peer; 46 | int data_rate_cluster; //10000000bps = 10 Mbps 47 | int delay_cluster; //3 MilliSeconds 48 | 49 | 50 | 51 | 52 | 53 | struct MarketModel{ 54 | string nodeNamePrefixes; 55 | int numberofnodes; 56 | int numberofgroups; 57 | string marketname; 58 | vector csma; 59 | NodeContainer market; 60 | }; 61 | 62 | vector parseLinkModel(string name) { 63 | 64 | vector toReturn; 65 | ifstream inputFile(name.c_str()); 66 | if(!inputFile.good()) 67 | throw std::invalid_argument("Cannot open file!"); 68 | 69 | MarketModel *toAdd; 70 | while(!inputFile.eof()){ 71 | toAdd=new MarketModel(); 72 | inputFile >> toAdd->numberofnodes 73 | >> toAdd->marketname 74 | >> toAdd->nodeNamePrefixes; 75 | toAdd->numberofgroups = (toAdd->numberofnodes+19)/20; 76 | if(toAdd->numberofnodes==0) //ifstream zicti 77 | continue; 78 | toReturn.push_back(toAdd); 79 | } 80 | return toReturn; 81 | 82 | } 83 | 84 | int main (int argc, char *argv[]) 85 | { 86 | data_rate_peer_to_peer = 40000000;//40000000bps = 4 Mbps 87 | delay_peer_to_peer = 3; 88 | data_rate_cluster = 10000000; //10000000bps = 10 Mbps 89 | delay_cluster = 3; //3 MilliSeconds 90 | // Don't remove 91 | //Flag 92 | data_rate_cluster = 2000000;// 93 | delay_cluster = 50;// 94 | 95 | if(argc < 2){ 96 | cout << "Usage ./first " << endl; 97 | return 0; 98 | } 99 | int totalNumberOfNodes=0; 100 | 101 | /* reads the list of market models from the linkModel file*/ 102 | 103 | /* Each market model is defined by its 104 | * size (Number of HVAC/controllers) 105 | * Name of Market (MarkNIF) 106 | * Prefix of Node Names ( Prefix for controller name) 107 | * the busid of the bus, market is connected to 108 | */ 109 | /* totalNumberOfNodes is the sum of size of all market model */ 110 | vector networks = parseLinkModel(string(argv[1])); 111 | 112 | cout << "Creating " << networks.size() << " networks." << endl; 113 | for (size_t i=0; inumberofgroups << " groups of " 116 | << networks[i]->numberofnodes << " nodes total" << endl; 117 | totalNumberOfNodes += networks[i]->numberofnodes; 118 | if (networks[i]->numberofgroups > 255) { 119 | cerr << "too many groups" << endl; 120 | return EXIT_FAILURE; 121 | } 122 | } 123 | cout << "Total number of nodes is " << totalNumberOfNodes << "." << endl; 124 | 125 | FncsSimulatorImpl *hb=new FncsSimulatorImpl(); 126 | Ptr hb2(hb); 127 | hb->Unref(); 128 | Simulator::SetImplementation(hb2); 129 | 130 | LogComponentEnable ("FncsApplication", LOG_LEVEL_INFO); 131 | 132 | Ipv4NixVectorHelper nixRouting; 133 | Ipv4StaticRoutingHelper staticRouting; 134 | Ipv4AddressHelper addresses; 135 | InternetStackHelper ihelper; 136 | Ipv4ListRoutingHelper list; 137 | list.Add (staticRouting, 0); 138 | list.Add (nixRouting, 10); 139 | ihelper.SetRoutingHelper (list); 140 | 141 | CsmaHelper chelper; 142 | 143 | //ns3::DataRate::DataRate ( uint64_t bps ) bps bit/s value 144 | 145 | 146 | //chelper.SetChannelAttribute ("DataRate", DataRateValue (10000000)); 147 | //chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (3))); 148 | 149 | //chelper.SetChannelAttribute ("DataRate", StringValue ("4Mbps")); 150 | //chelper.SetChannelAttribute ("Delay", StringValue ("1000000ms")); 151 | 152 | chelper.SetChannelAttribute ("DataRate", DataRateValue (data_rate_cluster)); 153 | chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_cluster))); 154 | 155 | ApplicationContainer fncsaps; 156 | 157 | /* Create the various networks. */ 158 | for (size_t netIndex=0; netIndexnumberofgroups; 166 | model->csma.resize(groups); 167 | for (int csmaIndex=0; csmaIndexcsma[csmaIndex].Create(21); 169 | } 170 | model->market.Create(1); 171 | 172 | ihelper.Install(model->market); 173 | 174 | NetDeviceContainer *csmaDevices = new NetDeviceContainer[groups]; 175 | 176 | for(int i=0;icsma[i]); 181 | 182 | ihelper.Install(model->csma[i]); 183 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 184 | addresses.Assign(csmaDevices[i]); 185 | ip.str(string()); 186 | } 187 | 188 | PointToPointHelper phelper3; 189 | //phelper3.SetDeviceAttribute ("DataRate", StringValue ("4Mbps")); 190 | // phelper3.SetChannelAttribute ("Delay", StringValue ("2ms")); 191 | 192 | 193 | phelper3.SetDeviceAttribute ("DataRate", DataRateValue (data_rate_peer_to_peer)); 194 | phelper3.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_peer_to_peer))); 195 | 196 | //connect market nodes to csma nodes. 197 | for(int i=0;imarket.Get(0), model->csma[i].Get(0)); 203 | 204 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 205 | addresses.Assign(csma1dbell1); 206 | 207 | ip.str(string()); 208 | } 209 | 210 | NodeContainer gldnodes; 211 | for(int i=0;icsma[i].Get(j)); 214 | } 215 | } 216 | 217 | /* the '1' below is the offset where number of nodes begins */ 218 | FncsApplicationHelper help(model->nodeNamePrefixes, 1); 219 | fncsaps.Add(help.Install(gldnodes)); 220 | fncsaps.Add(help.Install(model->market.Get(0), model->marketname)); 221 | } 222 | 223 | fncsaps.Start (Seconds (0.0)); 224 | fncsaps.Stop (Seconds (259200.0)); 225 | 226 | Simulator::Run (); 227 | Simulator::Destroy (); 228 | } 229 | -------------------------------------------------------------------------------- /Database/13_Nodes_73_Houses/run_ns-3.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-1ile-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation; 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 General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "ns3/core-module.h" 18 | #include "ns3/network-module.h" 19 | #include "ns3/internet-module.h" 20 | #include "ns3/point-to-point-module.h" 21 | #include "ns3/applications-module.h" 22 | #include "ns3/nix-vector-routing-module.h" 23 | #include "ns3/mobility-module.h" 24 | #include "ns3/csma-module.h" 25 | #include "ns3/point-to-point-dumbbell.h" 26 | #include "ns3/bridge-helper.h" 27 | #include "ns3/wifi-module.h" 28 | #include "ns3/netanim-module.h" 29 | #include "ns3/wimax-helper.h" 30 | #include "ns3/lte-helper.h" 31 | #include "ns3/ipv4.h" 32 | #include "ns3/fncs-application.h" 33 | #include "ns3/fncs-application-helper.h" 34 | #include "ns3/fncs-simulator-impl.h" 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | using namespace ns3; 43 | using namespace std; 44 | int data_rate_peer_to_peer; 45 | int delay_peer_to_peer; 46 | int data_rate_cluster; //10000000bps = 10 Mbps 47 | int delay_cluster; //3 MilliSeconds 48 | 49 | 50 | 51 | 52 | 53 | struct MarketModel{ 54 | string nodeNamePrefixes; 55 | int numberofnodes; 56 | int numberofgroups; 57 | string marketname; 58 | vector csma; 59 | NodeContainer market; 60 | }; 61 | 62 | vector parseLinkModel(string name) { 63 | 64 | vector toReturn; 65 | ifstream inputFile(name.c_str()); 66 | if(!inputFile.good()) 67 | throw std::invalid_argument("Cannot open file!"); 68 | 69 | MarketModel *toAdd; 70 | while(!inputFile.eof()){ 71 | toAdd=new MarketModel(); 72 | inputFile >> toAdd->numberofnodes 73 | >> toAdd->marketname 74 | >> toAdd->nodeNamePrefixes; 75 | toAdd->numberofgroups = (toAdd->numberofnodes+19)/20; 76 | if(toAdd->numberofnodes==0) //ifstream zicti 77 | continue; 78 | toReturn.push_back(toAdd); 79 | } 80 | return toReturn; 81 | 82 | } 83 | 84 | int main (int argc, char *argv[]) 85 | { 86 | data_rate_peer_to_peer = 40000000;//40000000 bps = 4 Mbps 87 | delay_peer_to_peer = 3; 88 | data_rate_cluster = 10000000; //10000000 bps = 10 Mbps 89 | delay_cluster = 3; //3 MilliSeconds 90 | // Don't remove 91 | //Flag 92 | data_rate_cluster = 5000000;// 93 | delay_cluster = 50;// 94 | 95 | if(argc < 2){ 96 | cout << "Usage ./first " << endl; 97 | return 0; 98 | } 99 | int totalNumberOfNodes=0; 100 | 101 | /* reads the list of market models from the linkModel file*/ 102 | 103 | /* Each market model is defined by its 104 | * size (Number of HVAC/controllers) 105 | * Name of Market (MarkNIF) 106 | * Prefix of Node Names ( Prefix for controller name) 107 | * the busid of the bus, market is connected to 108 | */ 109 | /* totalNumberOfNodes is the sum of size of all market model */ 110 | vector networks = parseLinkModel(string(argv[1])); 111 | 112 | cout << "Creating " << networks.size() << " networks." << endl; 113 | for (size_t i=0; inumberofgroups << " groups of " 116 | << networks[i]->numberofnodes << " nodes total" << endl; 117 | totalNumberOfNodes += networks[i]->numberofnodes; 118 | if (networks[i]->numberofgroups > 255) { 119 | cerr << "too many groups" << endl; 120 | return EXIT_FAILURE; 121 | } 122 | } 123 | cout << "Total number of nodes is " << totalNumberOfNodes << "." << endl; 124 | 125 | FncsSimulatorImpl *hb=new FncsSimulatorImpl(); 126 | Ptr hb2(hb); 127 | hb->Unref(); 128 | Simulator::SetImplementation(hb2); 129 | 130 | LogComponentEnable ("FncsApplication", LOG_LEVEL_INFO); 131 | 132 | Ipv4NixVectorHelper nixRouting; 133 | Ipv4StaticRoutingHelper staticRouting; 134 | Ipv4AddressHelper addresses; 135 | InternetStackHelper ihelper; 136 | Ipv4ListRoutingHelper list; 137 | list.Add (staticRouting, 0); 138 | list.Add (nixRouting, 10); 139 | ihelper.SetRoutingHelper (list); 140 | 141 | CsmaHelper chelper; 142 | 143 | //ns3::DataRate::DataRate ( uint64_t bps ) bps bit/s value 144 | 145 | 146 | //chelper.SetChannelAttribute ("DataRate", DataRateValue (10000000)); 147 | //chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (3))); 148 | 149 | //chelper.SetChannelAttribute ("DataRate", StringValue ("4Mbps")); 150 | //chelper.SetChannelAttribute ("Delay", StringValue ("1000000ms")); 151 | 152 | chelper.SetChannelAttribute ("DataRate", DataRateValue (data_rate_cluster)); 153 | chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_cluster))); 154 | 155 | ApplicationContainer fncsaps; 156 | 157 | /* Create the various networks. */ 158 | for (size_t netIndex=0; netIndexnumberofgroups; 166 | model->csma.resize(groups); 167 | for (int csmaIndex=0; csmaIndexcsma[csmaIndex].Create(21); 169 | } 170 | model->market.Create(1); 171 | 172 | ihelper.Install(model->market); 173 | 174 | NetDeviceContainer *csmaDevices = new NetDeviceContainer[groups]; 175 | 176 | for(int i=0;icsma[i]); 181 | 182 | ihelper.Install(model->csma[i]); 183 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 184 | addresses.Assign(csmaDevices[i]); 185 | ip.str(string()); 186 | } 187 | 188 | PointToPointHelper phelper3; 189 | //phelper3.SetDeviceAttribute ("DataRate", StringValue ("4Mbps")); 190 | // phelper3.SetChannelAttribute ("Delay", StringValue ("2ms")); 191 | 192 | 193 | phelper3.SetDeviceAttribute ("DataRate", DataRateValue (data_rate_peer_to_peer)); 194 | phelper3.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_peer_to_peer))); 195 | 196 | //connect market nodes to csma nodes. 197 | for(int i=0;imarket.Get(0), model->csma[i].Get(0)); 203 | 204 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 205 | addresses.Assign(csma1dbell1); 206 | 207 | ip.str(string()); 208 | } 209 | 210 | NodeContainer gldnodes; 211 | for(int i=0;icsma[i].Get(j)); 214 | } 215 | } 216 | 217 | /* the '1' below is the offset where number of nodes begins */ 218 | FncsApplicationHelper help(model->nodeNamePrefixes, 1); 219 | fncsaps.Add(help.Install(gldnodes)); 220 | fncsaps.Add(help.Install(model->market.Get(0), model->marketname)); 221 | } 222 | 223 | fncsaps.Start (Seconds (0.0)); 224 | fncsaps.Stop (Seconds (259200.0)); 225 | 226 | Simulator::Run (); 227 | Simulator::Destroy (); 228 | } 229 | -------------------------------------------------------------------------------- /Database/4_Nodes_1_House/run_ns-3.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-1ile-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation; 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 General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "ns3/core-module.h" 18 | #include "ns3/network-module.h" 19 | #include "ns3/internet-module.h" 20 | #include "ns3/point-to-point-module.h" 21 | #include "ns3/applications-module.h" 22 | #include "ns3/nix-vector-routing-module.h" 23 | #include "ns3/mobility-module.h" 24 | #include "ns3/csma-module.h" 25 | #include "ns3/point-to-point-dumbbell.h" 26 | #include "ns3/bridge-helper.h" 27 | #include "ns3/wifi-module.h" 28 | #include "ns3/netanim-module.h" 29 | #include "ns3/wimax-helper.h" 30 | #include "ns3/lte-helper.h" 31 | #include "ns3/ipv4.h" 32 | #include "ns3/fncs-application.h" 33 | #include "ns3/fncs-application-helper.h" 34 | #include "ns3/fncs-simulator-impl.h" 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | using namespace ns3; 43 | using namespace std; 44 | int data_rate_peer_to_peer; 45 | int delay_peer_to_peer; 46 | int data_rate_cluster; //10000000bps = 10 Mbps 47 | int delay_cluster; //3 MilliSeconds 48 | 49 | 50 | 51 | 52 | 53 | struct MarketModel{ 54 | string nodeNamePrefixes; 55 | int numberofnodes; 56 | int numberofgroups; 57 | string marketname; 58 | vector csma; 59 | NodeContainer market; 60 | }; 61 | 62 | vector parseLinkModel(string name) { 63 | 64 | vector toReturn; 65 | ifstream inputFile(name.c_str()); 66 | if(!inputFile.good()) 67 | throw std::invalid_argument("Cannot open file!"); 68 | 69 | MarketModel *toAdd; 70 | while(!inputFile.eof()){ 71 | toAdd=new MarketModel(); 72 | inputFile >> toAdd->numberofnodes 73 | >> toAdd->marketname 74 | >> toAdd->nodeNamePrefixes; 75 | toAdd->numberofgroups = (toAdd->numberofnodes+19)/20; 76 | if(toAdd->numberofnodes==0) //ifstream zicti 77 | continue; 78 | toReturn.push_back(toAdd); 79 | } 80 | return toReturn; 81 | 82 | } 83 | 84 | int main (int argc, char *argv[]) 85 | { 86 | data_rate_peer_to_peer = 40000000;//40000000bps = 4 Mbps 87 | delay_peer_to_peer = 3; 88 | data_rate_cluster = 10000000; //10000000bps = 10 Mbps 89 | delay_cluster = 3; //3 MilliSeconds 90 | // Don't remove 91 | //Flag 92 | data_rate_peer_to_peer = 1000000;// 93 | delay_peer_to_peer = 100;// 94 | 95 | if(argc < 2){ 96 | cout << "Usage ./first " << endl; 97 | return 0; 98 | } 99 | int totalNumberOfNodes=0; 100 | 101 | /* reads the list of market models from the linkModel file*/ 102 | 103 | /* Each market model is defined by its 104 | * size (Number of HVAC/controllers) 105 | * Name of Market (MarkNIF) 106 | * Prefix of Node Names ( Prefix for controller name) 107 | * the busid of the bus, market is connected to 108 | */ 109 | /* totalNumberOfNodes is the sum of size of all market model */ 110 | vector networks = parseLinkModel(string(argv[1])); 111 | 112 | cout << "Creating " << networks.size() << " networks." << endl; 113 | for (size_t i=0; inumberofgroups << " groups of " 116 | << networks[i]->numberofnodes << " nodes total" << endl; 117 | totalNumberOfNodes += networks[i]->numberofnodes; 118 | if (networks[i]->numberofgroups > 255) { 119 | cerr << "too many groups" << endl; 120 | return EXIT_FAILURE; 121 | } 122 | } 123 | cout << "Total number of nodes is " << totalNumberOfNodes << "." << endl; 124 | 125 | FncsSimulatorImpl *hb=new FncsSimulatorImpl(); 126 | Ptr hb2(hb); 127 | hb->Unref(); 128 | Simulator::SetImplementation(hb2); 129 | 130 | LogComponentEnable ("FncsApplication", LOG_LEVEL_INFO); 131 | 132 | Ipv4NixVectorHelper nixRouting; 133 | Ipv4StaticRoutingHelper staticRouting; 134 | Ipv4AddressHelper addresses; 135 | InternetStackHelper ihelper; 136 | Ipv4ListRoutingHelper list; 137 | list.Add (staticRouting, 0); 138 | list.Add (nixRouting, 10); 139 | ihelper.SetRoutingHelper (list); 140 | 141 | CsmaHelper chelper; 142 | 143 | //ns3::DataRate::DataRate ( uint64_t bps ) bps bit/s value 144 | 145 | 146 | //chelper.SetChannelAttribute ("DataRate", DataRateValue (10000000)); 147 | //chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (3))); 148 | 149 | //chelper.SetChannelAttribute ("DataRate", StringValue ("4Mbps")); 150 | //chelper.SetChannelAttribute ("Delay", StringValue ("1000000ms")); 151 | 152 | chelper.SetChannelAttribute ("DataRate", DataRateValue (data_rate_cluster)); 153 | chelper.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_cluster))); 154 | 155 | ApplicationContainer fncsaps; 156 | 157 | /* Create the various networks. */ 158 | for (size_t netIndex=0; netIndexnumberofgroups; 166 | model->csma.resize(groups); 167 | for (int csmaIndex=0; csmaIndexcsma[csmaIndex].Create(21); 169 | } 170 | model->market.Create(1); 171 | 172 | ihelper.Install(model->market); 173 | 174 | NetDeviceContainer *csmaDevices = new NetDeviceContainer[groups]; 175 | 176 | for(int i=0;icsma[i]); 181 | 182 | ihelper.Install(model->csma[i]); 183 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 184 | addresses.Assign(csmaDevices[i]); 185 | ip.str(string()); 186 | } 187 | 188 | PointToPointHelper phelper3; 189 | //phelper3.SetDeviceAttribute ("DataRate", StringValue ("4Mbps")); 190 | // phelper3.SetChannelAttribute ("Delay", StringValue ("2ms")); 191 | 192 | 193 | phelper3.SetDeviceAttribute ("DataRate", DataRateValue (data_rate_peer_to_peer)); 194 | phelper3.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (delay_peer_to_peer))); 195 | 196 | //connect market nodes to csma nodes. 197 | for(int i=0;imarket.Get(0), model->csma[i].Get(0)); 203 | 204 | addresses.SetBase(ip.str().c_str(),"255.255.255.0"); 205 | addresses.Assign(csma1dbell1); 206 | 207 | ip.str(string()); 208 | } 209 | 210 | NodeContainer gldnodes; 211 | for(int i=0;icsma[i].Get(j)); 214 | } 215 | } 216 | 217 | /* the '1' below is the offset where number of nodes begins */ 218 | FncsApplicationHelper help(model->nodeNamePrefixes, 1); 219 | fncsaps.Add(help.Install(gldnodes)); 220 | fncsaps.Add(help.Install(model->market.Get(0), model->marketname)); 221 | } 222 | 223 | fncsaps.Start (Seconds (0.0)); 224 | fncsaps.Stop (Seconds (259200.0)); 225 | 226 | Simulator::Run (); 227 | Simulator::Destroy (); 228 | } 229 | -------------------------------------------------------------------------------- /GridAttackSim.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter.ttk import * 3 | from tkinter import ttk 4 | import tkinter.font as tkfont 5 | import json 6 | import shutil 7 | import os 8 | import sys 9 | import fileinput 10 | import subprocess 11 | from tkinter import messagebox 12 | from tkinter import Menu 13 | import time 14 | import glob 15 | import datetime 16 | from graphviz import Source 17 | window = Tk() 18 | 19 | window.title("Smart Grid Simulation") 20 | window.option_add( "*font", "Times 14" ) 21 | 22 | window.geometry() 23 | window.config(bg="#D6E2F3") 24 | 25 | database_path = "Database/" 26 | 27 | 28 | menu = Menu(window) 29 | 30 | menu_file = Menu(menu) 31 | menu_file.add_command(label='New', font=("Times", 11)) 32 | 33 | menu_file.add_separator() 34 | 35 | menu_file.add_command(label='Open', font=("Times", 11)) 36 | 37 | menu_file.add_separator() 38 | 39 | menu_file.add_command(label='Exit', font=("Times", 11)) 40 | 41 | menu.add_cascade(label='File', menu=menu_file, font=("Times", 11)) 42 | 43 | menu_documents = Menu(menu) 44 | menu_documents.add_command(label='Document', font=("Times", 11)) 45 | menu.add_cascade(label='Document', menu=menu_documents, font=("Times", 11)) 46 | 47 | 48 | menu_help = Menu(menu) 49 | menu_help.add_command(label='Contact Us', font=("Times", 11)) 50 | menu.add_cascade(label='Help', menu=menu_help, font=("Times", 11)) 51 | 52 | menu.config(bg='#49A') 53 | 54 | window.config(menu=menu) 55 | 56 | 57 | 58 | 59 | 60 | 61 | lbl = Label(window, text="Smart Grid Attack Simulation System ", font=("Times", 18), background="#D6E2F3", foreground="#000280") 62 | 63 | lbl.grid(column=0, row=0, columnspan=2) 64 | 65 | 66 | lbl_smartgrid_model = Label(window, text=" Smart Grid Model\n", background="#D6E2F3", foreground="#000280") 67 | # sticky="W" left align 68 | lbl_smartgrid_model.grid(sticky="W", column=0, row=2) 69 | lbl_smartgrid_model.config(width=18) 70 | combo_smartgrid_model = Combobox(window, width=35) 71 | 72 | combo_smartgrid_model['values']= ("1 Node 255 Houses", 73 | "4 Nodes 1 House", 74 | "4 Nodes 492 Houses", 75 | "13 Nodes 15 Houses", 76 | "13 Nodes 73 Houses") 77 | 78 | combo_smartgrid_model.current(4) #set the selected item 79 | 80 | combo_smartgrid_model.grid(column=1, row=2) 81 | 82 | 83 | 84 | def show_model(): 85 | 86 | path_1 = database_path+combo_smartgrid_model.get().replace(" ", "_") + '/'+'GridLab-D.glm' 87 | path_2 = database_path+combo_smartgrid_model.get().replace(" ", "_") + '/'+'GridLab-D.dot' 88 | os.system('python glmMap.py ' + path_1 + ' ' + path_2) 89 | s = Source.from_file(path_2) 90 | s.view() 91 | print(os.getcwd()) 92 | 93 | 94 | 95 | 96 | btn_show_model = Button(window, text=" Show Model", command=show_model) 97 | btn_show_model.grid(column=2, row=2) 98 | 99 | 100 | 101 | 102 | 103 | lbl_application = Label( window, justify=LEFT, anchor="w", text=" Application\n", background="#D6E2F3", foreground="#000280") 104 | lbl_application.grid(sticky="W", column=0, row=4) 105 | combo_application = Combobox(window, width=35) 106 | 107 | combo_application ['values']= ("Demand/Response (DR)", "Dynamic Pricing (DP)", "Both DR and DP") 108 | 109 | combo_application.current(0) #set the selected item 110 | 111 | combo_application.grid(column=1, row=4) 112 | 113 | 114 | 115 | 116 | 117 | 118 | def on_attack_category_change(index, value, op): 119 | if combo_attack_category.get() == "Nefarious Activity": 120 | combo_attack_type['values']= ("1 - Channel Jamming - Cluster", 121 | "2 - Channel Jamming - Peer-to-Peer", 122 | "3 - DNS attacks - Cluster", 123 | "4 - DNS attacks - Peer-to-Peer", 124 | "5 - Injection Attacks - Control Systems", 125 | "6 - Injection Attacks - End-point Systems", 126 | "7 - Malicious Code - End-point Systems") 127 | combo_attack_type.current(0) #set the selected item 128 | elif combo_attack_category.get() == "Eavesdropping, Interception and Hijacking": 129 | combo_attack_type['values']= ("8 - Replay of Messages - Cluster", 130 | "9 - Replay of Messages - Peer-to-Peer") 131 | combo_attack_type.current(0) #set the selected item 132 | elif combo_attack_category.get() == "None": 133 | combo_attack_type['values']= ("None") 134 | combo_attack_type.current(0) #set the selected item 135 | 136 | 137 | 138 | 139 | 140 | 141 | string_attack_category = StringVar() 142 | string_attack_category.trace('w',on_attack_category_change) 143 | lbl_attack_category = Label(window, text=" Attack Category\n", background="#D6E2F3", foreground="#000280") 144 | lbl_attack_category.grid(sticky="W", column=0, row=6) 145 | combo_attack_category = Combobox(window, textvar=string_attack_category, width=35) 146 | 147 | combo_attack_category['values']= ("None","Nefarious Activity", "Eavesdropping, Interception and Hijacking") 148 | 149 | 150 | 151 | 152 | combo_attack_category.grid(column=1, row=6) 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | lbl_attack_type = Label(window, text=" Attack Type\n", background="#D6E2F3", foreground="#000280") 161 | lbl_attack_type.grid(sticky="W", column=0, row=8) 162 | combo_attack_type = Combobox(window, width=35) 163 | 164 | 165 | combo_attack_type.grid(column=1, row=8) 166 | 167 | 168 | 169 | 170 | 171 | 172 | #Check Process is running or not 173 | def is_running(pid): 174 | try: 175 | os.kill(pid, 0) 176 | except OSError: 177 | return False 178 | 179 | return True 180 | 181 | def run(): 182 | messagebox.showinfo("Message", "The simulation is running") 183 | string_code = 'python attack_broker.py ' + database_path+combo_smartgrid_model.get().replace(" ", "_") + '/ '+ combo_attack_type.get()[0:1] 184 | 185 | current_time = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") 186 | os.system(string_code) 187 | 188 | messagebox.showinfo("Message", "The simulation has been finished") 189 | os.chdir(database_path+combo_smartgrid_model.get().replace(" ", "_") + '/') 190 | os.system('mv baseprice_clearedprice_clearedquantity.csv ' + 'price_' +combo_attack_type.get().replace(" ", "_").replace("-", "")+'_'+ current_time + '.csv') 191 | 192 | os.system('mv totalload.csv ' + 'totalload_' +combo_attack_type.get().replace(" ", "_").replace("-", "")+'_'+ current_time + '.csv') 193 | 194 | os.chdir("..") 195 | os.chdir("..") 196 | 197 | 198 | 199 | 200 | 201 | def result(): 202 | Lb_files.delete(0, END) 203 | path = database_path+combo_smartgrid_model.get().replace(" ", "_") + '/' 204 | extension = 'csv' 205 | print(os.getcwd()) 206 | os.chdir(path) 207 | file_list = glob.glob('*.{}'.format(extension)) 208 | #print(file_list) 209 | j = 0 210 | if combo_application.get() == "Demand/Response (DR)": 211 | for i in range(len(file_list)): 212 | if(file_list[i][0]=="t"): 213 | #print(file_list[i].find('totalload')) 214 | Lb_files.insert(j, file_list[i]) 215 | j = j+1 216 | elif combo_application.get() == "Dynamic Pricing (DP)": 217 | for i in range(len(file_list)): 218 | if(file_list[i][0]=="p"): 219 | #print(file_list[i].find('baseprice')) 220 | Lb_files.insert(j, file_list[i]) 221 | j = j+1 222 | else: 223 | for i in range(len(file_list)): 224 | if(file_list[i][0]=="p" or file_list[i][0]=="t"): 225 | Lb_files.insert(j, file_list[i]) 226 | j = j+1 227 | os.chdir("..") 228 | os.chdir("..") 229 | 230 | 231 | 232 | btn_run = Button(window, text="Run Simulation", command=run) 233 | btn_run.grid(column=0, row=10) 234 | 235 | 236 | btn_result= Button(window, text="Load Results", command=result) 237 | btn_result.grid(column=1, row=10) 238 | 239 | 240 | lbl_result = Label(window, text="\nSimulation Results", font=("Times", 18), background="#D6E2F3", foreground="#000280") 241 | 242 | lbl_result.grid(column=0, row=11, columnspan=2) 243 | lbl_files = Label(window, text="Output Files", background="#D6E2F3", foreground="#000280") 244 | lbl_files.grid(column=0, row=12) 245 | 246 | 247 | 248 | 249 | Lb_files = Listbox(window, width=35, selectmode=MULTIPLE, height = 10) 250 | Lb_files.grid(row=12, column=1) 251 | 252 | 253 | 254 | def show(): 255 | plot_price = "null:" 256 | plot_totalload = "null:" 257 | selection = Lb_files.curselection() 258 | for i in selection: 259 | print(i) 260 | if(Lb_files.get(i)[0]=='t'): 261 | plot_totalload += Lb_files.get(i)+':' 262 | elif(Lb_files.get(i)[0]=='p'): 263 | plot_price += Lb_files.get(i)+':' 264 | 265 | 266 | os.system('python3 plot_result.py '+ database_path+combo_smartgrid_model.get().replace(" ", "_") + '/ '+ plot_price +' '+ plot_totalload) 267 | 268 | 269 | btn_show = Button(window, text="Show Charts", command=show) 270 | btn_show.grid(column=1, row=13) 271 | 272 | 273 | 274 | 275 | 276 | window.mainloop() 277 | --------------------------------------------------------------------------------