8 from mininet.util import pexpect
9 from mininet.util import quietRun
11 destIP = '8.8.8.8' # Google DNS
13 class testNAT( unittest.TestCase ):
17 @unittest.skipIf( '0 received' in quietRun( 'ping -c 1 %s' % destIP ),
18 'Destination IP is not reachable' )
20 "Attempt to ping an IP on the Internet and verify 0% packet loss"
21 p = pexpect.spawn( 'python -m mininet.examples.nat' )
22 p.expect( self.prompt )
23 p.sendline( 'h1 ping -c 1 %s' % destIP )
24 p.expect ( '(\d+)% packet loss' )
25 percent = int( p.match.group( 1 ) ) if p.match else -1
26 p.expect( self.prompt )
29 self.assertEqual( percent, 0 )
31 if __name__ == '__main__':