Ignore:
Timestamp:
08/01/15 19:04:49 (9 years ago)
Author:
tim
Message:

.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/blackhat-demo/jregistrate-collect

    r15 r18  
    3434parser = argparse.ArgumentParser(
    3535    description="")
    36 parser.add_argument('-c', dest='cases', type=str, default='{"valid":"0012-5969","invalid":"0012-9999"}',
    37                     help='JSON representation of echo timing cases.')
    38 parser.add_argument('--no-tcpts', action='store_true', help='Disbale TCP timestamp profiling')
     36parser.add_argument('--no-tcpts', action='store_true', help='Disable TCP timestamp profiling')
    3937parser.add_argument('--no-control', action='store_true', help='Do not collect separate control data.  Instead, synthesize it from test and train data.')
    4038parser.add_argument('session_name', default=None,
     
    5553protocol = 'http'
    5654
    57 cases = json.loads(options.cases)
     55cases = {"valid":"0012-8846","invalid":"0012-9999"}
    5856
    5957
     
    6967
    7068
    71 def sendRequest(data=None):
     69def sendRequest(case_data):
    7270    method = 'POST'
    7371    path = '/jregistrate/register'
    7472    url = "%s://%s:%d%s" % (protocol,hostname,port,path)
    7573    headers = {"Content-Type":"application/x-www-form-urlencoded"}
    76     body = (b'member_id='+data.encode('utf-8')+b'&last_four=1111&zip_code=97219&username=bob&password=&conf_pwd=')
     74    body = (b'member_id='+case_data.encode('utf-8')+b'&last_four=1111&zip_code=97219&username=bob&password=&conf_pwd=')
    7775    req = requests.Request(method, url, headers=headers, data=body).prepare()
    7876
     
    8280            session = requests.Session()
    8381            response = session.send(req, verify=False)
    84             #print(repr(response.raw._original_response.local_address))
    8582            reported = extractReportedRuntime(response.headers, response.text)
    8683            retry = False
     
    8986            time.sleep(1.0)
    9087            sys.stderr.write("ERROR: retrying...\n")
    91         #print(data.encode('utf-8'), reported)
    9288       
    9389    return {'userspace_rtt':response.elapsed.microseconds*1000,
     
    170166                sample_order[i] = (sample_order[i][0],sample_order[0][1])
    171167            random.shuffle(sample_order)
    172             #print('after', sample_order)
    173168           
    174169        results = []
     
    179174                                 sample_order[i][1]))
    180175
    181         #print(results)
    182176        db.addProbes(results)
    183177        db.conn.commit()
     
    185179
    186180        if (time.time() > next_report):
    187             #s = time.time()
    188181            reportProgress(db, sample_types, start)
    189             #print("reportProgress time:", time.time()-s)
    190182            next_report += report_interval
    191183
     
    194186stopSniffer(sniffer)
    195187
    196 start = time.time()
    197188associatePackets(sniffer_fp, db)
    198189sniffer_fp.close()
    199 end = time.time()
    200 print("associate time:", end-start)
    201190
    202191if options.no_control:
Note: See TracChangeset for help on using the changeset viewer.