Iperf test using TRM240

I am creating a Python script to do iperf using the TRM240 in different RATs (2G, 3G, 4G). And I had some questions because I have had some issues with not being to able bind the IP address I get from the modem due to this issue:

iperf3: error - unable to connect to server - server may have stopped running or use a different port, firewall issue, etc.: Cannot assign requested address

Some background information: the 2G and 3G use just one APN whereas 4G uses another APN.

I was also wondering what are the AT commands when I can switch between operators and switch between different RATs or do I HAVE to? I was also wondering if I should define multiple PDP contexts or should I just overwrite the current one each time? And the last question, do I NEED to have chosen an operator to activate the PDP context to get an IP address?

Here is the output (4G):
AT+QCFG=“nwscanmode”,3,1
OK

AT+CGDCONT=1,“IP”,“5gapn1”
OK

+QIURC: “pdpdeact”,1

AT+COPS=0,7

OK

+CREG: 1,“009A”,“0CFDB29”,7

+CEREG: 1,“009A”,“0CFDB29”,7

AT+CGDCONT?
+CGDCONT: 1,“IP”,“5gapn1”,“0.0.0.0”,0,0,0,0
+CGDCONT: 2,“IP”,“5gapn1”,“0.0.0.0”,0,0,0,0
+CGDCONT: 3,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 4,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 5,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 6,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 7,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 8,“IP”,“”,“0.0.0.0”,0,0,0,0

OK

AT+QIACT=1
OK

AT+QIACT?
+QIACT: 1,1,1,“192.245.162.150”

OK

192.245.162.150
iperf3 -c 10.33.92.47 -B 192.245.162.150
Output:
Error: iperf3: error - unable to connect to server - server may have stopped running or use a different port, firewall issue, etc.: Cannot assign requested address

For 3G:
AT+QCFG=“nwscanmode”,2,1
OK

AT+CGDCONT=1,“IP”,“ruskoap1”
OK

AT+COPS=0,2
OK

+CREG: 1,“0032”,“259C4E2”,2

AT+COPS?
+COPS: 0,0,“RNC50 Test Network”,2

OK

AT+CGDCONT?
+CGDCONT: 2,“IP”,“5gapn1”,“0.0.0.0”,0,0,0,0
+CGDCONT: 3,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 4,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 5,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 6,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 7,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 8,“IP”,“”,“0.0.0.0”,0,0,0,0

OK

AT+QIACT=1
ERROR

AT+QIACT?
+QIACT: 1,1,1,“192.202.213.11”

OK

192.202.213.11
iperf3 -c 10.33.92.47 -B 192.202.213.11
Output:
Error: iperf3: error - unable to connect to server - server may have stopped running or use a different port, firewall issue, etc.: Cannot assign requested address

2G:
AT+QCFG=“nwscanmode”,1,1
OK

AT+CGDCONT=1,“IP”,“ruskoap1”
OK

AT+COPS=0,0
OK

AT+COPS?
+COPS: 0,0,“VIIVI258 Test Network”,0

OK

AT+CGDCONT?
+CGDCONT: 2,“IP”,“5gapn1”,“0.0.0.0”,0,0,0,0
+CGDCONT: 3,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 4,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 5,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 6,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 7,“IP”,“”,“0.0.0.0”,0,0,0,0
+CGDCONT: 8,“IP”,“”,“0.0.0.0”,0,0,0,0

OK

AT+QIACT=1
ERROR

AT+QIACT?
+QIACT: 1,1,1,“192.202.213.11”

OK

192.202.213.11
iperf3 -c 10.33.92.47 -B 192.202.213.11
Output:
Error: iperf3: error - unable to connect to server - server may have stopped running or use a different port, firewall issue, etc.: Cannot assign requested address

Hello,

The issue is likely not with the modem itself, but with the reachability of your iperf3 server. Are you sure that the IP address 10.33.92.47 is reachable from your device? This address is in a private range, which might be causing the problem.

Best regards,

It is reachable from my device, and I am able to ping it. The funny thing is that when I do a 2G iperf3 test from the TRM250, it works. Not sure why the TRM240 doesn’t work.

Hello,

TRM240 and TRM250 are very similar devices, with the main difference being that TRM250 supports Cat-M1/NB-IoT and includes 2G capabilities, whereas TRM240 is a CAT1 device without 2G capabilities. Could it be possible that the iperf3 server is reachable only via the 2G network? Is an internet connection with TRM240 present when it is connected? Is 10.33.92.47 pingable?

Best regards,

Hi,

Using the TRM240 on 4G, I am able to ping the iperf3 server. I did this with AT+QPING.

Here are my results:
AT+COPS=0,7

OK

+QIURC: “pdpdeact”,1

AT+QCFG=“nwscanmode”,3,1
OK

AT+CGDCONT=1,“IP”,“5gapn1”
OK

+CREG: 1,“009A”,“0CFDB29”,7

+CEREG: 1,“009A”,“0CFDB29”,7

AT+QIACT=1
OK

AT+QPING=1,“10.33.92.47”
OK

+QPING: 0,“10.33.92.47”,32,65,255

+QPING: 0,“10.33.92.47”,32,18,255

+QPING: 0,“10.33.92.47”,32,20,255

+QPING: 0,“10.33.92.47”,32,20,255

+QPING: 0,4,4,0,18,65,30

Hello,

Can you ping 10.33.92.47 from an end device connected to TRM240? Also, is Iperf running on 10.33.92.47?

Best regards

Hi,

Yes I can ping from the end device that is connected to the TRM240:
image

And yes, there is an iperf3 server running currently:
image

Additionally I did “netsh mbn show interfaces”, perhaps it could of help to you:
image

And I did “ipconfig /all” too:
image

Hope this can be of help to you

Hello,

Based on the “netsh” output, it seems that the connection is not established:

image

Furthermore, the IP address 10.33.92.47 belongs to a private address range. It’s possible that your SIM card is configured with a private APN or there might be another configuration issue.

Best regards,

Hi,

Yes, you are correct that the modem is not connected. For some reason Cellular 2 is not connected, I tried out another TRM240 which is connected and it seems to work.

I was also wondering if you could answer these questions?:

  • What are the AT command steps to switch between operators and switch between RATs? Do I have to switch operators to switch RATs?

  • Should I define multiple PDP contexts or should I just overwrite the current one each time?

  • Do I need to have chosen an operator to activate the PDP context to get an IP address?

Here is my setup so far:

from AT import AT
from ftplib import FTP
import time
import subprocess
import iperf3

port = ‘COM15’

Initialize modem

modem1 = AT(port)

def run_iperf_test(options):

rat = "4G"

print(modem1.send_AT_command("AT+CFUN=0"))
print(modem1.send_AT_command("AT+CFUN=1"))
print(modem1.send_AT_command("AT+QIDEACT=1"))

if rat == "2G":
    print(modem1.send_AT_command("AT+COPS=0,,,2"))
    print(modem1.send_AT_command("AT+COPS?"))
    print(modem1.send_AT_command('AT+QCFG="nwscanmode",1,1'))
    print(modem1.send_AT_command('AT+CGDCONT=1,"IP","ruskoap1"'))
    print(modem1.send_AT_command("AT+QIACT=1"))
    print(modem1.send_AT_command("AT+QIACT?"))
    

elif rat == "3G":
    print(modem1.send_AT_command("AT+COPS=0,,,2"))
    print(modem1.send_AT_command("AT+COPS?"))
    print(modem1.send_AT_command('AT+QCFG="nwscanmode",2,1'))
    print(modem1.send_AT_command('AT+CGDCONT=1,"IP","ruskoap1"'))
    print(modem1.send_AT_command("AT+QIACT=1"))
    print(modem1.send_AT_command("AT+QIACT?"))
    
elif rat == "4G":
    print(modem1.send_AT_command("AT+COPS=0,,,7"))
    print(modem1.send_AT_command("AT+COPS?"))
    print(modem1.send_AT_command('AT+QCFG="nwscanmode",3,1'))
    print(modem1.send_AT_command('AT+CGDCONT=1,"IP","5gapn1"'))
    print(modem1.send_AT_command("AT+QIACT=1"))
    print(modem1.send_AT_command("AT+QIACT?"))
    
    

ip_address = modem1.get_ip_address()
print(ip_address)

command = f'iperf3 {options} -B {ip_address}'
print(command)
result = subprocess.run(command, shell=True,capture_output=True, text=True)
print("Output:", result.stdout)
print("Error:", result.stderr)

Example usage

run_iperf_test(‘-c 10.33.92.47’)

Close modem connection

modem1.close()

Hi,

So after more investigation and testing, the reason why the Cellular 2 didn’t work was not only because it was not connected but also the Cellular APN settings activation on Windows were overriding the APN activation that I did via AT commands:
image

This topic was automatically closed 40 hours after the last reply. New replies are no longer allowed.