---
name: "rte_random.h"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_random.h"
---

# rte\_random.h(3)

## NAME

rte\_random.h

## SYNOPSIS

`#include <stdint.h>`\

### Functions

void **rte\_srand** (uint64\_t seedval)\
 uint64\_t **rte\_rand** (void)\
 uint64\_t **rte\_rand\_max** (uint64\_t upper\_bound)\
 double **rte\_drand** (void)\

## Detailed Description

Pseudo-random Generators in RTE

Definition in file **rte\_random.h**.

## Function Documentation

### void rte\_srand (uint64\_t seedval)

Seed the pseudo-random generator.

The generator is automatically seeded by the EAL init with a timer value. It may need to be re-seeded by the user with a real random value.

This function is not multi-thread safe in regards to other **rte\_srand()** calls, nor is it in relation to concurrent **rte\_rand()**, **rte\_rand\_max()** or **rte\_drand()** calls.

**Parameters**

*seedval* The value of the seed.

### uint64\_t rte\_rand (void)

Get a pseudo-random value.

The generator is not cryptographically secure.

**rte\_rand()**, **rte\_rand\_max()** and **rte\_drand()** are multi-thread safe, with the exception that they may not be called by multiple *unregistered* non-EAL threads in parallel.

**Returns**

A pseudo-random value between 0 and (1\<\<64)-1.

### uint64\_t rte\_rand\_max (uint64\_t upper\_bound)

Generates a pseudo-random number with an upper bound.

This function returns an uniformly distributed (unbiased) random number less than a user-specified maximum value.

**rte\_rand()**, **rte\_rand\_max()** and **rte\_drand()** are multi-thread safe, with the exception that they may not be called by multiple *unregistered* non-EAL threads in parallel.

**Parameters**

*upper\_bound* The upper bound of the generated number.

**Returns**

A pseudo-random value between 0 and (upper\_bound-1).

### double rte\_drand (void)

Generates a pseudo-random floating point number.

This function returns a non-negative double-precision floating random number uniformly distributed over the interval \[0.0, 1.0).

The generator is not cryptographically secure.

**rte\_rand()**, **rte\_rand\_max()** and **rte\_drand()** are multi-thread safe, with the exception that they may not be called by multiple *unregistered* non-EAL threads in parallel.

**Returns**

A pseudo-random value between 0 and 1.0.

## Author

Generated automatically by Doxygen for DPDK from the source code.
