public class AnonUDPChannel extends AbstractAnonUDPChannel
AnonService.createChannel(AnonChannel.UDP)
. Afterwards you set
the destination host and port as well as the source port. Data transmission
can be done by using the Input-/Outputstream returned by
getInputStream()
/ getOutputStream()
.
Hint: for performance optimization / efficiency have a look at
setSentAutoFlushDelay(int)
.
Example:
AnonService anonservice=AnonServiceFactory.getAnonServiceInstance(AnonServiceFactory.SERVICE_ANON);
AnonUDPChannel anonchannel=(AnonUDPChannel)anonservice.createChannel(AnonChannel.UDP);
anonchannel.setDst("desti.nation",80);
anonchannel.setSrcPort(5678);
InputStream in=anonchannel.getInputStream();
OutputStream out=anonchannel.getOutputStream();
out.write(...);
in.read(...)
anonchannel.close();
Note: Since the AnonUDPChannel implementation uses an anonymous VPN UDP protocol channel, an AnonUDPChannel can only be established using a cascade which supports VPN.
HTTP, SMTP, SOCKS, TCP, UDP, UDP_OVER_TCP, UDP_OVER_UDP, VPN
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the channel and releases all resources used.
|
int |
getOutputBlockSize()
Returns a value that indicates the current optimum size of data to write.
|
boolean |
isClosed()
Returns if the channel is already closed, i.e. no data can be sent / recieved any more on this channel.
|
int |
readPacket(byte[] payload,
int off,
int len)
Reads the payload of a whole UDP packet sent from the peer.
|
void |
setSentAutoFlushDelay(int msAutoFlushDelay)
Sets the time to wait before actually sending some data over this channel
in case the packet belonging to the underlying anonymisation protocol is
not full yet.
|
void |
writePacket(byte[] payload,
int offset,
int len) |
getInputStream, getOutputStream, setDestination, setSourcePort, writePacket
public void setSentAutoFlushDelay(int msAutoFlushDelay)
This method can be used for performance optimisations / efficiency. One
use case would be if you know that this channel will sent data
immediately after connection establishment. Therefore you would call
setSentAutoFlushDelay
with some delayvalue > 0
just before you call the connect
method. If you call
Outputstream.write
within delayvalue
milliseconds after the connect
call then the data you intend
to sent will be piggybacked on the connect request. This will save some
roundtrip-time delay.
Additionally, using this method correctly could decrease the bandwidth overhead introduced by the underlying anonymisation protocol. Many anonymisation protocols fragment the data stream into fixed sized packets which are filled with dummy data if not enough real data is available. Therefore waiting a certain amount of time for additional real data can increase the channel utilisation.
Note: This method will not do anything at the moment as the implementation is not ready yet.
setSentAutoFlushDelay
in interface IAnonUDPChannel
setSentAutoFlushDelay
in class AbstractAnonUDPChannel
msAutoFlushDelay
- the amount of time in milliseconds to wait for new data before
the current sent buffer is flushed. Setting this value to
0
will always auto flush immediately. Setting this
value to -1
will only flush the sent buffer, if the
sent buffer is full, i.e. getOutputBufgferSize many bytes are
contained in the buffer.public void writePacket(byte[] payload, int offset, int len) throws java.io.IOException
java.io.IOException
public int readPacket(byte[] payload, int off, int len) throws java.io.IOException, UDPPacketStreamDesynchronisationException, UDPPacketToLargeException
payload
- off
- len
- java.io.IOException
UDPPacketStreamDesynchronisationException
UDPPacketToLargeException
public int getOutputBlockSize()
AnonChannel
public void close()
AnonChannel
public boolean isClosed()
AnonChannel
true
, if the channel is already closedCopyright © 2023. All rights reserved.