mqtt_random_payload_fuzzy.py 585 Bytes
import paho.mqtt.client as mqtt
import random
import multiprocessing
import signal
import string
import sys
import logging
import time
import unittest

def mqtt_ramdom_payload_fuzzy(mqtt_server_IP, mqtt_server_PORT, topic):
    client = mqtt.Client("AA")
    client.connect(mqtt_server_IP, mqtt_server_PORT)
    client.loop_start()
    
    for i in range(1, 1000, 4):
        payload = "".join([chr(random.randint(1, 127)) for _ in range(i)])
        print(f"Sent Payload {len(payload)} bytes")
        client.publish(topic, payload)

    client.loop_stop()
    client.disconnect()