Here we sketch a very simple example representing the structure of a computer network using class Graph
. A Node
in the graph represent a computer (server) and an Edge
represents a cable.
class Network: Graph
class Node::<
send(receiver: ref Node,P: ref Packet):
:::
receive(send: ref Node,P: ref Packet):
...
:::
...
class Edge::<
bandWidth: var integer
send(receiver: ref Node,P: ref Packet):
...
...
class Packet(S: var String):
...
- Class
Network
is a subclass ofGraph
. - It has further bindings of
Node
andEdge
fromGraph
. - It adds a class
Packet
representing the packets being communicated in the network.
Class Node
is extended with:
- A method
send
that send thePacket
P
to the node represents byreceiver
. - A method
receive
that receives a aPacket
P
from theNode
represented by receiver.
Class Edge
is extended with:
- An
integer
bandWidth
representing the bandwidth of the cable represented by theEdge
.
Th details of send in Node
may be sketched as follows:
send(receiver: ref Node,P: ref Packet):
map(receiver).send(receiver,P)
Send
uses an ancillary method map
to find the edge
representing the cable that has the fastest connection to the receiver
, and the invokes send
on this Edge
.
We do not add further details of this examples. It is major task to implement a computer network. It also involves using parallel programming for listening on input/output ports for packages being transmitted / received. Parallel programming is described in chapter