Renode networking

Important

This documentation is not recommended for new RISC-V projects. New RISC-V projects should reference the newest version of the documentation. Users targeting Arm devices can still use this documentation as their reference.

The newest version of the documentation can be found here: https://mi-v-ecosystem.github.io/SoftConsole-Documentation/

Renode logo

Note

Bridging the Renode’s emulated and host network adapters is only supported under Linux. Windows users who need to use the tunel/bridge networking under Renode can use Linux in a VM.

Wireshark constantly shows dialog about unsaved packets

Wait for the Renode’s Wireshark to open and then go to:

digraph {
         graph [rankdir="LR", ranksep=.01, bgcolor=transparent];
         node [fontname="Verdana", fontsize="9", shape="rectangle", width=.1, height=.2, margin=".04,.01", style=filled, fillcolor=white];
         edge [arrowsize=.7];
         "Edit" -> "Preferences" -> "Uncheck the 'Confirm unsaved capture files'" -> "Click 'OK'"
     }

Note

User’s Wireshark settings are not affected as these settings are for Renode’s Wireshark

Wireshark shows a significant amount of traffic and overloads my target

It is important to distinguish between really lost packets (for example when buffer overflow happened) and packets which just took too long for a response that they were considered lost and re-transmitting was triggered. In the case of PolarFire SoC model a Warning level logger can be enabled on the CadenceGEM peripheral by using:

logLevel 2 sysbus.mac0

If a buffer overflow occurs, then Renode will print the following message:

Receive DMA buffer overflow

Because Renode will not emulate the PolarFire SoC model at full speed, therefore the performance cannot be compared with the real hardware. Processing packets on Renode and sending responses will take longer than they would on the real hardware. Networking is very latency-sensitive and many protocols can timeout and send a retransmission of the request while the target was processing the response, causing the target to have even more requests to process. Therefore extra care should be made to not overload the target with unnecessary packets.

It’s recommended either not to bridge the renode-tap0 with the host’s interface to keep away unnecessary traffic and keep the interfaces separate with their own, non-overlapping IP networks. Even if the interfaces are not bridged there might be daemons running which queries and discovery requests to all networks. For example, NTP time sync service might at some cases start querying the network range and produce frequent packets. Temporarily disable the daemon to see if it does improve the issue:

sudo /etc/init.d/ntp stop

Monitoring what process do on the network might give indications of what services/tools might be causing unnecessary packets. Use netstat to print networking connections and disable unneeded services which flood the Renode’s network with unnecessary packets and requests.

Could not set TUNSETIFF, error: 2

When creating a networking bridge from the Renode emulation a TUN/TAP interface on the host must be created. Renode probes if the interface is already present and when it’s not, it will try if a current user has privileges to create such interface. In most cases, the current user doesn’t have privileges to do so and will invoke this error message. In general, it should be safe to ignore this error as it is sometimes expected.

When the user has no privileges to create the tap, then Renode will invoke polkit to elevate users privileges for this command to succeed. Behavior differs between distributions and how polkit/sudo is configured. It might request for user’s password, it might continue without prompt or it might wait for a fingerprint scan.

If the tap interface already is present on the system, Renode should continue without error message even when previously it was displaying the message. Related topics in Renode’s documentation:

https://renode.readthedocs.io/en/latest/networking/host-network.html https://renode.readthedocs.io/en/latest/networking/wireshark.html

How do I delete Renode’s bridge TAP networking interface?

ip link del tap0
sudo ip link del tap0

Can’t see the interface after invoking BridgeNetworkMac0 macro

The behavior strongly depends on the distribution’s settings.

Configuration of /etc/sysconfig/network-scripts/ file

Configuration of /etc/network/interfaces file.

However, in many cases the interface is by default down and will only show in the list when ifconfig -a is invoked. The interfaces needs to be brought up and probably with a specific IP, for example:

sudo ifconfig renode-tap0 172.16.0.1/24 up

The host IP shouldn’t be in conflict in any IPs on the network. Preferably your host IP should be guest’s gateway IP. The mask settings should match with mask settings of your target. The /24 is an equivalent representation of the 255.255.255.0 mask

Can’t ping my target

There might be a networking issue (go over the other existing networking related sections), or it might be because the target doesn’t have ICMP (ping) service/support. Not all targets do implement ping and the networking might be working correctly even without working ping.

The mpfs-freertos-lwip example does support ping and ICMP protocol and it’s by default enabled with the LWIP_ICMP define in the /src/modules/config/lwip-2.0.0-wip/lwipopts.h file.

Check the section “My target doesn’t respond to packets” below to troubleshoot if the target is responding to any packets at all.

My target doesn’t respond to packets

It can be caused by many various reasons and might be different between the host’s settings and as well different between the applications themselves as they can have different IP stacks (which can be configured differently).

  • A firewall is blocking the packets, temporarily disable the firewall. In case your distribution does save iptables on the reboot, then it’s preferable to save the rules before deleting and then restoring the rules before rebooting:

    sudo iptables-save > <TEMPORARY_FILE>
    

    And to restore them back:

    sudo iptables-save < <TEMPORARY_FILE>
    

    If a netfilter-persistent package is installed, then the following should work:

    sudo service netfilter-persistent save
    

    Package such as iptables-persistent might be restoring the settings every single time. To delete all existing firewall rules and have only “accept” policy issue as super user the following:

    iptables -P INPUT ACCEPT
    iptables -P FORWARD ACCEPT
    iptables -P OUTPUT ACCEPT
    iptables -t nat -F
    iptables -t mangle -F
    iptables -F
    iptables -X
    iptables -S
    
  • The target is not capable to respond to ARP messages. When using cut-down IP stack without ARP feature, then on the host the target’s HW address has to manually inserted into the ARP table:

    sudo arp -s <TARGET_IP> <TARGET_MAC>
    sudo arp -s 172.16.0.2 00:fc:00:12:34:56
    
  • Browsers might overwhelm the target as they can query many requests concurrently (such as favicon), instead of a browser try wget:

    wget http://172.16.0.2
    

    Or use curl which is more flexible and allows to control headers of POST/PUT requests as well.

  • If all other interfaces were put down, then the renode-tap0 can be made to the default gateway:

    sudo route del default                     # delete previous default gateway
    sudo route add default gw 172.16.0.1       # add your default gateway
    sudo route -n                              # show routing table
    
  • The Renode’s networking tunnel is similar to a tap, for some users this might be useful:

    http://www.shakthimaan.com/installs/debian-tun-tap-setup.html