GNS3
http://forum.gns3.net/

UDP Port increment bug [RESOLVED]
http://forum.gns3.net/topic6396.html
Page 1 of 1

Author:  rednectar [ Wed May 22, 2013 9:48 pm ]
Post subject:  UDP Port increment bug [RESOLVED]

I was trying to explain the concept of UDP pipes to someone, using GNS3, when I noticed that:

When a 2nd hypervisor is spawned, the GNS3 console debug STATES that the new base UDP port is 10101. But when the port is allocated, it ACTUALLY uses 11101 - incremented by 1100 rather than 100. Strangely, when a 3rd hypervisor is spawned, the port counting is sorted - and it uses 10201 as expected.

Code:
=> show run
autostart = False
[127.0.0.1:7200]
    workingdir = c:\users\chris\appdata\local\temp\GNS3_vptgsc\working
    udp = 10001
    [[7200]]
        image = C:\Users\chris\GNS3\Images\c7200-adventerprisek9-mz.150-1.M.image
        idlepc = 0x6017fe70
        sparsemem = True
        ghostios = True
    [[ROUTER R1]]
        console = 2103
        aux = 2503
        slot1 = PA-2FE-TX
        f1/0 = R2 f1/0
    [[ROUTER R2]]
        console = 2104
        aux = 2504
        slot1 = PA-2FE-TX
        f1/0 = R1 f1/0
[127.0.0.1:7201]
    workingdir = c:\users\chris\appdata\local\temp\GNS3_vptgsc\working
    udp = 10101
    [[7200]]
        image = C:\Users\chris\GNS3\Images\c7200-adventerprisek9-mz.150-1.M.image
        ram = 256
        idlepc = 0x6017fe70
        sparsemem = True
        ghostios = True
    [[ROUTER R3]]
        console = 2105
        aux = 2505
=> 06:40:09: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> nio get_stats nio_udp1
06:40:09: DEBUG (1): returned -> ['100-0 0 0 0']
06:40:11: DEBUG (1): sending to dynamips at 127.0.0.1:7201 -> vm slot_add_binding R3 1 0 PA-2FE-TX
06:40:11: DEBUG (1): returned -> ['100-OK']
06:40:11: DEBUG (2): Node R3: running config: {'console': 2105, 'aux': 2505, 'slot1': 'PA-2FE-TX'}
06:40:11: DEBUG (2): Connect link from R2 f1/1 to R3 f1/0
06:40:11: DEBUG (1): new base UDP port for dynamips at 127.0.0.1:7200 is now: 10004
06:40:11: DEBUG (1): new base UDP port for dynamips at 127.0.0.1:7201 is now: 11102

********************NOTE THE NEXT LINE - I see 11101 where I expect 10101

06:40:11: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> nio create_udp nio_udp2 10003 127.0.0.1 11101


06:40:11: DEBUG (1): returned -> ["100-NIO 'nio_udp2' created"]
06:40:11: DEBUG (1): sending to dynamips at 127.0.0.1:7201 -> nio create_udp nio_udp3 11101 127.0.0.1 10003
06:40:11: DEBUG (1): returned -> ["100-NIO 'nio_udp3' created"]
06:40:11: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm slot_add_nio_binding R2 1 1 nio_udp2
06:40:11: DEBUG (1): returned -> ['100-OK']
06:40:11: DEBUG (1): sending to dynamips at 127.0.0.1:7201 -> vm slot_add_nio_binding R3 1 0 nio_udp3
06:40:11: DEBUG (1): returned -> ['100-OK']
06:40:11: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> nio get_stats nio_udp1
06:40:11: DEBUG (1): returned -> ['100-0 0 0 0']
06:40:11: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> nio get_stats nio_udp2
06:40:11: DEBUG (1): returned -> ['100-0 0 0 0']
06:40:11: DEBUG (1): sending to dynamips at 127.0.0.1:7201 -> nio get_stats nio_udp3
06:40:11: DEBUG (1): returned -> ['100-0 0 0 0']


C:\Users\chris>netstat -an | find "UDP"
  UDP    0.0.0.0:10001          *:*
  UDP    0.0.0.0:10002          *:*
  UDP    0.0.0.0:10003          *:*
  UDP    0.0.0.0:11101          *:*


Curiously, if I add more routers so that a 3rd hypervisor is spawned, the 3rd hypervisor gets the expected maths - 10201!

Code:
06:56:51: DEBUG (2): Connect link from R5 f1/0 to R4 f1/0
06:56:51: DEBUG (1): new base UDP port for dynamips at 127.0.0.1:7202 is now: 10202
06:56:51: DEBUG (1): new base UDP port for dynamips at 127.0.0.1:7201 is now: 11103
06:56:51: DEBUG (1): sending to dynamips at 127.0.0.1:7202 -> nio create_udp nio_udp4 10201 127.0.0.1 11102
06:56:51: DEBUG (1): returned -> ["100-NIO 'nio_udp4' created"]
06:56:51: DEBUG (1): sending to dynamips at 127.0.0.1:7201 -> nio create_udp nio_udp5 11102 127.0.0.1 10201
06:56:51: DEBUG (1): returned -> ["100-NIO 'nio_udp5' created"]

Author:  rednectar [ Sun May 26, 2013 9:50 am ]
Post subject:  Re: UDP Port increment bug

UPDATE:

I got to wondering, "What happens when the port increment gets to 11101 after about 10 hypervisors?" So I created a topology with enough routers to find out.

Result? The numbers didn't go weird until I was expecting 10901 - here is a netstat -an (trimmed). And they took another strange jump after 11704...

This is very strange.


UDP 0.0.0.0:10001 *:*
UDP 0.0.0.0:10002 *:*
UDP 0.0.0.0:10003 *:*
UDP 0.0.0.0:10201 *:*
UDP 0.0.0.0:10202 *:*
UDP 0.0.0.0:10203 *:*
UDP 0.0.0.0:10204 *:*
UDP 0.0.0.0:10401 *:*
UDP 0.0.0.0:10402 *:*
UDP 0.0.0.0:10403 *:*
UDP 0.0.0.0:10404 *:*
UDP 0.0.0.0:10601 *:*
UDP 0.0.0.0:10602 *:*
UDP 0.0.0.0:10603 *:*
UDP 0.0.0.0:10604 *:*
UDP 0.0.0.0:10801 *:*
UDP 0.0.0.0:10802 *:*
UDP 0.0.0.0:10803 *:*
UDP 0.0.0.0:10804 *:*
UDP 0.0.0.0:11101 *:*
UDP 0.0.0.0:11102 *:*
UDP 0.0.0.0:11103 *:*
UDP 0.0.0.0:11104 *:*
UDP 0.0.0.0:11301 *:*
UDP 0.0.0.0:11302 *:*
UDP 0.0.0.0:11303 *:*
UDP 0.0.0.0:11304 *:*
UDP 0.0.0.0:11501 *:*
UDP 0.0.0.0:11502 *:*
UDP 0.0.0.0:11503 *:*
UDP 0.0.0.0:11504 *:*
UDP 0.0.0.0:11701 *:*
UDP 0.0.0.0:11702 *:*
UDP 0.0.0.0:11703 *:*
UDP 0.0.0.0:11704 *:*
UDP 0.0.0.0:11901 *:*
UDP 0.0.0.0:11902 *:*
UDP 0.0.0.0:11903 *:*

Author:  grossmj [ Fri Jun 14, 2013 3:14 am ]
Post subject:  Re: UDP Port increment bug

I believe this is fixed. Please see post20302.html#p20302

Author:  rednectar [ Thu Jun 20, 2013 9:41 pm ]
Post subject:  Re: UDP Port increment bug

Before 0.8.4 RC4, dynagen would increment udp port numbers by 1100 instead of the 100 specified in GNS3 Preferences, Dynamips settings [Hypervisor Manager] tab in the UDP incrementation field - but only the first time, after that it stuck to the specified 100.
WIth 0.8.4 RC4, this has changed. It now increments the udp port numbers by 201 instead of the 100 specified. Closer, but no cigar.

Scenario: Build a topology with 7200 routers, one router at at time
STAGE 1
Add R1
Add R2
Join R1 ro R2 (using auto-insert fast ethernet)
Add R3 - this will force the spawning of a 2nd dynamips instance because each 7200 uses 256MB RAM, and the Memory usage limit per hypervisor is 512MB
Later I will join R2 to R3 - but not yet:
Here's the relevant bits from the console:
Code:
=> show run
autostart = False
[127.0.0.1:7200]
    workingdir = c:\users\chris\appdata\local\temp\GNS3_w4qoj6\working
    udp = 10001
    [[7200]]
        image = C:\Users\chris\GNS3\Images\c7200-p-mz.124-10a.image
        idlepc = 0x60750000
        sparsemem = True
        ghostios = True
    [[ROUTER R1]]
        console = 2101
        aux = 2501
        slot1 = PA-2FE-TX
        f1/0 = R2 f1/0
    [[ROUTER R2]]
        console = 2102
        aux = 2502
        slot1 = PA-2FE-TX
        f1/0 = R1 f1/0
[127.0.0.1:7201]
    workingdir = c:\users\chris\appdata\local\temp\GNS3_w4qoj6\working
    udp = 10101 <=================== NOTE udp = 10101
    [[7200]]
        image = C:\Users\chris\GNS3\Images\c7200-p-mz.124-10a.image
        ram = 256
        idlepc = 0x60750000
        sparsemem = True
        ghostios = True
    [[ROUTER R3]]
        console = 2103
        aux = 2503

Note: udp = 10101 for hypervisor 127.0.0.1:7201
STAGE 2
Now see what ports are used when I Join R2 to R3
Code:
06:10:19: DEBUG (1): sending to dynamips at 127.0.0.1:7201 -> vm slot_add_binding R3 1 0 PA-2FE-TX
06:10:19: DEBUG (1): returned -> ['100-OK']
06:10:19: DEBUG (2): Node R3: running config: {'console': 2103, 'aux': 2503, 'slot1': 'PA-2FE-TX'}
06:10:19: DEBUG (2): Connect link from R2 f1/1 to R3 f1/0
06:10:19: DEBUG (1): new base UDP port for dynamips at 127.0.0.1:7200 is now: 10004
06:10:19: DEBUG (1): new base UDP port for dynamips at 127.0.0.1:7201 is now: 10202  <=============== 10202 ????  why not 10101 ???
06:10:19: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> nio create_udp nio_udp2 10003 127.0.0.1 10201  <===== 10201 ????  why not 10100 ???
06:10:19: DEBUG (1): returned -> ["100-NIO 'nio_udp2' created"]
06:10:19: DEBUG (1): sending to dynamips at 127.0.0.1:7201 -> nio create_udp nio_udp3 10201 127.0.0.1 10003
06:10:19: DEBUG (1): returned -> ["100-NIO 'nio_udp3' created"]
06:10:19: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> vm slot_add_nio_binding R2 1 1 nio_udp2
06:10:19: DEBUG (1): returned -> ['100-OK']
06:10:19: DEBUG (1): sending to dynamips at 127.0.0.1:7201 -> vm slot_add_nio_binding R3 1 0 nio_udp3
06:10:19: DEBUG (1): returned -> ['100-OK']
06:10:19: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> nio get_stats nio_udp1
06:10:19: DEBUG (1): returned -> ['100-0 0 0 0']
06:10:19: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> nio get_stats nio_udp2
06:10:19: DEBUG (1): returned -> ['100-0 0 0 0']
06:10:19: DEBUG (1): sending to dynamips at 127.0.0.1:7201 -> nio get_stats nio_udp3
06:10:19: DEBUG (1): returned -> ['100-0 0 0 0']

Note nio create_udp nio_udp3 10201 127.0.0.1 10003
This is going to be interesting, because I'm expecting that udp port 10201 will be allocated to the next hypervisor, if I say add R4 and R5
So here I go
STAGE 3
Add R4
join R3 to R4
Now add R5
Code:
show run
autostart = False
[127.0.0.1:7202]
    workingdir = c:\users\chris\appdata\local\temp\GNS3_w4qoj6\working
    udp = 10201 <========== HMMMMM This is interesting, 10201 has already been used
    [[7200]]
        image = C:\Users\chris\GNS3\Images\c7200-p-mz.124-10a.image
        ram = 256
        idlepc = 0x60750000
        sparsemem = True
        ghostios = True
    [[ROUTER R5]]
        console = 2105
        aux = 2505

STAGE 4
Lets see if it does use UDP port 10201 when I join say R5 to R1
Oh dear!!!!!!!

Attachment:
oh dear.jpg
oh dear.jpg [ 13.25 KiB | Viewed 9534 times ]


I have suspected a bug here for a long time - I have a topology that I created with about 20 routers in it, and I kept getting this error [206-unable to create UDP NIO] when I loaded it again, and I couldn't work out how I was able to create it, but not able to load it. I now know that UDP NIOs get recreated each time you load the topology, and are not necessarily the same each time you save and re-load. It was this problem that got me hunting down this devil - and I fixed my 20 router topology by manually adjusting the .net file so that I used fewer hypervisors, and the problem went away.

FWIW - I noticed that if in STAGE2 above, I join R3 to R2, rather than R2 to R3, I get a different pair of ports:
Code:
06:03:24: DEBUG (2): Connect link from R3 f1/0 to R2 f1/1
06:03:24: DEBUG (1): new base UDP port for dynamips at 127.0.0.1:7201 is now: 10102 <=== NIce!
06:03:24: DEBUG (1): new base UDP port for dynamips at 127.0.0.1:7200 is now: 10104 <===== Why not 10004???
06:03:24: DEBUG (1): sending to dynamips at 127.0.0.1:7201 -> nio create_udp nio_udp2 10101 127.0.0.1 10103 <===  expected 10101 127.0.0.1 10003
06:03:24: DEBUG (1): returned -> ["100-NIO 'nio_udp2' created"]
06:03:24: DEBUG (1): sending to dynamips at 127.0.0.1:7200 -> nio create_udp nio_udp3 10103 127.0.0.1 10101 <===  expected 10003 127.0.0.1 10101
06:03:24: DEBUG (1): returned -> ["100-NIO 'nio_udp3' created"]


I think this one better get fixed before we release!

Author:  grossmj [ Thu Jun 27, 2013 7:49 pm ]
Post subject:  Re: UDP Port increment bug

Hey Chris, you are becoming an expert at troubleshooting GNS3 ;) Indeed this one was evil, reproducible and has been present for ages! Now this is really fixed, I'll send you a dev snapshot of GNS3 so you can double check, I prefer to be sure before the final release.

Thanks for hunting this down.

Cheers,

Author:  rednectar [ Thu Jun 27, 2013 9:19 pm ]
Post subject:  Re: UDP Port increment bug

@Jeremy
No worries - I'll be happy to test it. Prefer Linux version to test, but any is OK
Chris

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/