SlideShare a Scribd company logo
15-441: Computer Networking Lecture 3: Application Layer and Socket Programming
Lecture Overview Application layer Client-server Application requirements Background TCP vs. UDP Byte ordering  Socket I/O TCP/UDP server and client I/O multiplexing
Applications and Application-Layer Protocols Application: communicating, distributed processes Running in network hosts in “user space” Exchange messages to implement app e.g., email, file transfer, the Web Application-layer protocols One “piece” of an app Define messages exchanged by apps and actions taken User services provided by lower layer protocols application transport network data link physical application transport network data link physical application transport network data link physical
Client-Server Paradigm Typical network app has two pieces:  client  and  server Client: Initiates contact with server (“speaks first”) Typically requests service from server,  For Web, client is implemented in browser; for e-mail, in mail reader Server: Provides requested service to client e.g., Web server sends requested Web page, mail server delivers e-mail application transport network data link physical application transport network data link physical request reply
Ftp: The File Transfer Protocol Transfer file to/from remote host Client/server model Client:  side that initiates transfer (either to/from remote) Server:  remote host ftp: RFC 959 ftp server: port 21 file transfer remote file system user  at host FTP server FTP user interface FTP client local file system
Ftp: Separate Control, Data Connections Ftp client contacts ftp server at port 21, specifying TCP as transport protocol Two parallel TCP connections opened: Control:  exchange commands, responses between client, server. “ out of band control” Data:  file data to/from server Ftp server maintains “state”: current directory, earlier authentication FTP client FTP server TCP control connection port 21 TCP data connection port 20
Ftp Commands, Responses Sample Commands: sent as ASCII text over control channel USER  username PASS  password LIST   return list of files in current directory RETR filename   retrieves (gets) file STOR filename   stores (puts) file onto remote host Sample Return Codes status code and phrase 331 Username OK, password required 125 data connection already open; transfer starting 425 Can’t open data connection 452 Error writing file
What Transport Service Does an Application Need? Data loss Some apps (e.g., audio) can tolerate some loss Other apps (e.g., file transfer, telnet) require 100% reliable data transfer   Timing Some apps (e.g., Internet telephony, interactive games) require low delay to be “effective” Bandwidth Some apps (e.g., multimedia) require minimum amount of bandwidth to be “effective” Other apps (“elastic apps”) make use of whatever bandwidth they get
Transport Service Requirements of Common Apps no loss no loss no loss loss-tolerant loss-tolerant loss-tolerant no loss elastic elastic elastic audio: 5Kb-1Mb video:10Kb-5Mb same as above  few Kbps elastic no no no yes, 100’s msec yes, few secs yes, 100’s msec yes and no file transfer e-mail web documents real-time audio/ video stored audio/video interactive games financial apps Application Data loss Bandwidth Time Sensitive
Lecture Overview Application layer Client-server Application requirements Background TCP vs. UDP Byte ordering  Socket I/O TCP/UDP server and client I/O multiplexing
Server and Client TCP/UDP IP Ethernet Adapter Server TCP/UDP IP Ethernet Adapter Clients Server and Client exchange messages over the network through a common  Socket API Socket API hardware kernel  space user  space ports
User Datagram Protocol(UDP):  An Analogy Postal Mail Single mailbox to receive messages Unreliable     Not necessarily in-order delivery Each letter is independent Must address each reply Example UDP applications Multimedia, voice over IP UDP Single socket to receive messages No guarantee of delivery Not necessarily in-order delivery Datagram – independent packets Must address each packet Postal Mail Single mailbox to receive letters Unreliable   Not necessarily in-order delivery Letters sent independently  Must address each reply
Transmission Control Protocol (TCP): An Analogy  TCP Reliable – guarantee delivery Byte stream – in-order delivery Connection-oriented – single socket per connection Setup connection followed by data transfer Telephone Call Guaranteed delivery In-order delivery Connection-oriented  Setup connection followed by conversation Example TCP applications Web, Email, Telnet
Network Addressing Analogy 412-268-8000 ext.123 Central Number Applications/Servers Web Port 80 Mail Port 25 Exchange Area Code 412-268-8000 ext.654 IP Address Network No. Host Number Telephone No 15-441 Students Clients Professors at CMU Network Programming Telephone Call Port No. Extension
Concept of Port Numbers Port numbers are used to identify “entities” on a host Port numbers can be Well-known (port 0-1023) Dynamic or private (port 1024-65535) Servers/daemons usually use well-known ports Any client can identify the server/service HTTP = 80, FTP = 21, Telnet = 23, ... /etc/service  defines well-known ports Clients usually use dynamic ports Assigned by the kernel at run time TCP/UDP IP Ethernet Adapter NTP daemon Web  server port 123 port 80
Names and Addresses Each attachment point on Internet is given unique address Based on location within network – like phone numbers Humans prefer to deal with names not addresses DNS provides mapping of name to address Name based on administrative ownership of host
Internet Addressing Data Structure sin_family = AF_INET selects Internet address family #include < netinet/in.h > /* Internet address structure */ struct in_addr  { u_long  s_addr ; /* 32-bit IPv4 address */ }; /* network byte ordered */ /* Socket address, Internet style. */ struct sockaddr_in  { u_char  sin_family ; /* Address Family */ u_short  sin_port ; /* UDP or TCP Port# */ /* network byte ordered */ struct in_addr  sin_addr ;  /* Internet Address */ char  sin_zero[8]; /* unused */ };
Byte Ordering Big Endian Sun Solaris, PowerPC, ... Little Endian i386, alpha, ... Network byte order = Big Endian 128 2 194 95 union { u_int32_t addr;  /* 4 bytes address */ char c[4]; } un; /* 128.2.194.95 */ un.addr = 0x8002c25f; /* c[0] = ? */ c[0] c[1] c[2] c[3] 95 194 2 128
Byte Ordering Functions Converts between  host byte order  and  network byte order ‘ h’ = host byte order ‘ n’ = network byte order ‘ l’ = long (4 bytes), converts IP addresses ‘ s’ = short (2 bytes), converts port numbers #include <netinet/in.h> unsigned long int  htonl (unsigned long int hostlong); unsigned short int  htons (unsigned short int hostshort); unsigned long int  ntohl (unsigned long int netlong); unsigned short int  ntohs (unsigned short int netshort);
Lecture Overview Application layer Client-server Application requirements Background TCP vs. UDP Byte ordering  Socket I/O TCP/UDP server and client I/O multiplexing
A socket is a file descriptor that lets an application read/write data from/to the network socket  returns an integer (socket descriptor) fd < 0 indicates that an error occurred socket descriptors are similar to file descriptors AF_INET: associates a socket with the Internet protocol family SOCK_STREAM: selects the TCP protocol SOCK_DGRAM: selects the UDP protocol What is a Socket? int fd;  /* socket descriptor */ if ((fd =  socket ( AF_INET ,  SOCK_STREAM , 0)) < 0) } perror(“socket”); exit(1); }
For example: web server What does a  web server  need to do so that a  web client  can connect to it? TCP IP Ethernet Adapter Web Server Port 80 TCP Server
Since web traffic uses TCP, the web server must create a socket of type SOCK_STREAM int fd; /* socket descriptor */ if((fd =  socket ( AF_INET ,  SOCK_STREAM , 0)) < 0) { perror(“socket”); exit(1); } socket  returns an integer ( socket descriptor ) fd   < 0 indicates that an error occurred AF_INET  associates a socket with the Internet protocol family SOCK_STREAM  selects the TCP protocol Socket I/O: socket()
A  socket  can be bound to a  port int fd; /* socket descriptor */ struct sockaddr_in  srv; /* used by bind() */ /* create the socket */ srv.sin_family =  AF_INET ; /* use the Internet addr family */ srv.sin_port =  htons ( 80 ); /* bind socket ‘fd’ to port 80*/ /* bind: a client may connect to any of my addresses */ srv.sin_addr.s_addr =  htonl ( INADDR_ANY ); if( bind (fd, (struct sockaddr*) &srv, sizeof(srv)) < 0) { perror(&quot;bind&quot;); exit(1); } Still not quite ready to communicate with a client... Socket I/O: bind()
Socket I/O: listen() listen  indicates that the server will accept a connection int fd;   /* socket descriptor */ struct sockaddr_in srv;   /* used by bind() */ /* 1) create the socket */ /* 2) bind the socket to a port */ if( listen (fd, 5) < 0) { perror(“listen”); exit(1); } Still not quite ready to communicate with a client...
Socket I/O: accept() accept  blocks waiting for a connection int fd; /* socket descriptor */ struct sockaddr_in srv;   /* used by bind() */ struct sockaddr_in cli;   /* used by accept() */ int newfd;   /* returned by accept() */ int cli_len = sizeof(cli); /* used by accept() */ /* 1) create the socket */ /* 2) bind the socket to a port */ /* 3) listen on the socket */ newfd =  accept (fd, (struct sockaddr*) &cli, &cli_len); if(newfd < 0) { perror(&quot;accept&quot;); exit(1); } accept  returns a new socket ( newfd ) with the same properties as the original socket ( fd ) newfd  < 0 indicates that an error occurred
Socket I/O: accept() continued... struct sockaddr_in cli; /* used by accept() */ int newfd; /* returned by accept() */ int cli_len = sizeof(cli); /* used by accept() */ newfd =  accept (fd, (struct sockaddr*) &cli, &cli_len); if(newfd < 0) { perror(&quot;accept&quot;); exit(1); } How does the server know which client it is? cli.sin_addr.s_addr   contains the client’s  IP address cli.sin_port  contains the client’s  port number Now the server can exchange data with the client by using  read  and  write  on the descriptor  newfd . Why does  accept  need to return a new descriptor?
Socket I/O: read() read  can be used with a socket read   blocks  waiting for data from the client but does not guarantee that sizeof(buf) is read int fd; /* socket descriptor */ char buf[512]; /* used by read() */ int nbytes;   /* used by read() */ /* 1) create the socket */ /* 2) bind the socket to a port */ /* 3) listen on the socket */ /* 4) accept the incoming connection */ if((nbytes =  read (newfd, buf, sizeof(buf))) < 0) { perror(“read”); exit(1); }
TCP Client For example: web client How does a  web client  connect to a  web server ?  TCP IP Ethernet Adapter 2 Web Clients
Dealing with IP Addresses IP Addresses are commonly written as strings (“128.2.35.50”), but programs deal with IP addresses as integers. struct sockaddr_in srv; srv.sin_addr.s_addr =  inet_addr(“128.2.35.50”); if(srv.sin_addr.s_addr == (in_addr_t) -1) { fprintf(stderr, &quot;inet_addr failed!\n&quot;); exit(1); } Converting a numerical address to a string: struct sockaddr_in srv; char *t =  inet_ntoa(srv.sin_addr); if(t == 0) { fprintf(stderr, “inet_ntoa failed!\n”); exit(1); } Converting strings to numerical address:
Translating Names to Addresses Gethostbyname provides interface to DNS Additional useful calls Gethostbyaddr – returns  hostent  given sockaddr_in Getservbyname Used to get service description (typically port number) Returns  servent  based on name #include <netdb.h> struct hostent *hp; /*ptr to host info for remote*/  struct sockaddr_in peeraddr; char *name = “www.cs.cmu.edu”; peeraddr.sin_family = AF_INET;  hp = gethostbyname(name)  peeraddr.sin_addr.s_addr = ((struct in_addr*)(hp->h_addr))->s_addr;
Socket I/O: connect() connect  allows a client to connect to a server... int fd; /* socket descriptor */ struct sockaddr_in srv; /* used by connect() */ /* create the socket */ /* connect: use the Internet address family */ srv.sin_family =  AF_INET ; /* connect: socket ‘fd’ to port 80 */ srv.sin_port = htons( 80 ); /* connect: connect to IP Address “128.2.35.50” */ srv.sin_addr.s_addr =  inet_addr (“ 128.2.35.50 ”); if( connect (fd, (struct sockaddr*) &srv, sizeof(srv)) < 0) { perror(”connect&quot;); exit(1); }
Socket I/O: write() write  can be used with a socket int fd; /* socket descriptor */ struct sockaddr_in srv; /* used by connect() */ char buf[512]; /* used by write() */ int nbytes; /* used by write() */ /* 1) create the socket */ /* 2) connect() to the server */ /* Example: A client could “write” a request to a server */ if((nbytes =  write (fd, buf, sizeof(buf))) < 0) { perror(“write”); exit(1); }
Review: TCP Client-Server Interaction socket() bind() listen() accept() write() read() read() TCP Server close() socket() TCP Client connect() write() read() close() connection establishment data request data reply end-of-file notification from UNIX Network Programming Volume 1, figure 4.1
UDP Server Example For example: NTP daemon What does a  UDP server  need to do so that a  UDP client  can connect to it? UDP IP Ethernet Adapter NTP daemon Port 123
Socket I/O: socket() The UDP server must create a  datagram  socket… int fd; /* socket descriptor */ if((fd =  socket (AF_INET,  SOCK_DGRAM , 0)) < 0) { perror(“socket”); exit(1); } socket  returns an integer ( socket descriptor ) fd   < 0 indicates that an error occurred AF_INET: associates a socket with the Internet protocol family SOCK_DGRAM:  selects the UDP protocol
Socket I/O: bind() A  socket  can be bound to a  port int fd; /* socket descriptor */ struct sockaddr_in srv; /* used by bind() */ /* create the socket */ /* bind: use the Internet address family */ srv.sin_family =  AF_INET ; /* bind: socket ‘fd’ to port 80*/ srv.sin_port = htons( 80 ); /* bind: a client may connect to any of my addresses */ srv.sin_addr.s_addr = htonl( INADDR_ANY ); if( bind (fd, (struct sockaddr*) &srv, sizeof(srv)) < 0) { perror(&quot;bind&quot;); exit(1); } Now the UDP server  is ready to accept packets…
Socket I/O: recvfrom() read  does not provide the client’s address to the UDP server int fd; /* socket descriptor */ struct sockaddr_in srv; /* used by bind() */ struct sockaddr_in cli; /* used by recvfrom() */ char buf[512]; /* used by recvfrom() */ int cli_len = sizeof(cli);  /* used by recvfrom() */ int nbytes; /* used by recvfrom() */ /* 1) create the socket */ /* 2) bind to the socket */ nbytes =  recvfrom (fd, buf, sizeof(buf), 0 /* flags */,   (struct sockaddr*) &cli, &cli_len); if(nbytes < 0) { perror(“recvfrom”); exit(1); }
Socket I/O: recvfrom() continued... nbytes =  recvfrom (fd, buf, sizeof(buf), 0 /* flags */,   (struct sockaddr*) cli, &cli_len); The actions performed by  recvfrom returns the number of bytes read ( nbytes ) copies  nbytes  of data into  buf returns the address of the client ( cli ) returns the length of  cli  ( cli_len ) don’t worry about flags
UDP Client Example How does a  UDP client  communicate with a  UDP server ? TCP IP Ethernet Adapter 2 UDP Clients ports
Socket I/O: sendto() write  is not allowed Notice that the UDP client does not  bind  a port number a port number is  dynamically assigned  when the first  sendto  is called int fd; /* socket descriptor */ struct sockaddr_in srv; /* used by sendto() */ /* 1) create the socket */ /* sendto: send data to IP Address “128.2.35.50” port 80 */ srv.sin_family =  AF_INET ; srv.sin_port = htons( 80 );  srv.sin_addr.s_addr = inet_addr(“ 128.2.35.50 ”); nbytes =  sendto (fd, buf, sizeof(buf), 0 /* flags */,   (struct sockaddr*) &srv, sizeof(srv)); if(nbytes < 0) { perror(“sendto”); exit(1); }
Review: UDP Client-Server Interaction socket() bind() recvfrom() sendto() UDP Server socket() UDP Client sendto() recvfrom() close() blocks until datagram received from a client data request data reply from UNIX Network Programming Volume 1, figure 8.1
The UDP Server How can the  UDP server  service multiple ports simultaneously? UDP IP Ethernet Adapter UDP Server Port 2000 Port 3000
UDP Server: Servicing Two Ports  What problems does this code have? int s1; /* socket descriptor 1 */ int s2; /* socket descriptor 2 */ /* 1) create socket s1 */ /* 2) create socket s2 */ /* 3) bind s1 to port 2000 */ /* 4) bind s2 to port 3000 */ while(1) { recvfrom (s1, buf, sizeof(buf), ...); /* process buf */ recvfrom (s2, buf, sizeof(buf), ...); /* process buf */ }
Socket I/O: select() maxfds : number of descriptors to be tested descriptors (0, 1, ... maxfds-1) will be tested readfds : a set of  fds  we want to check if data is available returns a set of  fds  ready to read if input argument is  NULL , not interested in that condition writefds : returns a set of  fds  ready to write exceptfds : returns a set of  fds  with exception conditions int select(int  maxfds , fd_set * readfds , fd_set * writefds ,    fd_set * exceptfds , struct timeval *timeout); FD_CLR(int fd, fd_set *fds);  /* clear the bit for  fd  in  fds  */ FD_ISSET(int fd, fd_set *fds); /* is the bit for  fd  in  fds ? */ FD_SET(int fd, fd_set *fds);  /* turn on the bit for  fd  in fds */ FD_ZERO(fd_set *fds);  /* clear all bits in  fds  */
Socket I/O: select() timeout if NULL, wait forever and return only when one of the descriptors is ready for I/O otherwise, wait up to a fixed amount of time specified by  timeout if we don’t want to wait at all, create a timeout structure with timer value equal to 0 Refer to the man page for more information int select(int maxfds, fd_set *readfds, fd_set *writefds,    fd_set *exceptfds, struct timeval * timeout ); struct timeval { long tv_sec; /* seconds / long tv_usec; /* microseconds */ }
Socket I/O: select() int s1, s2;  /* socket descriptors */ fd_set readfds; /* used by select() */ /* create and bind s1 and s2 */ while(1) { FD_ZERO (&readfds); /* initialize the fd set */ FD_SET (s1, &readfds); /* add s1 to the fd set */ FD_SET(s2, &readfds); /* add s2 to the fd set */ if( select (s2+1, &readfds, 0, 0, 0) < 0) { perror(“select”); exit(1); } if( FD_ISSET (s1, &readfds)) { recvfrom (s1, buf, sizeof(buf), ...); /* process buf */ } /* do the same for s2 */ } select  allows synchronous I/O multiplexing
TCP IP Ethernet Adapter Web Server Port 80 How can a a  web server  manage multiple connections simultaneously? Port 8001 More Details About a Web Server
Socket I/O: select() Now the web server can support multiple connections... int fd, next=0; /* original socket */ int newfd[10];  /* new socket descriptors */ while(1) { fd_set readfds; FD_ZERO (&readfds);  FD_SET (fd, &readfds); /* Now use FD_SET to initialize other newfd’s   that have already been returned by accept() */ select ( maxfd +1, &readfds, 0, 0, 0); if( FD_ISSET (fd, &readfds)) { newfd[ next++ ] =  accept (fd, ...);  } /* do the following for each descriptor newfd[ n ]   */ if( FD_ISSET (newfd[ n ], &readfds)) { read (newfd[ n ], buf, sizeof(buf)); /* process data */ } }
A Few Programming Notes: Representing Packets 0  1  2  3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |  Type  | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |  Length  |  Checksum  | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |  Address  |  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Type: 4-byte integer Length: 2-byte integer Checksum: 2-byte integer Address: 4-byte IP address
A Few Programming Notes: Building a Packet in a Buffer struct packet { u_int32_t type; u_int16_t length; u_int16_t checksum; u_int32_t address; }; /* ================================================== */ char buf[1024]; struct packet *pkt; pkt = (struct packet*) buf; pkt->type =  htonl (1); pkt->length =  htons (2); pkt->checksum =  htons (3); pkt->address =  htonl (4);
Socket Programming References Man page usage: man <function name> Textbook Sections 2.6, 2.7 demo programs written in Java Unix Network Programming : Networking APIs: Sockets and XTI (Volume 1) Section 2, 3, 4, 6, 8 ultimate socket programming bible!

More Related Content

What's hot (20)

Spanning tree protocol (stp)
Spanning tree protocol (stp)Spanning tree protocol (stp)
Spanning tree protocol (stp)
RaghulR21
 
IPV6 Addressing
IPV6 Addressing IPV6 Addressing
IPV6 Addressing
Heba_a
 
Traceroute- A Networking Tool
Traceroute- A Networking ToolTraceroute- A Networking Tool
Traceroute- A Networking Tool
Amit Kumar
 
Telnet & SSH
Telnet & SSHTelnet & SSH
Telnet & SSH
NetProtocol Xpert
 
Ports & sockets
Ports  & sockets Ports  & sockets
Ports & sockets
myrajendra
 
CCNA SUMMER TRAINNING PPT
CCNA SUMMER TRAINNING PPTCCNA SUMMER TRAINNING PPT
CCNA SUMMER TRAINNING PPT
Nishant Goel
 
Subnetting Presentation
Subnetting PresentationSubnetting Presentation
Subnetting Presentation
Touhidul Fahim
 
FreeRTOS
FreeRTOSFreeRTOS
FreeRTOS
Ankita Tiwari
 
Wide Area Networks - Jamie Reece Moore
Wide Area Networks - Jamie Reece MooreWide Area Networks - Jamie Reece Moore
Wide Area Networks - Jamie Reece Moore
Jamie Moore
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)
Andriy Berestovskyy
 
Ipv4 and Ipv6
Ipv4 and Ipv6Ipv4 and Ipv6
Ipv4 and Ipv6
rahul kundu
 
Application layer protocols
Application layer protocolsApplication layer protocols
Application layer protocols
FabMinds
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
mukul bhardwaj
 
PPP (Point to Point Protocol)
PPP (Point to Point Protocol)PPP (Point to Point Protocol)
PPP (Point to Point Protocol)
Ali Jafar
 
Berkeley Packet Filters
Berkeley Packet FiltersBerkeley Packet Filters
Berkeley Packet Filters
Kernel TLV
 
Internet control message protocol
Internet control message protocolInternet control message protocol
Internet control message protocol
asimnawaz54
 
Introduction to TCP/IP
Introduction to TCP/IPIntroduction to TCP/IP
Introduction to TCP/IP
Michael Lamont
 
The constrained application protocol (CoAP)
The constrained application protocol (CoAP)The constrained application protocol (CoAP)
The constrained application protocol (CoAP)
Hamdamboy (함담보이)
 
Rip ospf and bgp
Rip ospf and bgpRip ospf and bgp
Rip ospf and bgp
Abhishek Kesharwani
 
Link state routing protocol
Link state routing protocolLink state routing protocol
Link state routing protocol
Aung Thu Rha Hein
 
Spanning tree protocol (stp)
Spanning tree protocol (stp)Spanning tree protocol (stp)
Spanning tree protocol (stp)
RaghulR21
 
IPV6 Addressing
IPV6 Addressing IPV6 Addressing
IPV6 Addressing
Heba_a
 
Traceroute- A Networking Tool
Traceroute- A Networking ToolTraceroute- A Networking Tool
Traceroute- A Networking Tool
Amit Kumar
 
Ports & sockets
Ports  & sockets Ports  & sockets
Ports & sockets
myrajendra
 
CCNA SUMMER TRAINNING PPT
CCNA SUMMER TRAINNING PPTCCNA SUMMER TRAINNING PPT
CCNA SUMMER TRAINNING PPT
Nishant Goel
 
Subnetting Presentation
Subnetting PresentationSubnetting Presentation
Subnetting Presentation
Touhidul Fahim
 
Wide Area Networks - Jamie Reece Moore
Wide Area Networks - Jamie Reece MooreWide Area Networks - Jamie Reece Moore
Wide Area Networks - Jamie Reece Moore
Jamie Moore
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)
Andriy Berestovskyy
 
Application layer protocols
Application layer protocolsApplication layer protocols
Application layer protocols
FabMinds
 
PPP (Point to Point Protocol)
PPP (Point to Point Protocol)PPP (Point to Point Protocol)
PPP (Point to Point Protocol)
Ali Jafar
 
Berkeley Packet Filters
Berkeley Packet FiltersBerkeley Packet Filters
Berkeley Packet Filters
Kernel TLV
 
Internet control message protocol
Internet control message protocolInternet control message protocol
Internet control message protocol
asimnawaz54
 
Introduction to TCP/IP
Introduction to TCP/IPIntroduction to TCP/IP
Introduction to TCP/IP
Michael Lamont
 
The constrained application protocol (CoAP)
The constrained application protocol (CoAP)The constrained application protocol (CoAP)
The constrained application protocol (CoAP)
Hamdamboy (함담보이)
 

Viewers also liked (14)

Application Layer
Application Layer Application Layer
Application Layer
Dr Shashikant Athawale
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
elliando dias
 
QSpiders - Dod Model
QSpiders - Dod ModelQSpiders - Dod Model
QSpiders - Dod Model
Qspiders - Software Testing Training Institute
 
Chapter2 Application
Chapter2 ApplicationChapter2 Application
Chapter2 Application
Diego Corrales
 
socket programming
socket programming socket programming
socket programming
prashantzagade
 
Application layer chapter-9
Application layer chapter-9Application layer chapter-9
Application layer chapter-9
Student
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
Micro Programmed Control Unit
Micro Programmed Control UnitMicro Programmed Control Unit
Micro Programmed Control Unit
Kamal Acharya
 
Lecture application layer
Lecture application layerLecture application layer
Lecture application layer
Hasam Panezai
 
File transfer protocol (ftp)
File transfer protocol (ftp)File transfer protocol (ftp)
File transfer protocol (ftp)
Cort1026
 
Physical Layer of ISO-OSI model and Devices
Physical Layer of ISO-OSI model and DevicesPhysical Layer of ISO-OSI model and Devices
Physical Layer of ISO-OSI model and Devices
Shahid Khan
 
File Transfer Protocol
File Transfer ProtocolFile Transfer Protocol
File Transfer Protocol
guest029bcd
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control
Anuj Modi
 
The Data Link Layer
The Data Link LayerThe Data Link Layer
The Data Link Layer
robbbminson
 
Application layer chapter-9
Application layer chapter-9Application layer chapter-9
Application layer chapter-9
Student
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
Micro Programmed Control Unit
Micro Programmed Control UnitMicro Programmed Control Unit
Micro Programmed Control Unit
Kamal Acharya
 
Lecture application layer
Lecture application layerLecture application layer
Lecture application layer
Hasam Panezai
 
File transfer protocol (ftp)
File transfer protocol (ftp)File transfer protocol (ftp)
File transfer protocol (ftp)
Cort1026
 
Physical Layer of ISO-OSI model and Devices
Physical Layer of ISO-OSI model and DevicesPhysical Layer of ISO-OSI model and Devices
Physical Layer of ISO-OSI model and Devices
Shahid Khan
 
File Transfer Protocol
File Transfer ProtocolFile Transfer Protocol
File Transfer Protocol
guest029bcd
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control
Anuj Modi
 
The Data Link Layer
The Data Link LayerThe Data Link Layer
The Data Link Layer
robbbminson
 
Ad

Similar to Application Layer and Socket Programming (20)

lecture03 on socket programming000000.ppt
lecture03 on socket programming000000.pptlecture03 on socket programming000000.ppt
lecture03 on socket programming000000.ppt
SoumabhaRoy
 
lecture03for socket programming college.ppt
lecture03for socket programming college.pptlecture03for socket programming college.ppt
lecture03for socket programming college.ppt
SoumabhaRoy
 
socket programming
 socket programming  socket programming
socket programming
prashantzagade
 
Sockets
Sockets Sockets
Sockets
Gopaiah Sanaka
 
Basic socket programming
Basic socket programmingBasic socket programming
Basic socket programming
Kristian Arjianto
 
Sockets in unix
Sockets in unixSockets in unix
Sockets in unix
swtjerin4u
 
network programming lab manuaal in this file
network programming lab manuaal in this filenetwork programming lab manuaal in this file
network programming lab manuaal in this file
shivani158351
 
L5-Sockets.pptx
L5-Sockets.pptxL5-Sockets.pptx
L5-Sockets.pptx
ycelgemici1
 
Introduction to sockets tcp ip protocol.ppt
Introduction to sockets tcp ip protocol.pptIntroduction to sockets tcp ip protocol.ppt
Introduction to sockets tcp ip protocol.ppt
MajedAboubennah
 
Network Programming Assignment Help
Network Programming Assignment HelpNetwork Programming Assignment Help
Network Programming Assignment Help
HelpWithAssignment.com
 
sockets SMTP Bmsce ppt information science and engineering
sockets SMTP Bmsce ppt information science and engineeringsockets SMTP Bmsce ppt information science and engineering
sockets SMTP Bmsce ppt information science and engineering
UtkarshaMahajan6
 
sockets_intro.ppt
sockets_intro.pptsockets_intro.ppt
sockets_intro.ppt
AnilGupta681764
 
INTRODUCTION TO SOCKETS IN COMPUTER NETWORKS DEPT OF CSE.ppt
INTRODUCTION TO SOCKETS IN COMPUTER NETWORKS DEPT OF CSE.pptINTRODUCTION TO SOCKETS IN COMPUTER NETWORKS DEPT OF CSE.ppt
INTRODUCTION TO SOCKETS IN COMPUTER NETWORKS DEPT OF CSE.ppt
senthilnathans25
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using C
Ajit Nayak
 
03 sockets
03 sockets03 sockets
03 sockets
Pavan Illa
 
Sockets intro
Sockets introSockets intro
Sockets intro
AviNash ChaVhan
 
socketProgramming-TCP-and UDP-overview.pdf
socketProgramming-TCP-and UDP-overview.pdfsocketProgramming-TCP-and UDP-overview.pdf
socketProgramming-TCP-and UDP-overview.pdf
Shilpachaudhari10
 
Basics of sockets
Basics of socketsBasics of sockets
Basics of sockets
AviNash ChaVhan
 
Lecture set 7
Lecture set 7Lecture set 7
Lecture set 7
Gopi Saiteja
 
Computer Network in Network software.ppt
Computer Network in Network software.pptComputer Network in Network software.ppt
Computer Network in Network software.ppt
mcjaya2024
 
lecture03 on socket programming000000.ppt
lecture03 on socket programming000000.pptlecture03 on socket programming000000.ppt
lecture03 on socket programming000000.ppt
SoumabhaRoy
 
lecture03for socket programming college.ppt
lecture03for socket programming college.pptlecture03for socket programming college.ppt
lecture03for socket programming college.ppt
SoumabhaRoy
 
Sockets in unix
Sockets in unixSockets in unix
Sockets in unix
swtjerin4u
 
network programming lab manuaal in this file
network programming lab manuaal in this filenetwork programming lab manuaal in this file
network programming lab manuaal in this file
shivani158351
 
Introduction to sockets tcp ip protocol.ppt
Introduction to sockets tcp ip protocol.pptIntroduction to sockets tcp ip protocol.ppt
Introduction to sockets tcp ip protocol.ppt
MajedAboubennah
 
sockets SMTP Bmsce ppt information science and engineering
sockets SMTP Bmsce ppt information science and engineeringsockets SMTP Bmsce ppt information science and engineering
sockets SMTP Bmsce ppt information science and engineering
UtkarshaMahajan6
 
INTRODUCTION TO SOCKETS IN COMPUTER NETWORKS DEPT OF CSE.ppt
INTRODUCTION TO SOCKETS IN COMPUTER NETWORKS DEPT OF CSE.pptINTRODUCTION TO SOCKETS IN COMPUTER NETWORKS DEPT OF CSE.ppt
INTRODUCTION TO SOCKETS IN COMPUTER NETWORKS DEPT OF CSE.ppt
senthilnathans25
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using C
Ajit Nayak
 
socketProgramming-TCP-and UDP-overview.pdf
socketProgramming-TCP-and UDP-overview.pdfsocketProgramming-TCP-and UDP-overview.pdf
socketProgramming-TCP-and UDP-overview.pdf
Shilpachaudhari10
 
Computer Network in Network software.ppt
Computer Network in Network software.pptComputer Network in Network software.ppt
Computer Network in Network software.ppt
mcjaya2024
 
Ad

More from elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
elliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
elliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
elliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
elliando dias
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
elliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
elliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
elliando dias
 
Ragel talk
Ragel talkRagel talk
Ragel talk
elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
elliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
elliando dias
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
elliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
elliando dias
 
Rango
RangoRango
Rango
elliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
elliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
elliando dias
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
elliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
elliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
elliando dias
 
Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
elliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
elliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
elliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
elliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
elliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
elliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
elliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
elliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
elliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
elliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
elliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
elliando dias
 

Recently uploaded (20)

Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Data Validation and System Interoperability
Data Validation and System InteroperabilityData Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptxFIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdfWar_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API CatalogMuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptxFIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Data Validation and System Interoperability
Data Validation and System InteroperabilityData Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptxFIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdfWar_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API CatalogMuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptxFIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 

Application Layer and Socket Programming

  • 1. 15-441: Computer Networking Lecture 3: Application Layer and Socket Programming
  • 2. Lecture Overview Application layer Client-server Application requirements Background TCP vs. UDP Byte ordering Socket I/O TCP/UDP server and client I/O multiplexing
  • 3. Applications and Application-Layer Protocols Application: communicating, distributed processes Running in network hosts in “user space” Exchange messages to implement app e.g., email, file transfer, the Web Application-layer protocols One “piece” of an app Define messages exchanged by apps and actions taken User services provided by lower layer protocols application transport network data link physical application transport network data link physical application transport network data link physical
  • 4. Client-Server Paradigm Typical network app has two pieces: client and server Client: Initiates contact with server (“speaks first”) Typically requests service from server, For Web, client is implemented in browser; for e-mail, in mail reader Server: Provides requested service to client e.g., Web server sends requested Web page, mail server delivers e-mail application transport network data link physical application transport network data link physical request reply
  • 5. Ftp: The File Transfer Protocol Transfer file to/from remote host Client/server model Client: side that initiates transfer (either to/from remote) Server: remote host ftp: RFC 959 ftp server: port 21 file transfer remote file system user at host FTP server FTP user interface FTP client local file system
  • 6. Ftp: Separate Control, Data Connections Ftp client contacts ftp server at port 21, specifying TCP as transport protocol Two parallel TCP connections opened: Control: exchange commands, responses between client, server. “ out of band control” Data: file data to/from server Ftp server maintains “state”: current directory, earlier authentication FTP client FTP server TCP control connection port 21 TCP data connection port 20
  • 7. Ftp Commands, Responses Sample Commands: sent as ASCII text over control channel USER username PASS password LIST return list of files in current directory RETR filename retrieves (gets) file STOR filename stores (puts) file onto remote host Sample Return Codes status code and phrase 331 Username OK, password required 125 data connection already open; transfer starting 425 Can’t open data connection 452 Error writing file
  • 8. What Transport Service Does an Application Need? Data loss Some apps (e.g., audio) can tolerate some loss Other apps (e.g., file transfer, telnet) require 100% reliable data transfer Timing Some apps (e.g., Internet telephony, interactive games) require low delay to be “effective” Bandwidth Some apps (e.g., multimedia) require minimum amount of bandwidth to be “effective” Other apps (“elastic apps”) make use of whatever bandwidth they get
  • 9. Transport Service Requirements of Common Apps no loss no loss no loss loss-tolerant loss-tolerant loss-tolerant no loss elastic elastic elastic audio: 5Kb-1Mb video:10Kb-5Mb same as above few Kbps elastic no no no yes, 100’s msec yes, few secs yes, 100’s msec yes and no file transfer e-mail web documents real-time audio/ video stored audio/video interactive games financial apps Application Data loss Bandwidth Time Sensitive
  • 10. Lecture Overview Application layer Client-server Application requirements Background TCP vs. UDP Byte ordering Socket I/O TCP/UDP server and client I/O multiplexing
  • 11. Server and Client TCP/UDP IP Ethernet Adapter Server TCP/UDP IP Ethernet Adapter Clients Server and Client exchange messages over the network through a common Socket API Socket API hardware kernel space user space ports
  • 12. User Datagram Protocol(UDP): An Analogy Postal Mail Single mailbox to receive messages Unreliable  Not necessarily in-order delivery Each letter is independent Must address each reply Example UDP applications Multimedia, voice over IP UDP Single socket to receive messages No guarantee of delivery Not necessarily in-order delivery Datagram – independent packets Must address each packet Postal Mail Single mailbox to receive letters Unreliable  Not necessarily in-order delivery Letters sent independently Must address each reply
  • 13. Transmission Control Protocol (TCP): An Analogy TCP Reliable – guarantee delivery Byte stream – in-order delivery Connection-oriented – single socket per connection Setup connection followed by data transfer Telephone Call Guaranteed delivery In-order delivery Connection-oriented Setup connection followed by conversation Example TCP applications Web, Email, Telnet
  • 14. Network Addressing Analogy 412-268-8000 ext.123 Central Number Applications/Servers Web Port 80 Mail Port 25 Exchange Area Code 412-268-8000 ext.654 IP Address Network No. Host Number Telephone No 15-441 Students Clients Professors at CMU Network Programming Telephone Call Port No. Extension
  • 15. Concept of Port Numbers Port numbers are used to identify “entities” on a host Port numbers can be Well-known (port 0-1023) Dynamic or private (port 1024-65535) Servers/daemons usually use well-known ports Any client can identify the server/service HTTP = 80, FTP = 21, Telnet = 23, ... /etc/service defines well-known ports Clients usually use dynamic ports Assigned by the kernel at run time TCP/UDP IP Ethernet Adapter NTP daemon Web server port 123 port 80
  • 16. Names and Addresses Each attachment point on Internet is given unique address Based on location within network – like phone numbers Humans prefer to deal with names not addresses DNS provides mapping of name to address Name based on administrative ownership of host
  • 17. Internet Addressing Data Structure sin_family = AF_INET selects Internet address family #include < netinet/in.h > /* Internet address structure */ struct in_addr { u_long s_addr ; /* 32-bit IPv4 address */ }; /* network byte ordered */ /* Socket address, Internet style. */ struct sockaddr_in { u_char sin_family ; /* Address Family */ u_short sin_port ; /* UDP or TCP Port# */ /* network byte ordered */ struct in_addr sin_addr ; /* Internet Address */ char sin_zero[8]; /* unused */ };
  • 18. Byte Ordering Big Endian Sun Solaris, PowerPC, ... Little Endian i386, alpha, ... Network byte order = Big Endian 128 2 194 95 union { u_int32_t addr; /* 4 bytes address */ char c[4]; } un; /* 128.2.194.95 */ un.addr = 0x8002c25f; /* c[0] = ? */ c[0] c[1] c[2] c[3] 95 194 2 128
  • 19. Byte Ordering Functions Converts between host byte order and network byte order ‘ h’ = host byte order ‘ n’ = network byte order ‘ l’ = long (4 bytes), converts IP addresses ‘ s’ = short (2 bytes), converts port numbers #include <netinet/in.h> unsigned long int htonl (unsigned long int hostlong); unsigned short int htons (unsigned short int hostshort); unsigned long int ntohl (unsigned long int netlong); unsigned short int ntohs (unsigned short int netshort);
  • 20. Lecture Overview Application layer Client-server Application requirements Background TCP vs. UDP Byte ordering Socket I/O TCP/UDP server and client I/O multiplexing
  • 21. A socket is a file descriptor that lets an application read/write data from/to the network socket returns an integer (socket descriptor) fd < 0 indicates that an error occurred socket descriptors are similar to file descriptors AF_INET: associates a socket with the Internet protocol family SOCK_STREAM: selects the TCP protocol SOCK_DGRAM: selects the UDP protocol What is a Socket? int fd; /* socket descriptor */ if ((fd = socket ( AF_INET , SOCK_STREAM , 0)) < 0) } perror(“socket”); exit(1); }
  • 22. For example: web server What does a web server need to do so that a web client can connect to it? TCP IP Ethernet Adapter Web Server Port 80 TCP Server
  • 23. Since web traffic uses TCP, the web server must create a socket of type SOCK_STREAM int fd; /* socket descriptor */ if((fd = socket ( AF_INET , SOCK_STREAM , 0)) < 0) { perror(“socket”); exit(1); } socket returns an integer ( socket descriptor ) fd < 0 indicates that an error occurred AF_INET associates a socket with the Internet protocol family SOCK_STREAM selects the TCP protocol Socket I/O: socket()
  • 24. A socket can be bound to a port int fd; /* socket descriptor */ struct sockaddr_in srv; /* used by bind() */ /* create the socket */ srv.sin_family = AF_INET ; /* use the Internet addr family */ srv.sin_port = htons ( 80 ); /* bind socket ‘fd’ to port 80*/ /* bind: a client may connect to any of my addresses */ srv.sin_addr.s_addr = htonl ( INADDR_ANY ); if( bind (fd, (struct sockaddr*) &srv, sizeof(srv)) < 0) { perror(&quot;bind&quot;); exit(1); } Still not quite ready to communicate with a client... Socket I/O: bind()
  • 25. Socket I/O: listen() listen indicates that the server will accept a connection int fd; /* socket descriptor */ struct sockaddr_in srv; /* used by bind() */ /* 1) create the socket */ /* 2) bind the socket to a port */ if( listen (fd, 5) < 0) { perror(“listen”); exit(1); } Still not quite ready to communicate with a client...
  • 26. Socket I/O: accept() accept blocks waiting for a connection int fd; /* socket descriptor */ struct sockaddr_in srv; /* used by bind() */ struct sockaddr_in cli; /* used by accept() */ int newfd; /* returned by accept() */ int cli_len = sizeof(cli); /* used by accept() */ /* 1) create the socket */ /* 2) bind the socket to a port */ /* 3) listen on the socket */ newfd = accept (fd, (struct sockaddr*) &cli, &cli_len); if(newfd < 0) { perror(&quot;accept&quot;); exit(1); } accept returns a new socket ( newfd ) with the same properties as the original socket ( fd ) newfd < 0 indicates that an error occurred
  • 27. Socket I/O: accept() continued... struct sockaddr_in cli; /* used by accept() */ int newfd; /* returned by accept() */ int cli_len = sizeof(cli); /* used by accept() */ newfd = accept (fd, (struct sockaddr*) &cli, &cli_len); if(newfd < 0) { perror(&quot;accept&quot;); exit(1); } How does the server know which client it is? cli.sin_addr.s_addr contains the client’s IP address cli.sin_port contains the client’s port number Now the server can exchange data with the client by using read and write on the descriptor newfd . Why does accept need to return a new descriptor?
  • 28. Socket I/O: read() read can be used with a socket read blocks waiting for data from the client but does not guarantee that sizeof(buf) is read int fd; /* socket descriptor */ char buf[512]; /* used by read() */ int nbytes; /* used by read() */ /* 1) create the socket */ /* 2) bind the socket to a port */ /* 3) listen on the socket */ /* 4) accept the incoming connection */ if((nbytes = read (newfd, buf, sizeof(buf))) < 0) { perror(“read”); exit(1); }
  • 29. TCP Client For example: web client How does a web client connect to a web server ? TCP IP Ethernet Adapter 2 Web Clients
  • 30. Dealing with IP Addresses IP Addresses are commonly written as strings (“128.2.35.50”), but programs deal with IP addresses as integers. struct sockaddr_in srv; srv.sin_addr.s_addr = inet_addr(“128.2.35.50”); if(srv.sin_addr.s_addr == (in_addr_t) -1) { fprintf(stderr, &quot;inet_addr failed!\n&quot;); exit(1); } Converting a numerical address to a string: struct sockaddr_in srv; char *t = inet_ntoa(srv.sin_addr); if(t == 0) { fprintf(stderr, “inet_ntoa failed!\n”); exit(1); } Converting strings to numerical address:
  • 31. Translating Names to Addresses Gethostbyname provides interface to DNS Additional useful calls Gethostbyaddr – returns hostent given sockaddr_in Getservbyname Used to get service description (typically port number) Returns servent based on name #include <netdb.h> struct hostent *hp; /*ptr to host info for remote*/ struct sockaddr_in peeraddr; char *name = “www.cs.cmu.edu”; peeraddr.sin_family = AF_INET; hp = gethostbyname(name) peeraddr.sin_addr.s_addr = ((struct in_addr*)(hp->h_addr))->s_addr;
  • 32. Socket I/O: connect() connect allows a client to connect to a server... int fd; /* socket descriptor */ struct sockaddr_in srv; /* used by connect() */ /* create the socket */ /* connect: use the Internet address family */ srv.sin_family = AF_INET ; /* connect: socket ‘fd’ to port 80 */ srv.sin_port = htons( 80 ); /* connect: connect to IP Address “128.2.35.50” */ srv.sin_addr.s_addr = inet_addr (“ 128.2.35.50 ”); if( connect (fd, (struct sockaddr*) &srv, sizeof(srv)) < 0) { perror(”connect&quot;); exit(1); }
  • 33. Socket I/O: write() write can be used with a socket int fd; /* socket descriptor */ struct sockaddr_in srv; /* used by connect() */ char buf[512]; /* used by write() */ int nbytes; /* used by write() */ /* 1) create the socket */ /* 2) connect() to the server */ /* Example: A client could “write” a request to a server */ if((nbytes = write (fd, buf, sizeof(buf))) < 0) { perror(“write”); exit(1); }
  • 34. Review: TCP Client-Server Interaction socket() bind() listen() accept() write() read() read() TCP Server close() socket() TCP Client connect() write() read() close() connection establishment data request data reply end-of-file notification from UNIX Network Programming Volume 1, figure 4.1
  • 35. UDP Server Example For example: NTP daemon What does a UDP server need to do so that a UDP client can connect to it? UDP IP Ethernet Adapter NTP daemon Port 123
  • 36. Socket I/O: socket() The UDP server must create a datagram socket… int fd; /* socket descriptor */ if((fd = socket (AF_INET, SOCK_DGRAM , 0)) < 0) { perror(“socket”); exit(1); } socket returns an integer ( socket descriptor ) fd < 0 indicates that an error occurred AF_INET: associates a socket with the Internet protocol family SOCK_DGRAM: selects the UDP protocol
  • 37. Socket I/O: bind() A socket can be bound to a port int fd; /* socket descriptor */ struct sockaddr_in srv; /* used by bind() */ /* create the socket */ /* bind: use the Internet address family */ srv.sin_family = AF_INET ; /* bind: socket ‘fd’ to port 80*/ srv.sin_port = htons( 80 ); /* bind: a client may connect to any of my addresses */ srv.sin_addr.s_addr = htonl( INADDR_ANY ); if( bind (fd, (struct sockaddr*) &srv, sizeof(srv)) < 0) { perror(&quot;bind&quot;); exit(1); } Now the UDP server is ready to accept packets…
  • 38. Socket I/O: recvfrom() read does not provide the client’s address to the UDP server int fd; /* socket descriptor */ struct sockaddr_in srv; /* used by bind() */ struct sockaddr_in cli; /* used by recvfrom() */ char buf[512]; /* used by recvfrom() */ int cli_len = sizeof(cli); /* used by recvfrom() */ int nbytes; /* used by recvfrom() */ /* 1) create the socket */ /* 2) bind to the socket */ nbytes = recvfrom (fd, buf, sizeof(buf), 0 /* flags */, (struct sockaddr*) &cli, &cli_len); if(nbytes < 0) { perror(“recvfrom”); exit(1); }
  • 39. Socket I/O: recvfrom() continued... nbytes = recvfrom (fd, buf, sizeof(buf), 0 /* flags */, (struct sockaddr*) cli, &cli_len); The actions performed by recvfrom returns the number of bytes read ( nbytes ) copies nbytes of data into buf returns the address of the client ( cli ) returns the length of cli ( cli_len ) don’t worry about flags
  • 40. UDP Client Example How does a UDP client communicate with a UDP server ? TCP IP Ethernet Adapter 2 UDP Clients ports
  • 41. Socket I/O: sendto() write is not allowed Notice that the UDP client does not bind a port number a port number is dynamically assigned when the first sendto is called int fd; /* socket descriptor */ struct sockaddr_in srv; /* used by sendto() */ /* 1) create the socket */ /* sendto: send data to IP Address “128.2.35.50” port 80 */ srv.sin_family = AF_INET ; srv.sin_port = htons( 80 ); srv.sin_addr.s_addr = inet_addr(“ 128.2.35.50 ”); nbytes = sendto (fd, buf, sizeof(buf), 0 /* flags */, (struct sockaddr*) &srv, sizeof(srv)); if(nbytes < 0) { perror(“sendto”); exit(1); }
  • 42. Review: UDP Client-Server Interaction socket() bind() recvfrom() sendto() UDP Server socket() UDP Client sendto() recvfrom() close() blocks until datagram received from a client data request data reply from UNIX Network Programming Volume 1, figure 8.1
  • 43. The UDP Server How can the UDP server service multiple ports simultaneously? UDP IP Ethernet Adapter UDP Server Port 2000 Port 3000
  • 44. UDP Server: Servicing Two Ports What problems does this code have? int s1; /* socket descriptor 1 */ int s2; /* socket descriptor 2 */ /* 1) create socket s1 */ /* 2) create socket s2 */ /* 3) bind s1 to port 2000 */ /* 4) bind s2 to port 3000 */ while(1) { recvfrom (s1, buf, sizeof(buf), ...); /* process buf */ recvfrom (s2, buf, sizeof(buf), ...); /* process buf */ }
  • 45. Socket I/O: select() maxfds : number of descriptors to be tested descriptors (0, 1, ... maxfds-1) will be tested readfds : a set of fds we want to check if data is available returns a set of fds ready to read if input argument is NULL , not interested in that condition writefds : returns a set of fds ready to write exceptfds : returns a set of fds with exception conditions int select(int maxfds , fd_set * readfds , fd_set * writefds , fd_set * exceptfds , struct timeval *timeout); FD_CLR(int fd, fd_set *fds); /* clear the bit for fd in fds */ FD_ISSET(int fd, fd_set *fds); /* is the bit for fd in fds ? */ FD_SET(int fd, fd_set *fds); /* turn on the bit for fd in fds */ FD_ZERO(fd_set *fds); /* clear all bits in fds */
  • 46. Socket I/O: select() timeout if NULL, wait forever and return only when one of the descriptors is ready for I/O otherwise, wait up to a fixed amount of time specified by timeout if we don’t want to wait at all, create a timeout structure with timer value equal to 0 Refer to the man page for more information int select(int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval * timeout ); struct timeval { long tv_sec; /* seconds / long tv_usec; /* microseconds */ }
  • 47. Socket I/O: select() int s1, s2; /* socket descriptors */ fd_set readfds; /* used by select() */ /* create and bind s1 and s2 */ while(1) { FD_ZERO (&readfds); /* initialize the fd set */ FD_SET (s1, &readfds); /* add s1 to the fd set */ FD_SET(s2, &readfds); /* add s2 to the fd set */ if( select (s2+1, &readfds, 0, 0, 0) < 0) { perror(“select”); exit(1); } if( FD_ISSET (s1, &readfds)) { recvfrom (s1, buf, sizeof(buf), ...); /* process buf */ } /* do the same for s2 */ } select allows synchronous I/O multiplexing
  • 48. TCP IP Ethernet Adapter Web Server Port 80 How can a a web server manage multiple connections simultaneously? Port 8001 More Details About a Web Server
  • 49. Socket I/O: select() Now the web server can support multiple connections... int fd, next=0; /* original socket */ int newfd[10]; /* new socket descriptors */ while(1) { fd_set readfds; FD_ZERO (&readfds); FD_SET (fd, &readfds); /* Now use FD_SET to initialize other newfd’s that have already been returned by accept() */ select ( maxfd +1, &readfds, 0, 0, 0); if( FD_ISSET (fd, &readfds)) { newfd[ next++ ] = accept (fd, ...); } /* do the following for each descriptor newfd[ n ] */ if( FD_ISSET (newfd[ n ], &readfds)) { read (newfd[ n ], buf, sizeof(buf)); /* process data */ } }
  • 50. A Few Programming Notes: Representing Packets 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Length | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Type: 4-byte integer Length: 2-byte integer Checksum: 2-byte integer Address: 4-byte IP address
  • 51. A Few Programming Notes: Building a Packet in a Buffer struct packet { u_int32_t type; u_int16_t length; u_int16_t checksum; u_int32_t address; }; /* ================================================== */ char buf[1024]; struct packet *pkt; pkt = (struct packet*) buf; pkt->type = htonl (1); pkt->length = htons (2); pkt->checksum = htons (3); pkt->address = htonl (4);
  • 52. Socket Programming References Man page usage: man <function name> Textbook Sections 2.6, 2.7 demo programs written in Java Unix Network Programming : Networking APIs: Sockets and XTI (Volume 1) Section 2, 3, 4, 6, 8 ultimate socket programming bible!