Spring 2001CS 4611 Elements of a Protocol Implementation Outline Service Interface Process Model Common Subroutines Example Protocol.

Slides:



Advertisements
Similar presentations
Sockets: Network IPC Internet Socket UNIX Domain Socket.
Advertisements

Spring 2003CS 4611 Introduction, Continued COS 461.
Sockets. Socket Berkeley Software Distribution Handle-like data structure for communicating A socket is an endpoint  Send and receive  Attach a protocol.
Socket Programming Application Programming Interface.
Sockets CS 3516 – Computer Networks. Outline Socket basics Socket details (TCP and UDP) Socket options Final notes.
Sockets Programming CS144 Review Session 1 April 4, 2008 Ben Nham.
Tutorial 8 Socket Programming
Spring 2003CS 4611 Welcome to COS 461 Vivek Pai. Spring 2003CS 4612 Mechanics First time teaching 461 –But have been doing some level of networking for.
CSE/EE 461 Getting Started with Networking. Basic Concepts  A PROCESS is an executing program somewhere.  Eg, “./a.out”  A MESSAGE contains information.
Sockets COS 518: Advanced Computer Systems Michael Freedman Fall
CS 360 – Spring 2007 Pacific University TCP section 6.5 (Read this section!) 27 Feb 2007.
UNIX Sockets COS 461 Precept 1. Clients and Servers Client program – Running on end host – Requests service – E.g., Web browser Server program – Running.
1 Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Yukun Zhu (Slides are mainly from Monia Ghobadi, and Amin Tootoonchian,
UNIX Sockets COS 461 Precept 1.
Fall 2009COSC 6501 Welcome to COSC650 Towson University Yanggon Kim.
Basic Socket Programming TCP/IP overview. TCP interface Reference: –UNIX Network Programming, by Richard Stevens. –UNIX man page.
UNIX Socket Programming CS 6378
ECE 4110 – Internetwork Programming Client-Server Model.
Sockets and intro to IO multiplexing. Goals We are going to study sockets programming as means to introduce IO multiplexing problem. We will revisit socket.
Fall 2000Datacom 11 Socket Programming Review Examples: Client and Server-Diagnostics UDP versus TCP Echo.
Assignment 3 A Client/Server Application: Chatroom.
Fall 2000Datacom 11 Lecture 4 Socket Interface Programming: Service Interface between Applications and TCP.
CS345 Operating Systems Φροντιστήριο Άσκησης 2. Inter-process communication Exchange data among processes Methods –Signal –Pipe –Sockets.
IT1352-NETWORK PROGRAMMING AND MANAGEMENT
---- IT Acumens. COM IT Acumens. COMIT Acumens. COM.
Remote Shell CS230 Project #4 Assigned : Due date :
Computer Networks : TP1 Prof. Dr. Amine Berqia and Prof. Dr. Fernando Lobo {bamine,
Networking Tutorial Special Interest Group for Software Engineering Luke Rajlich.
CS 158A1 1.4 Implementing Network Software Phenomenal success of the Internet: – Computer # connected doubled every year since 1981, now approaching 200.
Advanced Sockets API-II Vinayak Jagtap
1 Computer Networks An Introduction to Computer Networks University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani Lecture 3: Sockets.
TELE202 Lecture 15 Socket programming 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (2) »Source: chapter 17 ¥This Lecture »Socket programming.
UNIX Sockets COS 461 Precept 1. Socket and Process Communication The interface that the OS provides to its networking subsystem application layer transport.
CSE 331: Introduction to Networks and Security Fall 2000 Instructor: Carl A. Gunter Slide Set 5.
Spring 2002CS 4611 Introduction Outline Statistical Multiplexing Inter-Process Communication Network Architecture Performance Metrics Implementation Issues.
CSS CSS432 Foundation Textbook Ch1 Professor: Munehiro Fukuda.
CSE/EE 461 Getting Started with Networking. 2 Basic Concepts A PROCESS is an executing program somewhere. –Eg, “./a.out” A MESSAGE contains information.
Socket Programming Lab 1 1CS Computer Networks.
CS 6401 Introduction to Computer Networks 09/21/2010 Outline - UNIX sockets - A simple client-server program - Project 1 - LAN bridges and learning.
Requirements Connectivity Resource Sharing Support for Common Services Performance.
CSCI 330 UNIX and Network Programming Unit XV: Transmission Control Protocol.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: HsinYu Ha.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Read() recv() connection establishment Server (connection-oriented protocol) blocks until connection from client Client socket() bind() listen() accept()
1 Introduction Outline Statistical Multiplexing Inter-Process Communication Network Architecture Performance Metrics Implementation Issues.
Socket Programming. Computer Science, FSU2 Interprocess Communication Within a single system – Pipes, FIFOs – Message Queues – Semaphores, Shared Memory.
UNIX Sockets Outline UNIX sockets CS 640.
1 Spring Semester 2008, Dept. of Computer Science, Technion Internet Networking recitation #7 Socket Programming.
Spring 2000CS 4611 Remote Procedure Call Outline Protocol Stack Presentation Formatting.
1 CS716 Advanced Computer Networks By Dr. Amir Qayyum.
1 Socket Interface. 2 Client-Server Architecture The client is the one who speaks first Typical client-server situations  Client and server on the same.
1 Socket Interface. 2 Basic Sockets API Review Socket Library TCPUDP IP EthernetPPP ARP DHCP, Mail, WWW, TELNET, FTP... Network cardCom Layer 4 / Transport.
Sockets API Developing Applications using the Sockets API.
Sockets and Beginning Network Programming
Sockets and Beginning Network Programming
CS 3700 Networks and Distributed Systems
UNIX Sockets COS 461 Precept 1.
Socket Programming in C
Transport layer API: Socket Programming
CS 3700 Networks and Distributed Systems
UNIX Sockets Outline Homework #1 posted by end of day
Socket Programming in C
Socket Programming.
Advanced Computer Networks
University of Houston Remote Procedure Call Datacom II Lecture 6
Elements of a Protocol Implementation
Socket Programming Neil Tang 09/08/2008
Internet Networking recitation #8
Outline Communications in Distributed Systems Socket Programming
Sockets.
Presentation transcript:

Spring 2001CS 4611 Elements of a Protocol Implementation Outline Service Interface Process Model Common Subroutines Example Protocol

Spring 2001CS 4612 Socket API Creating a socket int socket(int domain, int type, int protocol) domain = PF_INET, PF_UNIX type = SOCK_STREAM, SOCK_DGRAM, SOCK_RAW 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 2001CS 4613 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 2001CS 4614 Protocol-to-Protocol Interface Configure multiple layers –static versus extensible Process Model –avoid context switches Buffer Model –avoid data copies

Spring 2001CS 4615 Configuration 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; TCPUDPICMP IP ARP ETH TUPLIP

Spring 2001CS 4616 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 2001CS 4617 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 2001CS 4618 Process Model Process-per-ProtocolProcess-per-Message

Spring 2001CS 4619 Message Library Add header abcdefg bcopy (“xyz”,hdr, 3); msgAddHdr (m,hdr, 3); xyzabcdefg m m abcdefg hdr =msgStripHdr (m, 3); defg+hdr =“abc” m m Strip header

Spring 2001CS Message Library (cont) Fragment message new m m abcdefg defg + abc msgFragment (m,new, 3); m1m2 new abcdefg msgReassemble(new, m1, m2) Reassemble messages abcdefg

Spring 2001CS Event Library Scheduling Timeouts & Book-keeping activity Operations Event evSchedule(EvFunc function, void *argument, int time) EvCancelReturn evCancel(Event event)

Spring 2001CS 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 2001CS Example static Sessn aspOpen(Protl self, Protl hlp, Part *p) { Sessnasp_s; Sessnlls; ActiveIdkey; 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 2001CS /* 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 2001CS 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 2001CS static XkReturn aspDemux(Protl self, Sessn lls, Msg *msg) { AspHdr h; Sessn s; ActiveId activeid; PassiveId passiveid; ProtlState *pstate; Enable *e; void *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 2001CS /* 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 2001CS 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); }