msg: change size of messages

This commit is contained in:
Quentin De Coninck 2017-02-28 21:08:58 +01:00
parent 0da979c2b5
commit 5833eecc54
4 changed files with 11 additions and 7 deletions

View File

@ -36,6 +36,7 @@ class MpExperienceMsg(MpExperience):
self.client_sleep = self.xpParam.getParam(MpParamXp.MSGCLIENTSLEEP) self.client_sleep = self.xpParam.getParam(MpParamXp.MSGCLIENTSLEEP)
self.server_sleep = self.xpParam.getParam(MpParamXp.MSGSERVERSLEEP) self.server_sleep = self.xpParam.getParam(MpParamXp.MSGSERVERSLEEP)
self.nb_requests = self.xpParam.getParam(MpParamXp.MSGNBREQUESTS) self.nb_requests = self.xpParam.getParam(MpParamXp.MSGNBREQUESTS)
self.bytes = self.xpParam.getParam(MpParamXp.MSGBYTES)
def prepare(self): def prepare(self):
MpExperience.prepare(self) MpExperience.prepare(self)
@ -46,14 +47,14 @@ class MpExperienceMsg(MpExperience):
def getMsgServerCmd(self): def getMsgServerCmd(self):
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \ s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
"/msg_server.py --sleep " + self.server_sleep + " &>" + MpExperienceMsg.SERVER_LOG + "&" "/msg_server.py --sleep " + self.server_sleep + " --bytes " + self.bytes + " &>" + MpExperienceMsg.SERVER_LOG + "&"
print(s) print(s)
return s return s
def getMsgClientCmd(self): def getMsgClientCmd(self):
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \ s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
"/msg_client.py --sleep " + self.client_sleep + " --nb " + self.nb_requests + \ "/msg_client.py --sleep " + self.client_sleep + " --nb " + self.nb_requests + \
" >" + MpExperienceMsg.CLIENT_LOG + " 2>" + MpExperienceMsg.CLIENT_ERR " --bytes " + self.bytes + " >" + MpExperienceMsg.CLIENT_LOG + " 2>" + MpExperienceMsg.CLIENT_ERR
print(s) print(s)
return s return s

View File

@ -63,6 +63,7 @@ class MpParamXp(MpParam):
MSGCLIENTSLEEP = "msgClientSleep" MSGCLIENTSLEEP = "msgClientSleep"
MSGSERVERSLEEP = "msgServerSleep" MSGSERVERSLEEP = "msgServerSleep"
MSGNBREQUESTS = "msgNbRequests" MSGNBREQUESTS = "msgNbRequests"
MSGBYTES = "msgBytes"
PRIOPATH0 = "prioPath0" PRIOPATH0 = "prioPath0"
PRIOPATH1 = "prioPath1" PRIOPATH1 = "prioPath1"
BACKUPPATH0 = "backupPath0" BACKUPPATH0 = "backupPath0"
@ -155,6 +156,7 @@ class MpParamXp(MpParam):
defaultValue[MSGCLIENTSLEEP] = "5.0" defaultValue[MSGCLIENTSLEEP] = "5.0"
defaultValue[MSGSERVERSLEEP] = "5.0" defaultValue[MSGSERVERSLEEP] = "5.0"
defaultValue[MSGNBREQUESTS] = "5" defaultValue[MSGNBREQUESTS] = "5"
defaultValue[MSGBYTES] = "1200"
defaultValue[PRIOPATH0] = "0" defaultValue[PRIOPATH0] = "0"
defaultValue[PRIOPATH1] = "0" defaultValue[PRIOPATH1] = "0"
defaultValue[BACKUPPATH0] = "0" defaultValue[BACKUPPATH0] = "0"

View File

@ -7,7 +7,6 @@ import time
BUFFER_SIZE = 2048 BUFFER_SIZE = 2048
ENCODING = 'ascii' ENCODING = 'ascii'
MSG_SIZE = 1200
threads = {} threads = {}
to_join = [] to_join = []
@ -16,6 +15,7 @@ parser = argparse.ArgumentParser(description="Msg client")
parser.add_argument("-s", "--sleep", type=float, help="sleep time between two sendings", default=5.0) parser.add_argument("-s", "--sleep", type=float, help="sleep time between two sendings", default=5.0)
parser.add_argument("-n", "--nb", type=int, help="number of requests done", default=5) parser.add_argument("-n", "--nb", type=int, help="number of requests done", default=5)
parser.add_argument("-B", "--bulk", help="if set, don't wait for reply to send another packet", action="store_true") parser.add_argument("-B", "--bulk", help="if set, don't wait for reply to send another packet", action="store_true")
parser.add_argument("-b", "--bytes", type=float, help="number of bytes to send and receive", default=1200)
args = parser.parse_args() args = parser.parse_args()
@ -41,7 +41,7 @@ delays = []
try: try:
for i in range(args.nb): for i in range(args.nb):
time.sleep(args.sleep) time.sleep(args.sleep)
request = string_generator(size=MSG_SIZE, chars=string.digits) request = string_generator(size=args.bytes, chars=string.digits)
start_time = datetime.datetime.now() start_time = datetime.datetime.now()
sock.sendall(request.encode(ENCODING)) sock.sendall(request.encode(ENCODING))
@ -49,7 +49,7 @@ try:
continue continue
buffer_data = "" buffer_data = ""
while len(buffer_data) < MSG_SIZE: while len(buffer_data) < args.bytes:
data = sock.recv(BUFFER_SIZE).decode(ENCODING) data = sock.recv(BUFFER_SIZE).decode(ENCODING)
if len(data) == 0: if len(data) == 0:
@ -58,7 +58,7 @@ try:
buffer_data += data buffer_data += data
if len(buffer_data) == MSG_SIZE: if len(buffer_data) == args.bytes:
stop_time = datetime.datetime.now() stop_time = datetime.datetime.now()
delays.append(stop_time - start_time) delays.append(stop_time - start_time)
else: else:

View File

@ -14,6 +14,7 @@ to_join = []
parser = argparse.ArgumentParser(description="Msg server") parser = argparse.ArgumentParser(description="Msg server")
parser.add_argument("-s", "--sleep", type=float, help="sleep time between reception and sending", default=5.0) parser.add_argument("-s", "--sleep", type=float, help="sleep time between reception and sending", default=5.0)
parser.add_argument("-b", "--bytes", type=float, help="number of bytes to send and receive", default=1200)
args = parser.parse_args() args = parser.parse_args()
@ -95,7 +96,7 @@ conn_id = 0
while True: while True:
# Wait for a connection # Wait for a connection
connection, client_address = sock.accept() connection, client_address = sock.accept()
thread = HandleClientConnectionThread(connection, client_address, conn_id, 1200) thread = HandleClientConnectionThread(connection, client_address, conn_id, args.bytes)
threads[conn_id] = thread threads[conn_id] = thread
conn_id += 1 conn_id += 1
thread.start() thread.start()