This prose is close enough to a spec to write some C code for format A.
I assume hardware (DMA) that deposits link data in memory in the order so that integers from the link are in memory so that a normal load command from the address where the hardware put it, results in the right integer.
This means for little endian machines, depositing the bytes in decreasing addresses.
To port such code between machines of different endianness it is necessary to:
- Swap the order of fields in struct declarations,
- Change the sign of offsets into internal arrays.
I will come back and make this precise after I have debugged and ported some code.
For this code the packet header (money & SS) comes first for those systems that may be in a position to perform routing logic before the entire packet has arrived.
Both of the stabs below emphasize simplicity as a means to speed.
In the 2nd I store turn ops in characters to speed and simplify the code at the expense of packet size.
- Here we follow format 3 from these proposals.
First is the 4 byte money field, then the 16 bit payload byte count,
then the 2 byte SSC followed by the words of the SS,
then the payload.
This layout is slightly hokey but I think the code will be fast, and by extension special hardware cheap.
I will not write the link level transport layer but presume that it delivers packets and reports the address where the packets were deposited in memory, aligned at 4.
The longest SS is 32 octets supporting paths thru 62 nodes.
- Here we follow this simpler format.
I have ignored the vital problem of allocating and freeing buffer space.
Routine void nerr(int, packet *) reports an error that the previous node should have noticed.
void send(packet *, int) disposes somehow the packet on interface j.
void keep(packet *) interprets messages addressed to this node from far away.
DMA architectures have gone many ways according to this.
Hyper transport may be involved.
I will assume here a DMA that moves a stream of bytes from fiber to contiguous real memory in order of decreasing significance, which means towards smaller addresses on a little endian machine.
A maximum byte count is specified by the program