Unreliable NetworkingPart II notesPart II questions?Goalminimsg – minithread networkingminimsg – Best Effort Deliveryminiports – minthreads mailboxesminiports – Low-level codeExamplePseudo-Networking detailsNotesSlide 12Questions about Part III?Unreliable NetworkingTom RoederCS415 2005spPart II notesTablet distribution today!2:15-3:15 Upson 4135If you can’t make it, send mail, and we’ll set up some other wayAs usual, you will sign them outWill use them for Part III and onTom has an office hour this weekend3-4pm Saturday, Upson 5138Part II questions?GoalAdd an unreliable networking layerWe will build on this in future projects TCP – add reliabilityAd hoc networking – take away reliance on infrastructureWe give you a wrapper around NT socketsThis is your IP layerYour layer will be like a simplified UDPTwo componentsminimsgminiportsminimsg – 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 DeliverySender sideGiven data, formulate a packetHand it off to the network layer to be sentForget about itReceiver sideReceive a packet from the network layerFigure out who has registered to receive itHand it offNote: don’t drop packets or reorder them hereminiports – minthreads mailboxesRecall from lecture that ports allow receptionIf A wants to send to B, A must send to some portB needs to know the port to which to respondWe represent this as local and rem ote portsLocal portUsed for receivingRemote portRepresentation on A of a local port on BUsed for sendingminiports – Low-level codenetwork.[ch] is the socket codeIt really listens on a UDP portWhen a packet comes in on this port, interruptsYou will write a new interrupt handler for miniportsIt will pass it to the right portPoor application mechanismneed to know magic numbered portsThe world still mostly works like thisRanveer will talk later about nameserversExampleA B1202msgblockPseudo-Networking detailsMust call network_initialize()Clock interrupts must be disabledThis is the case after calling minithread_clock_init()Do this before calling any networking functionsYou can run two copies on the same machineWe have provided a function: network_udp_portsnetwork.[ch] also contains code for testing ad hoc networks on wired machinesNotesOn minimsg_receiveYou get back a remote miniportThe caller must free itAs usual, the network handler must be fastSome functions contain network_address_t: Treat as opaqueWe have given you functions to handle themLocal ports created in a sequence should always get the same numbers, regardless of remote ports created between themNotesThere is no fragmentationWe have a max packet size: too high is droppedYou are not required to implement fragmentationTwo types of miniports, but one structUse unions: eg.typedef struct miniport_t {int type; /* LOCAL or REMOTE */unsigned int portnum;union {struct { /* … */ } local;struct { /* … */ } remote;}}Questions about Part
View Full Document