# Iperf test using TRM240

**URL:** <https://community.teltonika.lt/t/iperf-test-using-trm240/6612>\
**Category:** Networking Solutions\
**Created:** [July 4, 2024, 5:43am UTC](https://community.teltonika.lt/t/iperf-test-using-trm240/6612 "2024-07-04T05:43:01Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![aykay](https://community.teltonika.lt/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@aykay](https://community.teltonika.lt/u/aykay)\
**Post date:** [July 4, 2024, 5:43am UTC](https://community.teltonika.lt/t/iperf-test-using-trm240/6612/1 "2024-07-04T05:43:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Marijus](https://community.teltonika.lt/user_avatar/community.teltonika.lt/marijus/32/694_2.png) [@Marijus](https://community.teltonika.lt/u/Marijus)\
**Post date:** [July 4, 2024, 7:02am UTC](https://community.teltonika.lt/t/iperf-test-using-trm240/6612/3 "2024-07-04T07:02:46Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![aykay](https://community.teltonika.lt/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@aykay](https://community.teltonika.lt/u/aykay)\
**Post date:** [July 4, 2024, 7:34am UTC](https://community.teltonika.lt/t/iperf-test-using-trm240/6612/4 "2024-07-04T07:34:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Marijus](https://community.teltonika.lt/user_avatar/community.teltonika.lt/marijus/32/694_2.png) [@Marijus](https://community.teltonika.lt/u/Marijus)\
**Post date:** [July 4, 2024, 8:31am UTC](https://community.teltonika.lt/t/iperf-test-using-trm240/6612/5 "2024-07-04T08:31:28Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![aykay](https://community.teltonika.lt/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@aykay](https://community.teltonika.lt/u/aykay)\
**Post date:** [July 4, 2024, 9:16am UTC](https://community.teltonika.lt/t/iperf-test-using-trm240/6612/6 "2024-07-04T09:16:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Marijus](https://community.teltonika.lt/user_avatar/community.teltonika.lt/marijus/32/694_2.png) [@Marijus](https://community.teltonika.lt/u/Marijus)\
**Post date:** [July 4, 2024, 9:28am UTC](https://community.teltonika.lt/t/iperf-test-using-trm240/6612/7 "2024-07-04T09:28:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![aykay](https://community.teltonika.lt/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@aykay](https://community.teltonika.lt/u/aykay)\
**Post date:** [July 4, 2024, 9:31am UTC](https://community.teltonika.lt/t/iperf-test-using-trm240/6612/8 "2024-07-04T09:31:22Z")

</div>

Hi,

Yes I can ping from the end device that is connected to the TRM240:  
 ![image](https://community.teltonika.lt/uploads/default/original/2X/7/75cbb02fdd6d2e11bedabd15336609ab14fa5840.png)

And yes, there is an iperf3 server running currently:  
 ![image](https://community.teltonika.lt/uploads/default/original/2X/6/64a02ea0b6643d3d2629a86f6cd9c2293878566c.png)

Additionally I did “netsh mbn show interfaces”, perhaps it could of help to you:  
 ![image](https://community.teltonika.lt/uploads/default/original/2X/4/46889005ca68d6c4ff7e65bab2744fb60adf2a04.png)

And I did “ipconfig /all” too:  
 ![image](https://community.teltonika.lt/uploads/default/original/2X/e/e550c8a441f91a1fd9882d5cb3956aec3cae43bc.png)

Hope this can be of help to you

---

<div class="post-metadata">

**Author:** ![Marijus](https://community.teltonika.lt/user_avatar/community.teltonika.lt/marijus/32/694_2.png) [@Marijus](https://community.teltonika.lt/u/Marijus)\
**Post date:** [July 4, 2024, 9:48am UTC](https://community.teltonika.lt/t/iperf-test-using-trm240/6612/9 "2024-07-04T09:48:29Z")

</div>

Hello,

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

![image](https://community.teltonika.lt/uploads/default/original/2X/8/88622dee709c0ad5bf2c83bff4fc19c433e14ed8.png)

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,

---

<div class="post-metadata">

**Author:** ![aykay](https://community.teltonika.lt/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@aykay](https://community.teltonika.lt/u/aykay)\
**Post date:** [July 4, 2024, 10:58am UTC](https://community.teltonika.lt/t/iperf-test-using-trm240/6612/10 "2024-07-04T10:58:29Z")

</div>

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()

---

<div class="post-metadata">

**Author:** ![aykay](https://community.teltonika.lt/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@aykay](https://community.teltonika.lt/u/aykay)\
**Post date:** [July 4, 2024, 12:24pm UTC](https://community.teltonika.lt/t/iperf-test-using-trm240/6612/11 "2024-07-04T12:24:04Z")

</div>

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](https://community.teltonika.lt/uploads/default/original/2X/f/fa1187ad1f010e0defb77e320882f2243951a44f.png)

---

<div class="post-metadata">

**Author:** ![system](https://community.teltonika.lt/user_avatar/community.teltonika.lt/system/32/15707_2.png) [@system](https://community.teltonika.lt/u/system)\
**Post date:** [July 6, 2024, 4:24am UTC](https://community.teltonika.lt/t/iperf-test-using-trm240/6612/12 "2024-07-06T04:24:20Z")

</div>

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