Could a truly random number be generated using pings to pseudo-randomly selected IP addresses?

后端 未结 23 1627
天命终不由人
天命终不由人 2021-01-30 16:28

The question posed came about during a 2nd Year Comp Science lecture while discussing the impossibility of generating numbers in a deterministic computational device.

Th

相关标签:
23条回答
  • 2021-01-30 16:29

    If you want commodity hardware, your sound card should pretty much do it. Just turn up the volume on an analog input and you have a cheap white noise source. Cheap randomness without the need for a network.

    0 讨论(0)
  • 2021-01-30 16:29

    I got some code that creates random numbers with traceroute. I also have a program that does it using ping. I did it over a year ago for a class project. All it does is run traceroute on and address and it takes the least sig digit of the ms times. It works pretty well at getting random numbers but I really don't know how close it is to true random.

    Here is a list of 8 numbers that I got when I ran it.

    455298558263758292242406192

    506117668905625112192115962

    805206848215780261837105742

    095116658289968138760389050

    465024754117025737211084163

    995116659108459780006127281

    814216734206691405380713492

    124216749135482109975241865

    #include <iostream>
    #include <string>
    #include <stdio.h>
    #include <cstdio>
    #include <stdlib.h>
    #include <vector>
    #include <fstream>
    
    using namespace std;
    
    int main()
    {
    system("traceroute -w 5 www.google.com >> trace.txt");
    
    string fname = "trace.txt";
    ifstream in;
    string temp;
    
    vector<string> tracer;
    vector<string> numbers;
    
    in.open(fname.c_str());
    while(in>>temp)
    tracer.push_back(temp);
    
    system("rm trace.txt");
    
    unsigned index = 0;
    
    string a = "ms";
    while(index<tracer.size())
    {
    if(tracer[index]== a)
    numbers.push_back(tracer[index-1]);
    ++index;
    }
    
    
    std::string rand;
    
    for(unsigned i = 0 ; i < numbers.size() ; ++i)
    {
    std::string temp = numbers[i];
    int index = temp.size();
    rand += temp[index - 1];
    }
    
    cout<<rand<<endl;
    
    return 0;
    
    }
    
    0 讨论(0)
  • 2021-01-30 16:31

    here is my suggestion :

    1- choose a punch of websites that are as far away from your location as possible. e.g. if you are in US try some websites that have their server IPs in malasia , china , russia , India ..etc . servers with high traffic are better.

    2- during times of high internet traffic in your country (in my country it is like 7 to 11 pm) ping those websites many many many times ,take each ping result (use only the integer value) and calculate modulus 2 of it ( i.e from each ping operation you get one bit : either 0 or 1).

    3- repeat the process for several days ,recording the results.

    4- collect all the bits you got from all your pings (probably you will get hundreds of thousands of bits ) and choose from them your bits . (maybe you wanna choose your bits by using some data from the same method mentioned above :) )

    BE CAREFUL : in your code you should check for timeout ..etc

    0 讨论(0)
  • 2021-01-30 16:32

    Part of a good random number generator is equal probabilities of all numbers as n -> infinity.

    So if you are planning to generate random bytes, then with sufficient data from a good rng, each byte should have an equal probability of being returned. Further, there should be no pattern or predictibiltiy (spikes in probability during certain time periods) of certain numbers being returned.

    I am not too sure with using ping what you would be measuring to get the random variable, is it response time? If so, you can be pretty sure that some response times, or ranges of response times, will be more frequent than others and hence would make a potentially insecure random number generator.

    0 讨论(0)
  • 2021-01-30 16:36

    Random numbers are too important to be left to chance.

    Or external influence/manipulation.

    0 讨论(0)
  • 2021-01-30 16:37

    The approach of measuring something to generate a random seed appears to be a pretty good one. The O'Reilly book Practical Unix and Internet Security gives a few similar additional methods of determining a random seed, such as asking the user to type a few keystrokes, and then measuring the time between keystrokes. (The book notes that this technique is used by PGP as a source of its randomness.)

    I wonder if the current temperature of a system's CPU (measured out to many decimal places) could be a viable component of a random seed. This approach would have the advantage of not needing to access the network (so the random generator wouldn't become unavailable when the network connection goes down).

    However, it's probably not likely that a CPU's internal sensor could accurately measure the CPU temperature out to enough decimal places to make the value truly viable as a random number seed; at least, not with "commodity-class hardware," as mentioned in the question!

    0 讨论(0)
提交回复
热议问题