def fixLimits():
 debug('*** Setting resource limits\n')
 try:
  rlimitTestAndSet(RLIMIT_NPROC, 8192)
  rlimitTestAndSet(RLIMIT_NOFILE, 16384)
  sysctlTestAndSet('fs.file-max', 10000)
  sysctlTestAndSet('net.core.wmem_max', 16777216)
  sysctlTestAndSet('net.core.rmem_max', 16777216)
  sysctlTestAndSet('net.ipv4.tcp_rmem', '10240 87380 16777216')
  sysctlTestAndSet('net.ipv4.tcp_wmem', '10240 87380 16777216')
  sysctlTestAndSet('net.core.netdev_max_backlog', 5000)
  sysctlTestAndSet('net.ipv4.neigh.default.gc_thresh1', 4096)
  sysctlTestAndSet('net.ipv4.neigh.default.gc_thresh2', 8192)
  sysctlTestAndSet('net.ipv4.neigh.default.gc_thresh3', 16384)
  sysctlTestAndSet('net.ipv4.route.max_size', 32768)
  sysctlTestAndSet('kernel.pty.max', 20000)
 except Exception:
  warn("*** Error setting resource limits. Mininet's performance may be affected.\n")

def fixLimits ( ) : debug ( '*** Setting resource limits\n' ) try : rlimitTestAndSet ( RLIMIT_NPROC , 8192 ) rlimitTestAndSet ( RLIMIT_NOFILE , 16384 ) sysctlTestAndSet ( 'fs.file-max' , 10000 ) sysctlTestAndSet ( 'net.core.wmem_max' , 16777216 ) sysctlTestAndSet ( 'net.core.rmem_max' , 16777216 ) sysctlTestAndSet ( 'net.ipv4.tcp_rmem' , '10240 87380 16777216' ) sysctlTestAndSet ( 'net.ipv4.tcp_wmem' , '10240 87380 16777216' ) sysctlTestAndSet ( 'net.core.netdev_max_backlog' , 5000 ) sysctlTestAndSet ( 'net.ipv4.neigh.default.gc_thresh1' , 4096 ) sysctlTestAndSet ( 'net.ipv4.neigh.default.gc_thresh2' , 8192 ) sysctlTestAndSet ( 'net.ipv4.neigh.default.gc_thresh3' , 16384 ) sysctlTestAndSet ( 'net.ipv4.route.max_size' , 32768 ) sysctlTestAndSet ( 'kernel.pty.max' , 20000 ) except Exception : warn ( "*** Error setting resource limits. Mininet's performance may be affected.\n" )
fix ridiculously small resource limits .