1 / 55

Network Programming

Network Programming. Eddie Aronovich mail: eddiea@mta.ac.il. How did it started ?. How can we write communication ?. Application Program Interface (API) Sockets TLI (Transport Layer Interface) System calls Library functions. What is it for ?. Communication systems provides 3 services:

uta
Download Presentation

Network Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Network Programming Eddie Aronovich mail: eddiea@mta.ac.il

  2. How did it started ?

  3. How can we write communication ? • Application Program Interface (API) • Sockets • TLI (Transport Layer Interface) • System calls • Library functions

  4. What is it for ? Communication systems provides 3 services: • Information & resource Sharing • Distance gapping • Backup abilities

  5. Fundamentals • Server - An entity which gives services • Client - An entity which requests services • Transport layer - To transfer the data

  6. The 7 layers model

  7. The 7 Layer model in real life

  8. The message is built in one side...

  9. And striped in the dest. side…

  10. From Lynx to Netscapeor chat client Presentation

  11. Descriptors • Everything in Unix is a file • Descriptor is an index into an array

  12. Memory Buffers • Contains Socket Address Structure • Headers • Data

  13. The Basics of communication LectureII

  14. Processing Techniques Decentralized Centralized WEB

  15. The Client  Server Model • The server roles: • Give service as asked • Wait the client to appeal to him • The client roles: • Start the communication process • Asks the wanted service

  16. Design considerations • Serve single or multiple users • Use reliable or unreliable protocol • Software updates

  17. Client and server roles in UDP • Server roles: • Bind a port • Wait for a message to come • Send reply • Client roles: • Send a message • Get the reply

  18. User Datagram Protocol* • Simple protocol • Connectionless • Unreliable *{RFC 768}

  19. Socket:={ip_addr, port number} • API, an interface for the program to contact with communication. • Enable usage of regular file commands as read, write and so on. • The sockets are structures passed from kernel to process and vice versa.

  20. What the socket struct contains ? • Socket type {stream, dgram, raw,…} • Socket options {broadcast, OOB...} • Time to linger wait before close the socket • Socket state flags • Protocol Control Block • Protocol Handle

  21. The socket & address structs • Generalstruct sockaddr { uint8_t sa_len; /*Len of socket struct */ sa_family_t sa_family; /*Addr family as AF_INET */ char sa_data[20]; /*Protocol Address */ • IP V4 address socket struct sockaddr_in { uint8_t sin_len; /*The socket length */ sa_family_t sin_family; /*AF_INET for IP addresses */ unit16_t sin_port; /*The port id 16-bit port num */ struct in_addr sin_addr; /*The IP address 32-bit */ char sin_zero [8]; /* FFU - Must be zero */

  22. How the socket is created • The system call passes identifiers for address family(e.g.AF_UNIX, AF_INET,etc.), socket type and protocol. • Socket data structure is allocated. • Pointer from the fd table to other i-node struct which points to the socket.

  23. User Datagram Protocol (rfc 768) • Data transport layer protocol(Fragment packets to fit local MTU) • Used to make available datagram packet switched mode • Connectionless protocol • Used when RTT is important or no connection needed

  24. UDP header

  25. UDP by network monitor

  26. Lets do it in UDP - client C:\TEMP\udp-cli-c.htm C:\TEMP\udp-cli-c.htm

  27. Lets do it in UDP - server C:\TEMP\udp-srv-c.html

  28. TCP LectureIII

  29. Transmission Control Protocolrfc 793 • Reliability • Sequenced data transfer • Flow control • Full duplex

  30. TCP Header

  31. Ack & Flow control • Acknowledgements are sent by byte. • The acks can be sent for group of packets (but should arrive before time out of first packet). • Window size is used for flow control and is controlled by receiver.

  32. How connection starts ? SYN j SYN k, ACK j+1 ACK k+1 Connection Established

  33. How we do it in C ?

  34. Ending Sessions Passive close (FIN arrives) Vs. Active close FIN M ACK M+1 FIN N ACK N+1

  35. Internet Protocol LectureIV

  36. Network Layer • Passing packet from source host to destination host (cross networks if needed) • Independent of the datalink layer • QoS • Flow control

  37. Internet Protocol • Connectionless • Unreliable • Best effort

  38. Address • IP address consist 32bit and is divided into {network id.,host id} • Part of host id can be used for subnet mask • Some special addresses are defined (as: net-addr, broadcast-addr, multicast-addr)

  39. Addresses and Classes Class A Addresses: 0-127.X.X.X Class B Addresses: 128-191.0-255.X.X Class C Addresses: 192-223.0-255.0-255.X

  40. Masks • Mask is used to refine network division. • ‘1’b in mask symbolize bit belongs to network address. • ‘0’b in mask symbolize bit belongs to host address.

  41. Address conventions • Network address filled with ‘0’ in host address. • Broadcast address filled with ‘1’ in host address. • First, last subnet and address aren’t used

  42. How routing is done ? • The router compares destination IP with each Network & subnet address. • Unknown destination is routed to default. • Routers update each other with appropriate algorithms.

More Related