com.onionnetworks.fec.io
Class FECParameters

java.lang.Object
  extended by com.onionnetworks.fec.io.FECParameters

public class FECParameters
extends java.lang.Object

This class contains all of the functions for performing packet, block, and stripe calculations given a set of FEC parameters. Most important are the boundary conditions which are difficult to keep straight. FECParameters objects are immutable, therefore they may be safely used without synchronization. (c) Copyright 2001 Onion Networks (c) Copyright 2000 OpenCola

Author:
Justin F. Chapweske (justin@chapweske.com), Ry4an Brase (ry4an@ry4an.org)

Constructor Summary
FECParameters(int k, int n, int packetSize, long fileSize)
          Creates a new FECParameters instance.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 int getBlockCount()
           
 int getExpandedBlockSize()
           
 long getFileSize()
           
 int getK()
           
 int getMaxStripeSize()
           
 int getN()
           
 int getNumStripes()
           
 int getPacketSize()
           
 int getPacketSize(int whichBlock, int whichStripe)
           
 int getStripePacketCount(int whichStripe)
           
 long getStripeSize(int whichStripe)
           
 int getUnexpandedBlockSize()
           
 int getUnexpandedBlockSize(int whichBlock)
           
 int getUnexpandedPacketCount()
           
 int getUnexpandedPacketCount(int blockNum)
           
 int hashCode()
           
 boolean isPaddingPacket(int blockNum, int stripeNum)
          Padding packets are empty packets that should never been read or written and shouldn't be sent across the network (they are all '0's)
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FECParameters

public FECParameters(int k,
                     int n,
                     int packetSize,
                     long fileSize)
Creates a new FECParameters instance.

Parameters:
k - The number of vanilla packets per block.
n - The number of packets that the k vanilla packets can be expanded to.
packetSize - The size of each packet.
fileSize - The size of the original, unencoded file.
Method Detail

getFileSize

public long getFileSize()
Returns:
The size of the original, unencoded file.

getK

public int getK()
Returns:
k, The number of vanilla packets per block.

getN

public int getN()
Returns:
n, The number of packets that the k vanilla packets can be expanded to.

getPacketSize

public int getPacketSize()
Returns:
The maximum (and default) size that most packets will be.

getMaxStripeSize

public int getMaxStripeSize()
Returns:
The maximum size (in bytes) that a stripe will be.

getUnexpandedBlockSize

public int getUnexpandedBlockSize()
Returns:
The default number of vanilla bytes that a block will contain.

getExpandedBlockSize

public int getExpandedBlockSize()
Returns:
The maximum number of bytes that a fully encoded block can contain.

getBlockCount

public int getBlockCount()
Returns:
The number of blocks that this file will be partioned into.

getNumStripes

public int getNumStripes()
Returns:
The maximum number of stripes (N) that be created from this file.

getUnexpandedPacketCount

public int getUnexpandedPacketCount()
Returns:
The number of packets required to send across the original file. Also the minimum number of packets required to recreate the original file.

getUnexpandedPacketCount

public int getUnexpandedPacketCount(int blockNum)
Parameters:
blockNum - The blockNum for which to count packets.
Returns:
The number of packets requried to send across the original block.

getStripePacketCount

public int getStripePacketCount(int whichStripe)
Parameters:
whichStripe - The stripe for which we are counting packets.
Returns:
The number of packets in whichStripe. Most of the time this will be equal to numBlocks, but if this stripe lands on a gap in the last block then it will contain numBlocks-1

getPacketSize

public int getPacketSize(int whichBlock,
                         int whichStripe)
Parameters:
whichBlock - The block which the packet is in.
whichStripe - The stripe which the packet is in, or in other words the index of the packet within whichBlock
Returns:
The size of the packet. Normally the packet size will be the same as getPacketSize(). But if the packet is in the last block then it may be smaller. If the packet is in the last block and is in a gap between the end of the file and K, then it's size will be 0. Also if the packet is the last packet in the file (the packet right before the gap), then the packetSize > 0 && < maxPacketSize

getStripeSize

public long getStripeSize(int whichStripe)
Parameters:
whichStripe - The stripe for which we are finding the size of.
Returns:
The size of the stripe (in bytes). Normally the stripe size will simply be packetSize*numBlocks But if the stripe falls on a gap it will be less.

getUnexpandedBlockSize

public int getUnexpandedBlockSize(int whichBlock)
Parameters:
whichBlock - The block for which we are finding the size of.
Returns:
The size of the unexpanded block. Normally this will simply be k*packetSize. But if this is the last block then it may be less.

isPaddingPacket

public boolean isPaddingPacket(int blockNum,
                               int stripeNum)
Padding packets are empty packets that should never been read or written and shouldn't be sent across the network (they are all '0's)

Parameters:
blockNum - The blockNum of the packet to check
stripeNum - The stripeNum of the packet to check
Returns:
true if this packet is a padding packet.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002 Onion Networks. All Rights Reserved.