Exemplo n.º 1
0
	def __init__(self):
		"""Init base class; install required software; setup initial configuration."""
		DispatchAgent.__init__(self)
		self.pids = []

		# 'Attack Source'
		self.nodes = []		# nodelist 
		self.src = None		# CIDR

		# 'Basics'
		self.dst = None			# CIDR
		self.proto = None		# Valid values are these strings: ['tcp', 'udp']
		self.length = None		# minmax() dist or int (fixed minmax)

		# 'Rate Info'
		self.ratetype = None	# One of string: one of: ['flat', 'rampup', 'pulse'] 
		self.highrate = None	# int
		self.lowrate = None		# int
		self.hightime = None	# int
		self.lowtime = None		# int
		self.risetime = 0		# int 
		self.falltime = 0		# int 

		# 'UDP/TCP' config
		self.sport = 'minmax(0,65535)'	# minmax() dist or int (fixed minmax)
		self.dport = 'minmax(0,65535)'  # minmax() dist or int (fixed minmax)
		self.tcpflags = ['SYN']    # one or more of string set: 'SYN', 'FIN', 'RST', 'ACK', 'PSH', 'URG'		

		self.log = logging.getLogger(__name__)
Exemplo n.º 2
0
    def setConfiguration(self, msg, **kwargs):
        DispatchAgent.setConfiguration(self, msg, **kwargs)
        
        '''From simple_client > client.py'''
        from magi.testbed import testbed
        if self.clientId == None: 
            self.hostname = testbed.nodename
            log.info("Hostname: %s", self.hostname)
            self.clientId = self.hostname 

        # The clientId can be set programmatically to append the hostname .
        self.setClientid() 
        self.commClient = None
        
        '''Parsing for Parameters'''
        # create list of strings
        with open("/users/rning/magi-modules/SmartGridSchool/Parameters.conf", "r") as paramFile:
            self.paramList = paramFile.read().splitlines()
        
        # define the global parameters
        self.day = float(self.paramList[0][len("day:"):])
        self.panelEff = float(self.paramList[1][len("panelEff:"):])
        
        # define the parameters unique to the building
        # UNTIL SERVER PARAMS ARE IMPLEMENTED:
        if self.hostname != "server":
            index = self.paramList.index(self.hostname)
            self.area = float(self.paramList[index+1][len("area:"):]) 
            self.volume = float(self.paramList[index+2][len("volume:"):])
            self.panelArea = float(self.paramList[index+3][len("panelArea:"):])
            # set panelTracking to false as default, if true, then set
            self.panelTracking = False
            if self.paramList[index+4][len("panelTracking:"):] == "True":
                self.panelTracking = True
            self.pAZA = float(self.paramList[index+5][len("pAZA:"):])
            self.pELA = float(self.paramList[index+6][len("pELA:"):])
            self.lightDraw = float(self.paramList[index+7][len("lightDraw:"):])
            self.baselineCe = float(self.paramList[index+8][len("baselineCe:"):])
            self.outlets = float(self.paramList[index+9][len("outlets:"):])
            self.applianceDraw = float(self.paramList[index+10][len("applianceDraw:"):])
            self.tempAC = float(self.paramList[index+11][len("tempAC:"):])
            self.timeAC = self.paramList[index+12][len("timeAC:"):]
            # convert string from param file to list
            self.timeAC = [] # list: [ day start, day end, time of day start, time of day end ]
            ACList = self.paramList[index+12][len("timeAC:"):]
            timeACIndex = 0
            endIndex = 0
            for letter in ACList:
                if letter == "," or letter == "[":
                    endIndex = timeACIndex + 1
                    while ACList[endIndex] != "," and ACList[endIndex] != "]":
                        endIndex += 1
                    self.timeAC.append(float(ACList[timeACIndex + 1: endIndex]))
                    timeACIndex = endIndex
            self.thermalLeakCe = float(self.paramList[index+13][len("thermalLeak:"):])
            self.thermalPower = float(self.paramList[index+14][len("thermalPower:"):])
Exemplo n.º 3
0
 def __init__(self):
     DispatchAgent.__init__(self)
     
     #Default arguments for server and clientId:
     self.server = 'server'
     self.port = 55343
     self.clientId = None
     
     # set the time (in minutes): 0 to 1440 (1339 inclusive)
     self.LT = 0
Exemplo n.º 4
0
    def setConfiguration(self, msg, **kwargs):
        DispatchAgent.setConfiguration(self, msg, **kwargs)

        from magi.testbed import testbed
        if self.clientId == None:
            self.hostname = testbed.nodename
            log.info("Hostname: %s", self.hostname)
            self.clientId = self.hostname

        # The clientId can be set programmatically to append the hostname .
        self.setClientid()
        self.commClient = None
Exemplo n.º 5
0
    def setConfiguration(self, msg, **kwargs):
        DispatchAgent.setConfiguration(self, msg, **kwargs)
        
        from magi.testbed import testbed
        if self.clientId == None: 
            self.hostname = testbed.nodename
            log.info("Hostname: %s", self.hostname)
            self.clientId = self.hostname 

        # The clientId can be set programmatically to append the hostname .
        self.setClientid() 
        self.commClient = None
Exemplo n.º 6
0
    def __init__(self):
        """Init base class; install required software; setup initial configuration."""
        self.log = logging.getLogger(__name__)
        DispatchAgent.__init__(self)

        #requireSoftware('libpcap-dev')
        #requireSoftware('tcpreplay')

        self.pids = []

        # 'Basics'
        self.interface = 'eth0'  # CIDR
        self.pcapfile = None
Exemplo n.º 7
0
	def __init__(self):
		"""Init base class; install required software; setup initial configuration."""
		self.log = logging.getLogger(__name__)
		DispatchAgent.__init__(self)

		#requireSoftware('libpcap-dev')
		#requireSoftware('tcpreplay')  

		self.pids = []

		# 'Basics'
		self.interface = 'eth0' 			# CIDR
		self.pcapfile = None 
Exemplo n.º 8
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.cmdstring = " "
     self.pid = None
Exemplo n.º 9
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.cmdstring = " " 
     self.pid = None
Exemplo n.º 10
0
	def __init__(self):
		DispatchAgent.__init__(self)
		self.clientFile = '/tmp/iperfClientOutput.txt'
		self.serverFile = '/tmp/iperfServerOutput.txt'
		self.port = 28888
		self.serverProcess = None
Exemplo n.º 11
0
 def __init__(self):
     DispatchAgent.__init__(self)
     return
Exemplo n.º 12
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.server = None # configured by MAGI
     self.configFileName = None # configured by MAGI
Exemplo n.º 13
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.server = None  # configured by MAGI
     self.configPath = None  # configured by MAGI
     self.clientID = None
Exemplo n.º 14
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.filename = '/users/arapapor/magi-modules/FileCreator/calc.aal'
Exemplo n.º 15
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.simRunning = False
     self.configFileName = None # must be configured by MAGI
Exemplo n.º 16
0
 def stopclient(self, msg):
     DispatchAgent.stop(self, msg)
     if self.commClient:
         self.commClient.stop()
Exemplo n.º 17
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.clientFile = '/tmp/iperfClientOutput.txt'
     self.serverFile = '/tmp/iperfServerOutput.txt'
     self.pid = None
Exemplo n.º 18
0
 def __init__(self):
     # The default arguments for server and clientId go in here
     DispatchAgent.__init__(self)
     self.server = 'localhost'
     self.port = 55343
     self.clientId = None
Exemplo n.º 19
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.filename = 'tmp-scenario.json'
Exemplo n.º 20
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.sourceFile = ''
     self.destinationFile = ''
Exemplo n.º 21
0
	def __init__(self):
		DispatchAgent.__init__(self)
		self.clientFile = '/tmp/iperfClientOutput.txt'
		self.serverFile = '/tmp/iperfServerOutput.txt'
		self.pid = None
Exemplo n.º 22
0
    def __init__(self):
        # The default arguments for server and clientId go in here 
        DispatchAgent.__init__(self)
        self.server = 'localhost' 
	self.port = 55343 
        self.clientId = None 
Exemplo n.º 23
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.process = None
Exemplo n.º 24
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.path = ''
Exemplo n.º 25
0
 def __init__(self):
     DispatchAgent.__init__(self)
     # usually replaced by an "arg" from the agent
     self.report_dir = "/tmp"
Exemplo n.º 26
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.server = None # configured by MAGI
     self.configPath = None # configured by MAGI
     self.clientID = None
Exemplo n.º 27
0
	def stop(self, msg):
		self.stopFlood(msg)
		DispatchAgent.stop(self, msg)
Exemplo n.º 28
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.clientFile = '/tmp/iperfClientOutput.txt'
     self.serverFile = '/tmp/iperfServerOutput.txt'
     self.port = 28888
     self.serverProcess = None
Exemplo n.º 29
0
	def __init__(self):
		DispatchAgent.__init__(self)
		self.process = None
Exemplo n.º 30
0
 def __init__(self):
     DispatchAgent.__init__(self)
     # usually replaced by an "arg" from the agent
     self.report_dir = "/tmp"
Exemplo n.º 31
0
 def __init__(self):
     DispatchAgent.__init__(self)
Exemplo n.º 32
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.dumpfile = "/tmp/tcpdump.cap"
     self.dest = None
     self.pid = None
Exemplo n.º 33
0
 def __init__(self):
     DispatchAgent.__init__(self)
     self.path = ''
Exemplo n.º 34
0
 def stopclient(self, msg):
     DispatchAgent.stop(self, msg)
     if self.commClient:
         self.commClient.stop()