module: ‘client_tcp.py’

class gwa.eperf.client_tcp.ClientTCP(address, connection, interval, duration, upload, download)[source]

This class allow to create an object client. This client establish the number of connection, indicate while the object creation. The connection execute the same function to calculate bandwidth between interval and during the total duration.

Constructor:

new_client = ClientTCP()

Function:

initialization() runClient() formatValue() Client() bandwidthTCPDownload() bandwidthTCPDownload() stopClient()

Constuctor of this class. The constructor take 6 arguments to create an ClientTCP object.

Argument :
address (type Tuple)

This argument represents addres of the server, the format ist (“127.0.0.1”,5000)

connection (type Integer)

This argument represents the number of connection created

interval (type Integer)

This argument represents the time between two measure

duration (type Integer)

This argument represents the total time for this measure

upload (type Boolean)

This arguments represents if the measure execute the bandwidthTCPUpload function

download (type Boolean)

This arguments represents if the measure execute the bandwidthTCPDownload function

example

>>> ClI_TCP=ClientTCP(address,connection,interval,duration,upload,download)
>>> CLI_TCP.runClient()
Client(sharedProcessArray, number)[source]

This function is executed by the created processes to measure the bandwidth. Each process determine the first index of the shared memory area between the processes, to enter the values measured. Processes run “bandwidthTCPUpload” and / or “bandwidthTCPDownload” functions, after that booleans values, “upload” and “download”, are tested.

Argument :
sharedProcessArray (type Array)

This argument is an shared Array between processes (shared memory area)

number (type Int)

Its used to calculate the first index of the shared memory area.

bandwidthTCPDownload(sharedProcessArray, index)[source]

This function allow to initialize the connection with the server, then run a loop to receive data of the server. This loop calculate the bandwidth on each interval and during the length of the measure and fill the shared memory area. At the end, this function close the socket.

Argument :
sharedProcessArray (type Array)

This argument is an shared Array between processes (shared memory area)

index (type Int)

This argument represents the fist Array index for the process

bandwidthTCPUpload(sharedProcessArray, index)[source]

This function allow to initialize the connection with the server, then run a loop to send data to the server. This loop calculate the bandwidth on each interval and during the length of the measure and fill the shared memory area. At the end, this function close the socket.

Argument :
sharedProcessArray (type Array)

This argument is an shared Array between processes (shared memory area)

index (type Int)

This argument represents the fist Array index for the process

formatValue(listValue)[source]

This function allow to format the list passed in argument to the good format.

Argument :
listValue (type List)

This argument represents the list of values list. Values represents the number of octets sent or receive. [[inta, intb, intc], [int1, int2, int3]]

Return :

A String list with the rigth unit for the bandwidth. [ “inta+int1 Mbits/s”, “intb+int2 Mbits/s”, “intc+int3 Kbits/s”]

initialization(direction)[source]

This function allow to create the TCP socket and connection with the address specified in the constructor. After that, client programm send to the server the common parameters (interval, duration, direction). The answer’s server is an number to identify the client (“self.ID”).

Argument :
direction (type String)

“download” or “upload” This common parameter allow to synchronize the server.

runClient()[source]

This is principal function of this class. When it’s called, several processes are started simultaneously and bandwidth is measured between this processes.

stopClient()[source]

This function quit the programm

Previous topic

module: ‘main.py (Eperf)’

Next topic

module: ‘server_tcp.py’

This Page