Commit 1dc74b0c authored by Kirill Smelkov's avatar Kirill Smelkov

t/udpflood: Test program to simulate transmission bursts

It is useful to verify E-UTRAN IP Throughput KPI implementation, as
that KPI is defined in terms of burst samples.
parent 2824f50d
#!/usr/bin/env python
# Copyright (C) 2023 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
"""Program udpflood sends/floods packets via UDP.
It is useful to test how E-UTRAN IP Throughput KPI implementation handles bursts.
Usage: udpflood host:port npkt/period pause_ms
"""
import sys, time
from socket import socket, AF_INET, SOCK_DGRAM, IPPROTO_UDP
def main():
addr = sys.argv[1]
host, port = addr.split(':')
port = int(port)
npkt_period = 1
pause_ms = 0
if len(sys.argv) >= 3:
npkt_period = int(sys.argv[2])
if len(sys.argv) >= 4:
pause_ms = int(sys.argv[3])
print("# udpflood -> %s :%s %d pkt/period, %dms pause in between periods" %
(host, port, npkt_period, pause_ms))
sk = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
pkt = b'\xff'*1000
while 1:
for _ in range(npkt_period):
sk.sendto(pkt, (host, port))
if pause_ms:
time.sleep(pause_ms*0.001)
if __name__ == '__main__':
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment