1. imalse
  2. Untitled project
  3. imalse


imalse / scenario / ddos_flooding / server_cmd.py


This file contains the Server Command Meta Description for the ddos ping
flooding scenario.

import copy

import jsonpickle

from core.nodes.server import ServerCMD as SCMD
from scenario.ddos_flooding.config import ServerDescription as Description
from scenario.ddos_flooding.config import HttpGetFloodCmd
class ServerCMD(SCMD):
    """This class is a subclass of ServerCMD."""
    def __init__(self, desc=None):        
        if desc == None:
            desc = Description()
        SCMD.__init__(self, desc)
    def forward_to_bots(self, sock, command):
        """Forward data to all the bots"""        
        # If we are in simulation mode, the webservice will be started         
        if self.node.NODE_TYPE != 'real' and isinstance(command, HttpGetFloodCmd):
            print "starting webservice"
        self.logger.info('start to echo_bots' )
        new_data = copy.deepcopy(command)
        new_data.event = command.bot_event
        del new_data.bot_event
        for client_sock in self.node.client_socks:            
            self.node.send(client_sock, jsonpickle.encode(new_data))