sagar
sagar

Reputation: 74

Generate Gateway scenario in Contiki in cooja simulator

I want to generate scenario where IoT network communicate through ipv6 via Gateway Router natively mean on simulator i don't have real motes to test.

How to make linux communicate to Cooja simulator as a gateway?

Upvotes: 0

Views: 1112

Answers (1)

kfx
kfx

Reputation: 8537

Use serial2pty plugin: https://github.com/cmorty/cooja-serial2pty

The plugin creates a virtual serial port (pseudoterminal: PTY). You can then access that PTY as any regular serial port in Linux.

There might be a problem if the port is created dynamically - you won't know the name of the PTY device. So the plugin also includes discovery service functionality. It is a TCP server that returns the name of the PTY.

Here's Python code that can be used to get the name of the PTY using this discovery service:

    address = "localhost"
    port = 6100

    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.settimeout(3.0)
    sock.connect((address, port))
    data = ""
    while True:
        c = sock.recv(1)
        if c not in ['/', '.'] and not c.isalnum():
            break
        data += c
        if len(data) > 100: break
    sock.close()
    return data

Upvotes: 1

Related Questions