netemlite

package module
v0.0.0-...-97b716b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

README

Netemlite

This repository contains unfinished experimental code that I was writing to explore replacing Gvisor from ooni/netem with the intention of making the implementation leaner.

The general idea was that of replacing the TCP/IP implementation in Gvisor with a significantly simpler one where we basically just send bags of bytes around, we cannot change the latency, and we cannot drop TCP segments.

While exploring this possibility, I realized of a possible way to structure the interaction between the underlying network and the "conn" layer that is quite general and could be useful to me in the future. This is the main reason why I have decided to kept the unfinished code of this PoC.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Network

type Network struct {
	// contains filtered or unexported fields
}

Network simulates a TCP/IP network. The zero value is invalid; please, use NewNetwork to construct.

func NewNetwork

func NewNetwork() *Network

NewNetwork constructs an Network instance and spawns a background goroutine for processing network events that runs until you call the Close method.

func (*Network) Close

func (n *Network) Close() error

Close shuts down the background goroutine.

type UDPConn

type UDPConn struct {
	// contains filtered or unexported fields
}

UDPConn is an UDP connection. The zero value of this struct is invalid; please, use NewUDPConn to construct.

func NewUDPConn

func NewUDPConn(network *Network, localAddr, peerAddr netip.AddrPort) (*UDPConn, error)

NewUDPConn creates a new UDPConn instance.

Arguments:

- network is the Network to use;

- localAddr is the local address of the connection;

- peerAddr is the OPTIONAL peer address.

A zero value remoteAddr implies this socket is not connected.

func (*UDPConn) Close

func (c *UDPConn) Close() error

Close closes the connection.

func (*UDPConn) LocalAddr

func (c *UDPConn) LocalAddr() net.Addr

LocalAddr returns the local addr.

func (*UDPConn) Read

func (c *UDPConn) Read(buffer []byte) (int, error)

Read reads from a connected UDP socket.

func (*UDPConn) ReadFrom

func (c *UDPConn) ReadFrom(buffer []byte) (int, net.Addr, error)

ReadFrom reads from a non-connected UDP socket.

func (*UDPConn) RemoteAddr

func (c *UDPConn) RemoteAddr() net.Addr

RemoteAddr returns the POSSIBLY NIL remote addr.

func (*UDPConn) SetDeadline

func (c *UDPConn) SetDeadline(t time.Time) error

SetDeadline sets the read and the write deadlines.

func (*UDPConn) SetReadDeadline

func (c *UDPConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline.

func (*UDPConn) SetWriteDeadline

func (c *UDPConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the read deadline.

func (*UDPConn) Write

func (c *UDPConn) Write(data []byte) (int, error)

Write writes data on a connected UDP socket.

func (*UDPConn) WriteTo

func (c *UDPConn) WriteTo(data []byte, addr net.Addr) (int, error)

WriteTo writes data on an unconnected UDP socket.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL