Send
Close Add comments:
(status displays here)
Got it! This site "robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website. Note: This appears on each machine/browser from which this site is accessed.
Raspberry Pi: random number generator
1. Raspberry Pi: random number generator
The Raspberry Pi is a credit card size low powered compute board with Ethernet connection, HDMI video output, audio, full Linux operating system run from an SD card, and more, all for $45.
With cables, SD card, etc., the cost is about $70.
2. Name
The Raspberry part comes from the name of a fruit not yet used so that the name could be trademarked. For example, Apple is already taken. The Pi part is the Greek letter pi as used in the ratio of circumference to diameter.
3. Original design
Originally designed to help teach computer science principles to low income children and students, the Pi has taken on a life of its own, with many on-line resources and projects that cover most everything one would want to do with a small low monetary cost and low battery power computer.
4. Raspian
By default, the Pi runs a version of Debian Linux called Raspian. In some cases, such as the Firefox web browser, technical/legal limitations/restrictions of the open source Firefox web browser have caused it to be renamed IceWeasel, but is otherwise the same.
5. User support group
There is a huge user support group for the Raspberry Pi (suggest version 2).
6. Cluster
Six (6) node headless Raspberry Pi 2 cluster: (price estimates)
$280 - 6 Raspberry Pi 2 boards (quad processor, 1GB)
$60 - Micro SD cards
$15 - 7 network cables
$6 - stick-on pads
$10 - simple switch
$10 - pins and spacers (and rubber bands)
$30 - USB 3.0 power supply with 7 outlets
$24 - 6 USB power cables
----
$440 for 6 node 24 processor cluster
7. Raspberry Pi - 6 nodes, 6 cores
8. Raspberry Pi 2 - 14 nodes, 56 cores
9. Monitoring: SSH, node.js
I have used node.js (JavaScript as server) to control cluster computing such as with a cluster of Raspberry Pi computers.
10. Random number generator
I looked at the Raspberry Pi random number generator. I did not benchmark it to see how fast it is. However, it is closed source so one never knows.
The Raspberry Pi random number generator is configured as one of the following device names.
/dev/hwrng (hardware random number generator)
/dev/random (operating system random number generator)
The hardware random number generator output can be fed into the random number generator to increase the entropy.
11. Random number generator
C program:
#include
int main(){
unsigned int r;
FILE *frand=fopen("/dev/random","r");
fread(&r,sizeof(unsigned int),1,frand);
printf("Your random number is %u.\n",r);
return 0;
}
It appears to be also accessible via
/dev/hwrng.
12. Command line
Here are some command line commands to get and display
10 random numbers from the hardware generator in the range of
0 to
255. Note: You need admin rights (
sudo) to run the command.
sudo hexdump -v -n 10 -e '/1 "%03u\n"' /dev/hwrng
sudo hexdump -v -n 10 -e '/1 "%03u\n"' /dev/random
13. Output
1 [ pi@PX1 ~] sudo hexdump -v -n 10 -e '/1 "%03u\n"' /dev/random
218
237
079
238
243
207
043
004
009
139
1 [ pi@PX1 ~]
14. End of page