Skip to content
José Pereira edited this page Mar 13, 2015 · 2 revisions

Overview

The network in Minha is an abstract model of a local area network with a limited shared bandwidth. It is implemented by the following components:

Network simulation

  • Network: This is a global model that manages shared bandwidth and maps network addreses to model instances.

  • NetworkStack: This is a global model that manages an interface, with its addresses, and port maps of open sockets.

  • HostImpl: This is a local model that holds references to all components of a host. In particular, it holds a reference to its NetworkStack.

  • Socket.../SocketUpcalls: Local models for classes in java.net provide an implementation of global interface SocketUpcalls, that provides an entry point for invocations from the network and other hosts.

Operations

Models in each host and in the shared network communicate only by posting asynchronous events. Therefore, all methods exposed by Network, NetworkStack, and Upcall interfaces are limited to creating and scheduling an event.

Connecting a socket works as follows:

  1. A ServerSocket is createed. This registers a ServerSocketUpcall at the corresponding NetworkStack.

  2. A Socket is created. A connect request is posted at the Network. This is then relayed to the corresponding NetworkStack. If the corresponding ServerSocket exists, it is queued for accept at the ServerSocketUpcall interface, potentially waking up a thread sleeping on accept().

  3. Upon accept(), a matching Socket is created. This holds a direct reference to the connecting SocketUpcall reference. A reply is posted back providing the server-side SocketUpcall reference and waking up the connecting thread.

Data exchange happens as follows:

  1. Invocation on SocketOutputStream write waits until the data in transit for this socket is below the maximum. It then prepares a packet and posts it at the Network.

  2. When bandwidth is available, this event is relayed directly to the SocketUpcall at the receiving end.

  3. Data is then queued and waiting threads on read are woken up. At the same time, an acknowledgement is queued back to the sender socket. This allows it to decrement the amount of data in transit and do further writes.

Clone this wiki locally