C# Class Ipop.Ethernet

Provides an interface to the Virtual Network device known as a TAP device. Ethernet is an ISender, meaning to write to the device, one must call the Send method. It is also an ISource, meaning to receive packets one must subscribe via the Subscribe method to the output.
Inheritance: SimpleSource, ISender
Mostrar archivo Open project: pstjuste/brunet Class Usage Examples

Public Properties

Property Type Description
Address MemBlock

Protected Properties

Property Type Description
_read_thread Thread
_running bool
_send_buffer byte[]
_tap Ipop.Tap.TapDevice

Public Methods

Method Description
Ethernet ( string device_name ) : Brunet

Initializes the Ethernet device by opening the TAP device and starting the ISource thread.

Send ( ICopyable data ) : void

Writes the data to the Ethernet device.

The same max MTU byte array is always used to write the data to the device. Since the incoming data is an ICopyable, it needs to be copied to a single byte array before being sent to the unmanaged language.

Stop ( ) : void

Call this method when exiting to stop the _read_thread.

ToUri ( ) : String

Protected Methods

Method Description
ReadLoop ( ) : void

The thread acting as the ISource for Ethernet, this is where reading of the TAP is performed. Use Subscribe to receive the packets coming from here.

The same max MTU byte array is always read into. This is then copied to a minimum sized MemBlock and send to the subscriber.

Method Details

Ethernet() public method

Initializes the Ethernet device by opening the TAP device and starting the ISource thread.
public Ethernet ( string device_name ) : Brunet
device_name string
return Brunet

ReadLoop() protected method

The thread acting as the ISource for Ethernet, this is where reading of the TAP is performed. Use Subscribe to receive the packets coming from here.
The same max MTU byte array is always read into. This is then copied to a minimum sized MemBlock and send to the subscriber.
protected ReadLoop ( ) : void
return void

Send() public method

Writes the data to the Ethernet device.
The same max MTU byte array is always used to write the data to the device. Since the incoming data is an ICopyable, it needs to be copied to a single byte array before being sent to the unmanaged language.
public Send ( ICopyable data ) : void
data ICopyable ICopyable of the data to be written.
return void

Stop() public method

Call this method when exiting to stop the _read_thread.
public Stop ( ) : void
return void

ToUri() public method

public ToUri ( ) : String
return String

Property Details

Address public_oe property

The address of our TapDevice
public MemBlock Address
return MemBlock

_read_thread protected_oe property

The thread that provides the ISource for Ethernet
protected Thread _read_thread
return Thread

_running protected_oe property

Set to false when we're exiting
protected bool _running
return bool

_send_buffer protected_oe property

This is a constant buffer used for writing to the tap device
protected byte[] _send_buffer
return byte[]

_tap protected_oe property

protected TapDevice,Ipop.Tap _tap
return Ipop.Tap.TapDevice