Elements of a Protocol Implementation

Elements of a Protocol Implementation

Elements of a Protocol Implementation Outline Service Interface Process Model Common Subroutines Example Protocol Spring 2000 CS 461 1 Socket API Creating a socket int socket(int domain, int type, int protocol) domain = PF_INET, PF_UNIX type = SOCK_STREAM, SOCK_DGRAM Passive Open (on server) int bind(int socket, struct sockaddr *addr, int addr_len) int listen(int socket, int backlog)

int accept(int socket, struct sockaddr *addr, int addr_len) Spring 2000 CS 461 2 Sockets (cont) Active Open (on client) int connect(int socket, struct sockaddr *addr, int addr_len) Sending/Receiving Messages int send(int socket, char *msg, int mlen, int flags) int recv(int socket, char *buf, int blen, int flags) Spring 2000 CS 461 3 Protocol-to-Protocol Interface

Configure multiple layers static versus extensible Process Model avoid context switches Buffer Model avoid data copies Spring 2000 CS 461 4 Configuration TCP UDP IP ARP ETH

ICMP name=tulip; name=eth protocols=tulip; name=arp protocols=eth; name=ip protocols=eth,arp; name=icmp protocols=ip; name=udp protocols=ip; name=tcp protocols=ip; TUPLIP Spring 2000 CS 461 5 Protocol Objects Active Open Sessn xOpen(Protl hlp, Protl llp, Part *participants)

Passive Open XkReturn xOpenEnable(Protl hlp,Protl llp, Part *participant) XkReturn xOpenDone(Protl hlp, Protl llp,Sessn session, Part *participants) Demultiplexing XkReturn xDemux(Protl hlp, Sessn lls, Msg *message) Spring 2000 CS 461 6 Session Objects

Local end-point of a channel Interpret messages and maintain channel state Export operations for sending and receiving messages Operations send a message XkReturn xPush(Sessn lls,Msg *message) deliver a message XkReturn xPop(Sessn hls, Sessn lls, Msg *message,void *hdr) Spring 2000 CS 461 7 Process Model (a) (b) Process-per-Protocol

Spring 2000 Process-per-Message CS 461 8 Message Library Add header Strip header m m abcdefg abcdefg bcopy ( xyz , hdr , 3); msgAddHdr (m, hdr, 3); hdr =msgStripHdr (m, 3);

m m defg + hdr = abc xyzabcdefg Spring 2000 CS 461 9 Message Library (cont) Fragment message Reassemble messages m m1

abcdefg m abcd msgFragment (m, new, 3); new defg Spring 2000 + m2 efg msgReassemble(new, m1, m2) new abcdefg abc

CS 461 10 Event Library Scheduling Timeouts & Book-keeping activity Operations Event evSchedule(EvFunc function, void *argument, int time) EvCancelReturn evCancel(Event event) Spring 2000 CS 461 11 Map Library Demultiplex Packets Operations Map mapCreate(int number,int size) Binding mapBind(Map map,

void *key, void *id) XkReturn mapResolve(Map map, void *key,void **id) Spring 2000 CS 461 12 Example static Sessn aspOpen(Protl self, Protl hlp, Part *p) { Sessn asp_s; Sessn lls; ActiveId key; ProtlState *pstate = (ProtlState *)self->state; bzero((char *)&key, sizeof(key)); /* High level protocol must specify both */ /* local and remote ASP port */

key.localport = *((AspPort *) partPop(p[0])); key.remoteport = *((AspPort *) partPop(p[1])); /* Assume failure until proven otherwise */ asp_s = XK_FAILURE; Spring 2000 CS 461 13 /* Open session on low-level protocol */ lls = xOpen(self, xGetDown(self, 0), p); if ( lls != XK_FAILURE ) { key.lls = lls; /* Check for session in active map */ if (mapResolve(pstate->activemap, &key, (void **)&asp_s) == XK_FAILURE) { /* Session not in map; initialize it */ asp_s = asp_init_sessn(self, hlp, &key); if ( asp_s != XK_FAILURE )

{ /* A successful open */ return asp_s; } } /* Error has occurred */ xClose(lls); } } return asp_s; Spring 2000 CS 461 14 static XkReturn aspPush(Sessn s, Msg *msg) { SessnState *sstate; AspHdr

hdr; void *buf; /* create a header */ sstate = (SessnState *) s->state; hdr = sstate->hdr; hdr.ulen = msgLen(msg) + HLEN; /* attach header and send */ buf = msgAddrHdr(msg, HLEN); aspHdrStore(&hdr, buf, HLEN, msg); return xPush(xGetDown(s, 0), msg); } Spring 2000 CS 461 15 static XkReturn { AspHdr Sessn

ActiveId PassiveId ProtlState Enable void aspDemux(Protl self, Sessn lls, Msg *msg) h; s; activeid; passiveid; *pstate; *e; *buf; pstate = (ProtlState *)self->state; /* extract the header from the message */ buf = msgStripHdr(msg, HLEN); aspHdrLoad(&h, buf, HLEN, msg); /* construct a demux key from the header */ bzero((char *)&activeid, sizeof(activeid)); activeid.localport = h.dport; activeid.remoteport = h.sport;

activeid.lls = lls; Spring 2000 CS 461 16 /* see if demux key is in the active map */ if (mapResolve(pstate->activemap, &activeid, (void **)&s) == XK_FAILURE) { /* didn't find an active session, */ /* so check passive map */ passiveid = h.dport; if (mapResolve(pstate->passivemap, &passiveid, (void **)&e) == XK_FAILURE) { /* drop the message */ return XK_SUCCESS; } /* port was enabled, so create a new */ /* session and inform hlp */ s = asp_init_sessn(self, e->hlp, &activeid);

xOpenDone(e->hlp, s, self); } /* pop the message to the session */ return xPop(s, lls, msg, &h); } Spring 2000 CS 461 17 static XkReturn aspPop(Sessn s, Sessn ds, Msg *msg, void *inHdr) { AspHdr *h = (AspHdr *) inHdr; /* truncate message to length shown in header */ if ((h->ulen - HLEN) < msgLen(msg)) msgTruncate(msg, (int) h->ulen); /* pass message up the protocol stack */ return xDemux(xGetUp(s), s, msg); }

Spring 2000 CS 461 18

Recently Viewed Presentations

  • Welcome to 6th grade Curriculum Night!

    Welcome to 6th grade Curriculum Night!

    Social Studies Overview. Mr. Gebhardt , Mrs. Briggs, Mrs. Fields, & Mrs. Vickery. This school year we will . learn about . U.S. History. We study the
  • SafeKey-Schaltmodul SSM/x - ABB Group

    SafeKey-Schaltmodul SSM/x - ABB Group

    Nur bei Funktion potentialfreies Schalten 3 Verzögerte Scharfschaltung Direkte Scharfschaltung 4 Dynamische* Ansteuerung des Relais Statische** Ansteuerung des Relais 5 Zuschalten der integrierten Widerstandskombination für Funktion Scharf-/ Unscharf-anforderung an Ausgang E Abschalten der integrierten Widerstandskombination für Funktion ...
  • Middle English - ITS

    Middle English - ITS

    Middle English Dialects Caxton & Printing Emergence of a Standard Middle English Dialects Studying Middle English Dialects Linguistic Atlas of Late Middle English (1350-1450) • late time period means lots of texts • according to the atlas, almost any Middle...
  • 6th Grade Math Focus 2: Rates, including percents

    6th Grade Math Focus 2: Rates, including percents

    Develop connections between fractions, decimals, and percents (4.3) Develop strategies for expressing data in percent form (4.3) Relate fractions, decimals, and percents (4.4) To move from percents to other representations and from other representations to percents (4.4)
  • Unit 8 Chapter 12 Supreme Court Decision Making

    Unit 8 Chapter 12 Supreme Court Decision Making

    Section 1: The Supreme Court at Work Section 2: Shaping Public Policy Section 3: Influencing Court Decisions How does the Supreme Court determine which cases it will hear and the outcome of the each case?
  • THE TREES - asliteratureavcol

    THE TREES - asliteratureavcol

    The Trees The trees are coming into leaf. Like something almost being said; The recent buds relax and spread, Their greenness is a kind of grief. Is it that they are born again. And we grow old? No, they die...
  • Assessing Rate of Improvement of Individual Students

    Assessing Rate of Improvement of Individual Students

    The rate of improvement is the line that is calculated using a linear regression. This line takes into account each score entered to portray an average rate of improvement across weeks. Diego's Scores (3rd) Benchmark (3rd)
  • By the end of todays lesson you will:

    By the end of todays lesson you will:

    The problem of evil and suffering. The extent to which the classical form of the problem of evil is a problem. The degree to which modern problem of evil arguments are effective in proving God's nonexistence. Whether Augustinian type theodicies...