Intel® Simics® Simulator for Intel® FPGAs: User Guide

ID 784383
Date 4/01/2024
Public
Document Table of Contents

7.2.1.2.1. Example of SSH Connection With Outgoing Port Forwarding

The following example shows an SSH connection from the simulated target system to the host PC. In this example, you are connecting through SSH from the target system serial console to the port 22 in host PC.

The setup is done using the connect-real-network-port-out command. Define the service node port as 4022. The Ethernet link corresponds to ethernet_swith0. For host PC side, define (target of forwarding ports) its IP for the target-IP argument, and the port to forward the outgoing messages is defined as 22.

HostPC | Target system
 Outgoing      22 <- 4022
#Intel Simics simulator CLI 

simics> connect-real-network-port-out service-node-port = 4022 ethernet-link 
= ethernet_switch0 target-ip=10.122.105.138 target-port=22 -tcp

10.10.0.1 TCP port 4022 on link ethernet_switch0.link -> host 10.122.105.138:22
ff02::1:2 TCP port 4022 on link ethernet_switch0.link -> host 10.122.105.138:22
Warning: This can expose the target system on the host local network.
simics> list-port-forwarding-setup 

10.10.0.1 TCP port 4022 on link ethernet_switch0.link -> host 10.122.105.138:22
ff02::1:2 TCP port 4022 on link ethernet_switch0.link -> host 10.122.105.138:22
simics> run

Once you are done with the outgoing forwarding port setup, the SSH connection can be established from the simulated target system. The user is defined as simicsUser. In the example, the SSH connection in the target system always talks directly with the service node (service node IP and port 4022) regardless of the IP in the host PC. You can have a static configuration in the target software side, and the host IP is only used in the Intel® Simics® simulation set up when creating the forwarding port.

Once you input the ssh command, observe that you can connect to the host PC from the target system.

# Target Serial Console

root@psgdevice:~# ssh simicsUser@10.10.0.1 -p 4022

SimicsUser@10.10.0.1's password: 
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.15.0-52-generic x86_64)
 
* Documentation:  https://help.ubuntu.com
* Management:     https://landscape.canonical.com
* Support:        https://ubuntu.com/advantage
 
Your Hardware Enablement Stack (HWE) is supported until April 2025.
Last login: Mon Nov 14 11:10:17 2022 from 10.212.63.244
simicsUser@simicsUser-linux-lab:~$ whoami
SimicsUser
simicsUser@simicsUser-linux-lab:~$ exit
logout
Connection to 10.10.0.1 closed.
root@psgdevice:~#