Packet size randomization

Hi,
I’m a beginner in UVM/SystemVerilog, looking for a solution to randomize packet size and Its Burstiness and i have a limit to send each packet. i.e i can send only certain number of packets (lets call it as credits, if i have 5 credits i can only send 5 packets of different length) I need to randomize the credits too.

In reply to vvv:

You can use constraints as,

rand bit [LEN:0] p_length;
rand bit [LEN:0] packet[][];

rand int unsigned credit;

constraint c1{
  packet.size == credit;
}

constraint c2{
  foreach(packet[i]){
    packet[i].size == p_length;
  }
}