Assignment 3Unreliable NetworkingAri RabkinImplement simple unreliable datagrams (“messages”).Minithreads can send messages between machines, or between threads.Models UDP, the user datagram protocol in the Internet protocol family.GoalsPorts and messagesA message is a sequence of bytes addressed to a particular port on a particular machine.A miniport is a port number + machine address pair.A local miniport (a port on this machine) can also be used to receive messages.What you getWe give you network_address_t, and functions to manipulate it. (See network.h)Treat it as an opaque type, and don’t reach inside it.We give you network interrupts: set up handler via network_initialize()Give you network_send_pkt() to do sends.What you buildSending messages: minimsg_send()Message is either sent out over the wire with appropriate headers, or else delivered locally. Don’t call out to hardware for local sendsReceiver should call minimsg_receive()Blocks until message arrivesConcurrencyPorts should be thread-safe:Multiple threads can call receive, in which case each datagram will be delivered to exactly one of them. (Which one is arbitrary).Multiple concurrent sends should send out complete datagrams (ordering is arbitrary).Packets have headersA packet needs a header specifying who should receive it -- hardware may be broadcast, after all.Add src and dest (addr:port) pairsAlso add a message type fieldNeed length of bodyAnd then a body....Some other things to buildAlso need some functions to manage ports.minimsg_initialize()miniport_local_create()miniport_remote_create()miniport_destroy()Struct is something like...•struct minimsg_hdr {network_address_t src_addr, dst_addr;short src_port, dst_port;int msg_type, msg_len;}GotchasDon’t network_send to local addresses.Don’t leak memoryBe careful with the returned port from receive. Don’t want to free local ports!You shouldn’t use sscanf/sprintf to make headers. Just send binary data.Questions?Anyone used scheduling features of CMS?Come up and sign up for design doc reviews. I didn’t print out sheet -- talk to me. Your questions: now’s the time...I’m not around this
View Full Document