Networking chapter VI

451 views
411 views

Published on

Chapter VI of Networking talks about IP protocol & Routing. It also covers aspects of socket programming used for converting servers into Linux Daemons.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
451
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Networking chapter VI

  1. 1. Compiled by: Jayakumar Balasubramanian Web: http://www.jwritings.com Email: [email_address]
  2. 2. Introduction to IP <ul><li>The concept of ‘unreliability’ </li></ul><ul><li>Datagram delivery from source to destination </li></ul><ul><li>Creates a ‘virtual path’ and forms the basis of packet switching </li></ul><ul><li>Takes the optimal/shortest path </li></ul><ul><li>Learn the network topology and perform ‘routing’ functionality </li></ul><ul><li>Independent of data link layer technology </li></ul>
  3. 3. Recap of addressing
  4. 4. The IP address <ul><li>Logical address </li></ul><ul><li>32 bit length </li></ul><ul><li>IP address parts: </li></ul><ul><ul><ul><li>Network part </li></ul></ul></ul><ul><ul><ul><li>Host part </li></ul></ul></ul><ul><li>Multiple classes </li></ul><ul><ul><ul><li>Class A </li></ul></ul></ul><ul><ul><ul><li>Class B </li></ul></ul></ul><ul><ul><ul><li>Class C </li></ul></ul></ul><ul><ul><ul><li>Special class </li></ul></ul></ul><ul><li>The ‘heart’ of routing </li></ul>
  5. 5. Subnet mask <ul><li>The subnet mask is used to get the network portion of the IP address. </li></ul><ul><li>This is basically achieved by performing logical AND. </li></ul><ul><li>By looking into the subnet mask we can determine the class of the IP address. </li></ul><ul><li>The concept of ‘subnetting’ </li></ul>
  6. 6. Example
  7. 7. The concept of ‘routing’
  8. 8. Some more concepts <ul><li>Route types: </li></ul><ul><ul><ul><li>Network specific route </li></ul></ul></ul><ul><ul><ul><li>Host specific route </li></ul></ul></ul><ul><ul><ul><li>Default route </li></ul></ul></ul><ul><li>Type of protocols </li></ul><ul><ul><ul><li>Routing protocols (Ex) OSPF, BGP </li></ul></ul></ul><ul><ul><ul><li>Routed protocols (Ex) TCP, DNS, SNMP </li></ul></ul></ul><ul><li>Data link layer </li></ul><ul><ul><ul><li>Maximum Transfer Unit (MTU) </li></ul></ul></ul><ul><ul><ul><li>Segmentation and re-assembly (SAR) </li></ul></ul></ul>
  9. 9. Special class of IP addresses <ul><li>Broadcast Address </li></ul><ul><li>Multicast Address </li></ul><ul><li>Loop back Address </li></ul>
  10. 10. The concept of Multicasting <ul><li>Have you used Yahoo/Google groups? </li></ul><ul><li>Instead of sending a separate copy of the data for each recipient, the source ends the data only once. </li></ul><ul><li>Unicast does mass mailings; Multicast does chain letters. </li></ul><ul><li>Advantages: </li></ul><ul><ul><ul><li>Cost-efficient </li></ul></ul></ul><ul><ul><ul><li>Timely distribution of data </li></ul></ul></ul><ul><ul><ul><li>Reduces WAN traffic </li></ul></ul></ul>
  11. 11. Multicast IP addresses <ul><li>The IP address belongs to ‘Class D’ </li></ul><ul><li>Ranges from 224.0.0.0 to 239.255.255.255 </li></ul><ul><li>Each address corresponds to a particular group/pre-defined protocol. </li></ul><ul><li>224.0.0.1 is for “All-hosts-in-LAN” </li></ul>
  12. 12. Sockets and multicasting options <ul><li>The ‘setsockopt’ API: </li></ul><ul><li>setsockopt (int sockFd, int level, int optname, const void* optval, socklen_t optlen); </li></ul><ul><li>level : IPPROTO_IP </li></ul><ul><li>opt-name: IP_ADD_MEMBERSHIP </li></ul><ul><li>IP_DROP_MEMBERSHIP </li></ul>
  13. 13. struct ip_mreq <ul><li>struct ip_mreq </li></ul><ul><li>{ </li></ul><ul><li>struct in_addr imr_multiaddr; </li></ul><ul><li>struct in_addr imr_interface; </li></ul><ul><li>}; </li></ul>
  14. 14. The ‘xinetd’ daemon <ul><li>The ‘xinetd’ is a replacement for ‘inetd’, the internet services daemon. </li></ul><ul><li>Each internet services are categorized based on port number. </li></ul><ul><li>The daemons in Linux are started when the system is booting up. Basically all standard servers (Telnet, FTP, SSH, etc..) are started in the similar way. </li></ul><ul><li>Our idea is to make our server program as a daemon and try out some things. </li></ul>
  15. 15. Some basics <ul><li>The syntax of ‘select()’ and brush up. </li></ul><ul><li>Standard socket descriptors: STDIN and STDOUT. </li></ul><ul><li>Linux specific: </li></ul><ul><ul><li>The /etc directory </li></ul></ul><ul><ul><li>The *.conf files in Linux </li></ul></ul>
  16. 16. The /etc/services file <ul><li>Defines the sockets and protocols used for Internet services. </li></ul><ul><li>Each service is listed on a single line corresponding to the form: </li></ul><ul><li>Syntax: </li></ul><ul><li>ServiceName PortNumber/ProtocolName  Aliases </li></ul><ul><ul><li>ServiceName - Specifies an official Internet service </li></ul></ul><ul><ul><li>PortNumber - Specifies the socket port number user </li></ul></ul><ul><ul><li>ProtocolName - Specifies the transport protocol used </li></ul></ul><ul><ul><li>Aliases - Specifies a list of unofficial service names. </li></ul></ul>
  17. 17. Example <ul><li>echo          7/tcp </li></ul><ul><li>echo          7/udp discard       9/tcp       sink null discard       9/udp       sink null daytime      13/tcp </li></ul><ul><li>daytime      13/udp chargen      19/tcp       ttytst source chargen      19/udp      ttytst source ftp           21/tcp time          37/tcp      timeserver </li></ul>
  18. 18. The /etc/xinetd.conf file <ul><li>xinetd.conf is the configuration file that determines the services provided by xinetd . </li></ul><ul><li>Any line whose first non-white-space character is a '#' is considered a comment line. Empty lines are ignored. </li></ul><ul><li>Each entry defines a service identified by the service_name. </li></ul><ul><li>This is where the service specific details are provided. </li></ul>
  19. 19. Syntax and Example <ul><li>service <service_name> { </li></ul><ul><ul><li><attribute> <assign_op> <value> <value> ... ... </li></ul></ul><ul><li>} </li></ul><ul><li>service SMTP { </li></ul><ul><li>socket type = stream </li></ul><ul><li>protocol = tcp </li></ul><ul><li>wait = no </li></ul><ul><li>user = mail </li></ul><ul><li>server = /usr/sbin/exim </li></ul><ul><li>} </li></ul>
  20. 20. Inside your program <ul><li>Important points: </li></ul><ul><ul><li>Use ‘select’ and STDIN combination for receiving client requests. </li></ul></ul><ul><ul><li>Use STDOUT for sending the data out to clients. </li></ul></ul><ul><li>Restarting the ‘xinetd’ </li></ul><ul><ul><ul><li>/etc/init.d/xinetd restart </li></ul></ul></ul>
  21. 21. Web : http://www.jwritings.com Email: [email_address]

×