modus
Menu
On this page

The entry net

The source src/modules/demonstrations/net built with the setting DRAWING_THROUGH_MODULE=true. The text after this paragraph is the comment of that source.

The first layer of the network, shown case by case: the link and the address, an ARP answer of the gateway, an echo of the gateway, a UDP datagram to an echo server and its answer, the refusals of the grant, the frames from the wire that the network service refused, and the measures.

The process holds one endpoint (src/library/modus/contract/datagram): the root service granted it the remote 10.0.2.2, port 7, and nothing else. It has no address to choose and no port to open. The window shows each case, the answer, and whether it is the expected answer.

The process writes the UDP header and the checksum of each datagram that it sends, and checks the checksum of each datagram that it receives (src/library/modus/network, udp_header_write and udp_data_read): the network service copies a datagram and computes no checksum of it. Two cases show what follows: a datagram with a wrong checksum reaches this endpoint, and this process drops it; a datagram that this process writes with another source port is refused by the network service.

What it is for. It shows that a network grant is a capability: the process reaches the one remote of its grant, and the network service refuses each other request with the detail of the grant. It also measures what one datagram costs when no kernel entry is on the path of the data.

Start: start("net") in the console, or the bar of the desktop.

Grants, as the root service gives them:

  • Network: one datagram endpoint, the remote 10.0.2.2 port 7.
  • Inspect: the machine, read for the frequency of the cycle counter and for the kernel entries of the two services. With no such grant, the window says "the services: no right Inspect".

What a reader sees: the window lists the cases; the log has one line for each case ("net: ...: answer", with "(WRONG)" after an unexpected answer), one line for each word of a command record that names no command (None, one past the last command, the largest word), which the network service refuses with Bad_Command and the record Unsupported, then "net: ok, N cases", then the measures:

  • the header and the checksum of one datagram of 1472 bytes, in this process;
  • the round trip of one datagram of 64 bytes, least and middle;
  • the time from a refused command to its completion;
  • the rate of a burst with 64 datagrams in flight;
  • the kernel entries for each datagram, of this process, of the network service and of the frame service.

After the measures, each key sends one more datagram to the remote. After revoke("net", "network") in the console, that datagram is refused: the grant ends while the process runs.

What it does not prove: in the test of the network the echo server at the gateway is the peer of the modus tool (tools/modustool/machine/peer.odin), not a stack of another project; the test of TCP against libslirp is the process fetch.

net module with an entry

Hash
3da201fc7d17e2b65cf6c66742295824033855198523bd5cd98da7660a6a23e5
Size
227427 bytes
Exports
0
Imports
1
Imported by
0
License
MIT

The first layer of the network, shown case by case: the link and the address, an ARP answer of the gateway, an echo of the gateway, a UDP datagram to an echo server and its answer, the refusals of the grant, the frames from the wire that the network service refused, and the measures

FactValue
KindModules with an entry
Sourcesrc/modules/demonstrations/net
Boot imageyes: in the boot image, 227427 bytes in this build
Build settings
  • DRAWING_THROUGH_MODULE=true
Imports
Imported bynone

Neighbours

What it imports, at its left, and what imports it, at its right: the part of the module graph that touches it.

net drawing

Exports

ExportWhat it does
entry()The entry of net: it runs the cases of its endpoint once, then the measures, then sends one datagram after each key

entry

entry()

The entry of net: it runs the cases of its endpoint once, then the measures, then sends one datagram after each key.

The entry opens its window (with none, it stops with Failed), reads the frequency of the cycle counter, and opens its endpoint and its datagram region. With no endpoint it writes "net: no endpoint: the process has no grant of the network" and stops with Refused. Then it runs the cases, writes "net: ok, N cases" or "net: WRONG: ...", runs the three measures, and writes "net: the measures are done". The process then waits for keys for ever: each key runs after_key.

Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/demonstrations/net/main.odin:698

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

What the root service gives it

WhatValueAs the root service says
GrantsIt measures with the cycle counter.
Other terms of its start grant setnone
Budget that it asks for
  • working memory pages 691
  • pages of its threads 72
  • pages of the pictures of its window 5425
  • pages of the module and its imports from the files of the build
  • processes the least
  • threads the least
The least budget of 2048 pages, in which it ran before it stated its window, less that window at the scale 1 (1357 pages): its module, its stack, its tables and its glyph memory. The tool counts the window at the largest scale. See: Module contract: The budget that a module asks for

The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).

after_key procedure of the package net

after_key :: proc "contextless" ()

after_key sends one datagram to the remote of the grant, and shows the.

src/modules/demonstrations/net/main.odin:755