Using port forwarding, the target can also be accessed from the host, and potentially from any system that can access the host, so this should be used with care. Here is an example of setting up portforwarding that could allow transferring files between the target and the the host.
Follow the preparation steps to launch the simulator and reach prompt in the target machine.
Enable real time mode, to avoid network timeouts.
simics> enable-real-time-mode
Real-time mode enabled.
Inspect the service node DNS to find the IP address of the target machine.
simics> service_node.sn.list-host-info
┌───────────┬───────────────────┬─────────────────┐
│ IP │ name.domain │ MAC │
├───────────┼───────────────────┼─────────────────┤
│10.10.0.1 │simics0.network.sim│20:20:20:20:20:00│
│10.10.0.100│board.network.sim │00:17:a0:00:00:00│
└───────────┴───────────────────┴─────────────────┘
Set up port forwarding to the target. By default, this opens a few ports on the host corresponding to FTP, SSH, Telnet and HTTP, and connects them to the target. Other ports can also be opened by specifying parameters to the command.
simics> connect-real-network target-ip = 10.10.0.100
NAPT enabled with gateway 10.10.0.1/24 on link ethernet_switch.link.
NAPT enabled with gateway fe80::2220:20ff:fe20:2000/64 on link ethernet_switch.link.
Host TCP port 4021 -> 10.10.0.100:21
Host TCP port 4022 -> 10.10.0.100:22
Host TCP port 4023 -> 10.10.0.100:23
Host TCP port 4080 -> 10.10.0.100:80
Warning: This can expose the target system on the host local network.
Real DNS enabled at 10.10.0.1/24 on link ethernet_switch.link.
Real DNS enabled at fe80::2220:20ff:fe20:2000/64 on link ethernet_switch.link.
With port forwarding enabled, the simulated target can be accessed from the
host using standard network tools. The connect-real-network command above
set up the following port forwards:
| Service | Functionality | Access (localhost) | Destination (target) |
|---|---|---|---|
| SSH | Remote login | localhost:4022 | 10.10.0.100:22 |
| Telnet | Remote login | localhost:4023 | 10.10.0.100:23 |
| SCP | File transfer | localhost:4022 | 10.10.0.100:22 |
| FTP | File transfer | localhost:4021 | 10.10.0.100:21 |
So ssh to localhost on port 4022 will be redirected to port 22 on the simulated target (10.10.0.100).
These tools require:
ssh, telnet, scp, ftp) to be installed on the hostsshd, ftpd, etc.)SSH Authentication must be configured for the following examples to work, and the
qsp-x86/firststepstarget’s Linux image has no default password. A simple way to allow SSH login would be to add a user, and set a password (adduser someuser).
Once authentication is configured, you can transfer a file using scp:
$ scp -P 4022 myfile.txt someuser@localhost:/home/
Or log in to the target via SSH:
$ ssh -p 4022 someuser@localhost
A recommended first file to transfer is the Simics Agent. The Simics Agent binaries can be located with the following command:
simics> lookup-file "%simics%/targets/common/images/simics_agent_binaries.zip"
"C:\\Simics\\packages\\simics-7.75.0\\targets\\common\\images\\simics_agent_binaries.zip"
After the Simics Agent is available on the target, it provides additional functionality beyond file transfer; see Using the Simics Agent.
Using port forwarding, you can also connect to other network services available on the target, such as web servers (port 4080 forwards to HTTP port 80).