how to generate some test traffic?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
ARTaylor
Posts: 29
Joined: Fri Mar 23, 2018 4:04 pm
Contact:

how to generate some test traffic?

Post by ARTaylor » Thu Apr 26, 2018 8:34 am

Hello ladies and gents - I have a basic sensor monitoring system I am running on a ESP32 using Micropython and MQTT - It is working well at home. I have tried running it at the Uni I am based at but I get an EHOSTUNREACH error. It looks like I am getting blocked for some reason by the network here. I have been talking to IT and they are helping me out remotely, but have asked me to generate some traffic from the device - they said use http get or ping 8.8.8.8 - I'm pretty new to this stuff and don't know what it means exactly or how to do it - I put this test script (below) together to give it a shot but the urllib.urequest.urlopen("http://google.com") doesn't seem to be sufficient for what IT need.

I would really appreciate it if someone could help me out with a quick fix here, but also I want to understand what they want me to do and why, and of course how to do something similar in future - please and thanks!

Code: Select all

import machine
import ubinascii
import network
import time
import urllib.urequest

# Network
SSID = "SSID" # Network Name
Password = "PASSWORD" # Network password

station = network.WLAN(network.STA_IF)
station.active(True)

def WiFiConnect():
    # Connect
    station.connect(SSID, Password)

    # Wait for connection
    print("connecting...")
    while not station.isconnected():
        print("...")
        time.sleep(5)
        print("Connected!\n")

WiFiConnect()

while True:
    print('ip address, netmask, gateway, DNS:')
    print(station.ifconfig()) # reveal the devices ip address
    print('')
    print('Device MAC = ', ubinascii.hexlify(machine.unique_id(),':').decode())
    print('')
    print('wifi interface MAC = ', ubinascii.hexlify(station.config('mac'),':').decode())
    print('')

    contents = urllib.urequest.urlopen("http://google.com")
    contents.close()
    time.sleep(10)
Grow something!

ARTaylor
Posts: 29
Joined: Fri Mar 23, 2018 4:04 pm
Contact:

Re: how to generate some test traffic?

Post by ARTaylor » Thu Apr 26, 2018 8:45 am

Ok I think this has helped: http://docs.micropython.org/en/v1.9.2/e ... k_tcp.html

But some "explain like I am five" would still be appreciated! :D
Grow something!

Post Reply