I use python program to do traffic generator in Linux Ubuntu, and the code like below:
import socket, sys
host = sys.argv[1] #Server IP Address
textport = sys.argv[2] #Server Binding Port
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #socket
try:
port = int(textport)
except ValueError:
port = socket.getservbyname(textport, 'udp')
while 1:
try:
data = open('auth3.log')#read file
for each_line in data: #each rows
try:
(role,line_spoken) = each_line.split(': ',1)#split two parts
role = role.strip()
s.sendto(role, (host, port))
print('Send: ' + str(role) + "\n" )
except:
pass
except IOError as err:
print('file isn\'t exist!!~'+str(err))
finally:
if 'data' in locals(): #If data have no object, Don't use data to close!!~
data.close()
print "\n"
The size of auth3.log is about 1.8M.
When I send data to the destination server, I use snmp which OID is ''ifInOctets'' to get the traffic information.
But I the traffic recalculate to unit of ''Kbits'' is about 128.
How can I use this program to fill the bandwidth up to 1Gbits?(In other words, I want to fill out the bandwidth)
Thanks for your helping.