Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Port forwarding for UDP in App Build Environment

Port forwarding for UDP in App Build Environment

BennyF
Member

I'm developing an App with UDP communication. But I had trouble getting the communication running, even though I've entered the port number in the "Port forwarding" field.

BennyF_0-1718195118985.png

Then, I've found out that CtrlX WORKS is assuming tcp, which leads to the following line in the "start.bat" file of the app build environment:

call launch.bat amd64 noproxy "hostfwd=tcp::11022-:22,hostfwd=tcp::16110-:6110" Testbuilder whpx:tcg

When I manually changed it to "udp" and started the environment manually via "start.bat", my communication worked.

call launch.bat amd64 noproxy "hostfwd=tcp::11022-:22,hostfwd=udp::16110-:6110" Testbuilder whpx:tcg

Unfortunately, on every start via CtrlX Works, this line is set back to "tcp".

Is there a way to define port forwarding for "upd" in the app build environment properties in CtrlX WORKS?

3 REPLIES 3

nickH
Community Moderator
Community Moderator

Did you try to remove the port form the Port Forwarding settings in the ctrlX Works UI. And then manually add the udp port to the start.bat? 

Sgilk
Frequent Contributor

Hi @BennyF,

You can manually add the UDP ports to the launch.bat which won't be changed on modification of the ctrlX WORKS configuration.

 

@echo off

rem Parameters
rem %1 CPU Architecture Guest System: amd64 (default), aarch64
rem %2 Proxy usage: proxy (default), no-proxy

rem Important: 
rem Enclose these parameter values with quotation marks otherwise they will be splitted.
rem %3 Port Forwarding: "hostfwd=tcp::10022-:22,hostfwd=tcp::8000-:8000,hostfwd=...."
rem %4 Acceleration: "whpx:hax:tcg"

set ARCH=%~1
If not defined ARCH (set ARCH=amd64)

set PROXY=%~2
If not defined PROXY (set PROXY=proxy)

set TCP_PFW=%~3
If not defined TCP_PFW (set PFW=hostfwd=tcp::10022-:22)
set UDP_PFW=hostfwd=udp::16110-:6110
set PFW=%TCP_PFW%%UDP_PFW%
echo %PFW%
pause

set NAME=%~4
If not defined NAME (set NAME=App-Build-Environment)

set ACCEL=%~5
If not defined ACCEL (set ACCEL=whpx:hax:tcg)

set ACTIVITY="Initializing, please wait - restart if finshed"
if exist *.qcow2 (set ACTIVITY= )

TITLE %NAME% %ACTIVITY% %CD% %ARCH% %PFW%

set OS=ubuntu-20.04-server

set ARCH=amd64
set PROXY=proxy

set AR=ar
set NO=no

rem https://stackoverflow.com/questions/7005951/batch-file-find-if-substring-is-in-string-not-in-a-file
for %%x in (%*) do (
    echo %%x
    echo %%x | FINDSTR /C:%AR% >nul && ( set ARCH=aarch64)    
    echo %%x | FINDSTR /C:%NO% >nul && ( set PROXY=noproxy)    
)

:: Check cloud image file ---------------------------------------------------
set U=%OS%-cloudimg
set UA=%U%-%ARCH%
set IMG=%UA%.img
set QCOW2=%UA%-snapshot-%PROXY%.qcow2
set UDIMG=%UA%-user-data-%PROXY%.img

IF "%ARCH%" == "aarch64" (
set IMG=%U%-arm64.img
)
if not exist %IMG% (
    call wget.bat https://cloud-images.ubuntu.com/releases/focal/release/%IMG% %IMG%
)

if not exist %IMG% (
    echo ERROR: File '%IMG%' is missing 
    echo INFO: Download this file from 'https://cloud-images.ubuntu.com/releases/focal/release' and copy it into this directory
    exit /B 1
)

:: Create snapshot file --------------------------------------------------------
if not exist %QCOW2% (
    qemu-img create -b %IMG% -f qcow2 %QCOW2% -F qcow2 32G
)

:: Check user data image file -------------------------------------------------
if not exist %UDIMG% (
    echo ERROR: File '%UDIMG%' is missing 
    echo INFO: Copy this file from your SDK zip archive into this directory
    exit /B 1
)

REM wget.exe changes the title
TITLE %NAME% %ACTIVITY% %CD% %ARCH% %PFW%

REM Enable ESC sequences for enhanced text output in console - needs no admin rights
REG ADD HKCU\CONSOLE /f /v VirtualTerminalLevel /t REG_DWORD /d 1

IF "%ARCH%" == "amd64" (
    qemu-system-x86_64.exe ^
	-name "%NAME%" ^
    -machine q35,accel=%ACCEL% ^
    -smp 4 ^
    -m 4G ^
    -netdev user,id=eth0,%PFW% ^
    -device virtio-net-pci,netdev=eth0,mac=DE-AD-BE-00-00-01 ^
    -drive "file=%QCOW2%,format=qcow2" ^
    -drive "file=%UDIMG%,format=raw" ^
    -display none ^
    -nographic

    exit /B 0
)

if not exist QEMU_EFI.fd (
    call wget.bat https://releases.linaro.org/components/kernel/uefi-linaro/16.02/release/qemu64/QEMU_EFI.fd QEMU_EFI.fd
)

if not exist QEMU_EFI.fd (
    echo ERROR: File QEMU_EFI.fd is missing 
    echo INFO: Download this file from 'https://releases.linaro.org/components/kernel/uefi-linaro/16.02/release/qemu64' and copy it into this directory
    exit /B 1
)

REM Windows only: -cpu cortex-a72

qemu-system-aarch64.exe ^
-name "%NAME%" ^
-M virt ^
-cpu cortex-a72 ^
-accel tcg ^
-smp 4 ^
-m 4G ^
-bios QEMU_EFI.fd ^
-netdev user,id=eth0,%PFW% ^
-device virtio-net-pci,netdev=eth0,mac=DE-AD-BE-00-00-01 ^
-drive "file=%QCOW2%,format=qcow2" ^
-drive "file=%UDIMG%,format=raw" ^
-display none ^
-nographic






 

 

The relevant section is here. I had it pausing for debug purposes, so really you want to append the UDP ports to the PFW variable and remove the pause:

 

set TCP_PFW=%~3
If not defined TCP_PFW (set PFW=hostfwd=tcp::10022-:22)
set UDP_PFW=hostfwd=udp::16110-:6110
set PFW=%TCP_PFW%%UDP_PFW%
echo %PFW%
pause

 

Hello @Sgilk,

yes, that solution worked for me. The start.bat file is overwritten by CtrlX WORKS on starting the app build environment. The launch.bat file is not touched. I only had to add a "," between TCP_PFW and UDP_PFW:

set PFW=%TCP_PFW%,%UDP_PFW%

Then, your solution worked fine for me. Thanks!

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist