
Implements the RaptorQ FEC algorithm for efficient, loss-tolerant data transmission in P2P, distributed systems, and UDP applications. Features customizable symbol sizes and performance optimization.
Kotlin Multiplatform implementation of the RaptorQ FEC algorithm (RFC 6330), suitable for P2P protocols, distributed systems, and UDP-based applications requiring efficient, loss-tolerant data transmission.
Add to your build.gradle.kts:
repositories {
mavenCentral()
}
dependencies {
implementation("io.github.andreypfau:raptorq-kotlin:1.0.0")
}import io.github.andreypfau.raptorq.*
fun main() {
val data = ByteArray(10_000) { it.toByte() }
val symbolSize = 768
val encoder = Encoder(symbolSize, data)
val decoder = Decoder(encoder.parameters, encoder.symbolSize, encoder.dataSize)
for (i in 0 until 20_000) {
if (i % 5 == 0) continue // simulate 20% loss
val symbol = encoder.encodeToByteArray(i)
if (decoder.addSymbol(i, symbol)) {
val result = decoder.decodeFullyToByteArray()
if (result != null) {
println("Decoded successfully after \${i + 1} symbols")
break
}
}
}
}This project is licensed under the Apache 2.0 License. See the LICENSE file for details.
Kotlin Multiplatform implementation of the RaptorQ FEC algorithm (RFC 6330), suitable for P2P protocols, distributed systems, and UDP-based applications requiring efficient, loss-tolerant data transmission.
Add to your build.gradle.kts:
repositories {
mavenCentral()
}
dependencies {
implementation("io.github.andreypfau:raptorq-kotlin:1.0.0")
}import io.github.andreypfau.raptorq.*
fun main() {
val data = ByteArray(10_000) { it.toByte() }
val symbolSize = 768
val encoder = Encoder(symbolSize, data)
val decoder = Decoder(encoder.parameters, encoder.symbolSize, encoder.dataSize)
for (i in 0 until 20_000) {
if (i % 5 == 0) continue // simulate 20% loss
val symbol = encoder.encodeToByteArray(i)
if (decoder.addSymbol(i, symbol)) {
val result = decoder.decodeFullyToByteArray()
if (result != null) {
println("Decoded successfully after \${i + 1} symbols")
break
}
}
}
}This project is licensed under the Apache 2.0 License. See the LICENSE file for details.