4.2.2 Ethernet Bridging 4.3 Accessing Host Ethernet Interfaces
Ethernet Networking Technology Guide  /  4 Connecting to a Real Network  /  4.2 Connection Types  / 

4.2.3 Host Connection

Simics can connect a simulated network to a virtual Ethernet (TAP) interface on the simulation host. The simulation host and the simulated machines will then be able to communicate as if they were connected to the same Ethernet network. For example, by configuring the simulation host with an IP address on the TAP interface, the simulation host and the simulated machines will be able to send IP traffic to each other.

Enabling IP forwarding on the host will also allow the simulated machines to access other hosts on the real network, using the host operating system's IP routing facilities. Read the instructions after the example below for instructions about how to set it up.

To connect the simulated network to the TAP interface, the TAP interface should be configured on the simulation host, as described in section 4.3.1. Use the connect-real-network-host command, which simply takes the name of the TAP interface as the interface argument. The simulation host will now appear on the simulated network. Configure the TAP interface of the host with an IP address from the same subnet as the simulated machines, and the simulated machines will be able to communicate with the host.

Simulated machine configurations provided with Simics usually use IP addresses from the 10.10.0.x subnet, so the simulation host should typically get an IP address on the form 10.10.0.x with a netmask of 255.255.255.0.

On Linux, this is configured with ifconfig, which requires administrative privileges:

computer# ifconfig sim_tap0 10.10.0.x netmask 255.255.255.0 up

On Windows, use these steps instead:

  1. Open the Network Connections folder of the Control Panel.
  2. Right-click on the OpenVPN TAP interface to bring up a context menu, and select Properties.
  3. A property dialog box will open. Select Internet Protocol (TCP/IP) and click on the Properties button.
  4. A new property dialog box will open. Select Use the following IP address and enter the IP address and Subnet mask the simulation host should use on the simulated network.

    Select an IP address on the form 10.10.0.x and the netmask 255.255.255.0. The Default gateway field can typically be left blank.

  5. Click OK in both property dialog boxes.

Example

This example assumes that the simulation is starting from the checkpoint prepared in section 4.1, that there is a correctly set up TAP interface on the simulation host for host connection according to section 4.3.1, and that it has been configured with the IP address 10.10.0.1 as described above. Here the name if the TAP interface is assumed to be sim_tap0: replace it with the name of the TAP interface.

To connect the TAP interface to the simulated network, use the connect-real-network-host command:

simics> connect-real-network-host interface = sim_tap0
No Ethernet link found, created default_eth_switch0.
Connected board.mb.sb.eth_slot to default_eth_switch0
[rn0.rn info] Connecting to TAP device 'sim_tap0'
'default_eth_switch0' connected to real network.

Note: On Windows, the message "Connecting to existing TUN/TAP device 'sim_tap0'" will not appear.
Any kind of Ethernet traffic can now pass between the simulated network and the simulation host. It should be possible, for example, to ping the simulation host from the simulated machine, at the IP address configured on the TAP interface:

~# ping 10.10.0.1 -c 5
PING 10.10.0.1 (10.10.0.1) from 10.10.0.40 : 56(84) bytes of data.
64 bytes from 10.10.0.1: icmp_seq=1 ttl=64 time=1.15 ms
64 bytes from 10.10.0.1: icmp_seq=2 ttl=64 time=1.11 ms
64 bytes from 10.10.0.1: icmp_seq=3 ttl=64 time=10.9 ms
64 bytes from 10.10.0.1: icmp_seq=4 ttl=64 time=1.11 ms
64 bytes from 10.10.0.1: icmp_seq=5 ttl=64 time=1.11 ms

--- 10.10.0.1 ping statistics ---
5 packets transmitted, 5 received, 0% loss, time 4037ms
rtt min/avg/max/mdev = 1.113/3.085/10.932/3.923 ms

IP Forwarding

Enabling IP forwarding on the simulation host will allow real machines to access the simulated network by routing the traffic through the simulation host. This method is called IP forwarding.

On Linux run the following command to set up ip forwarding:

computer# sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1

And to disable IP forwarding again:

computer# sysctl -w net.ipv4.ip_forward=0
net.ipv4.ip_forward = 0

To set it up on Windows, change the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\IPEnableRouter from 0 to 1 and reboot. If the key does not exist, create it and give it the value 1. To disable IP forwarding, reset the registry key to 0 and reboot.

For the routing to work, both the simulated machines and the machines on the real network must be configured: on the simulated machines, a route must be added to the real network with the IP address of the host's TAP interface as gateway; on the real machines, it is a route to the simulated network with the IP address of the simulation host's Ethernet interface that should be added.

4.2.2 Ethernet Bridging 4.3 Accessing Host Ethernet Interfaces