@@ -74,3 +74,56 @@ PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
74
74
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.035 ms
75
75
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.021 ms
76
76
```
77
+
78
+ ## New System Calls
79
+
80
+ The implementation of network stack adds 7 new system calls: ` socket ` , ` bind ` ,
81
+ ` connect ` , ` listen ` , ` accept ` , ` send ` and ` recv ` . As only UDP is currently
82
+ supported, the ` listen ` and ` accept ` system calls are currently nops.
83
+
84
+ - ` socket ` - Creates a new socket of the specified type (currently UDP only)
85
+ - ` bind ` - Associates a socket with a local address and port
86
+ - ` connect ` - Associates a socket with a remote address and port
87
+ - ` listen ` - Not implemented
88
+ - ` accept ` - Not implemented
89
+ - ` send ` - Send data to a remote socket
90
+ - ` recv ` - Receive data from a remote socket
91
+
92
+ ## Using the Network Stack
93
+
94
+ An example netcat like userspace program, ` nc ` , is provided to exercise the
95
+ network stack.
96
+
97
+ The ` nc ` program operates in two modes, client or server:
98
+
99
+ ``` shell
100
+ nc [-c| -s] [address] [port]
101
+ ```
102
+
103
+ In client mode (` -c ` ), the program will send data from stdin to the specified
104
+ port of the host located at ` address ` . For example, to send data to ` 10.0.0.1 ` on port ` 4444 ` :
105
+
106
+ ``` shell
107
+ $ nc -c 10.0.0.1 4444
108
+ $ hello, world!
109
+ ```
110
+
111
+ In server mode (` -s ` ), the program will listen for data on the specified port.
112
+ To listen to data on port ` 5555 ` :
113
+
114
+ ``` shell
115
+ $ nc -s 10.0.0.2 5555
116
+ ```
117
+
118
+ As the network interface has a fixed local address (` 10.0.0.2 ` ), the ` address `
119
+ argument is currently ignored.
120
+
121
+ ## Notes
122
+
123
+ - The network interface is assigned a fixed address of ` 10.0.0.2 `
124
+ - The connect(...) system call is blocking on establishing the ARP resolution
125
+ of the hardware address of the remote host.
126
+ - The send(...) system call is blocking on the successful write of a transmit
127
+ descriptor to the network device.
128
+ - The recv(...) system call is non-blocking, returning immediately if no data
129
+ is available. This is until the functionality of proc.c is ported to Rust.
0 commit comments