Skip to content

Instantly share code, notes, and snippets.

@vankxr
Created February 4, 2021 16:29
Show Gist options
  • Save vankxr/8702b1e46a6f8024e3ca810eb6c64446 to your computer and use it in GitHub Desktop.
Save vankxr/8702b1e46a6f8024e3ca810eb6c64446 to your computer and use it in GitHub Desktop.
DVB-S2 bandwidth calculator
const k = Math.log2(16); // bits/symbol
const sr = 192e3; // Symbol rate
const fec = 4/5; // FEC rate
const ff = 64800; // FEC Frame size (16200 or 64800)
const gse = 3/4; // GSE rate
const rof = 0.20; // RRC roll-off factor
const pilots = false; // Pilots enabled
////////
function isclose(a, b, rel_tol=1e-02, abs_tol=0.0)
{
return Math.abs(a-b) <= Math.max(rel_tol * Math.max(Math.abs(a), Math.abs(b)), abs_tol);
}
function get_tbch()
{
if(ff == 64800)
if(isclose(2.0/3.0, fec))
return 16 * 10;
else if(isclose(5.0/6.0, fec))
return 16 * 10;
else if(isclose(8.0/9.0, fec))
return 16 * 8;
else if(isclose(9.0/10.0, fec))
return 16 * 8;
else
return 16 * 12;
else
return 16 * 12;
}
function get_pilot_length()
{
if(pilots)
return Math.floor(((ff / k / 90 - 1) / 16) * 36 );
else
return 0;
}
function humanify(x)
{
var unit = ["", "k", "M", "G", "T"];
var i = 0;
while(x > 1000 && i < 5)
{
x /= 1000;
i++;
}
return x.toFixed(3) + " " + unit[i];
}
////////
const brutto = sr * k;
const netto = sr / (ff / k + 90 + get_pilot_length()) * (ff * fec - get_tbch() - 80);
const tsr = (1 - gse) * netto;
const gser = gse * netto;
////////
const bw = sr;
const obw = (1 + rof) * sr;
const abw = (1 + rof + 0.15) * sr;
console.log("Bits per symbol: " + k);
console.log("Symbol rate: " + humanify(sr) + "sps");
console.log("FEC: " + fec);
console.log("FEC Frame size: " + ff + " bits");
console.log("RRC Roll-off factor: " + rof.toFixed(2));
console.log("Pilots: " + (pilots ? "enabled" : "disabled"));
console.log("--------------------------------");
console.log("Brutto data rate: " + humanify(brutto) + "bps");
console.log("Netto data rate: " + humanify(netto) + "bps");
console.log("Transport Stream data rate: " + humanify(tsr) + "bps");
console.log("GSE data rate: " + humanify(gser) + "bps");
console.log("--------------------------------");
console.log("Sattelite bandwidth: " + humanify(bw) + "Hz");
console.log("Occupied bandwidth: " + humanify(obw) + "Hz");
console.log("Allocated bandwidth: " + humanify(abw) + "Hz");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment