Unreliable Networking

Download Report

Transcript Unreliable Networking

Unreliable Networking
Tom Roeder
CS415 2005sp
Part II notes

Tablet distribution today!





2:15-3:15 Upson 4135
If you can’t make it, send mail, and we’ll set up
some other way
As usual, you will sign them out
Will use them for Part III and on
Tom has an office hour this weekend

3-4pm Saturday, Upson 5138
Part II questions?
Goal

Add an unreliable networking layer

We will build on this in future projects



We give you a wrapper around NT sockets



TCP – add reliability
Ad hoc networking – take away reliance on
infrastructure
This is your IP layer
Your layer will be like a simplified UDP
Two components


minimsg
miniports
minimsg – minithread networking
#define MINIMSG_MAX_MSG_SIZE (4096)
typedef struct miniport* miniport_t;
typedef char* minimsg_t;
extern void minimsg_initialize();
extern miniport_t miniport_local_create();
extern miniport_t miniport_remote_create(network_address_t addr, int id);
extern void miniport_destroy(miniport_t miniport);
extern int minimsg_send(miniport_t local, miniport_t remote,
minimsg_t msg, int len);
extern int minimsg_receive(miniport_t local, miniport_t* remote,
minimsg_t msg, int *len);
minimsg – Best Effort Delivery

Sender side




Given data, formulate a packet
Hand it off to the network layer to be sent
Forget about it
Receiver side




Receive a packet from the network layer
Figure out who has registered to receive it
Hand it off
Note: don’t drop packets or reorder them here
miniports – minthreads mailboxes

Recall from lecture that ports allow reception




Local port


If A wants to send to B, A must send to some port
B needs to know the port to which to respond
We represent this as local and remote ports
Used for receiving
Remote port


Representation on A of a local port on B
Used for sending
miniports – Low-level code

network.[ch] is the socket code





It really listens on a UDP port
When a packet comes in on this port, interrupts
You will write a new interrupt handler for miniports
It will pass it to the right port
Poor application mechanism



need to know magic numbered ports
The world still mostly works like this
Ranveer will talk later about nameservers
Example
msg
1
2 block
20
A
B
Pseudo-Networking details

Must call network_initialize()

Clock interrupts must be disabled
This is the case after calling
minithread_clock_init()

Do this before calling any networking functions


You can run two copies on the same machine


We have provided a function: network_udp_ports
network.[ch] also contains code for
testing ad hoc networks on wired machines
Notes

On minimsg_receive




As usual, the network handler must be fast
Some functions contain network_address_t:
Treat as opaque


You get back a remote miniport
The caller must free it
We have given you functions to handle them
Local ports created in a sequence should always get
the same numbers, regardless of remote ports
created between them
Notes

There is no fragmentation



We have a max packet size: too high is dropped
You are not required to implement fragmentation
Two types of miniports, but one struct

Use unions: eg.
typedef struct miniport_t {
int type; /* LOCAL or REMOTE */
unsigned int portnum;
union {
struct { /* … */ } local;
struct { /* … */ } remote;
}
}
Questions about Part III?