Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

NetworkInput Class Reference

The following class defines a physical network device. The network is capable of delivering fixed sized packets, in order but unreliably, to other machines connected to the network. The "reliability" of the network can be specified to the constructor. This number, between 0 and 1, is the chance that the network will lose a packet. Note that you can change the seed for the random number generator, by changing the arguments to RandomInit() in Initialize(). The random number generator is used to choose which packets to drop. More...

#include <network.h>

Inheritance diagram for NetworkInput::

CallBackObj List of all members.

Public Methods

 NetworkInput (CallBackObj *toCall)
 Allocate and initialize network input driver. More...

 ~NetworkInput ()
 De-allocate the network input driver data. More...

PacketHeader Receive (char *data)
 Poll the network for incoming messages. If there is a packet waiting, copy the packet into "data" and return the header. If no packet is waiting, return a header with length 0. More...

void CallBack ()
 A packet may have arrived. More...


Private Attributes

int sock
 UNIX socket number for incoming packets. More...

char sockName [32]
 File name corresponding to UNIX socket. More...

CallBackObjcallWhenAvail
 Interrupt handler, signalling packet has arrived. More...

bool packetAvail
 Packet has arrived, can be pulled off of network. More...

PacketHeader inHdr
 Information about arrived packet. More...

char inbox [MaxPacketSize]
 Data for arrived packet. More...


Detailed Description

The following class defines a physical network device. The network is capable of delivering fixed sized packets, in order but unreliably, to other machines connected to the network. The "reliability" of the network can be specified to the constructor. This number, between 0 and 1, is the chance that the network will lose a packet. Note that you can change the seed for the random number generator, by changing the arguments to RandomInit() in Initialize(). The random number generator is used to choose which packets to drop.

Definition at line 57 of file network.h.


Constructor & Destructor Documentation

NetworkInput::NetworkInput ( CallBackObj * toCall )
 

Allocate and initialize network input driver.

Definition at line 22 of file network.cc.

NetworkInput::~NetworkInput ( )
 

De-allocate the network input driver data.

NetworkInput::NetworkInput Deallocate the simulation for the network input (basically, deallocate the input mailbox)

Definition at line 44 of file network.cc.


Member Function Documentation

void NetworkInput::CallBack ( ) [virtual]
 

A packet may have arrived.

NetworkInput::CallBack Simulator calls this when a packet may be available to be read in from the simulated network.

First check to make sure packet is available & there's space to pull it in. Then invoke the "callBack" registered by whoever wants the packet.

Reimplemented from CallBackObj.

Definition at line 61 of file network.cc.

PacketHeader NetworkInput::Receive ( char * data )
 

Poll the network for incoming messages. If there is a packet waiting, copy the packet into "data" and return the header. If no packet is waiting, return a header with length 0.

NetworkInput::Receive Read a packet, if one is buffered

Definition at line 94 of file network.cc.

Referenced by PostOfficeInput::PostalDelivery().


Member Data Documentation

CallBackObj * NetworkInput::callWhenAvail [private]
 

Interrupt handler, signalling packet has arrived.

Definition at line 76 of file network.h.

PacketHeader NetworkInput::inHdr [private]
 

Information about arrived packet.

Definition at line 80 of file network.h.

char NetworkInput::inbox [private]
 

Data for arrived packet.

Definition at line 81 of file network.h.

bool NetworkInput::packetAvail [private]
 

Packet has arrived, can be pulled off of network.

Definition at line 78 of file network.h.

int NetworkInput::sock [private]
 

UNIX socket number for incoming packets.

Definition at line 73 of file network.h.

char NetworkInput::sockName [private]
 

File name corresponding to UNIX socket.

Definition at line 74 of file network.h.


The documentation for this class was generated from the following files:
Generated at Wed Jul 4 11:32:23 2001 for Nachos by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001