def test_dns_lsa_topo3(self): servers = ['3.1.4.15', '2.7.1.82'] dns = '29.97.92.45' server_file = os.path.join(self.topo_dir, 'topo3.servers') lsa_file = os.path.join(self.topo_dir, 'topo3.lsa') self.run_dns('', 'dns.log', dns, self.dnsport, server_file, lsa_file) time.sleep(1) for i in xrange(5): [query, response, flags] = sendDNSQuery(VIDEO_SERVER_NAME, '4.2.8.9', dns, self.dnsport) print response self.assertTrue(response == servers[0]) for i in xrange(5): [query, response, flags] = sendDNSQuery(VIDEO_SERVER_NAME, '9.26.8.8', dns, self.dnsport) print response self.assertTrue(response in servers) for i in xrange(5): [query, response, flags] = sendDNSQuery(VIDEO_SERVER_NAME, '3.4.0.29', dns, self.dnsport) print response self.assertTrue(response == servers[1])
def test_dns_lsa_topo2(self): server_file = os.path.join(self.topo_dir, 'topo2.servers') lsa_file = os.path.join(self.topo_dir, 'topo2.lsa') self.run_dns('', 'dns.log', '5.0.0.1', self.dnsport, server_file, lsa_file) time.sleep(1) for i in xrange(5): [query, response, flags] = sendDNSQuery(VIDEO_SERVER_NAME, '1.0.0.1', '5.0.0.1', self.dnsport) print response self.assertTrue(response == '4.0.0.1') for i in xrange(5): [query, response, flags] = sendDNSQuery(VIDEO_SERVER_NAME, '2.0.0.1', '5.0.0.1', self.dnsport) print response self.assertTrue(response == '5.0.0.1') for i in xrange(5): [query, response, flags] = sendDNSQuery(VIDEO_SERVER_NAME, '3.0.0.1', '5.0.0.1', self.dnsport) print response self.assertTrue(response == '6.0.0.1')
def test_dns_lsa_topo1(self): server_file = os.path.join(self.topo_dir, 'topo1.servers') lsa_file = os.path.join(self.topo_dir, 'topo1.lsa') self.run_dns('', 'dns.log', '5.0.0.1', self.dnsport, server_file, lsa_file) time.sleep(1) servers = ['3.0.0.1', '4.0.0.1'] for i in xrange(5): [query, response, flags] = sendDNSQuery(VIDEO_SERVER_NAME, '1.0.0.1', '5.0.0.1', self.dnsport) print response self.assertTrue(response in servers) for i in xrange(5): [query, response, flags] = sendDNSQuery(VIDEO_SERVER_NAME, '2.0.0.1', '5.0.0.1', self.dnsport) print response self.assertTrue(response in servers)
def test_dns_simple(self): server_file = os.path.join(self.topo_dir, 'simple-dns.servers') lsa_file = os.path.join(self.topo_dir, 'simple-dns.lsa') self.run_dns('-r', 'dns.log', '127.0.0.1', self.dnsport, server_file, lsa_file) time.sleep(1) [query, response, flags] = sendDNSQuery(VIDEO_SERVER_NAME, '127.0.0.1', '127.0.0.1', self.dnsport) print query, response, flags self.assertTrue(query == 'video.cs.cmu.edu') self.assertTrue(response == '2.0.0.1') self.assertTrue(flags['sent_trans_id'] == flags['recv_trans_id']) self.assertTrue(flags['qr'] == 1) self.assertTrue(flags['opcode'] == 0) self.assertTrue(flags['aa'] == 1) self.assertTrue(flags['tc'] == 0) self.assertTrue(flags['rd'] == 0) self.assertTrue(flags['ra'] == 0) self.assertTrue(flags['z'] == 0) self.assertTrue(flags['rcode'] == 0) self.assertTrue(flags['num_questions'] == 1) self.assertTrue(flags['num_answers'] == 1) self.assertTrue(flags['num_authority'] == 0) self.assertTrue(flags['num_additional'] == 0) self.assertTrue(flags['qtype'] == 1) self.assertTrue(flags['qclass'] == 1) #self.assertTrue(flags['rr_name'] == 49164) #C0 0C self.assertTrue(flags['rr_qtype'] == 1) self.assertTrue(flags['rr_qclass'] == 1) self.assertTrue(flags['rr_ttl'] == 0) self.assertTrue(flags['rr_dl'] == 4) print 'done test_dns_simple'
def test_dns_rr(self): server_file = os.path.join(self.topo_dir, 'rr-dns.servers') lsa_file = os.path.join(self.topo_dir, 'rr-dns.lsa') self.run_dns('-r', 'dns.log', '127.0.0.1', self.dnsport, server_file, lsa_file) time.sleep(1) servers = ['2.0.0.1', '3.0.0.1', '4.0.0.1', '5.0.0.1', '6.0.0.1'] for i in xrange(100): [query, response, flags] = sendDNSQuery(VIDEO_SERVER_NAME, '127.0.0.1', '127.0.0.1', self.dnsport) print response self.assertTrue(response == servers[i%len(servers)])
def test_dns_rr(self): server_file = os.path.join(self.topo_dir, 'rr-dns.servers') lsa_file = os.path.join(self.topo_dir, 'rr-dns.lsa') self.run_dns('-r', 'dns.log', '127.0.0.1', self.dnsport, server_file, lsa_file) time.sleep(1) servers = ['2.0.0.1', '3.0.0.1', '4.0.0.1', '5.0.0.1', '6.0.0.1'] for i in xrange(100): [query, response, flags] = sendDNSQuery(VIDEO_SERVER_NAME, '127.0.0.1', '127.0.0.1', self.dnsport) print response self.assertTrue(response == servers[i % len(servers)])
#!/usr/bin/python import socket, sys from dns_common import sendDNSQuery UDP_IP = '127.0.0.1' #'5.0.0.1' UDP_PORT = 5353 LOCAL_IP = '127.0.0.1' #'1.0.0.1' print sendDNSQuery(sys.argv[1],LOCAL_IP,UDP_IP,UDP_PORT)
#!/usr/bin/python import socket, sys from dns_common import sendDNSQuery UDP_IP = '127.0.0.1' #'5.0.0.1' UDP_PORT = 5353 LOCAL_IP = '127.0.0.1' #'1.0.0.1' print sendDNSQuery(sys.argv[1], LOCAL_IP, UDP_IP, UDP_PORT)