# Store this file in 'expect' directory with batch.csh file for {set k 0} {$k <= 0} {incr k 1} { set timeout -1 set underscore "_" # Fill this in set bitfile_src_dir "your directory with bitstrings" # Fill this in -- temporary directory where assess writes it's results. set results_src_dir "experiments/AlgorithmTesting" # Fill these in. Assumes ../results exists. if { $k == 0 } { set bitfile "$bitfile_src_dir/file name of your bitstring file" set base_res_dir "../results/your results directory name" set results_dest_dir "$base_res_dir/your results sub directory name" } # Get the bit stream length and the number of bit streams (number of chips). # Wait for get_bit_stream_length to terminate (wait -i $I) spawn "../code/get_bit_stream_length.pl" $bitfile set I $spawn_id wait -i $I expect -re "(.*)X(.*)" set bit_stream_len $expect_out(1,string) set num_chips $expect_out(2,string) expect -re "(.*) >" puts stdout "Bit string length: $bit_stream_len" puts stdout "Number of chips: $num_chips" # See papers_others/NIST_BITSTRING_SIZE_PAPER/Sadique_JTPC_2012.pdf # See MinimumBitLengths.txt file # 1) Frequency 2) BlockFrequency 3) CumulativeSums 4) Runs 5) LongestRun # 6) Rank 7) FFT 8) NonOverlappingTemplate 9) OverlappingTemplate 10) Universal # 11) Approx. Entropy 12) RandomExcursions 13) RandomExcursionsVariant 14) Serial 15) LinearComplexity # <= 128 bits: Freq, CummulativeSums, Runs, LongestRun, Approx. Entropy, CummulativeSums # Doesn't look like longest run works with anything less than 128 bits if { $bit_stream_len <= 127 } { set NIST_test_spec "101100000010000" set adjust_params 0 } else { # 1) Frequency 2) BlockFrequency 3) CumulativeSums 4) Runs 5) LongestRun # 6) Rank 7) FFT 8) NonOverlappingTemplate 9) OverlappingTemplate 10) Universal # 11) Approx. Entropy 12) RandomExcursions 13) RandomExcursionsVariant 14) Serial 15) LinearComplexity # <= 1000 bits: Freq, CummulativeSums, Runs, LongestRun, FFT, Approx. Entropy, CummulativeSums if { $bit_stream_len <= 1000 } { # USE THIS LINE FOR EXTRA TESTS. # set NIST_test_spec "111110100010011" set NIST_test_spec "101110100010000" # NOTE: Adjust m < log2(n = num bits) - 5. So if you have 512 bits, then log2(512) = 9 - 5 = 4. NEED TO MANUALLY SET THIS BELOW. # ******************** NEED TO MANUALLY SET THIS BELOW. set adjust_params 0 } else { # 1) Frequency 2) BlockFrequency 3) CumulativeSums 4) Runs 5) LongestRun # 6) Rank 7) FFT 8) NonOverlappingTemplate 9) OverlappingTemplate 10) Universal # 11) Approx. Entropy 12) RandomExcursions 13) RandomExcursionsVariant 14) Serial 15) LinearComplexity # Upto 9000 bits: Freq, BlockFrequency, CummulativeSums, Runs, LongestRun, FFT, Approx. Entropy, CummulativeSums # IMPORTANT NOTE: Adjust m < log2(n = num bits) - 5. So if you have 2048 bits, then log2(2048) = 11 - 5 = 6. # ******************** NEED TO MANUALLY SET THIS BELOW. if { $bit_stream_len <= 9000 } { # set NIST_test_spec "111110100010000" # ORIGINAL ONE set NIST_test_spec "111110100010010" set adjust_params 1 } else { # 1) Frequency 2) BlockFrequency 3) CumulativeSums 4) Runs 5) LongestRun # 6) Rank 7) FFT 8) NonOverlappingTemplate 9) OverlappingTemplate 10) Universal # 11) Approx. Entropy 12) RandomExcursions 13) RandomExcursionsVariant 14) Serial 15) LinearComplexity # <= 38912 bits: Freq, BlockFrequency, CummulativeSums, Runs, LongestRun, Rank, FFT, Approx. Entropy, CummulativeSums if { $bit_stream_len <= 38912 } { set NIST_test_spec "111111100010000" set adjust_params 0 } else { # 1) Frequency 2) BlockFrequency 3) CumulativeSums 4) Runs 5) LongestRun # 6) Rank 7) FFT 8) NonOverlappingTemplate 9) OverlappingTemplate 10) Universal # 11) Approx. Entropy 12) RandomExcursions 13) RandomExcursionsVariant 14) Serial 15) LinearComplexity # If the number of bits available is greater than 1M, run all tests. set NIST_test_spec "111111111111111" set adjust_params 0 }}}} # cd into the assess binary directory cd ../sts-2.1.1 # Remove the data from all subdirectories. NOTE: We need to do this because some analysis are NOT # run (depends on the size of the bit string), so when we do the copy below, we need to be sure # data from a previous analysis is not copied into the current results directory. spawn ../code/rm_assess_files.pl $results_src_dir set I $spawn_id wait -i $I # Start up assess spawn "./assess" $bit_stream_len set I $spawn_id # Enter '0' for the input choice expect -re "(.*) Choice: " send -i $I "0\n" # Send the file above as the input file expect -re "(.*) File: " send -i $I "$bitfile\n" # Tests specification -- this is largely determined by the number of bits available -- use '0' to specify tests and '1' for ALL expect -re "(.*) Choice: " send -i $I "0\n" # Output the tests to be applied expect -re "(.*) 012345" send -i $I "$NIST_test_spec\n" # ============================================================================== # Parameter adjustments # !!!!!!!!!!!!!!!!!!!! DEPENDENCY WITH ABOVE 'if stmt' !!!!!!!!!!!!!!!!!!!!!!!! # [1] Block Frequency Test - block length(M): 128 # [2] NonOverlapping Template Test - block length(m): 9 # [3] Overlapping Template Test - block length(m): 9 # [4] Approximate Entropy Test - block length(m): 10 # [5] Serial Test - block length(m): 16 # [6] Linear Complexity Test - block length(M): 500 expect -re "(.*)Select(.*)" if { $adjust_params == 0 } { send -i $I "0\n" # ADJUST ONLY Approx Entropy block length for now. NOTE: IT IS element 2 (NOT 4) for 2048 bits because # we do NOT run NonOverlapping or Overlapping. } else { send -i $I "2\n" expect -re "(.*)Approximate(.*)" send -i $I "6\n" expect -re "(.*)Select(.*)" send -i $I "0\n" } # ============================================================================== # Number of bitstreams expect -re "(.*)bitstreams(.*)" send -i $I "$num_chips\n" # Input file format expect -re "(.*)mode(.*)" send -i $I "0\n" # ========================================================== # OKAY -- NOW WAIT for the statistical testing to complete. expect -re "(.*)Statistical Testing Complete(.*)" wait -i $I # Make the base directory, if it does not exist. spawn mkdir $base_res_dir set I $spawn_id wait -i $I expect -re "(.*)" # Make the specific results directory, if it does not exist. spawn mkdir $results_dest_dir set I $spawn_id wait -i $I expect -re "(.*)" # Copy the results to the results directory -- wait for 'cp' to terminate # spawn cp -r spawn ../code/copy_files.pl $results_src_dir $results_dest_dir set I $spawn_id wait -i $I }