9 |
10 | // opp_msgc version check
11 | #define MSGC_VERSION 0x0402
12 | #if (MSGC_VERSION!=OMNETPP_VERSION)
13 | # error Version mismatch! Probably this file was generated by an earlier version of opp_msgc: 'make clean' should help.
14 | #endif
15 |
16 | // dll export symbol
17 | #ifndef SCADASim_API
18 | # if defined(SCADASim_EXPORT)
19 | # define SCADASim_API OPP_DLLEXPORT
20 | # elif defined(SCADASim_IMPORT)
21 | # define SCADASim_API OPP_DLLIMPORT
22 | # else
23 | # define SCADASim_API
24 | # endif
25 | #endif
26 |
27 | // cplusplus {{
28 | #include "IPControlInfo.h"
29 | #include "ReaSEDefs.h"
30 | // }}
31 |
32 |
33 |
34 | /**
35 | * Class generated from networklayer/contract/IPControlInfo_hacked.msg by opp_msgc.
36 | *
37 | * class IPControlInfo_hacked extends IPControlInfo
38 | * {
39 | *
40 | * short attackTag = 0;
41 | * }
42 | *
43 | */
44 | class SCADASim_API IPControlInfo_hacked : public ::IPControlInfo
45 | {
46 | protected:
47 | short attackTag_var;
48 |
49 | // protected and unimplemented operator==(), to prevent accidental usage
50 | bool operator==(const IPControlInfo_hacked&);
51 |
52 | public:
53 | IPControlInfo_hacked();
54 | IPControlInfo_hacked(const IPControlInfo_hacked& other);
55 | virtual ~IPControlInfo_hacked();
56 | IPControlInfo_hacked& operator=(const IPControlInfo_hacked& other);
57 | virtual IPControlInfo_hacked *dup() const {return new IPControlInfo_hacked(*this);}
58 | virtual void parsimPack(cCommBuffer *b);
59 | virtual void parsimUnpack(cCommBuffer *b);
60 |
61 | // field getter/setter methods
62 | virtual short getAttackTag() const;
63 | virtual void setAttackTag(short attackTag);
64 | };
65 |
66 | inline void doPacking(cCommBuffer *b, IPControlInfo_hacked& obj) {obj.parsimPack(b);}
67 | inline void doUnpacking(cCommBuffer *b, IPControlInfo_hacked& obj) {obj.parsimUnpack(b);}
68 |
69 |
70 | #endif // _IPCONTROLINFO_HACKED_M_H_
71 |
--------------------------------------------------------------------------------
/src/networklayer/contract/IPv6ControlInfo_hacked.msg:
--------------------------------------------------------------------------------
1 | cplusplus {{
2 | #include "IPv6ControlInfo.h"
3 | #include "ReaSEDefs.h"
4 | }}
5 |
6 | class noncobject IPv6ControlInfo;
7 |
8 | class IPv6ControlInfo_hacked extends IPv6ControlInfo
9 | {
10 | // ReaSE: for attack tracing, each IP packet contains an attackTag
11 | short attackTag = 0;
12 | }
13 |
--------------------------------------------------------------------------------
/src/networklayer/contract/IPv6ControlInfo_hacked_m.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file, do not edit! Created by opp_msgc 4.2 from networklayer/contract/IPv6ControlInfo_hacked.msg.
3 | //
4 |
5 | #ifndef _IPV6CONTROLINFO_HACKED_M_H_
6 | #define _IPV6CONTROLINFO_HACKED_M_H_
7 |
8 | #include
9 |
10 | // opp_msgc version check
11 | #define MSGC_VERSION 0x0402
12 | #if (MSGC_VERSION!=OMNETPP_VERSION)
13 | # error Version mismatch! Probably this file was generated by an earlier version of opp_msgc: 'make clean' should help.
14 | #endif
15 |
16 | // dll export symbol
17 | #ifndef SCADASim_API
18 | # if defined(SCADASim_EXPORT)
19 | # define SCADASim_API OPP_DLLEXPORT
20 | # elif defined(SCADASim_IMPORT)
21 | # define SCADASim_API OPP_DLLIMPORT
22 | # else
23 | # define SCADASim_API
24 | # endif
25 | #endif
26 |
27 | // cplusplus {{
28 | #include "IPv6ControlInfo.h"
29 | #include "ReaSEDefs.h"
30 | // }}
31 |
32 |
33 |
34 | /**
35 | * Class generated from networklayer/contract/IPv6ControlInfo_hacked.msg by opp_msgc.
36 | *
37 | * class IPv6ControlInfo_hacked extends IPv6ControlInfo
38 | * {
39 | *
40 | * short attackTag = 0;
41 | * }
42 | *
43 | */
44 | class SCADASim_API IPv6ControlInfo_hacked : public ::IPv6ControlInfo
45 | {
46 | protected:
47 | short attackTag_var;
48 |
49 | // protected and unimplemented operator==(), to prevent accidental usage
50 | bool operator==(const IPv6ControlInfo_hacked&);
51 |
52 | public:
53 | IPv6ControlInfo_hacked();
54 | IPv6ControlInfo_hacked(const IPv6ControlInfo_hacked& other);
55 | virtual ~IPv6ControlInfo_hacked();
56 | IPv6ControlInfo_hacked& operator=(const IPv6ControlInfo_hacked& other);
57 | virtual IPv6ControlInfo_hacked *dup() const {return new IPv6ControlInfo_hacked(*this);}
58 | virtual void parsimPack(cCommBuffer *b);
59 | virtual void parsimUnpack(cCommBuffer *b);
60 |
61 | // field getter/setter methods
62 | virtual short getAttackTag() const;
63 | virtual void setAttackTag(short attackTag);
64 | };
65 |
66 | inline void doPacking(cCommBuffer *b, IPv6ControlInfo_hacked& obj) {obj.parsimPack(b);}
67 | inline void doUnpacking(cCommBuffer *b, IPv6ControlInfo_hacked& obj) {obj.parsimUnpack(b);}
68 |
69 |
70 | #endif // _IPV6CONTROLINFO_HACKED_M_H_
71 |
--------------------------------------------------------------------------------
/src/networklayer/ipv4/IPDatagram_hacked.msg:
--------------------------------------------------------------------------------
1 | cplusplus {{
2 | #include "IPDatagram.h"
3 | #include "ReaSEDefs.h"
4 | }}
5 |
6 | packet IPDatagram;
7 |
8 | packet IPDatagram_hacked extends IPDatagram
9 | {
10 | // ReaSE: for attack tracing each IP packet contains an attackTag
11 | short attackTag = 0;
12 | }
13 |
--------------------------------------------------------------------------------
/src/networklayer/ipv4/IPDatagram_hacked_m.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file, do not edit! Created by opp_msgc 4.2 from networklayer/ipv4/IPDatagram_hacked.msg.
3 | //
4 |
5 | #ifndef _IPDATAGRAM_HACKED_M_H_
6 | #define _IPDATAGRAM_HACKED_M_H_
7 |
8 | #include
9 |
10 | // opp_msgc version check
11 | #define MSGC_VERSION 0x0402
12 | #if (MSGC_VERSION!=OMNETPP_VERSION)
13 | # error Version mismatch! Probably this file was generated by an earlier version of opp_msgc: 'make clean' should help.
14 | #endif
15 |
16 | // dll export symbol
17 | #ifndef SCADASim_API
18 | # if defined(SCADASim_EXPORT)
19 | # define SCADASim_API OPP_DLLEXPORT
20 | # elif defined(SCADASim_IMPORT)
21 | # define SCADASim_API OPP_DLLIMPORT
22 | # else
23 | # define SCADASim_API
24 | # endif
25 | #endif
26 |
27 | // cplusplus {{
28 | #include "IPDatagram.h"
29 | #include "ReaSEDefs.h"
30 | // }}
31 |
32 |
33 |
34 | /**
35 | * Class generated from networklayer/ipv4/IPDatagram_hacked.msg by opp_msgc.
36 | *
37 | * packet IPDatagram_hacked extends IPDatagram
38 | * {
39 | *
40 | * short attackTag = 0;
41 | * }
42 | *
43 | */
44 | class SCADASim_API IPDatagram_hacked : public ::IPDatagram
45 | {
46 | protected:
47 | short attackTag_var;
48 |
49 | // protected and unimplemented operator==(), to prevent accidental usage
50 | bool operator==(const IPDatagram_hacked&);
51 |
52 | public:
53 | IPDatagram_hacked(const char *name=NULL, int kind=0);
54 | IPDatagram_hacked(const IPDatagram_hacked& other);
55 | virtual ~IPDatagram_hacked();
56 | IPDatagram_hacked& operator=(const IPDatagram_hacked& other);
57 | virtual IPDatagram_hacked *dup() const {return new IPDatagram_hacked(*this);}
58 | virtual void parsimPack(cCommBuffer *b);
59 | virtual void parsimUnpack(cCommBuffer *b);
60 |
61 | // field getter/setter methods
62 | virtual short getAttackTag() const;
63 | virtual void setAttackTag(short attackTag);
64 | };
65 |
66 | inline void doPacking(cCommBuffer *b, IPDatagram_hacked& obj) {obj.parsimPack(b);}
67 | inline void doUnpacking(cCommBuffer *b, IPDatagram_hacked& obj) {obj.parsimUnpack(b);}
68 |
69 |
70 | #endif // _IPDATAGRAM_HACKED_M_H_
71 |
--------------------------------------------------------------------------------
/src/networklayer/ipv4/IP_hack.h:
--------------------------------------------------------------------------------
1 | #ifndef IP_HACK_H_
2 | #define IP_HACK_H_
3 |
4 | #include
5 | #include "IP.h"
6 | #include "IPDatagram_hacked_m.h"
7 | #include "ReaSEDefs.h"
8 |
9 | /**
10 | * @brief Extension of the original IP protocol.
11 | *
12 | * Extends the original IP protocol of INET by address spoofing and
13 | * packet tracing.
14 | * These tasks are necessary for simulation of attacks
15 | */
16 | class REASE_API IP_hack : public IP
17 | {
18 | protected:
19 | // service flags
20 | bool tracingOn, spoofingAllowed;
21 |
22 | // statistics
23 | cOutVector output, tcpout, udpout, icmpout;
24 |
25 | // state
26 | bool startTrace;
27 | int totalTrace, udpTrace, tcpTrace, icmpTrace;
28 | int totalPackets, udpPackets, tcpPackets, icmpPackets;
29 | double traceInterval;
30 | cMessage *traceMsg;
31 |
32 | public:
33 | IP_hack();
34 | virtual ~IP_hack();
35 | /// Dispatch received message to correct handler
36 | virtual void endService(cPacket *msg);
37 | void finish();
38 | protected:
39 | virtual void initialize();
40 | /// Includes new feature: Address spoofing
41 | IPDatagram *encapsulate(cPacket *transportPacket, InterfaceEntry *&destIE);
42 | /// Outputs packet counts into vector file
43 | virtual void handleMessage(cMessage *msg);
44 | /// Handle messages from higher layers
45 | virtual void handleMessageFromHL(cPacket *msg);
46 | /// Handle messages from lower layers
47 | virtual void handlePacketFromNetwork(IPDatagram *datagram);
48 | /// Processing of IP options
49 | virtual void processPacket(IPDatagram *datagram, InterfaceEntry *destIE, bool fromHL, bool checkOpts);
50 | };
51 |
52 | #endif /*IP_HACK_H_*/
53 |
--------------------------------------------------------------------------------
/src/networklayer/ipv4/IP_hack.ned:
--------------------------------------------------------------------------------
1 | package scadasim.networklayer.ipv4;
2 |
3 | import inet.networklayer.ipv4.IP;
4 |
5 | //
6 | // An extension of inet.networklayer.ipv4.IP
7 | // This module additionally allows for address spoofing and
8 | // packet tracing
9 | //
10 |
11 | simple IP_hack extends IP
12 | {
13 | parameters:
14 | @class(IP_hack);
15 | bool tracingOn;
16 | double tracingInterval @unit(s);
17 | double traceStartTime @unit(s);
18 | bool spoofingOn; // allow IP-Address Spoofing
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/src/networklayer/queue/DropTailTraceQueue.cc:
--------------------------------------------------------------------------------
1 | #include "DropTailTraceQueue.h"
2 |
3 | Define_Module( DropTailTraceQueue);
4 |
5 | /**
6 | * @brief Drop-tail queue with additional tracing support.
7 | *
8 | * Divides traffic into intervals of equal time-based sizes
9 | * and writes out the packet counts of different aggregates
10 | * observed in the last interval.
11 | *
12 | * @class DropTailTraceQueue
13 | */
14 |
15 | void DropTailTraceQueue::initialize()
16 | {
17 | PassiveQueueBase::initialize();
18 | queue.setName("l2queue");
19 |
20 | frameVec.setName("framesForQueue");
21 | dropVec.setName("dropsForQueue");
22 |
23 | // configuration
24 | frameCapacity = par("frameCapacity");
25 | intervalSize = par("intervalSize");
26 | tracingOn = par("traceOn");
27 | if (tracingOn)
28 | scheduleAt(simTime() + intervalSize, traceMessage);
29 |
30 | traceMessage = new cMessage("traceMsg");
31 |
32 | dropsInInterval = framesInInterval = 0;
33 | }
34 |
35 | /**
36 | * Checks if there is enough space in queue to enqueue this message.
37 | * State variables drops and frames are updated accordingly.
38 | *
39 | * @param msg Message to enqueue
40 | * @return True if message is enqueued, false if queue is full
41 | */
42 | bool DropTailTraceQueue::enqueue(cMessage *msg)
43 | {
44 | if (frameCapacity && queue.length() >= frameCapacity)
45 | {
46 | dropsInInterval++;
47 | delete msg;
48 | return true;
49 | }
50 | else
51 | {
52 | framesInInterval++;
53 | queue.insert(msg);
54 | return false;
55 | }
56 | }
57 |
58 | /**
59 | * Dequeues first message if queue is not empty
60 | *
61 | * @return Dequeued Message
62 | */
63 | cMessage *DropTailTraceQueue::dequeue()
64 | {
65 | if (queue.empty())
66 | return NULL;
67 |
68 | cMessage *pk = (cMessage *) queue.pop();
69 | return pk;
70 | }
71 |
72 | /**
73 | * Sends the given message to gate out.
74 | *
75 | * @param msg Message to be sent
76 | */
77 | void DropTailTraceQueue::sendOut(cMessage *msg)
78 | {
79 | send(msg, "out");
80 | }
81 |
82 | /**
83 | * Handles interval timer message.
84 | *
85 | * In case tracing support is activated, a periodic traceMessage is sent
86 | * and received. In case of reception the recorded values (drops, frames)
87 | * of the current interval are written out to vector file.
88 | * Then the state variables are reset to 0 for the next interval.
89 | *
90 | * @param msg Message to handle
91 | */
92 | void DropTailTraceQueue::handleMessage(cMessage *msg)
93 | {
94 | if (!tracingOn)
95 | PassiveQueueBase::handleMessage(msg);
96 | else
97 | {
98 | if (msg->isSelfMessage())
99 | {
100 | frameVec.recordWithTimestamp(simTime(), framesInInterval);
101 | framesInInterval = 0;
102 | dropVec.recordWithTimestamp(simTime(), dropsInInterval);
103 | dropsInInterval = 0;
104 | scheduleAt(simTime() + intervalSize, msg);
105 | }
106 | else
107 | PassiveQueueBase::handleMessage(msg);
108 | }
109 | }
110 |
111 |
--------------------------------------------------------------------------------
/src/networklayer/queue/DropTailTraceQueue.h:
--------------------------------------------------------------------------------
1 | #ifndef DROPTAILTRACEQUEUE_H_
2 | #define DROPTAILTRACEQUEUE_H_
3 |
4 | #include
5 | #include "PassiveQueueBase.h"
6 |
7 | /**
8 | * @brief Drop-tail queue with additional tracing support.
9 | *
10 | * Divides traffic into intervals of equal time-based length
11 | * and writes out the packet counts of different aggregates
12 | * observed in the last interval into vector file.
13 | *
14 | * @class DropTailTraceQueue
15 | */
16 | class DropTailTraceQueue : public PassiveQueueBase
17 | {
18 | protected:
19 | // configuration
20 | int frameCapacity;
21 | simtime_t intervalSize;
22 | bool tracingOn;
23 |
24 | // state
25 | cQueue queue;
26 | int dropsInInterval;
27 | int framesInInterval;
28 |
29 | // statistics
30 | cOutVector frameVec;
31 | cOutVector dropVec;
32 |
33 | // periodic message to trigger interval end
34 | cMessage *traceMessage;
35 |
36 | protected:
37 | virtual void initialize();
38 |
39 | /**
40 | * Redefined from PassiveQueueBase.
41 | */
42 | virtual bool enqueue(cMessage *msg);
43 |
44 | /**
45 | * Redefined from PassiveQueueBase.
46 | */
47 | virtual cMessage *dequeue();
48 |
49 | /**
50 | * Redefined from PassiveQueueBase.
51 | */
52 | virtual void sendOut(cMessage *msg);
53 |
54 | //virtual void finish(){/*do nothing*/}; //FIXME: is this needed? -Claus
55 |
56 | /**
57 | * Handles interval timer message.
58 | */
59 | virtual void handleMessage(cMessage *msg);
60 |
61 | };
62 |
63 | #endif /*DROPTAILTRACEQUEUE_H_*/
64 |
--------------------------------------------------------------------------------
/src/networklayer/queue/DropTailTraceQueue.ned:
--------------------------------------------------------------------------------
1 | package scadasim.networklayer.queue;
2 |
3 | simple DropTailTraceQueue
4 | {
5 | parameters:
6 | int frameCapacity;
7 | double intervalSize @unit(s);
8 | bool traceOn;
9 | gates:
10 | input in;
11 | output out;
12 | }
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/nodes/inet/BackupServer.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.inet;
2 |
3 | import inet.base.NotificationBoard;
4 | import inet.linklayer.ethernet.EthernetInterface;
5 | import inet.linklayer.ppp.PPPInterface;
6 | import inet.networklayer.common.InterfaceTable;
7 | import inet.networklayer.ipv4.RoutingTable;
8 | import inet.nodes.inet.NetworkLayer;
9 | import inet.util.NAMTraceWriter;
10 | import scadasim.applications.pingApp.GenericICMPPingApplication;
11 | import scadasim.applications.tcpApp.GenericTCPApplication;
12 | import scadasim.transport.tcp.TCP_hack;
13 | import scadasim.transport.udp.UDP_hack;
14 | import inet.transport.tcp.TCP;
15 |
16 | //
17 | // BackupServer: Server system for backup traffic profile using TCP as
18 | // transport protocol.
19 | // This profile generates many large client requests and only few
20 | // server replies.
21 | //
22 | // \IP host with TCP, UDP layers and applications.
23 | //
24 | module BackupServer
25 | {
26 | parameters:
27 | @node();
28 | int namid;
29 | int maxTCPThreadCount;
30 | gates:
31 | inout pppg[];
32 | inout ethg[];
33 | submodules:
34 | namTrace: NAMTraceWriter {
35 | parameters:
36 | namid = namid;
37 | @display("p=60,310;i=block/sink");
38 | }
39 | notificationBoard: NotificationBoard {
40 | parameters:
41 | @display("p=60,70;i=block/control");
42 | }
43 | interfaceTable: InterfaceTable {
44 | parameters:
45 | @display("p=60,150;i=block/table");
46 | }
47 | routingTable: RoutingTable {
48 | parameters:
49 | IPForward = false;
50 | routerId = "";
51 | routingFile = "";
52 | @display("p=60,230;i=block/table");
53 | }
54 | tcpApp: GenericTCPApplication {
55 | parameters:
56 | isServer = true;
57 | profileNumber = 1;
58 | port = 80;
59 | @display("p=163,67;i=block/app");
60 | }
61 | tcp: TCP {
62 | parameters:
63 | // maxThreadCount = maxTCPThreadCount;
64 | @display("p=163,154;i=block/wheelbarrow");
65 | }
66 | udp: UDP_hack {
67 | parameters:
68 | @display("p=272,154;i=block/transport");
69 | }
70 | pingApp: GenericICMPPingApplication {
71 | parameters:
72 | isServer = true;
73 | profileNumber = 21;
74 | port = 0;
75 | @display("i=block/app;p=343,200");
76 | }
77 | networkLayer: NetworkLayer {
78 | parameters:
79 | proxyARP = false;
80 | @display("p=248,247;i=block/fork;q=queue");
81 | gates:
82 | ifIn[sizeof(pppg)+sizeof(ethg)];
83 | ifOut[sizeof(pppg)+sizeof(ethg)];
84 | }
85 | ppp[sizeof(pppg)]: PPPInterface {
86 | parameters:
87 | @display("p=205,350,row,90;q=txQueue;i=block/ifcard");
88 | }
89 | eth[sizeof(ethg)]: EthernetInterface {
90 | parameters:
91 | @display("p=240,350,row,90;q=txQueue;i=block/ifcard");
92 | }
93 | connections allowunconnected:
94 | tcpApp.tcpOut --> tcp.appIn++;
95 | tcpApp.tcpIn <-- tcp.appOut++;
96 |
97 | tcp.ipOut --> networkLayer.tcpIn;
98 | tcp.ipIn <-- networkLayer.tcpOut;
99 |
100 | udp.ipOut --> networkLayer.udpIn;
101 | udp.ipIn <-- networkLayer.udpOut;
102 |
103 | networkLayer.pingOut --> pingApp.pingIn;
104 | networkLayer.pingIn <-- pingApp.pingOut;
105 |
106 | // connections to network outside
107 | for i=0..sizeof(pppg)-1 {
108 | pppg[i] <--> ppp[i].phys;
109 | ppp[i].netwOut --> networkLayer.ifIn[i];
110 | ppp[i].netwIn <-- networkLayer.ifOut[i];
111 | }
112 |
113 | for i=0..sizeof(ethg)-1 {
114 | ethg[i] <--> eth[i].phys;
115 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
116 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/src/nodes/inet/DDoSZombie.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.inet;
2 |
3 | import inet.base.NotificationBoard;
4 | import inet.linklayer.ethernet.EthernetInterface;
5 | import inet.linklayer.ppp.PPPInterface;
6 | import inet.networklayer.common.InterfaceTable;
7 | import inet.networklayer.ipv4.RoutingTable;
8 | import inet.util.NAMTraceWriter;
9 | import scadasim.applications.ddos.TribeFloodNetwork;
10 |
11 |
12 | //
13 | // Compound module which behaves as zombie system in a DDoS attack.
14 | // Therefore, TribeFloodNetwork is included in addition to the normal
15 | // TCP/IP layers
16 | //
17 | // NetworkLayer_hack is used to spoof packets sent during the DDoS attack.
18 | //
19 | module DDoSZombie
20 | {
21 | parameters:
22 | @node();
23 | int namid;
24 | gates:
25 | inout pppg[];
26 | inout ethg[];
27 | submodules:
28 | namTrace: NAMTraceWriter {
29 | parameters:
30 | namid = namid;
31 | @display("p=60,310;i=block/sink");
32 |
33 | }
34 | notificationBoard: NotificationBoard {
35 | parameters:
36 | @display("p=60,70;i=block/control");
37 |
38 | }
39 | interfaceTable: InterfaceTable {
40 | parameters:
41 | @display("p=60,150;i=block/table");
42 |
43 | }
44 | routingTable: RoutingTable {
45 | parameters:
46 | IPForward = false;
47 | routerId = "";
48 | routingFile = "";
49 | @display("p=60,230;i=block/table");
50 |
51 | }
52 | tribeFloodNetwork: TribeFloodNetwork {
53 | parameters:
54 | @display("p=272,154;i=old/telnet");
55 |
56 | }
57 | networkLayer: NetworkLayer_hack {
58 | parameters:
59 | proxyARP = false;
60 | tracingOn = false;
61 | spoofingOn = true;
62 | @display("p=248,247;i=block/fork;q=queue");
63 |
64 | gates:
65 | ifIn[sizeof(pppg)+sizeof(ethg)];
66 | ifOut[sizeof(pppg)+sizeof(ethg)];
67 | }
68 | ppp[sizeof(pppg)]: PPPInterface {
69 | parameters:
70 | @display("p=164,350,row,90;q=txQueue;i=block/ifcard");
71 |
72 | }
73 | eth[sizeof(ethg)]: EthernetInterface {
74 | parameters:
75 | @display("p=272,350,row,90;q=txQueue;i=block/ifcard");
76 |
77 | }
78 | connections allowunconnected:
79 | tribeFloodNetwork.to_ip_tcp --> networkLayer.tcpIn;
80 | tribeFloodNetwork.ipIn++ <-- networkLayer.tcpOut;
81 |
82 | tribeFloodNetwork.to_ip_udp --> networkLayer.udpIn;
83 | tribeFloodNetwork.ipIn++ <-- networkLayer.udpOut;
84 |
85 | tribeFloodNetwork.to_ip_ping --> networkLayer.pingIn;
86 | tribeFloodNetwork.ipIn++ <-- networkLayer.pingOut;
87 |
88 | // connections to network outside
89 | for i=0..sizeof(pppg)-1 {
90 | pppg[i] <--> ppp[i].phys;
91 | ppp[i].netwOut --> networkLayer.ifIn[i];
92 | ppp[i].netwIn <-- networkLayer.ifOut[i];
93 | }
94 |
95 | for i=0..sizeof(ethg)-1 {
96 | ethg[i] <--> eth[i].phys;
97 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
98 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
99 | }
100 |
101 | }
102 |
103 |
--------------------------------------------------------------------------------
/src/nodes/inet/DatabaseServer.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.inet;
2 |
3 | import inet.base.NotificationBoard;
4 | import inet.linklayer.ethernet.EthernetInterface;
5 | import inet.linklayer.ppp.PPPInterface;
6 | import inet.networklayer.common.InterfaceTable;
7 | import inet.networklayer.ipv4.RoutingTable;
8 | import inet.nodes.inet.NetworkLayer;
9 | import inet.util.NAMTraceWriter;
10 | import scadasim.applications.pingApp.GenericICMPPingApplication;
11 | import scadasim.applications.tcpApp.GenericTCPApplication;
12 | import scadasim.transport.tcp.TCP_hack;
13 | import scadasim.transport.udp.UDP_hack;
14 | import inet.transport.tcp.TCP;
15 |
16 | //
17 | // InteractiveServer: Server system for interactive traffic profile using
18 | // TCP as transport protocol.
19 | // This profile generates a similar number of equally large client requests
20 | // and server replies.
21 | //
22 | // \IP host with TCP, UDP layers and applications.
23 | //
24 | module DatabaseServer
25 | {
26 | parameters:
27 | @node();
28 | int namid;
29 | int maxTCPThreadCount;
30 | gates:
31 | inout pppg[];
32 | inout ethg[];
33 | submodules:
34 | namTrace: NAMTraceWriter {
35 | parameters:
36 | namid = namid;
37 | @display("p=60,310;i=block/sink");
38 |
39 | }
40 | notificationBoard: NotificationBoard {
41 | parameters:
42 | @display("p=60,70;i=block/control");
43 |
44 | }
45 | interfaceTable: InterfaceTable {
46 | parameters:
47 | @display("p=60,150;i=block/table");
48 |
49 | }
50 | routingTable: RoutingTable {
51 | parameters:
52 | IPForward = false;
53 | routerId = "";
54 | routingFile = "";
55 | @display("p=60,230;i=block/table");
56 |
57 | }
58 | // tcpApp: GenericTCPApplication {
59 | // parameters:
60 | // isServer = true;
61 | // profileNumber = 2;
62 | // port = 80;
63 | // @display("p=163,67;i=block/app");
64 | //
65 | // }
66 | tcp: TCP {
67 | parameters:
68 | // maxThreadCount = maxTCPThreadCount;
69 | @display("p=163,154;i=block/wheelbarrow");
70 |
71 | }
72 | // udp: UDP_hack {
73 | // parameters:
74 | // @display("p=272,154;i=block/transport");
75 | //
76 | // }
77 | // pingApp: GenericICMPPingApplication {
78 | // parameters:
79 | // isServer = true;
80 | // profileNumber = 21;
81 | // port = 0;
82 | // @display("i=block/app;p=343,200");
83 | //
84 | // }
85 | networkLayer: NetworkLayer {
86 | parameters:
87 | proxyARP = false;
88 | @display("p=248,247;i=block/fork;q=queue");
89 |
90 | gates:
91 | ifIn[sizeof(pppg)+sizeof(ethg)];
92 | ifOut[sizeof(pppg)+sizeof(ethg)];
93 | }
94 | ppp[sizeof(pppg)]: PPPInterface {
95 | parameters:
96 | @display("p=202,350,row,90;q=txQueue;i=block/ifcard");
97 |
98 | }
99 | eth[sizeof(ethg)]: EthernetInterface {
100 | parameters:
101 | @display("p=349,350,row,90;q=txQueue;i=block/ifcard");
102 |
103 | }
104 | connections allowunconnected:
105 | // tcpApp.tcpOut --> tcp.appIn++;
106 | // tcpApp.tcpIn <-- tcp.appOut++;
107 |
108 | tcp.ipOut --> networkLayer.tcpIn;
109 | tcp.ipIn <-- networkLayer.tcpOut;
110 |
111 | // udp.ipOut --> networkLayer.udpIn;
112 | // udp.ipIn <-- networkLayer.udpOut;
113 | //
114 | // networkLayer.pingOut --> pingApp.pingIn;
115 | // networkLayer.pingIn <-- pingApp.pingOut;
116 |
117 | // connections to network outside
118 | for i=0..sizeof(pppg)-1 {
119 | pppg[i] <--> ppp[i].phys;
120 | ppp[i].netwOut --> networkLayer.ifIn[i];
121 | ppp[i].netwIn <-- networkLayer.ifOut[i];
122 | }
123 |
124 | for i=0..sizeof(ethg)-1 {
125 | ethg[i] <--> eth[i].phys;
126 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
127 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
128 | }
129 | }
130 |
131 |
--------------------------------------------------------------------------------
/src/nodes/inet/InetUserHost.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.inet;
2 |
3 | import inet.base.NotificationBoard;
4 | import inet.linklayer.ethernet.EthernetInterface;
5 | import inet.linklayer.ppp.PPPInterface;
6 | import inet.networklayer.common.InterfaceTable;
7 | import inet.networklayer.ipv4.RoutingTable;
8 | import inet.nodes.inet.NetworkLayer;
9 | import inet.util.NAMTraceWriter;
10 | import scadasim.transport.tcp.TCP_hack;
11 | import scadasim.applications.generic.InetUser;
12 | import scadasim.applications.pingApp.GenericICMPPingApplication;
13 | import scadasim.applications.tcpApp.GenericTCPApplication;
14 | import scadasim.applications.udpApp.GenericUDPApplication;
15 | import scadasim.transport.udp.UDP_hack;
16 | import inet.transport.tcp.TCP;
17 |
18 | //
19 | // Default IP host which replaces the standard host of the original
20 | // INET framework.
21 | // This host system consists of TCP, UDP layers and applications.
22 | // In comparison to StandardHost TCP_hack and UDP_hack are used.
23 | // In addition the GenericXXApplications are used for traffic generation
24 | // instead of the original XXApp implementations.
25 | // Thus, only a single application is necessary per protocol type.
26 | //
27 | // Finally, the simple module InetUser is contained that actually requests
28 | // traffic profiles at random times and therefore, creates self-similar
29 | // background traffic.
30 | //
31 | module InetUserHost
32 | {
33 | parameters:
34 | @node();
35 | int namid;
36 | int maxTCPThreadCount;
37 | gates:
38 | inout pppg[];
39 | inout ethg[];
40 | submodules:
41 | namTrace: NAMTraceWriter {
42 | parameters:
43 | namid = namid;
44 | @display("p=60,310;i=block/sink");
45 |
46 | }
47 | inetUser: InetUser {
48 | parameters:
49 | @display("p=60,390;i=abstract/person");
50 |
51 | }
52 | notificationBoard: NotificationBoard {
53 | parameters:
54 | @display("p=60,70;i=block/control");
55 |
56 | }
57 | interfaceTable: InterfaceTable {
58 | parameters:
59 | @display("p=60,150;i=block/table");
60 |
61 | }
62 | routingTable: RoutingTable {
63 | parameters:
64 | IPForward = false;
65 | routerId = "";
66 | routingFile = "";
67 | @display("p=60,230;i=block/table");
68 |
69 | }
70 | clientTCP: GenericTCPApplication {
71 | parameters:
72 | isServer = false;
73 | profileNumber = 3;
74 | port = 1;
75 | @display("p=163,67;i=block/app");
76 |
77 | }
78 | tcp: TCP {
79 | parameters:
80 | //maxThreadCount = maxTCPThreadCount;
81 | @display("p=163,154;i=block/wheelbarrow");
82 |
83 | }
84 | // udpApp: GenericUDPApplication {
85 | // parameters:
86 | // isServer = false;
87 | // profileNumber = 13;
88 | // port = 2101;
89 | // noThreads = 0;
90 | // @display("i=block/app;p=272,67");
91 | //
92 | // }
93 | // udp: UDP_hack {
94 | // parameters:
95 | // @display("p=272,154;i=block/transport");
96 | //
97 | // }
98 | // pingApp: GenericICMPPingApplication {
99 | // parameters:
100 | // isServer = false;
101 | // profileNumber = 21;
102 | // port = 0;
103 | // noThreads = 0;
104 | // @display("i=block/app;p=343,200");
105 | //
106 | // }
107 | networkLayer: NetworkLayer_hack {
108 | parameters:
109 | proxyARP = false;
110 | @display("p=248,247;i=block/fork;q=queue");
111 |
112 | gates:
113 | ifIn[sizeof(pppg)+sizeof(ethg)];
114 | ifOut[sizeof(pppg)+sizeof(ethg)];
115 | }
116 | ppp[sizeof(pppg)]: PPPInterface {
117 | parameters:
118 | @display("p=163,350,row,90;q=txQueue;i=block/ifcard");
119 |
120 | }
121 | eth[sizeof(ethg)]: EthernetInterface {
122 | parameters:
123 | @display("p=297,350,row,90;q=txQueue;i=block/ifcard");
124 |
125 | }
126 | connections allowunconnected:
127 | clientTCP.tcpOut --> tcp.appIn++;
128 | clientTCP.tcpIn <-- tcp.appOut++;
129 | tcp.ipOut --> networkLayer.tcpIn;
130 | tcp.ipIn <-- networkLayer.tcpOut;
131 |
132 | // udpApp.udpOut --> udp.appIn++;
133 | // udpApp.udpIn <-- udp.appOut++;
134 | //
135 | // udp.ipOut --> networkLayer.udpIn;
136 | // udp.ipIn <-- networkLayer.udpOut;
137 | //
138 | // networkLayer.pingOut --> pingApp.pingIn;
139 | // networkLayer.pingIn <-- pingApp.pingOut;
140 |
141 | // connections to network outside
142 | for i=0..sizeof(pppg)-1 {
143 | pppg[i] <--> ppp[i].phys;
144 | ppp[i].netwOut --> networkLayer.ifIn[i];
145 | ppp[i].netwIn <-- networkLayer.ifOut[i];
146 | }
147 |
148 | for i=0..sizeof(ethg)-1 {
149 | ethg[i] <--> eth[i].phys;
150 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
151 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
152 | }
153 |
154 | }
155 |
156 |
--------------------------------------------------------------------------------
/src/nodes/inet/InteractiveServer.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.inet;
2 |
3 | import inet.base.NotificationBoard;
4 | import inet.linklayer.ethernet.EthernetInterface;
5 | import inet.linklayer.ppp.PPPInterface;
6 | import inet.networklayer.common.InterfaceTable;
7 | import inet.networklayer.ipv4.RoutingTable;
8 | import inet.nodes.inet.NetworkLayer;
9 | import inet.util.NAMTraceWriter;
10 | import scadasim.applications.pingApp.GenericICMPPingApplication;
11 | import scadasim.applications.tcpApp.GenericTCPApplication;
12 | import scadasim.transport.tcp.TCP_hack;
13 | import scadasim.transport.udp.UDP_hack;
14 | import inet.transport.tcp.TCP;
15 |
16 | //
17 | // InteractiveServer: Server system for interactive traffic profile using
18 | // TCP as transport protocol.
19 | // This profile generates a similar number of equally large client requests
20 | // and server replies.
21 | //
22 | // \IP host with TCP, UDP layers and applications.
23 | //
24 | module InteractiveServer
25 | {
26 | parameters:
27 | @node();
28 | int namid;
29 | int maxTCPThreadCount;
30 | gates:
31 | inout pppg[];
32 | inout ethg[];
33 | submodules:
34 | namTrace: NAMTraceWriter {
35 | parameters:
36 | namid = namid;
37 | @display("p=60,310;i=block/sink");
38 |
39 | }
40 | notificationBoard: NotificationBoard {
41 | parameters:
42 | @display("p=60,70;i=block/control");
43 |
44 | }
45 | interfaceTable: InterfaceTable {
46 | parameters:
47 | @display("p=60,150;i=block/table");
48 |
49 | }
50 | routingTable: RoutingTable {
51 | parameters:
52 | IPForward = false;
53 | routerId = "";
54 | routingFile = "";
55 | @display("p=60,230;i=block/table");
56 |
57 | }
58 | tcpApp: GenericTCPApplication {
59 | parameters:
60 | isServer = true;
61 | profileNumber = 2;
62 | port = 80;
63 | @display("p=163,67;i=block/app");
64 |
65 | }
66 | tcp: TCP {
67 | parameters:
68 | // maxThreadCount = maxTCPThreadCount;
69 | @display("p=163,154;i=block/wheelbarrow");
70 |
71 | }
72 | udp: UDP_hack {
73 | parameters:
74 | @display("p=272,154;i=block/transport");
75 |
76 | }
77 | pingApp: GenericICMPPingApplication {
78 | parameters:
79 | isServer = true;
80 | profileNumber = 21;
81 | port = 0;
82 | @display("i=block/app;p=343,200");
83 |
84 | }
85 | networkLayer: NetworkLayer {
86 | parameters:
87 | proxyARP = false;
88 | @display("p=248,247;i=block/fork;q=queue");
89 |
90 | gates:
91 | ifIn[sizeof(pppg)+sizeof(ethg)];
92 | ifOut[sizeof(pppg)+sizeof(ethg)];
93 | }
94 | ppp[sizeof(pppg)]: PPPInterface {
95 | parameters:
96 | @display("p=205,350,row,90;q=txQueue;i=block/ifcard");
97 |
98 | }
99 | eth[sizeof(ethg)]: EthernetInterface {
100 | parameters:
101 | @display("p=240,350,row,90;q=txQueue;i=block/ifcard");
102 |
103 | }
104 | connections allowunconnected:
105 | tcpApp.tcpOut --> tcp.appIn++;
106 | tcpApp.tcpIn <-- tcp.appOut++;
107 |
108 | tcp.ipOut --> networkLayer.tcpIn;
109 | tcp.ipIn <-- networkLayer.tcpOut;
110 |
111 | udp.ipOut --> networkLayer.udpIn;
112 | udp.ipIn <-- networkLayer.udpOut;
113 |
114 | networkLayer.pingOut --> pingApp.pingIn;
115 | networkLayer.pingIn <-- pingApp.pingOut;
116 |
117 | // connections to network outside
118 | for i=0..sizeof(pppg)-1 {
119 | pppg[i] <--> ppp[i].phys;
120 | ppp[i].netwOut --> networkLayer.ifIn[i];
121 | ppp[i].netwIn <-- networkLayer.ifOut[i];
122 | }
123 |
124 | for i=0..sizeof(ethg)-1 {
125 | ethg[i] <--> eth[i].phys;
126 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
127 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
128 | }
129 | }
130 |
131 |
--------------------------------------------------------------------------------
/src/nodes/inet/MailServer.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.inet;
2 |
3 | import inet.base.NotificationBoard;
4 | import inet.linklayer.ethernet.EthernetInterface;
5 | import inet.linklayer.ppp.PPPInterface;
6 | import inet.networklayer.common.InterfaceTable;
7 | import inet.networklayer.ipv4.RoutingTable;
8 | import inet.nodes.inet.NetworkLayer;
9 | import inet.util.NAMTraceWriter;
10 | import scadasim.applications.pingApp.GenericICMPPingApplication;
11 | import scadasim.applications.tcpApp.GenericTCPApplication;
12 | import scadasim.transport.tcp.TCP_hack;
13 | import scadasim.transport.udp.UDP_hack;
14 | import inet.transport.tcp.TCP;
15 |
16 | //
17 | // MailServer: Server system for mail traffic profile using TCP as
18 | // transport protocol.
19 | // This profile generates many small client requests and only few
20 | // server replies.
21 | //
22 | // \IP host with TCP, UDP layers and applications.
23 | //
24 | module MailServer
25 | {
26 | parameters:
27 | @node();
28 | int namid;
29 | int maxTCPThreadCount;
30 | gates:
31 | inout pppg[];
32 | inout ethg[];
33 | submodules:
34 | namTrace: NAMTraceWriter {
35 | parameters:
36 | namid = namid;
37 | @display("p=60,310;i=block/sink");
38 |
39 | }
40 | notificationBoard: NotificationBoard {
41 | parameters:
42 | @display("p=60,70;i=block/control");
43 |
44 | }
45 | interfaceTable: InterfaceTable {
46 | parameters:
47 | @display("p=60,150;i=block/table");
48 |
49 | }
50 | routingTable: RoutingTable {
51 | parameters:
52 | IPForward = false;
53 | routerId = "";
54 | routingFile = "";
55 | @display("p=60,230;i=block/table");
56 |
57 | }
58 | tcpApp: GenericTCPApplication {
59 | parameters:
60 | isServer = true;
61 | profileNumber = 4;
62 | port = 125;
63 | @display("p=163,67;i=block/app");
64 |
65 | }
66 | tcp: TCP {
67 | parameters:
68 | // maxThreadCount = maxTCPThreadCount;
69 | @display("p=163,154;i=block/wheelbarrow");
70 |
71 | }
72 | udp: UDP_hack {
73 | parameters:
74 | @display("p=272,154;i=block/transport");
75 |
76 | }
77 | pingApp: GenericICMPPingApplication {
78 | parameters:
79 | isServer = true;
80 | profileNumber = 21;
81 | port = 0;
82 | @display("i=block/app;p=343,200");
83 |
84 | }
85 | networkLayer: NetworkLayer {
86 | parameters:
87 | proxyARP = false;
88 | @display("p=248,247;i=block/fork;q=queue");
89 |
90 | gates:
91 | ifIn[sizeof(pppg)+sizeof(ethg)];
92 | ifOut[sizeof(pppg)+sizeof(ethg)];
93 | }
94 | ppp[sizeof(pppg)]: PPPInterface {
95 | parameters:
96 | @display("p=205,350,row,90;q=txQueue;i=block/ifcard");
97 |
98 | }
99 | eth[sizeof(ethg)]: EthernetInterface {
100 | parameters:
101 | @display("p=240,350,row,90;q=txQueue;i=block/ifcard");
102 |
103 | }
104 | connections allowunconnected:
105 | tcpApp.tcpOut --> tcp.appIn++;
106 | tcpApp.tcpIn <-- tcp.appOut++;
107 |
108 | tcp.ipOut --> networkLayer.tcpIn;
109 | tcp.ipIn <-- networkLayer.tcpOut;
110 |
111 | udp.ipOut --> networkLayer.udpIn;
112 | udp.ipIn <-- networkLayer.udpOut;
113 |
114 | networkLayer.pingOut --> pingApp.pingIn;
115 | networkLayer.pingIn <-- pingApp.pingOut;
116 |
117 | // connections to network outside
118 | for i=0..sizeof(pppg)-1 {
119 | pppg[i] <--> ppp[i].phys;
120 | ppp[i].netwOut --> networkLayer.ifIn[i];
121 | ppp[i].netwIn <-- networkLayer.ifOut[i];
122 | }
123 |
124 | for i=0..sizeof(ethg)-1 {
125 | ethg[i] <--> eth[i].phys;
126 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
127 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
128 | }
129 | }
130 |
131 |
--------------------------------------------------------------------------------
/src/nodes/inet/NameServer.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.inet;
2 |
3 | import inet.base.NotificationBoard;
4 | import inet.linklayer.ethernet.EthernetInterface;
5 | import inet.linklayer.ppp.PPPInterface;
6 | import inet.networklayer.common.InterfaceTable;
7 | import inet.networklayer.ipv4.RoutingTable;
8 | import inet.nodes.inet.NetworkLayer;
9 | import scadasim.transport.tcp.TCP_hack;
10 | import inet.util.NAMTraceWriter;
11 | import scadasim.applications.pingApp.GenericICMPPingApplication;
12 | import scadasim.applications.udpApp.GenericUDPApplication;
13 | import scadasim.transport.udp.UDP_hack;
14 | import inet.transport.tcp.TCP;
15 | import inet.transport.udp.UDP;
16 | //
17 | // NameServer: Server system for DNS traffic profile using UDP as
18 | // transport protocol.
19 | // This profile generates few small client requests and few small
20 | // server replies.
21 | //
22 | // \IP host with TCP, UDP layers and applications.
23 | //
24 | module NameServer
25 | {
26 | parameters:
27 | @node();
28 | int namid;
29 | int maxTCPThreadCount;
30 | gates:
31 | inout pppg[];
32 | inout ethg[];
33 | submodules:
34 | namTrace: NAMTraceWriter {
35 | parameters:
36 | namid = namid;
37 | @display("p=60,310;i=block/sink");
38 |
39 | }
40 | notificationBoard: NotificationBoard {
41 | parameters:
42 | @display("p=60,70;i=block/control");
43 |
44 | }
45 | interfaceTable: InterfaceTable {
46 | parameters:
47 | @display("p=60,150;i=block/table");
48 |
49 | }
50 | routingTable: RoutingTable {
51 | parameters:
52 | IPForward = false;
53 | routerId = "";
54 | routingFile = "";
55 | @display("p=60,230;i=block/table");
56 |
57 | }
58 | tcp: TCP {
59 | parameters:
60 | @display("p=163,154;i=block/wheelbarrow");
61 | // maxThreadCount = maxTCPThreadCount;
62 |
63 |
64 | }
65 | udpApp: GenericUDPApplication {
66 | parameters:
67 | isServer = true;
68 | profileNumber = 11;
69 | port = 1245;
70 | @display("i=block/app;p=272,67");
71 |
72 | }
73 | udp: UDP {
74 | parameters:
75 | @display("p=272,154;i=block/transport");
76 |
77 | }
78 | pingApp: GenericICMPPingApplication {
79 | parameters:
80 | isServer = true;
81 | profileNumber = 21;
82 | port = 0;
83 | @display("i=block/app;p=343,200");
84 |
85 | }
86 | networkLayer: NetworkLayer {
87 | parameters:
88 | proxyARP = false;
89 | @display("p=248,247;i=block/fork;q=queue");
90 |
91 | gates:
92 | ifIn[sizeof(pppg)+sizeof(ethg)];
93 | ifOut[sizeof(pppg)+sizeof(ethg)];
94 | }
95 | ppp[sizeof(pppg)]: PPPInterface {
96 | parameters:
97 | @display("p=205,350,row,90;q=txQueue;i=block/ifcard");
98 |
99 | }
100 | eth[sizeof(ethg)]: EthernetInterface {
101 | parameters:
102 | @display("p=240,350,row,90;q=txQueue;i=block/ifcard");
103 |
104 | }
105 | connections allowunconnected:
106 | tcp.ipOut --> networkLayer.tcpIn;
107 | tcp.ipIn <-- networkLayer.tcpOut;
108 |
109 | udpApp.udpOut --> udp.appIn++;
110 | udpApp.udpIn <-- udp.appOut++;
111 |
112 | udp.ipOut --> networkLayer.udpIn;
113 | udp.ipIn <-- networkLayer.udpOut;
114 |
115 | networkLayer.pingOut --> pingApp.pingIn;
116 | networkLayer.pingIn <-- pingApp.pingOut;
117 |
118 | // connections to network outside
119 | for i=0..sizeof(pppg)-1 {
120 | pppg[i] <--> ppp[i].phys;
121 | ppp[i].netwOut --> networkLayer.ifIn[i];
122 | ppp[i].netwIn <-- networkLayer.ifOut[i];
123 | }
124 |
125 | for i=0..sizeof(ethg)-1 {
126 | ethg[i] <--> eth[i].phys;
127 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
128 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
129 | }
130 | }
131 |
132 |
--------------------------------------------------------------------------------
/src/nodes/inet/NetworkLayer_hack.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.inet;
2 |
3 | //
4 | // Network layer of an \IP node that includes IP_hack instead of the original
5 | // IP implementation.
6 | // IP_hack allows for spoofing, packet tracing, etc.
7 | //
8 | //
9 |
10 |
11 | import inet.networklayer.arp.ARP;
12 | import inet.networklayer.ipv4.ErrorHandling;
13 | import inet.networklayer.ipv4.ICMP;
14 | import inet.networklayer.ipv4.IGMP;
15 | import scadasim.networklayer.ipv4.IP_hack;
16 |
17 |
18 | //
19 | // Network layer of an \IP node.
20 | //
21 | // Interfaces to transport layer: TCP, UDP, echo/ping, RSVP
22 | //
23 | module NetworkLayer_hack
24 | {
25 | parameters:
26 | bool proxyARP;
27 | bool tracingOn;
28 | bool spoofingOn;
29 | gates:
30 | input ifIn[];
31 | input tcpIn;
32 | input udpIn;
33 | input sctpIn; //I.R.
34 | input rsvpIn;
35 | input ospfIn;
36 | input pingIn;
37 | output ifOut[];
38 | output tcpOut;
39 | output udpOut;
40 | output sctpOut; //I.R.
41 | output rsvpOut;
42 | output ospfOut;
43 | output pingOut;
44 | submodules:
45 | ip: IP_hack {
46 | parameters:
47 | timeToLive = 125;
48 | multicastTimeToLive = 32;
49 | fragmentTimeout = 60s;
50 | protocolMapping = "6:0,17:1,1:2,2:3,46:4,89:5,132:6,254:7,135:7";
51 | spoofingOn = spoofingOn;
52 | tracingOn = tracingOn;
53 | @display("p=85,95;i=block/routing;q=queue");
54 | gates:
55 | transportIn[8];
56 | transportOut[8];
57 | queueIn[sizeof(ifIn)];
58 | }
59 | arp: ARP {
60 | parameters:
61 | proxyARP = proxyARP;
62 | @display("p=163,206;i=block/layer;q=pendingQueue");
63 | gates:
64 | nicOut[sizeof(ifOut)];
65 | }
66 | icmp: ICMP {
67 | parameters:
68 | @display("p=160,63;i=block/control_s");
69 | }
70 | igmp: IGMP {
71 | parameters:
72 | @display("p=160,122;i=block/cogwheel_s");
73 | }
74 | errorHandling: ErrorHandling {
75 | parameters:
76 | @display("p=239,63;i=block/process_s");
77 | }
78 | connections allowunconnected:
79 | // transport Layer
80 | ip.transportOut[0] --> tcpOut;
81 | ip.transportIn[0] <-- tcpIn;
82 |
83 | ip.transportOut[1] --> udpOut;
84 | ip.transportIn[1] <-- udpIn;
85 |
86 | ip.transportOut[2] --> icmp.localIn;
87 | ip.transportIn[2] <-- icmp.sendOut;
88 |
89 | ip.transportOut[3] --> igmp.localIn;
90 | ip.transportIn[3] <-- igmp.sendOut;
91 |
92 | ip.transportOut[4] --> rsvpOut;
93 | ip.transportIn[4] <-- rsvpIn;
94 |
95 | ip.transportOut[5] --> ospfOut;
96 | ip.transportIn[5] <-- ospfIn;
97 |
98 | ip.transportOut[6] --> sctpOut; //I.R.
99 | ip.transportIn[6] <-- sctpIn;
100 |
101 | icmp.pingOut --> pingOut;
102 | icmp.pingIn <-- pingIn;
103 |
104 | icmp.errorOut --> errorHandling.in;
105 |
106 | ip.queueOut --> arp.ipIn;
107 |
108 | // L2 interfaces to IP and from ARP
109 | for i=0..sizeof(ifOut)-1 {
110 | ifIn[i] --> { @display("m=s"); } --> ip.queueIn[i];
111 | ifOut[i] <-- { @display("m=s"); } <-- arp.nicOut[i];
112 | }
113 | }
114 |
115 |
--------------------------------------------------------------------------------
/src/nodes/inet/StreamingServer.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.inet;
2 |
3 | import inet.base.NotificationBoard;
4 | import inet.linklayer.ethernet.EthernetInterface;
5 | import inet.linklayer.ppp.PPPInterface;
6 | import inet.networklayer.common.InterfaceTable;
7 | import inet.networklayer.ipv4.RoutingTable;
8 | import inet.nodes.inet.NetworkLayer;
9 | import scadasim.transport.tcp.TCP_hack;
10 | import inet.util.NAMTraceWriter;
11 | import scadasim.applications.pingApp.GenericICMPPingApplication;
12 | import scadasim.applications.udpApp.GenericUDPApplication;
13 | import scadasim.transport.udp.UDP_hack;
14 | import inet.transport.tcp.TCP;
15 | import inet.transport.udp.UDP;
16 | //
17 | // StreamingServer: Server system for streaming traffic profile using UDP as
18 | // transport protocol.
19 | // This profile generates few client requests and many server replies.
20 | //
21 | // \IP host with TCP, UDP layers and applications.
22 | //
23 | module StreamingServer
24 | {
25 | parameters:
26 | @node();
27 | int namid;
28 | int maxTCPThreadCount;
29 | gates:
30 | inout pppg[];
31 | inout ethg[];
32 | submodules:
33 | namTrace: NAMTraceWriter {
34 | parameters:
35 | namid = namid;
36 | @display("p=60,310;i=block/sink");
37 |
38 | }
39 | notificationBoard: NotificationBoard {
40 | parameters:
41 | @display("p=60,70;i=block/control");
42 |
43 | }
44 | interfaceTable: InterfaceTable {
45 | parameters:
46 | @display("p=60,150;i=block/table");
47 |
48 | }
49 | routingTable: RoutingTable {
50 | parameters:
51 | IPForward = false;
52 | routerId = "";
53 | routingFile = "";
54 | @display("p=60,230;i=block/table");
55 |
56 | }
57 | tcp: TCP {
58 | parameters:
59 | // maxThreadCount = maxTCPThreadCount;
60 | @display("p=163,154;i=block/wheelbarrow");
61 | }
62 | udpApp: GenericUDPApplication {
63 | parameters:
64 | isServer = true;
65 | profileNumber = 12;
66 | port = 1245;
67 | @display("i=block/app;p=272,67");
68 |
69 | }
70 | udp: UDP {
71 | parameters:
72 | @display("p=272,154;i=block/transport");
73 |
74 | }
75 | pingApp: GenericICMPPingApplication {
76 | parameters:
77 | isServer = true;
78 | profileNumber = 21;
79 | port = 0;
80 | @display("i=block/app;p=343,200");
81 |
82 | }
83 | networkLayer: NetworkLayer {
84 | parameters:
85 | proxyARP = false;
86 | @display("p=248,247;i=block/fork;q=queue");
87 |
88 | gates:
89 | ifIn[sizeof(pppg)+sizeof(ethg)];
90 | ifOut[sizeof(pppg)+sizeof(ethg)];
91 | }
92 | ppp[sizeof(pppg)]: PPPInterface {
93 | parameters:
94 | @display("p=205,350,row,90;q=txQueue;i=block/ifcard");
95 |
96 | }
97 | eth[sizeof(ethg)]: EthernetInterface {
98 | parameters:
99 | @display("p=240,350,row,90;q=txQueue;i=block/ifcard");
100 |
101 | }
102 | connections allowunconnected:
103 | tcp.ipOut --> networkLayer.tcpIn;
104 | tcp.ipIn <-- networkLayer.tcpOut;
105 |
106 | udpApp.udpOut --> udp.appIn++;
107 | udpApp.udpIn <-- udp.appOut++;
108 |
109 | udp.ipOut --> networkLayer.udpIn;
110 | udp.ipIn <-- networkLayer.udpOut;
111 |
112 | networkLayer.pingOut --> pingApp.pingIn;
113 | networkLayer.pingIn <-- pingApp.pingOut;
114 |
115 | // connections to network outside
116 | for i=0..sizeof(pppg)-1 {
117 | pppg[i] <--> ppp[i].phys;
118 | ppp[i].netwOut --> networkLayer.ifIn[i];
119 | ppp[i].netwIn <-- networkLayer.ifOut[i];
120 | }
121 |
122 | for i=0..sizeof(ethg)-1 {
123 | ethg[i] <--> eth[i].phys;
124 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
125 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
126 | }
127 | }
128 |
129 |
--------------------------------------------------------------------------------
/src/nodes/inet/TraceRouter.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.inet;
2 |
3 | //
4 | //Router-Module that traces packet
5 | //
6 |
7 | import inet.base.NotificationBoard;
8 | import inet.linklayer.ethernet.EthernetInterface;
9 | import inet.linklayer.ppp.PPPInterface;
10 | import inet.networklayer.common.InterfaceTable;
11 | import inet.networklayer.ipv4.RoutingTable;
12 | import inet.util.NAMTraceWriter;
13 |
14 |
15 | //
16 | // \IP router that is able to trace packets
17 | // Tracing means that the number of packets, observed within a certain
18 | // time period, is written to a file. This observation is done
19 | // periodically within fix interval lengths.
20 | //
21 | module TraceRouter
22 | {
23 | parameters:
24 | @node();
25 | string routingFile;
26 | gates:
27 | inout pppg[];
28 | inout ethg[];
29 | submodules:
30 | namTrace: NAMTraceWriter {
31 | parameters:
32 | namid = -1; // auto
33 | @display("p=330,60;i=block/sink");
34 | }
35 | notificationBoard: NotificationBoard {
36 | parameters:
37 | @display("p=60,60;i=block/control");
38 | }
39 | interfaceTable: InterfaceTable {
40 | parameters:
41 | @display("p=150,60;i=block/table");
42 | }
43 | routingTable: RoutingTable {
44 | parameters:
45 | IPForward = true;
46 | routerId = "auto";
47 | routingFile = routingFile;
48 | @display("p=240,60;i=block/table");
49 | }
50 | networkLayer: NetworkLayer_hack {
51 | parameters:
52 | tracingOn = true;
53 | spoofingOn = false;
54 | @display("p=200,141;i=block/fork;q=queue");
55 | gates:
56 | ifIn[sizeof(pppg)+sizeof(ethg)];
57 | ifOut[sizeof(pppg)+sizeof(ethg)];
58 | }
59 | ppp[sizeof(pppg)]: PPPInterface {
60 | parameters:
61 | @display("p=90,257,row,110;q=l2queue;i=block/ifcard");
62 | }
63 | eth[sizeof(ethg)]: EthernetInterface {
64 | parameters:
65 | @display("p=145,257,row,110;q=l2queue;i=block/ifcard");
66 | }
67 | connections allowunconnected:
68 | // connections to network outside
69 | for i=0..sizeof(pppg)-1 {
70 | pppg[i] <--> ppp[i].phys;
71 | ppp[i].netwOut --> networkLayer.ifIn[i];
72 | ppp[i].netwIn <-- networkLayer.ifOut[i];
73 | }
74 |
75 | for i=0..sizeof(ethg)-1 {
76 | ethg[i] <--> eth[i].phys;
77 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
78 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
79 | }
80 | }
81 |
82 |
--------------------------------------------------------------------------------
/src/nodes/inet/WebServer.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.inet;
2 |
3 | import inet.base.NotificationBoard;
4 | import inet.linklayer.ethernet.EthernetInterface;
5 | import inet.linklayer.ppp.PPPInterface;
6 | import inet.networklayer.common.InterfaceTable;
7 | import inet.networklayer.ipv4.RoutingTable;
8 | import inet.nodes.inet.NetworkLayer;
9 | import inet.util.NAMTraceWriter;
10 | import inet.util.TCPDump;
11 | import scadasim.applications.pingApp.GenericICMPPingApplication;
12 | import scadasim.applications.tcpApp.GenericTCPApplication;
13 | import scadasim.transport.tcp.TCP_hack;
14 | import scadasim.transport.udp.UDP_hack;
15 | import inet.transport.tcp.TCP;
16 |
17 | //
18 | // WebServer: Server system for web traffic profile using TCP as
19 | // transport protocol.
20 | // This profile generates small client requests and many large
21 | // server replies.
22 | //
23 | // \IP host with TCP, UDP layers and applications.
24 | //
25 | module WebServer
26 | {
27 | parameters:
28 | @node();
29 | int namid;
30 | int maxTCPThreadCount;
31 | gates:
32 | inout pppg[];
33 | inout ethg[];
34 | submodules:
35 | namTrace: NAMTraceWriter {
36 | parameters:
37 | namid = namid;
38 | @display("p=60,310;i=block/sink");
39 |
40 | }
41 | notificationBoard: NotificationBoard {
42 | parameters:
43 | @display("p=60,70;i=block/control");
44 |
45 | }
46 | interfaceTable: InterfaceTable {
47 | parameters:
48 | @display("p=60,150;i=block/table");
49 |
50 | }
51 | routingTable: RoutingTable {
52 | parameters:
53 | IPForward = false;
54 | routerId = "";
55 | routingFile = "";
56 | @display("p=60,230;i=block/table");
57 |
58 | }
59 | tcpApp: GenericTCPApplication {
60 | parameters:
61 | isServer = true;
62 | profileNumber = 3;
63 | port = 80;
64 | @display("p=163,67;i=block/app");
65 |
66 | }
67 | tcp: TCP {
68 | parameters:
69 | // maxThreadCount = maxTCPThreadCount;
70 | @display("p=163,154;i=block/wheelbarrow");
71 |
72 | }
73 | // udp: UDP_hack {
74 | // parameters:
75 | // @display("p=272,154;i=block/transport");
76 | //
77 | // }
78 | // pingApp: GenericICMPPingApplication {
79 | // parameters:
80 | // isServer = true;
81 | // profileNumber = 21;
82 | // port = 0;
83 | // @display("i=block/app;p=343,200");
84 | //
85 | // }
86 | networkLayer: NetworkLayer {
87 | parameters:
88 | proxyARP = false;
89 | @display("p=248,247;i=block/fork;q=queue");
90 |
91 | gates:
92 | ifIn[sizeof(pppg)+sizeof(ethg)];
93 | ifOut[sizeof(pppg)+sizeof(ethg)];
94 | }
95 | ppp[sizeof(pppg)]: PPPInterface {
96 | parameters:
97 | @display("p=147,350,row,90;q=txQueue;i=block/ifcard");
98 |
99 | }
100 | eth[sizeof(ethg)]: EthernetInterface {
101 | parameters:
102 | @display("p=240,350,row,90;q=txQueue;i=block/ifcard");
103 |
104 | }
105 | // tcpdump: TCPDump {
106 | // parameters:
107 | // @display("p=336,302;i=abstract/cache_s");
108 | // gates:
109 | // ifIn[sizeof(pppg)+sizeof(ethg)];
110 | // in2[sizeof(pppg)+sizeof(ethg)];
111 | // ifOut[sizeof(pppg)+sizeof(ethg)];
112 | // out2[sizeof(pppg)+sizeof(ethg)];
113 | // }
114 | connections allowunconnected:
115 | tcpApp.tcpOut --> tcp.appIn++;
116 | tcpApp.tcpIn <-- tcp.appOut++;
117 |
118 | tcp.ipOut --> networkLayer.tcpIn;
119 | tcp.ipIn <-- networkLayer.tcpOut;
120 |
121 | // udp.ipOut --> networkLayer.udpIn;
122 | // udp.ipIn <-- networkLayer.udpOut;
123 |
124 | // networkLayer.pingOut --> pingApp.pingIn;
125 | // networkLayer.pingIn <-- pingApp.pingOut;
126 |
127 | // connections to network outside
128 | for i=0..sizeof(pppg)-1 {
129 | pppg[i] <--> ppp[i].phys;
130 | ppp[i].netwOut --> networkLayer.ifIn[i];
131 | ppp[i].netwIn <-- networkLayer.ifOut[i];
132 | }
133 |
134 | for i=0..sizeof(ethg)-1 {
135 | ethg[i] <--> eth[i].phys;
136 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
137 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
138 | }
139 | // connections to network outside
140 | // for i=0..sizeof(pppg)-1 {
141 | // pppg[i] <--> ppp[i].phys;
142 | // ppp[i].netwOut --> tcpdump.ifIn[i];
143 | // tcpdump.out2[i] --> networkLayer.ifIn[i];
144 | // ppp[i].netwIn <-- tcpdump.ifOut[i];
145 | // tcpdump.in2[i] <-- networkLayer.ifOut[i];
146 | // }
147 | //
148 | // for i=0..sizeof(ethg)-1 {
149 | // ethg[i] <--> eth[i].phys;
150 | // eth[i].netwOut --> tcpdump.ifIn[sizeof(pppg)+i];
151 | // tcpdump.out2[sizeof(pppg)+i] --> networkLayer.ifIn[sizeof(pppg)+i];
152 | // eth[i].netwIn <-- tcpdump.ifOut[sizeof(pppg)+i];
153 | // tcpdump.in2[sizeof(pppg)+i] <-- networkLayer.ifOut[sizeof(pppg)+i];
154 | // }
155 |
156 | }
157 |
158 |
--------------------------------------------------------------------------------
/src/nodes/inet/WormHost.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.inet;
2 |
3 | import inet.base.NotificationBoard;
4 | import inet.linklayer.ethernet.EthernetInterface;
5 | import inet.linklayer.ppp.PPPInterface;
6 | import inet.networklayer.common.InterfaceTable;
7 | import inet.networklayer.ipv4.RoutingTable;
8 | import inet.util.NAMTraceWriter;
9 | import scadasim.applications.worm.UDPWormVictim;
10 |
11 | //
12 | // Compound module which behaves as infected or vulnerable worm host in a
13 | // worm propagation.
14 | // Therefore, UDPWormVictim is included in addition to the normal
15 | // TCP/IP layers
16 | //
17 | module WormHost
18 | {
19 | parameters:
20 | @node();
21 | int namid;
22 | gates:
23 | inout pppg[];
24 | inout ethg[];
25 | submodules:
26 | namTrace: NAMTraceWriter {
27 | parameters:
28 | namid = namid;
29 | @display("p=60,310;i=block/sink");
30 | }
31 | notificationBoard: NotificationBoard {
32 | parameters:
33 | @display("p=60,70;i=block/control");
34 | }
35 | interfaceTable: InterfaceTable {
36 | parameters:
37 | @display("p=60,150;i=block/table");
38 | }
39 | routingTable: RoutingTable {
40 | parameters:
41 | IPForward = false;
42 | routerId = "";
43 | routingFile = "";
44 | @display("p=60,230;i=block/table");
45 | }
46 | udpWormVictim: UDPWormVictim {
47 | parameters:
48 | @display("p=272,154;i=old/telnet");
49 | }
50 | networkLayer: NetworkLayer_hack {
51 | parameters:
52 | proxyARP = false;
53 | tracingOn = false;
54 | spoofingOn = false;
55 | @display("p=248,247;i=block/fork;q=queue");
56 | gates:
57 | ifIn[sizeof(pppg)+sizeof(ethg)];
58 | ifOut[sizeof(pppg)+sizeof(ethg)];
59 | }
60 | ppp[sizeof(pppg)]: PPPInterface {
61 | parameters:
62 | @display("p=205,350,row,90;q=txQueue;i=block/ifcard");
63 |
64 | }
65 | eth[sizeof(ethg)]: EthernetInterface {
66 | parameters:
67 | @display("p=240,350,row,90;q=txQueue;i=block/ifcard");
68 |
69 | }
70 | connections allowunconnected:
71 | udpWormVictim.ipOut --> networkLayer.udpIn;
72 | udpWormVictim.ipIn <-- networkLayer.udpOut;
73 |
74 |
75 | // connections to network outside
76 | for i=0..sizeof(pppg)-1 {
77 | pppg[i] <--> ppp[i].phys;
78 | ppp[i].netwOut --> networkLayer.ifIn[i];
79 | ppp[i].netwIn <-- networkLayer.ifOut[i];
80 | }
81 |
82 | for i=0..sizeof(ethg)-1 {
83 | ethg[i] <--> eth[i].phys;
84 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
85 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
86 | }
87 | }
88 |
89 |
--------------------------------------------------------------------------------
/src/nodes/scada/Historian.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.scada;
2 |
3 | import inet.base.NotificationBoard;
4 | import inet.linklayer.ethernet.EthernetInterface;
5 | import inet.linklayer.ppp.PPPInterface;
6 | import inet.networklayer.common.InterfaceTable;
7 | import inet.networklayer.ipv4.RoutingTable;
8 | import inet.nodes.inet.NetworkLayer;
9 | import inet.util.NAMTraceWriter;
10 | import scadasim.applications.pingApp.GenericICMPPingApplication;
11 | import scadasim.applications.tcpApp.GenericTCPApplication;
12 | import scadasim.transport.tcp.TCP_hack;
13 | import scadasim.transport.udp.UDP_hack;
14 | import inet.transport.tcp.TCP;
15 |
16 | //
17 | // InteractiveServer: Server system for interactive traffic profile using
18 | // TCP as transport protocol.
19 | // This profile generates a similar number of equally large client requests
20 | // and server replies.
21 | //
22 | // \IP host with TCP, UDP layers and applications.
23 | //
24 | module Historian
25 | {
26 | parameters:
27 | @node();
28 | int namid;
29 | int maxTCPThreadCount;
30 | gates:
31 | inout pppg[];
32 | inout ethg[];
33 | submodules:
34 | namTrace: NAMTraceWriter {
35 | parameters:
36 | namid = namid;
37 | @display("p=60,310;i=block/sink");
38 |
39 | }
40 | notificationBoard: NotificationBoard {
41 | parameters:
42 | @display("p=60,70;i=block/control");
43 |
44 | }
45 | interfaceTable: InterfaceTable {
46 | parameters:
47 | @display("p=60,150;i=block/table");
48 |
49 | }
50 | routingTable: RoutingTable {
51 | parameters:
52 | IPForward = false;
53 | routerId = "";
54 | routingFile = "";
55 | @display("p=60,230;i=block/table");
56 |
57 | }
58 | // tcpApp: GenericTCPApplication {
59 | // parameters:
60 | // isServer = true;
61 | // profileNumber = 2;
62 | // port = 80;
63 | // @display("p=163,67;i=block/app");
64 | //
65 | // }
66 | tcp: TCP {
67 | parameters:
68 | // maxThreadCount = maxTCPThreadCount;
69 | @display("p=163,154;i=block/wheelbarrow");
70 |
71 | }
72 | // udp: UDP_hack {
73 | // parameters:
74 | // @display("p=272,154;i=block/transport");
75 | //
76 | // }
77 | // pingApp: GenericICMPPingApplication {
78 | // parameters:
79 | // isServer = true;
80 | // profileNumber = 21;
81 | // port = 0;
82 | // @display("i=block/app;p=343,200");
83 | //
84 | // }
85 | networkLayer: NetworkLayer {
86 | parameters:
87 | proxyARP = false;
88 | @display("p=248,247;i=block/fork;q=queue");
89 |
90 | gates:
91 | ifIn[sizeof(pppg)+sizeof(ethg)];
92 | ifOut[sizeof(pppg)+sizeof(ethg)];
93 | }
94 | ppp[sizeof(pppg)]: PPPInterface {
95 | parameters:
96 | @display("p=202,350,row,90;q=txQueue;i=block/ifcard");
97 |
98 | }
99 | eth[sizeof(ethg)]: EthernetInterface {
100 | parameters:
101 | @display("p=349,350,row,90;q=txQueue;i=block/ifcard");
102 |
103 | }
104 | connections allowunconnected:
105 | // tcpApp.tcpOut --> tcp.appIn++;
106 | // tcpApp.tcpIn <-- tcp.appOut++;
107 |
108 | tcp.ipOut --> networkLayer.tcpIn;
109 | tcp.ipIn <-- networkLayer.tcpOut;
110 |
111 | // udp.ipOut --> networkLayer.udpIn;
112 | // udp.ipIn <-- networkLayer.udpOut;
113 | //
114 | // networkLayer.pingOut --> pingApp.pingIn;
115 | // networkLayer.pingIn <-- pingApp.pingOut;
116 |
117 | // connections to network outside
118 | for i=0..sizeof(pppg)-1 {
119 | pppg[i] <--> ppp[i].phys;
120 | ppp[i].netwOut --> networkLayer.ifIn[i];
121 | ppp[i].netwIn <-- networkLayer.ifOut[i];
122 | }
123 |
124 | for i=0..sizeof(ethg)-1 {
125 | ethg[i] <--> eth[i].phys;
126 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
127 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
128 | }
129 | }
130 |
131 |
--------------------------------------------------------------------------------
/src/nodes/scada/MTU.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.scada;
2 |
3 | import inet.base.NotificationBoard;
4 | import inet.linklayer.ethernet.EthernetInterface;
5 | import inet.linklayer.ppp.PPPInterface;
6 | import inet.networklayer.common.InterfaceTable;
7 | import inet.networklayer.ipv4.RoutingTable;
8 | import inet.nodes.inet.NetworkLayer;
9 | import inet.util.NAMTraceWriter;
10 | import scadasim.applications.pingApp.GenericICMPPingApplication;
11 | import scadasim.applications.tcpApp.GenericTCPApplication;
12 | import scadasim.transport.tcp.TCP_hack;
13 | import scadasim.transport.udp.UDP_hack;
14 | import inet.transport.tcp.TCP;
15 | import scadasim.applications.generic.InetUser;
16 |
17 |
18 | //
19 | // WebServer: Server system for web traffic profile using TCP as
20 | // transport protocol.
21 | // This profile generates small client requests and many large
22 | // server replies.
23 | //
24 | // \IP host with TCP, UDP layers and applications.
25 | //
26 | module MTU
27 | {
28 | parameters:
29 | @node();
30 | int namid;
31 | int maxTCPThreadCount;
32 |
33 | gates:
34 | inout pppg[];
35 | inout ethg[];
36 | submodules:
37 | namTrace: NAMTraceWriter {
38 | parameters:
39 | namid = namid;
40 | @display("p=60,310;i=block/sink");
41 |
42 | }
43 | notificationBoard: NotificationBoard {
44 | parameters:
45 | @display("p=60,70;i=block/control");
46 |
47 | }
48 | interfaceTable: InterfaceTable {
49 | parameters:
50 | @display("p=60,150;i=block/table");
51 |
52 | }
53 | routingTable: RoutingTable {
54 | parameters:
55 | IPForward = false;
56 | routerId = "";
57 | routingFile = "";
58 | @display("p=60,230;i=block/table");
59 |
60 | }
61 |
62 | inetUser: InetUser {
63 | parameters:
64 | @display("p=60,390;i=abstract/person");
65 |
66 | }
67 |
68 |
69 | mtuServer: GenericTCPApplication {
70 | parameters:
71 | isServer = true;
72 | profileNumber = 3;
73 | port = 80;
74 |
75 | @display("p=163,67;i=block/app");
76 |
77 | }
78 |
79 | mtuClient: GenericTCPApplication {
80 | parameters:
81 | isServer = false;
82 | profileNumber = 5;
83 | port = 1;
84 | @display("p=267,67;i=block/app");
85 |
86 | }
87 |
88 | tcp: TCP {
89 | parameters:
90 | //maxThreadCount = maxTCPThreadCount;
91 |
92 | @display("p=163,154;i=block/wheelbarrow");
93 |
94 | }
95 | // udp: UDP_hack {
96 | // parameters:
97 | // @display("p=272,154;i=block/transport");
98 | //
99 | // }
100 | // pingApp: GenericICMPPingApplication {
101 | // parameters:
102 | // isServer = true;
103 | // profileNumber = 21;
104 | // port = 0;
105 | // @display("i=block/app;p=343,200");
106 | //
107 | // }
108 | networkLayer: NetworkLayer {
109 | parameters:
110 | proxyARP = false;
111 | @display("p=248,247;i=block/fork;q=queue");
112 |
113 | gates:
114 | ifIn[sizeof(pppg)+sizeof(ethg)];
115 | ifOut[sizeof(pppg)+sizeof(ethg)];
116 | }
117 | ppp[sizeof(pppg)]: PPPInterface {
118 | parameters:
119 | @display("p=147,350,row,90;q=txQueue;i=block/ifcard");
120 |
121 | }
122 | eth[sizeof(ethg)]: EthernetInterface {
123 | parameters:
124 | @display("p=331,343,row,90;q=txQueue;i=block/ifcard");
125 |
126 | }
127 | connections allowunconnected:
128 | mtuServer.tcpOut --> tcp.appIn++;
129 | mtuServer.tcpIn <-- tcp.appOut++;
130 |
131 | mtuClient.tcpIn <-- tcp.appOut++;
132 | mtuClient.tcpOut --> tcp.appIn++;
133 |
134 | tcp.ipOut --> networkLayer.tcpIn;
135 | tcp.ipIn <-- networkLayer.tcpOut;
136 |
137 | // udp.ipOut --> networkLayer.udpIn;
138 | // udp.ipIn <-- networkLayer.udpOut;
139 |
140 | // networkLayer.pingOut --> pingApp.pingIn;
141 | // networkLayer.pingIn <-- pingApp.pingOut;
142 |
143 | // connections to network outside
144 | for i=0..sizeof(pppg)-1 {
145 | pppg[i] <--> ppp[i].phys;
146 | ppp[i].netwOut --> networkLayer.ifIn[i];
147 | ppp[i].netwIn <-- networkLayer.ifOut[i];
148 | }
149 |
150 | for i=0..sizeof(ethg)-1 {
151 | ethg[i] <--> eth[i].phys;
152 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
153 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
154 | }
155 | }
156 |
157 |
--------------------------------------------------------------------------------
/src/nodes/scada/PLC.ned:
--------------------------------------------------------------------------------
1 | package scadasim.nodes.scada;
2 |
3 | import inet.base.NotificationBoard;
4 | import inet.linklayer.ethernet.EthernetInterface;
5 | import inet.linklayer.ppp.PPPInterface;
6 | import inet.networklayer.common.InterfaceTable;
7 | import inet.networklayer.ipv4.RoutingTable;
8 | import inet.nodes.inet.NetworkLayer;
9 | import inet.util.NAMTraceWriter;
10 | import scadasim.applications.pingApp.GenericICMPPingApplication;
11 | import scadasim.applications.tcpApp.GenericTCPApplication;
12 | import scadasim.transport.tcp.TCP_hack;
13 | import scadasim.transport.udp.UDP_hack;
14 | import inet.transport.tcp.TCP;
15 |
16 | //
17 | // WebServer: Server system for web traffic profile using TCP as
18 | // transport protocol.
19 | // This profile generates small client requests and many large
20 | // server replies.
21 | //
22 | // \IP host with TCP, UDP layers and applications.
23 | //
24 | module PLC
25 | {
26 | parameters:
27 | @node();
28 | int namid;
29 | int maxTCPThreadCount;
30 | gates:
31 | inout pppg[];
32 | inout ethg[];
33 | submodules:
34 | namTrace: NAMTraceWriter {
35 | parameters:
36 | namid = namid;
37 | @display("p=60,310;i=block/sink");
38 |
39 | }
40 | notificationBoard: NotificationBoard {
41 | parameters:
42 | @display("p=60,70;i=block/control");
43 |
44 | }
45 | interfaceTable: InterfaceTable {
46 | parameters:
47 | @display("p=60,150;i=block/table");
48 |
49 | }
50 | routingTable: RoutingTable {
51 | parameters:
52 | IPForward = false;
53 | routerId = "";
54 | routingFile = "";
55 | @display("p=60,230;i=block/table");
56 |
57 | }
58 | plcServer: GenericTCPApplication {
59 | parameters:
60 | isServer = true;
61 | profileNumber = 5;
62 | port = 502;
63 | @display("p=163,67;i=block/app");
64 |
65 | }
66 | tcp: TCP {
67 | parameters:
68 | //maxThreadCount = maxTCPThreadCount;
69 | @display("p=163,154;i=block/wheelbarrow");
70 |
71 | }
72 | // udp: UDP_hack {
73 | // parameters:
74 | // @display("p=272,154;i=block/transport");
75 | //
76 | // }
77 | // pingApp: GenericICMPPingApplication {
78 | // parameters:
79 | // isServer = true;
80 | // profileNumber = 21;
81 | // port = 0;
82 | // @display("i=block/app;p=343,200");
83 | //
84 | // }
85 | networkLayer: NetworkLayer {
86 | parameters:
87 | proxyARP = false;
88 | @display("p=248,247;i=block/fork;q=queue");
89 |
90 | gates:
91 | ifIn[sizeof(pppg)+sizeof(ethg)];
92 | ifOut[sizeof(pppg)+sizeof(ethg)];
93 | }
94 | ppp[sizeof(pppg)]: PPPInterface {
95 | parameters:
96 | @display("p=147,350,row,90;q=txQueue;i=block/ifcard");
97 |
98 | }
99 | eth[sizeof(ethg)]: EthernetInterface {
100 | parameters:
101 | @display("p=240,350,row,90;q=txQueue;i=block/ifcard");
102 |
103 | }
104 | connections allowunconnected:
105 | plcServer.tcpOut --> tcp.appIn++;
106 | plcServer.tcpIn <-- tcp.appOut++;
107 |
108 | tcp.ipOut --> networkLayer.tcpIn;
109 | tcp.ipIn <-- networkLayer.tcpOut;
110 |
111 | // udp.ipOut --> networkLayer.udpIn;
112 | // udp.ipIn <-- networkLayer.udpOut;
113 |
114 | // networkLayer.pingOut --> pingApp.pingIn;
115 | // networkLayer.pingIn <-- pingApp.pingOut;
116 |
117 | // connections to network outside
118 | for i=0..sizeof(pppg)-1 {
119 | pppg[i] <--> ppp[i].phys;
120 | ppp[i].netwOut --> networkLayer.ifIn[i];
121 | ppp[i].netwIn <-- networkLayer.ifOut[i];
122 | }
123 |
124 | for i=0..sizeof(ethg)-1 {
125 | ethg[i] <--> eth[i].phys;
126 | eth[i].netwOut --> networkLayer.ifIn[sizeof(pppg)+i];
127 | eth[i].netwIn <-- networkLayer.ifOut[sizeof(pppg)+i];
128 | }
129 | }
130 |
131 |
--------------------------------------------------------------------------------
/src/package.ned:
--------------------------------------------------------------------------------
1 | package scadasim;
2 |
3 | @license(LGPL);
4 |
--------------------------------------------------------------------------------
/src/scadasim:
--------------------------------------------------------------------------------
1 | ../out/gcc-debug/src/scadasim
--------------------------------------------------------------------------------
/src/transport/contract/UDPSocketVector.cc:
--------------------------------------------------------------------------------
1 | #include "UDPSocketVector.h"
2 |
3 | /**
4 | * @brief Small utility class for managing a large number of UDPSocket objects.
5 | *
6 | * This class is just a copy of the functionality of TCPSocketMap.
7 | * In comparison to TCPSocketMap, however, remote Port and Address are used
8 | * for unique identification of a connection instead of connectionId.
9 | *
10 | * @class UDPSocketVector
11 | */
12 | UDPSocketVector::UDPSocketVector()
13 | {
14 | }
15 |
16 | UDPSocketVector::~UDPSocketVector()
17 | {
18 | }
19 |
20 | /**
21 | * Searches for the UDPSocket that corresponds to the the remote information
22 | * of the received UDP message. This information is extracted of the
23 | * UDPControlInfo contained in UDP messages.
24 | *
25 | * @param msg Received UDP message
26 | * @return Corresponding UDP socket
27 | */
28 | UDPSocket *UDPSocketVector::findSocketFor(cMessage *msg)
29 | {
30 | UDPControlInfo *ctrl = dynamic_cast (msg->getControlInfo());
31 | if (!ctrl)
32 | opp_error("UDPSocketVector: findSocketFor(): no UDPControl info in message (not from UDP?)");
33 | SocketVector::iterator i = socketVector.begin();
34 | while (i != socketVector.end())
35 | {
36 | if ((*i)->remoteAddr == ctrl->getSrcAddr())
37 | if ((*i)->remotePort == ctrl->getSrcPort())
38 | break;
39 | i++;
40 | }
41 | return (i == socketVector.end()) ? NULL : (*i)->socket;
42 | }
43 |
44 | /**
45 | * First the method checks if a socket with these remote informations
46 | * already exists. If not, the new socket is added.
47 | *
48 | * @param socket UDPSocket belonging to the received message information
49 | * @param init Received UDP message
50 | */
51 | void UDPSocketVector::addSocket(UDPSocket *socket, cMessage *init)
52 | {
53 | UDPControlInfo *ctrl = dynamic_cast (init->getControlInfo());
54 | if (!ctrl)
55 | opp_error("UDPSocketVector: findSocketFor(): no UDPControl info in message (not from UDP?)");
56 | SocketVector::iterator i = socketVector.begin();
57 | while (i != socketVector.end())
58 | {
59 | if ((*i)->remoteAddr == ctrl->getSrcAddr())
60 | if ((*i)->remotePort == ctrl->getSrcPort())
61 | break;
62 | i++;
63 | }
64 | ASSERT(i == socketVector.end());
65 | socketVector.push_back(new UDPSocketVectorInfo(socket, ctrl->getSrcAddr(), ctrl->getSrcPort()));
66 | }
67 |
68 | /**
69 | * First the method checks if a socket with these remote informations
70 | * already exists. If not, the new socket is added.
71 | *
72 | * @param socket UDPSocket belonging to the received message information
73 | * @param t TargetInfo of received UDP message
74 | */
75 | void UDPSocketVector::addSocket(UDPSocket *socket, TargetInfo &t)
76 | {
77 | SocketVector::iterator i = socketVector.begin();
78 | while (i != socketVector.end())
79 | {
80 | if ((*i)->remoteAddr == t.address)
81 | if ((*i)->remotePort == t.port)
82 | break;
83 | i++;
84 | }
85 | ASSERT(i == socketVector.end());
86 | socketVector.push_back(new UDPSocketVectorInfo(socket, t.address, t.port));
87 | }
88 |
89 | /**
90 | * Checks if this socket really is contained in the vector.
91 | * If so, delete it from vector and return it.
92 | *
93 | * @param socket UDPSocket to delete
94 | * @return Returns UDPSocket that should be deleted
95 | */
96 | UDPSocket *UDPSocketVector::removeSocket(UDPSocket *socket)
97 | {
98 | SocketVector::iterator i = socketVector.begin();
99 | while (i != socketVector.end())
100 | {
101 | if ((*i)->socket->getSocketId() == socket->getSocketId())
102 | {
103 | socketVector.erase(i);
104 | break;
105 | }
106 | }
107 | return socket;
108 | }
109 |
110 | /**
111 | * Deletes all UDPSocket contained in the vector.
112 | */
113 | void UDPSocketVector::deleteSockets()
114 | {
115 | for (SocketVector::iterator i = socketVector.begin(); i != socketVector.end(); ++i)
116 | delete *i;
117 | socketVector.clear();
118 | }
119 |
--------------------------------------------------------------------------------
/src/transport/contract/UDPSocketVector.h:
--------------------------------------------------------------------------------
1 | #ifndef UDPSOCKETVECTOR_H_
2 | #define UDPSOCKETVECTOR_H_
3 |
4 | #include
5 | #include
6 | #include "UDPSocket.h"
7 | #include "TransmissionConfig.h"
8 | #include "IPvXAddress.h"
9 | #include "ReaSEDefs.h"
10 |
11 | //
12 | // this is just a copy of the functionality of TCPSocketMap
13 | //
14 | // compared to TCPSocketMap we use the remote Port and Address
15 | // instead of using the connectionId.
16 | //
17 | //
18 |
19 | /**
20 | * This struct unites the informations of a UDP socket: UDPSocket, IPvX
21 | * address, and port.
22 | */
23 | struct UDPSocketVectorInfo
24 | {
25 | UDPSocket *socket;
26 | IPvXAddress remoteAddr;
27 | int remotePort;
28 | UDPSocketVectorInfo(UDPSocket *sock, IPvXAddress addr, int port)
29 | {
30 | socket = sock;
31 | remoteAddr =addr;
32 | remotePort = port;
33 | }
34 | };
35 |
36 | /**
37 | * @brief Small utility class for managing a large number of UDPSocket objects.
38 | *
39 | * This class is just a copy of the functionality of TCPSocketMap.
40 | * In comparison to TCPSocketMap, however, remote Port and Address are used
41 | * for unique identification of a connection instead of connectionId.
42 | *
43 | * @class UDPSocketVector
44 | */
45 | class REASE_API UDPSocketVector
46 | {
47 | protected:
48 | typedef std::vector SocketVector;
49 | /// Vector of UDP Sockets
50 | SocketVector socketVector;
51 | public:
52 | UDPSocketVector();
53 | ~UDPSocketVector();
54 | /// Returns UDPSocket corresponding to a specific message
55 | UDPSocket *findSocketFor(cMessage *msg);
56 | /// Adds a new UDPSocket to the vector
57 | void addSocket(UDPSocket *socket, cMessage *initialMsg);
58 | /// Adds a new UDPSocket to the vector
59 | void addSocket(UDPSocket *socket, TargetInfo &t);
60 | /// Deletes a UDPSocket from the vector
61 | UDPSocket *removeSocket(UDPSocket *socket);
62 | /// Returns size of the current UDPSocket vector
63 | unsigned int size() {return socketVector.size();}
64 | /// Clear complete UDPSocket vector
65 | void deleteSockets();
66 | };
67 |
68 | #endif /*UDPSOCKETMAP_H_*/
69 |
--------------------------------------------------------------------------------
/src/transport/tcp/TCPConnection_hack.h:
--------------------------------------------------------------------------------
1 | #ifndef TCPCONNECTION_HACK_H_
2 | #define TCPCONNECTION_HACK_H_
3 | #include
4 | #include "TCPConnection.h"
5 | #include "ReaSEDefs.h"
6 |
7 | /**
8 | * @brief Extends the original TCP implementation by limited number of open
9 | * TCP connections
10 | *
11 | * This class is derived from the original TCPConnection class.
12 | * The extension allows for simulation of a limited number of open TCP
13 | * connections per host system. Thus, overload situations at endsystems
14 | * can be simulated, too.
15 | *
16 | * @class TCPConnection_hack
17 | */
18 | class REASE_API TCPConnection_hack: public TCPConnection {
19 | protected:
20 | /// @brief state variable: Worker thread or not?
21 | bool worker;
22 | public:
23 | TCPConnection_hack(TCP *mod, int appGateIndex, int connId) :
24 | TCPConnection(mod, appGateIndex, connId) {
25 | this->worker = false;
26 | }
27 | ;
28 | ~TCPConnection_hack();
29 | int getTCPQueueDrops();
30 | int getTCPRecvQueueLen();
31 | int getFreeSpaceRecvQueue();
32 | int getMaxRecvQueueLimit();
33 | const char * getTCPRecvQueueInfo();
34 | protected:
35 | /// @brief Process incoming TCP segment
36 | TCPEventCode processSegmentInListen(TCPSegment *tcpseg, IPvXAddress src,
37 | IPvXAddress dest);
38 | /// @brief Sets this TCPConnection to the state of a worker thread
39 | void setWorkerThread() {
40 | this->worker = true;
41 | }
42 | ;
43 | /// @brief Returns if this connections is a worker thread or not
44 | bool isWorkerThread() {
45 | return worker;
46 | }
47 | ;
48 | /// @brief Clone a listening connection. Used for forking.
49 | TCPConnection *cloneListeningConnection();
50 | /// @brief Implements the slightly changed TCP state machine
51 | bool performStateTransition(const TCPEventCode& event);
52 |
53 | void sendToApp(cMessage *msg);
54 | };
55 |
56 | #endif /*TCPCONNECTION_HACK_H_*/
57 |
--------------------------------------------------------------------------------
/src/transport/tcp/TCP_hack.cc:
--------------------------------------------------------------------------------
1 | #include "TCP_hack.h"
2 | #include "TCPConnection_hack.h"
3 | #include "TCPSegment.h"
4 | #include "IPControlInfo.h"
5 | #include "TCPCommand_m.h"
6 | //#include "DataDump.h"
7 | Define_Module( TCP_hack);
8 |
9 | /**
10 | * @brief Extends the original TCP implementation by limited number of open
11 | * TCP connections
12 | *
13 | * This class is derived from the original TCP class.
14 | * The extension allows for simulation of a limited number of open TCP
15 | * connections per host system. Thus, overload situations at endsystems
16 | * can be simulated, too.
17 | *
18 | * @class TCP_hack
19 | */
20 |
21 | /**
22 | * Initializes maxThreadCount to the number given in the NED file.
23 | * If a negative value is given, it will be set to INT_MAX.
24 | */
25 | void TCP_hack::initialize()
26 | {
27 | TCP::initialize();
28 |
29 | maxThreadCount = par("maxThreadCount");
30 | currentConnectionCount = 0;
31 | droppedConnections = 0;
32 | WATCH(maxThreadCount);
33 | WATCH(currentConnectionCount);
34 |
35 | if (maxThreadCount <= 0)
36 | maxThreadCount = INT_MAX;
37 | }
38 |
39 | /**
40 | * Similar to the createConnection method of the original TCP implementation
41 | */
42 | TCPConnection *TCP_hack::createConnection(int appGateIndex, int connId)
43 | {
44 | return new TCPConnection_hack(this, appGateIndex, connId);
45 | }
46 |
47 | int TCP_hack::getCurrentNumberOfConnection() {
48 | return currentConnectionCount;
49 | }
50 |
51 | int TCP_hack::getCurrentNumberOfDroppedConnections() {
52 | return droppedConnections;
53 | }
54 |
55 | int TCP_hack::getMaxThreadCount() {
56 | return maxThreadCount;
57 | }
58 |
59 | //void TCP_hack::dump(cMessage *msg, TCPConnection *conn, bool received) {
60 | // cModuleType *moduleType = cModuleType::get("scadasim.util.DataDump");
61 | // cModule *mod = moduleType->createScheduleInit("datadump", this);
62 | // DataDump *dd = check_and_cast (mod);
63 | // dd->handleMessage(msg, conn, received);
64 | // dd->deleteModule();
65 | //}
66 | /**
67 | * Handle method for message that arrivedOn "appIn".
68 | * Handling for other messages is done by original TCP implementation
69 | */
70 | void TCP_hack::handleMessage(cMessage *msg)
71 | {
72 | if (msg->arrivedOn("appIn"))
73 | {
74 | TCPCommand *controlInfo = check_and_cast (msg->getControlInfo());
75 | int appGateIndex = msg->getArrivalGate()->getIndex();
76 | int connId = controlInfo->getConnId();
77 |
78 | TCPConnection *conn = findConnForApp(appGateIndex, connId);
79 |
80 | if (!conn)
81 | {
82 | //
83 | // create a new connection that only accepts threadCountMax
84 | // concurrently connections. This is for forking-sockets only
85 | //
86 | conn = createConnection(appGateIndex, connId);
87 |
88 | // add into appConnMap here; it'll be added to connMap during processing
89 | // the OPEN command in TCPConnection's processAppCommand().
90 | AppConnKey key;
91 | key.appGateIndex = appGateIndex;
92 | key.connId = connId;
93 | tcpAppConnMap[key] = conn;
94 |
95 | tcpEV<< "TCP connection created for " << msg << "\n";
96 | }
97 | // else
98 | // if(msg->getKind()== TCP_C_SEND)
99 | // TCP_hack::dump(msg,conn,false);
100 |
101 | try {
102 | bool ret = conn->processAppCommand(msg);
103 |
104 | if (!ret)
105 | removeConnection(conn);
106 | } catch (cException& e) {
107 | printf("error: %s\n",e.what());
108 | }
109 | if (ev.isGUI())
110 | updateDisplayString();
111 | }
112 | else
113 | TCP::handleMessage(msg);
114 |
115 | }
116 |
117 |
118 | /**
119 | * @return Returns true if another connection can be accepted and false if
120 | * connection limit already is reached.
121 | */
122 | bool TCP_hack::acceptAnotherConnection()
123 | {
124 | if (maxThreadCount > currentConnectionCount) {
125 | currentConnectionCount++;
126 | droppedConnections = 0;
127 | return true;
128 | }else{
129 | droppedConnections++;
130 | return false;
131 | }
132 | }
133 |
134 | /**
135 | * decreases number of open connections in case a half open connection is
136 | * closed (called by TCPConnection_hack).
137 | */
138 | bool TCP_hack::canceledHalfOpenConnection()
139 | {
140 | if (currentConnectionCount <= 0)
141 | {
142 | return false;
143 | }
144 | else
145 | {
146 | currentConnectionCount--;
147 | return true;
148 | }
149 | }
150 |
151 |
--------------------------------------------------------------------------------
/src/transport/tcp/TCP_hack.h:
--------------------------------------------------------------------------------
1 | #ifndef TCP_HACK_H_
2 | #define TCP_HACK_H_
3 |
4 | #include
5 | #include
6 | #include "TCP.h"
7 | #include "ReaSEDefs.h"
8 |
9 | /**
10 | * @brief Extends the original TCP implementation by limited number of open
11 | * TCP connections
12 | *
13 | * This class is derived from the original TCP class.
14 | * The extension allows for simulation of a limited number of open TCP
15 | * connections per host system. Thus, overload situations at endsystems
16 | * can be simulated, too.
17 | *
18 | * @class TCP_hack
19 | */
20 | class REASE_API TCP_hack : public TCP
21 | {
22 | protected:
23 | /// Maximum number of open TCP connections allowed
24 | int maxThreadCount;
25 | /// Current number of open TCP connections
26 | int currentConnectionCount;
27 | int droppedConnections;
28 | public:
29 | /// @brief Checks wether another new connection can be opened
30 | bool acceptAnotherConnection();
31 | /// @brief Decreases number of currently open connections
32 | bool canceledHalfOpenConnection();
33 |
34 | //void dump(cMessage *msg, TCPConnection *tcpConn, bool received);
35 | int getCurrentNumberOfConnection();
36 | int getCurrentNumberOfDroppedConnections();
37 | int getMaxThreadCount();
38 | protected:
39 | /// Factory method
40 | virtual TCPConnection *createConnection(int appGateIndex, int connId);
41 | /// Handle method for messages from application
42 | virtual void handleMessage(cMessage *msg);
43 | /// Initializiation of TCP instance and new parameters
44 | virtual void initialize();
45 | };
46 |
47 | #endif /*TCP_HACK_H_*/
48 |
--------------------------------------------------------------------------------
/src/transport/tcp/TCP_hack.ned:
--------------------------------------------------------------------------------
1 | package scadasim.transport.tcp;
2 |
3 | //
4 | // Overwrites original TCP.ned file.
5 | // This module allows for definition of a maximum number of open connections
6 | // that are accepted by a listening socket concurrently.
7 | // Such a limitation is necessary to simulate overload situations.
8 | //
9 | simple TCP_hack extends inet.transport.tcp.TCP
10 | {
11 | parameters:
12 | delayedAcksEnabled = default(false); // delayed ACKs enabled/disabled
13 | nagleEnabled = default(true); // Nagle's algorithm (RFC 896) enabled/disabled
14 | limitedTransmitEnabled = default(false); // Limited Transmit algorithm (RFC 3042)
15 | // enabled/disabled (can be used for TCPReno/TCPTahoe/TCPNewReno/TCPNoCongestionControl)
16 | increasedIWEnabled = default(false); // increased initial window (min(4*MSS, max (2*MSS, 4380 bytes)))
17 | // (RFC 3390) enabled/disabled
18 | sackSupport = default(false); // Selective Acknowledgment (RFC 2018, 2883, 3517) support (header option)
19 | // (SACK will be enabled for a connection if both endpoints support it)
20 | mss = default(1024); // maximum segment size
21 | advertisedWindow = default(14*this.mss); // in bytes (Note: normally, NIC queues should be at least this size)
22 | tcpAlgorithmClass = default("TCPReno"); // TCPTahoe/TCPReno/TCPNoCongestionControl/DumbTCP
23 | sendQueueClass = default("TCPMsgBasedSendQueue"); // TCPVirtualDataSendQueue/TCPMsgBasedSendQueue
24 | receiveQueueClass = default("TCPMsgBasedRcvQueue"); // TCPVirtualDataRcvQueue/TCPMsgBasedRcvQueue
25 | recordStats = default(true); // recording seqNum etc. into output vectors on/off
26 | int maxThreadCount; // how many concurrent Threads are accepted
27 | @class(TCP_hack);
28 | @display("i=block/wheelbarrow");
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/src/transport/udp/UDP_hack.cc:
--------------------------------------------------------------------------------
1 | #include "UDP_hack.h"
2 | #include "GenericApplicationMessage_m.h"
3 |
4 | Define_Module( UDP_hack);
5 |
6 | /**
7 | * @brief Overwrites original UDP in order to process
8 | * undeliverable GenericAppMsg messages.
9 | *
10 | * The original functionality is kept except of the processing of undeliverable
11 | * GenericAppMsg messages. Such undeliverable messages are caused by the fact
12 | * that a client's UDP socket connection is closed too early if a UDP profile
13 | * of our traffic generation is used. In the original implementation all
14 | * incoming UDP packets then are sent back to the source as ICMP error
15 | * messages.
16 | *
17 | * @class UDP_hack
18 | */
19 | UDP_hack::UDP_hack()
20 | {
21 | }
22 |
23 | UDP_hack::~UDP_hack()
24 | {
25 | }
26 |
27 | /**
28 | * Undeliverable GenericAppMsg messages are silently discarded if the socket
29 | * connection has already been closed. All other messages are processed
30 | * according to the original UDP implementation.
31 | */
32 | void UDP_hack::processUndeliverablePacket(UDPPacket *udpPacket, cPolymorphic *ctrl)
33 | {
34 | if (dynamic_cast (udpPacket->getEncapsulatedMsg()))
35 | {
36 | delete udpPacket;
37 | delete ctrl;
38 | }
39 | else
40 | UDP::processUndeliverablePacket(udpPacket, ctrl);
41 | }
42 |
--------------------------------------------------------------------------------
/src/transport/udp/UDP_hack.h:
--------------------------------------------------------------------------------
1 | #ifndef UDP_HACK_H_
2 | #define UDP_HACK_H_
3 |
4 | #include
5 | #include "UDP.h"
6 | #include "UDPPacket.h"
7 | #include "UDPControlInfo_m.h"
8 | #include "ReaSEDefs.h"
9 |
10 | /**
11 | * @brief Overwrites original UDP in order to process
12 | * undeliverable GenericAppMsg messages.
13 | *
14 | * The original functionality is kept except of the processing of undeliverable
15 | * GenericAppMsg messages. Such undeliverable messages are caused by the fact
16 | * that a client's UDP socket connection is closed too early if a UDP profile
17 | * of our traffic generation is used. In the original implementation all
18 | * incoming UDP packets then are sent back to the source as ICMP error
19 | * messages.
20 | *
21 | * @class UDP_hack
22 | */
23 | class REASE_API UDP_hack : public UDP
24 | {
25 | public:
26 | UDP_hack();
27 | virtual ~UDP_hack();
28 | protected:
29 | /// @brief Processes undeliverable GenericAppMsg messages
30 | virtual void processUndeliverablePacket(UDPPacket *udpPacket, cPolymorphic *ctrl);
31 | };
32 |
33 | #endif /*UDP_HACK_H_*/
34 |
--------------------------------------------------------------------------------
/src/transport/udp/UDP_hack.ned:
--------------------------------------------------------------------------------
1 | package scadasim.transport.udp;
2 |
3 |
4 | //
5 | // Overwrites original UDP.ned file.
6 | // This module handles undeliverable GenericAppMsg messages tha otherwise
7 | // would cause ICMP error messages due to socket connections that are closed
8 | // too early.
9 | //
10 | simple UDP_hack
11 | {
12 | gates:
13 | input appIn[];
14 | input ipIn;
15 | input ipv6In;
16 | output appOut[];
17 | output ipOut;
18 | output ipv6Out;
19 | }
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/util/DataDump.h:
--------------------------------------------------------------------------------
1 | //
2 | // This program is free software: you can redistribute it and/or modify
3 | // it under the terms of the GNU Lesser General Public License as published by
4 | // the Free Software Foundation, either version 3 of the License, or
5 | // (at your option) any later version.
6 | //
7 | // This program is distributed in the hope that it will be useful,
8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | // GNU Lesser General Public License for more details.
11 | //
12 | // You should have received a copy of the GNU Lesser General Public License
13 | // along with this program. If not, see http://www.gnu.org/licenses/.
14 | //
15 |
16 | #ifndef __DATADUMP_H__
17 | #define __DATADUMP_H__
18 |
19 | #include
20 | #include
21 | #include "TCPConnection.h"
22 | #include
23 | #include
24 | #include
25 |
26 | /**
27 | * TODO - Generated class
28 | */
29 | class DataDump : public cSimpleModule
30 | {
31 | private :
32 |
33 | const char *user;
34 | const char *passwd;
35 | const char *database;
36 | const char *addr;
37 | char *socket;
38 | unsigned int port;
39 | void tcpDump(cMessage *msg, MYSQL *conn, bool received, TCPConnection *tcpConn);
40 | protected:
41 | virtual void initialize();
42 | virtual void finish();
43 | public:
44 | void handleMessage(cMessage *msg,TCPConnection *tcpConn, bool received);
45 | const char * printPath(TCPConnection *tcpConn) ;
46 | };
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/src/util/DataDump.ned:
--------------------------------------------------------------------------------
1 | //
2 | // This program is free software: you can redistribute it and/or modify
3 | // it under the terms of the GNU Lesser General Public License as published by
4 | // the Free Software Foundation, either version 3 of the License, or
5 | // (at your option) any later version.
6 | //
7 | // This program is distributed in the hope that it will be useful,
8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | // GNU Lesser General Public License for more details.
11 | //
12 | // You should have received a copy of the GNU Lesser General Public License
13 | // along with this program. If not, see http://www.gnu.org/licenses/.
14 | //
15 |
16 | package scadasim.util;
17 |
18 | //
19 | // TODO auto-generated module
20 | //
21 | simple DataDump
22 | {
23 | parameters:
24 | string databaseAddress = default("localhost");
25 | string database = default("simulation");
26 | string user = default("root");
27 | string passwd = default("1303");
28 | bool threadEnable = default(false);
29 | int port = default(3306);
30 | int verbosity = default(0);
31 | @display("i=block/filter");
32 |
33 |
34 | }
35 |
--------------------------------------------------------------------------------