1gwu cs 259 brad taylor spring 2004 systems programming meeting 9: connectionless communication

24
U CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Meeting 9: Connectionless Connectionless Communication Communication

Upload: kristina-french

Post on 30-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

1GWU CS 259 Brad Taylor Spring 2004

Systems Programming

Meeting 9:Meeting 9:

Connectionless Connectionless CommunicationCommunication

Page 2: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

2GWU CS 259 Brad Taylor Spring 2004

Objectives

• Connectionless CommunicationConnectionless Communication• User Data Protocol (UCP) User Data Protocol (UCP) • Team Formation (Peer-to-Peer) Model Team Formation (Peer-to-Peer) Model • Wireless CommunicationWireless Communication• Project Status Briefs (100% code Project Status Briefs (100% code review)review)• Assignment 4: due next week Assignment 4: due next week • Project PresentationsProject Presentations next week! next week!

Page 3: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

3GWU CS 259 Brad Taylor Spring 2004

From TCP to UDP

Page 4: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

4GWU CS 259 Brad Taylor Spring 2004

Success story #1: UDP

User Datagram Protocol: best-effort, process-to-processUser Datagram Protocol: best-effort, process-to-process– Lives on top of IP: adds corruption detection and “ports” so Lives on top of IP: adds corruption detection and “ports” so

packets can be addressed to a process on hostpackets can be addressed to a process on host– Many header fields are hiddenMany header fields are hidden

UDP

IP

data cksum src portdst port

Hdr cksumsrc IP addrdst IP addr

Host: IP addr = 18.26.0.1

Port 1028

Port 92Port 18

Page 5: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

5GWU CS 259 Brad Taylor Spring 2004

Two Connection Models• ConnectionlessConnectionless (or “datagram”): (or “datagram”):

– Packets contain enough information so routers can Packets contain enough information so routers can decide how to get it to its final destinationdecide how to get it to its final destination

• Connection-orientedConnection-oriented (or “virtual circuit”) (or “virtual circuit”)– Connection between two nodes first set up Connection between two nodes first set up – Label it (called virtual circuit identifier: VCI)Label it (called virtual circuit identifier: VCI)– All packets carry labelAll packets carry label

BAb b

C

BA1 1

C

1

Page 6: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

6GWU CS 259 Brad Taylor Spring 2004

Datagrams

• Simple idea:Simple idea:– Don’t set up a connection, just make sure each packet Don’t set up a connection, just make sure each packet

contains enough information to get to destination contains enough information to get to destination – What is this? Complete destination addressWhat is this? Complete destination address– ““In a connectionless network, you are always connected.” In a connectionless network, you are always connected.”

D. CheritonD. Cheriton

• Forwarding: Forwarding: – Switch creates “forwarding table”, mapping destinations to Switch creates “forwarding table”, mapping destinations to

output port (ignores input ports)output port (ignores input ports)– When packet with destination address in table arrives, pushes When packet with destination address in table arrives, pushes

it out appropriate output portit out appropriate output port– When packet with destination address not in table arrives, When packet with destination address not in table arrives,

must find out more routing information (next problem)must find out more routing information (next problem)

Page 7: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

7GWU CS 259 Brad Taylor Spring 2004

Datagram Tradeoffs

• Good: Good: – No round-trip delay to setup connectionNo round-trip delay to setup connection– Each packet forwarded independently of last: if Each packet forwarded independently of last: if

switch or link fails, will be routed around itswitch or link fails, will be routed around it– Resources allocated dynamically (adaptively) rather Resources allocated dynamically (adaptively) rather

than statically bound at connection time: lets each than statically bound at connection time: lets each “flow” achieve peak bandwidth of idle link“flow” achieve peak bandwidth of idle link

• Bad:Bad:– Busy link = unpredictable, wild service fluctuationsBusy link = unpredictable, wild service fluctuations– Each packet carries full destination address, which Each packet carries full destination address, which

makes per packet overhead highermakes per packet overhead higher

• Internet supports datagram (IP protocol)Internet supports datagram (IP protocol)

Page 8: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

8GWU CS 259 Brad Taylor Spring 2004

Mobile Ad-Hoc Networks

• ProxiNetProxiNet: : – Supports ad-hoc networks comprised of hand held Supports ad-hoc networks comprised of hand held

devices that facilitate exchange of information devices that facilitate exchange of information between nodes between nodes

– Forms teams to accomplish given tasks Forms teams to accomplish given tasks – Allows dynamic introduction and extraction of nodes Allows dynamic introduction and extraction of nodes

• Extends and demonstrates Extends and demonstrates MANET MANET issues :issues :– Node and link establishment and maintenance Node and link establishment and maintenance – Communication scheme alternatives and Communication scheme alternatives and

enhancements enhancements – Network instantiation applications Network instantiation applications

Page 9: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

9GWU CS 259 Brad Taylor Spring 2004

On-Demand Multicast Routing Protocol (ODMRP)

• Developed by Internet Engineering Task Force (IETF) MANET working group Developed by Internet Engineering Task Force (IETF) MANET working group • ODMRP forwards multicast packets to subset of nodes, minimizing ODMRP forwards multicast packets to subset of nodes, minimizing

communication loading communication loading • Source establishes and maintains membership & routing information on demandSource establishes and maintains membership & routing information on demand• Soft state group membership maintenance approach: explicit control message Soft state group membership maintenance approach: explicit control message

not required to leave not required to leave

Multicast Receiver

Multicast Source

Mobile Node

Join Reply

Join Query

Page 10: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

10GWU CS 259 Brad Taylor Spring 2004

ODMRP Creation & Maintenance

• Multicast source with messages to send, but not a multicast group Multicast source with messages to send, but not a multicast group route, periodically broadcasts a route, periodically broadcasts a Join-QueryJoin-Query until receiving until receiving membership & routing information membership & routing information

• Node receiving ODMRP message stores message source & sequence Node receiving ODMRP message stores message source & sequence number for duplicate detectionnumber for duplicate detection

• Reverse path to source node updated if routing table changed Reverse path to source node updated if routing table changed • Join-Query rebroadcast if not duplicate & time to live (TTL) > 0Join-Query rebroadcast if not duplicate & time to live (TTL) > 0• Multicast group member receiving Join-Query, creates & broadcasts Multicast group member receiving Join-Query, creates & broadcasts

Join-ReplyJoin-Reply to neighbors to neighbors • Node receiving Join-Reply as “next hop” on source return path is Node receiving Join-Reply as “next hop” on source return path is

forwarding group member; sets a flag for that source node & sends forwarding group member; sets a flag for that source node & sends its its Join TableJoin Table

• Process recursively executed by next routing table node, until Process recursively executed by next routing table node, until reaching multicast source, constructing (updating) route mesh from reaching multicast source, constructing (updating) route mesh from sources to receivers sources to receivers

• Join-Query periodically sent to refresh forwarding group & routes Join-Query periodically sent to refresh forwarding group & routes • Multicast source simply stops sending Join-Query messages to leave Multicast source simply stops sending Join-Query messages to leave

group group

Page 11: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

11GWU CS 259 Brad Taylor Spring 2004

Unicast Routing:Dynamic Source Routing

• DSR provides reactive, on-demand message routing DSR provides reactive, on-demand message routing • Each node maintains cache of routes to other known nodes, dynamically Each node maintains cache of routes to other known nodes, dynamically

updated as new routes determined updated as new routes determined • Route negotiation process entails first checking cache for non-expired hop-by-Route negotiation process entails first checking cache for non-expired hop-by-

hop route to destination hop route to destination • Expiration occurs if route error received, indicating broken link Expiration occurs if route error received, indicating broken link • Route discovery initiated if destination not in cache Route discovery initiated if destination not in cache

N1

N2

N3

N4

N5

N1-N2-N5

N1-N2-N5

Route Reply

N1

N2

N3

N4

N5N1

N1-N2

N1-N2

N1

N1-N3-N4

N1-N3

Route Discovery

N1-N3

Page 12: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

12GWU CS 259 Brad Taylor Spring 2004

DSR Creation & Maintenance

• Route discovery broadcast to all neighbors, with Route discovery broadcast to all neighbors, with source and destination addresses and a unique source and destination addresses and a unique identifier identifier

• Recipients respond if Recipients respond if – (1) the destination or (1) the destination or – (2) holding a non-expired route in cache (2) holding a non-expired route in cache

• Otherwise, node appends its address to the Otherwise, node appends its address to the discovery request & forwards to all other neighbors discovery request & forwards to all other neighbors

• Nodes only forward requests not yet seen by Nodes only forward requests not yet seen by examining the header field, limiting message examining the header field, limiting message complexitycomplexity

Page 13: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

13GWU CS 259 Brad Taylor Spring 2004

Unicast Routing:Cluster-based Routing Protocol

• CBRP: a clustered, hierarchical, reactive (table driven) distant CBRP: a clustered, hierarchical, reactive (table driven) distant vector routing method vector routing method

• Ad hoc network partitioned into clusters; each ‘elects’ Ad hoc network partitioned into clusters; each ‘elects’ cluster headcluster head • Mobile node belonging to two or more clusters is a Mobile node belonging to two or more clusters is a gatewaygateway, ,

known to cluster heads, connecting the clusters known to cluster heads, connecting the clusters • Inter-cluster messages are routed via these gateways Inter-cluster messages are routed via these gateways

Cluster-head Gateway Normal node

Source

Destination

Page 14: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

14GWU CS 259 Brad Taylor Spring 2004

CBRP Creation & Maintenance

• Each node maintains two tables for originating messages: Each node maintains two tables for originating messages: – (1) (1) Cluster member tableCluster member table, broadcast periodically, with cluster , broadcast periodically, with cluster

membership information and membership information and – (2) (2) Routing tableRouting table, with paths to cluster members, including the , with paths to cluster members, including the

head head • Intra-cluster messages are routed as previously discussed Intra-cluster messages are routed as previously discussed • Remote message routed:Remote message routed:

– 1: Local cluster head, 1: Local cluster head, – 2: Via gateways and cluster heads until reaching destination 2: Via gateways and cluster heads until reaching destination

cluster head, and cluster head, and – 3: Onto destination node 3: Onto destination node

• A lowest-ID algorithm applied to form clusters:A lowest-ID algorithm applied to form clusters:– Each node, assigned a distinct ID, periodically broadcasts a Each node, assigned a distinct ID, periodically broadcasts a

cluster nodes list, including its ID cluster nodes list, including its ID – Lowest ID node in cluster, hearing only IDs higher than own, is Lowest ID node in cluster, hearing only IDs higher than own, is

(becomes) cluster head (becomes) cluster head – Others are cluster members Others are cluster members – Node hearing two or more cluster heads is a gateway Node hearing two or more cluster heads is a gateway

Page 15: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

15GWU CS 259 Brad Taylor Spring 2004

Group Formation and Management

• Group formation allows Group formation allows decomposition of decomposition of responsibilitiesresponsibilities too complex for individual too complex for individual accomplishmentaccomplishment into into sub-taskssub-tasks given deadline given deadline assigned or resources availableassigned or resources available

• ProxiNetProxiNet DSR protocol demonstrates robust team DSR protocol demonstrates robust team management method suite suitable for variety of management method suite suitable for variety of mobile, ad hoc, distributed environmentsmobile, ad hoc, distributed environments

• Clique (or Clique (or TeamTeam) ) FormationFormation allows teams, and allows teams, and nodes belonging to multiple teams nodes belonging to multiple teams

• Team challenges stem from two aspects:Team challenges stem from two aspects:– Mobile environment teams form dynamically: nodes join Mobile environment teams form dynamically: nodes join

and leave at will, requiring proper maintenance procedures and leave at will, requiring proper maintenance procedures – Same requirements and problems of any node in the Same requirements and problems of any node in the

regular wireless infrastructure continue to apply to team regular wireless infrastructure continue to apply to team nodes nodes

Page 16: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

16GWU CS 259 Brad Taylor Spring 2004

Team Methods

• Team methods Team methods – Provide basic application-level (i.e., above Provide basic application-level (i.e., above

network layer) functionality network layer) functionality – Organize, maintain and disband MANET team Organize, maintain and disband MANET team

(group of nodes organized in peer-to-peer (group of nodes organized in peer-to-peer manner) from previously unassociated entities manner) from previously unassociated entities

• Individual nodes Individual nodes – Unique, static name and IP address Unique, static name and IP address – Dynamic set of skills (Dynamic set of skills (gainSkillgainSkill))– Negotiate to join team created for a set goal Negotiate to join team created for a set goal

((joinTeamReqjoinTeamReq))• Team leader (administration proxy)Team leader (administration proxy)

– Advertises for team membersAdvertises for team members– Accepts bids meeting specified criteria Accepts bids meeting specified criteria

((joinTeamjoinTeam))– Records member and collective informationRecords member and collective information– Assigns each member a unique team ID Assigns each member a unique team ID

• Goal partitioned into task set (Goal partitioned into task set (assignTaskassignTask))– Tasks assigned & communicated to members for Tasks assigned & communicated to members for

accomplishmentaccomplishment– Handshaking used for robust operation Handshaking used for robust operation

Page 17: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

17GWU CS 259 Brad Taylor Spring 2004

Team Methods (con’t)

• Team member (node) may leave team Team member (node) may leave team ((leaveTeamReqleaveTeamReq))– Internal reasons or Internal reasons or – Lost due to communications link failureLost due to communications link failure– mobile, ad hoc, nature of the network highlights this mobile, ad hoc, nature of the network highlights this

concern concern • Team leader loss requires New leader (Team leader loss requires New leader (electLeaderelectLeader))

– Elected from among peers (using the Bully Algorithm)Elected from among peers (using the Bully Algorithm)– Learn additional distributed team attributes from Learn additional distributed team attributes from

members, minimizing information loss and overhead members, minimizing information loss and overhead while remaining robust while remaining robust

• ChangesChanges– Team membership & leadership changes sent to all Team membership & leadership changes sent to all

members use members use lightweightlightweight roster roster – Negotiations with or requests from single members (i.e., Negotiations with or requests from single members (i.e.,

acquiring new skills or assigned new tasks) acquiring new skills or assigned new tasks) communicated between leader & involved member with communicated between leader & involved member with detailed detailed heavyweightheavyweight team information team information

– Special case: new leader election, as Bully Algorithm Special case: new leader election, as Bully Algorithm entails sending successive messages to rapidly entails sending successive messages to rapidly shrinking group subset (those with lower team IDs) until shrinking group subset (those with lower team IDs) until complete complete

Page 18: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

18GWU CS 259 Brad Taylor Spring 2004

Extended Team Methods•Extended methods provide Extended methods provide

– Attribute-based negotiations for ‘active’ & Attribute-based negotiations for ‘active’ & ‘reserve’ members ‘reserve’ members

– Modify task assignment process for Modify task assignment process for classification consistencyclassification consistency

– Automate member negotiation and Automate member negotiation and reclassification between categories upon reclassification between categories upon departure departure

– Allow dynamic active team resource Allow dynamic active team resource expansion or reduction, as might be expansion or reduction, as might be necessary for varying network resource necessary for varying network resource demand demand

•Initial constraints include specified team Initial constraints include specified team size size

– As target reached, subsequent bidders held As target reached, subsequent bidders held in reserve in reserve

– As size requirements change or a member As size requirements change or a member leaving team requires replacement, active leaving team requires replacement, active and reserve members’ skills serve as and reserve members’ skills serve as negotiation basis negotiation basis

Page 19: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

19GWU CS 259 Brad Taylor Spring 2004

UDP/Socket Example: Bare Minimum Client/Server

• ServerServer::– Creates a server socket bound to a fixed Creates a server socket bound to a fixed

port (12345)port (12345)– Receives a message from a client and Receives a message from a client and

displays itdisplays it• ClientClient::

– Creates a client socketCreates a client socket– Repeatedly sends the  message "Hi" out Repeatedly sends the  message "Hi" out

of this socket to the server of this socket to the server

Page 20: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

20GWU CS 259 Brad Taylor Spring 2004

UDP Minimum: udpServer.c

#include "def"#include "def"main()main(){{

int sd;int sd;struct sockaddr_in server;struct sockaddr_in server;char buf[512];char buf[512];int rc;int rc;

server.sin_family = AF_INET;server.sin_family = AF_INET;server.sin_addr.s_addr = htonl(INADDR_ANY);server.sin_addr.s_addr = htonl(INADDR_ANY);server.sin_port = htons(12345);server.sin_port = htons(12345);sd = sd = socketsocket (AF_INET,SOCK_DGRAM,0); (AF_INET,SOCK_DGRAM,0);

bindbind ( sd, (SA *) &server, sizeof(server)); ( sd, (SA *) &server, sizeof(server));

for(;;){for(;;){rc = rc = recvrecv (sd, buf, sizeof(buf), 0); (sd, buf, sizeof(buf), 0);buf[rc]= (char) NULL;buf[rc]= (char) NULL;printf("Received: %s\n", buf);printf("Received: %s\n", buf);

}}}}

Page 21: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

21GWU CS 259 Brad Taylor Spring 2004

UDP Minimum: udpClient.c

#include "def"#include "def"main(..)main(..)

{{int sd;int sd;struct sockaddr_in server;struct sockaddr_in server;struct hostent *hp, *gethostbyname();struct hostent *hp, *gethostbyname();

sd = sd = socketsocket (AF_INET,SOCK_DGRAM,0); (AF_INET,SOCK_DGRAM,0);

server.sin_family = AF_INET;server.sin_family = AF_INET;hp = gethostbyname(argv[1]);hp = gethostbyname(argv[1]);bcopy ( hp->h_addr, &(server.sin_addr.s_addr), hp-bcopy ( hp->h_addr, &(server.sin_addr.s_addr), hp-

>h_length);>h_length);server.sin_port = htons(12345);server.sin_port = htons(12345);

for (;;) {for (;;) {sendtosendto(sd, "HI",2, 0, (SA *) &server, (sd, "HI",2, 0, (SA *) &server,

sizeof(server));sizeof(server));sleep(2);sleep(2);

}}}}

Page 22: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

22GWU CS 259 Brad Taylor Spring 2004

Mapping UICI to Teams

• UICI UICI functions and UDP functions and UDP SocketSocket Team Team Formation functions:Formation functions:– u_joinu_join => {create UDP socket, bind & => {create UDP socket, bind &

listen for multicast messages}listen for multicast messages}– u_leaveu_leave => {leave => {leave multicast group}multicast group}

Page 23: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

23GWU CS 259 Brad Taylor Spring 2004

Final Project Report

• Teams report next week (4/19)Teams report next week (4/19)• Following week (4/26) “Final Prep”Following week (4/26) “Final Prep”• 15-20 minute Powerpoint presentation15-20 minute Powerpoint presentation• All group members participateAll group members participate• Humor, A/V within capabilities encouragedHumor, A/V within capabilities encouraged• Discussion items include Discussion items include

– FrameworkFramework– Tasks UndertakenTasks Undertaken– Unique SolutionsUnique Solutions– ChallengesChallenges– GWire IntegrationGWire Integration– Lessons LearnedLessons Learned– Code HighlightsCode Highlights

• Written Report Written Report – 5 – 8 pages, project synopsis5 – 8 pages, project synopsis– Code and Test cases, as appendicesCode and Test cases, as appendices– Due: 4/26 (in class) or NLT 4/28 (CS mailbox)Due: 4/26 (in class) or NLT 4/28 (CS mailbox)– ““Formal Name” for Web AttributionFormal Name” for Web Attribution

Page 24: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 9: Connectionless Communication

24GWU CS 259 Brad Taylor Spring 2004

100% Project Status Report

Group I: Dan, Ricardo & Kamal: “Wire Socket”Group I: Dan, Ricardo & Kamal: “Wire Socket”

Group II: Clayton, Jason: “Named Pipes”Group II: Clayton, Jason: “Named Pipes”

Group III: Brooke, Nush, Ram: “Shared Memory, Group III: Brooke, Nush, Ram: “Shared Memory, Semaphores & Futexs”Semaphores & Futexs”

Integration: Nate & BradIntegration: Nate & Brad

Issues to discuss:Issues to discuss:Code Review for Each GroupCode Review for Each GroupError checkingError checkingRough draft code submission for integration reviewRough draft code submission for integration reviewFurther Guidance, QuestionsFurther Guidance, Questions