It is currently Mon Mar 01, 2021 9:53 am


All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: dynamips networking: limited to 10ms per packet?
PostPosted: Fri Jun 13, 2014 3:44 pm 
Offline

Joined: Thu Nov 21, 2013 7:50 pm
Posts: 5
I am emulating a C7200, two interfaces connected to tap1 and tap11. On one side is a KVM virtual machine and on the other is the host and the outside world.

When I send a burst of packets from the outside through the router to the VM, I find they get drip-fed out at intervals of almost exactly 10ms. This seems suspicious: it suggests there is something in the code which is rate limiting, or forwarding only one packet per timer tick.

Setup:

Code:
KVM VM --< [vnet0] [br1] [tap1] >-- DYNAMIPS --< [tap11] [br-lan] [eth0] >--- outside


Here's what I see using tcpdump when sending a burst of packets through:

Code:
** tap11 (outside) **
15:30:57.709432 IP 10.10.0.241.53366 > 10.10.1.1.1234: UDP, length 12
15:30:57.709457 IP 10.10.0.241.53366 > 10.10.1.1.1234: UDP, length 12
15:30:57.709466 IP 10.10.0.241.53366 > 10.10.1.1.1234: UDP, length 12
15:30:57.709474 IP 10.10.0.241.53366 > 10.10.1.1.1234: UDP, length 12
...

** tap1 (inside) **
15:30:57.717011 IP 10.10.0.241.53366 > 10.10.1.1.1234: UDP, length 12
15:30:57.727148 IP 10.10.0.241.53366 > 10.10.1.1.1234: UDP, length 12
15:30:57.737780 IP 10.10.0.241.53366 > 10.10.1.1.1234: UDP, length 12
15:30:57.748004 IP 10.10.0.241.53366 > 10.10.1.1.1234: UDP, length 12
....


Now, after digging through the code, I found that there is a ptask_sleep_time with a 10ms default. So I tried changing this to 5ms:

Code:
--- a/common/dynamips.c
+++ b/common/dynamips.c
@@ -942,7 +942,7 @@ int main(int argc,char *argv[])
    create_log_file();

    /* Periodic tasks initialization */
-   if (ptask_init(0) == -1)
+   if (ptask_init(5) == -1)
       exit(EXIT_FAILURE);

    /* Create instruction lookup tables */


and hey presto, I now get my packets at intervals of 5ms instead of 10ms.

Code:
** tap11 (outside) **
15:22:03.288594 IP 10.10.0.241.35998 > 10.10.1.1.1234: UDP, length 12
15:22:03.288618 IP 10.10.0.241.35998 > 10.10.1.1.1234: UDP, length 12
15:22:03.288624 IP 10.10.0.241.35998 > 10.10.1.1.1234: UDP, length 12
15:22:03.288637 IP 10.10.0.241.35998 > 10.10.1.1.1234: UDP, length 12
15:22:03.288643 IP 10.10.0.241.35998 > 10.10.1.1.1234: UDP, length 12
15:22:03.288648 IP 10.10.0.241.35998 > 10.10.1.1.1234: UDP, length 12
...

** tap1 (inside) **
15:22:03.294211 IP 10.10.0.241.35998 > 10.10.1.1.1234: UDP, length 12
15:22:03.299343 IP 10.10.0.241.35998 > 10.10.1.1.1234: UDP, length 12
15:22:03.304553 IP 10.10.0.241.35998 > 10.10.1.1.1234: UDP, length 12
15:22:03.309883 IP 10.10.0.241.35998 > 10.10.1.1.1234: UDP, length 12
15:22:03.315210 IP 10.10.0.241.35998 > 10.10.1.1.1234: UDP, length 12
15:22:03.320466 IP 10.10.0.241.35998 > 10.10.1.1.1234: UDP, length 12
...


So this implies there's definitely scope for improving the performance. Perhaps if multiple packets are waiting in the same tick, they could all be processed?

The reason that this matters to me: I use dynamips for teaching labs where the students have a VM behind the dynamips virtual router (which they configured with things like SNMP, netflow etc). All their downloads go through the dynamips router. As a result, they are limited to a throughput of around 140KB/sec (which is shared between all the VMs behind the same dynamips router), or less when there are smaller packets going back and forth like SNMP.

Platform: ubuntu 12.04 (64-bit)

Dynamips version: I see the same with dynamips 0.2.12 from the PPA, and dynamips-stable built from git (cmake .; make; stable/dynamips -H 7200). This is the one I tweaked as above.

I couldn't get dynamips-unstable to work at all: it just ate all the CPU resources it could get, and I got no console messages from the virtual routers.

Additional info:

Code:
=> ver
Dynagen version 0.11.0
hypervisor version(s):
dynamips at s1.ws.nsrc.org:7200 has version 0.2.13-dev-amd64

=> show device r1
Router r1 is running
  Hardware is dynamips emulated Cisco 7206VXR NPE-400 with 176 MB RAM
  Router's hypervisor runs on s1.ws.nsrc.org:7200, console is on port 2101
  Image is shared c7200-1514M4.bin-s1.ws.nsrc.org.ghost with idle-pc value of 0x60608f64
  Idle-max value is 1500, idlesleep is 30 ms
  128 KB NVRAM, 64 MB disk0 size, 0 MB disk1 size
   slot 0 hardware is C7200-IO-2FE with 2 interfaces
      FastEthernet0/0 is connected to real TAP tap11 interface
      FastEthernet0/1 is connected to real TAP tap1 interface


Is this a known issue, or are there any plans for improvements in this area?

Thanks,

Brian.

P.S. Here is the test program I use to send a burst of UDP packets. Note that "ping -f" is no good because it also forces an interval of 10ms per packet when sending but not receiving any replies.

Code:
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <stdio.h>
#include <arpa/inet.h>

int main(int argc, char *argv[])
{
  char buf[]="hello world";
  int i;
  struct sockaddr_in sa;
  int fd = socket(PF_INET, SOCK_DGRAM, 0);
  if (fd < 0) { perror("socket"); return 1; }
  if (argc < 2) { fprintf(stderr, "Usage: %s addr\n", argv[0]); return 1; }
  sa.sin_family = AF_INET;
  sa.sin_port = htons(1234);
  if (inet_aton(argv[1], &sa.sin_addr) <= 0) { perror("inet_aton"); return 1; }
  if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) { perror("connect"); return 1; }
  for (i=0; i<20; i++) {
    if (send(fd, buf, sizeof(buf), 0) <= 0) { perror("send"); return 1; }
  }
  return 0;
}




Top
 Profile  
 
 Post subject: Re: dynamips networking: limited to 10ms per packet?
PostPosted: Fri Jun 13, 2014 7:52 pm 
Offline

Joined: Thu Nov 21, 2013 7:50 pm
Posts: 5
The patch to fix this turned out to be simpler than I'd expected. The dev_mueslix driver already sends up to 16 packets for each call, so I modified the i8254x driver to do this as well. This has given a 16 times speedup for packets going via FastEthernet on NPE400, and via GigabitEthernet on PA-GE.

If anybody would like to review it or test it for themselves, I've put it on github at
https://github.com/candlerb/dynamips/tr ... erformance

Regards,

Brian.


Top
 Profile  
 
 Post subject: Re: dynamips networking: limited to 10ms per packet?
PostPosted: Sat Jun 14, 2014 9:18 am 
Offline

Joined: Sun Sep 16, 2012 9:55 pm
Posts: 541
Location: England
candlerb wrote:
The patch to fix this turned out to be simpler than I'd expected. The dev_mueslix driver already sends up to 16 packets for each call, so I modified the i8254x driver to do this as well. This has given a 16 times speedup for packets going via FastEthernet on NPE400, and via GigabitEthernet on PA-GE.

If anybody would like to review it or test it for themselves, I've put it on github at
https://github.com/candlerb/dynamips/tr ... erformance

Regards,

Brian.

Hi Brian!

Many thanks for your work here, I see you created the pull request on Github, which I've had a brief look at and it looks good to me.

Travis CI also ran successfully on your pull request which looks promising! I'm not going to merge it myself, as the dynamips code isn't something I know very well.. but I'm sure @flaviojs will take a look and report back soon

_________________
Daniel
Forum Moderator & Debian Package Maintainer for GNS3, Dynamips & VPCS.
Standalone DEB Packages are available from http://gns3.serverb.co.uk - To be updated!


Top
 Profile  
 
 Post subject: Re: dynamips networking: limited to 10ms per packet?
PostPosted: Sun Jun 15, 2014 2:01 pm 
Offline

Joined: Wed May 22, 2013 7:48 am
Posts: 93
Location: Portugal
I noticed your pull request (https://github.com/GNS3/dynamips/pull/45) and finally got the time to look at it.
Merged, good job! =)

Also, thank you @Raizo62 for pointing me to this topic which I didn't know about.
I once read someone asking if the traffic/packet rate was limited, but no one answered him/her and I didn't see any obvious limit glancing at the source...

This topic explains why it's limited and tells me how to reproduce it.
Thanks, this information is very useful. ;D
The packet rate is still limited, so I'll try to improve the situation.

_________________
Dynamips maintainer and sporadic developer
https://github.com/GNS3/dynamips


Top
 Profile  
 
 Post subject: Re: dynamips networking: limited to 10ms per packet?
PostPosted: Sun Jun 15, 2014 3:10 pm 
Offline

Joined: Wed May 22, 2013 7:48 am
Posts: 93
Location: Portugal
Related bug report: https://github.com/GNS3/dynamips/issues/46

_________________
Dynamips maintainer and sporadic developer
https://github.com/GNS3/dynamips


Top
 Profile  
 
 Post subject: Re: dynamips networking: limited to 10ms per packet?
PostPosted: Sun Jun 15, 2014 4:03 pm 
Offline

Joined: Thu Nov 21, 2013 7:50 pm
Posts: 5
flaviojs wrote:
This topic explains why it's limited and tells me how to reproduce it.
Thanks, this information is very useful. ;D
The packet rate is still limited, so I'll try to improve the situation.


Excellent, and thanks for picking this up so quickly.

I'm also impressed how travis CI is linked into the dynamips workflow via github: it's looking very professional!

Cheers,

Brian.


Top
 Profile  
 
 Post subject: Re: dynamips networking: limited to 10ms per packet?
PostPosted: Mon Jun 16, 2014 8:37 am 
Offline

Joined: Sun Sep 16, 2012 9:55 pm
Posts: 541
Location: England
candlerb wrote:
I'm also impressed how travis CI is linked into the dynamips workflow via github: it's looking very professional!


Indeed! It took as while to get the configuration for Travis CI right, but it's a very useful tool once it's working!

The benifits of being able to see immediately whether a commit/pull reuquest is sane from the build side is imense! The next challenge I haven't looked at yet, is implementing tests, to see if the compiled binary works as expected!

_________________
Daniel
Forum Moderator & Debian Package Maintainer for GNS3, Dynamips & VPCS.
Standalone DEB Packages are available from http://gns3.serverb.co.uk - To be updated!


Top
 Profile  
 
 Post subject: Re: dynamips networking: limited to 10ms per packet?
PostPosted: Sun Jun 22, 2014 3:43 am 
Offline

Joined: Fri Mar 15, 2013 9:26 pm
Posts: 5
Ewww I never realized this is how it was set up. This explains so much. Any chance it can be refactored to be event driven instead of timer based, or at least try to make it unlimited up to a time limted escape in the cycle something like 2-10ms clock time?




Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

phpBB SEO