Advanced UNIX programming - PowerPoint PPT Presentation

About This Presentation
Title:

Advanced UNIX programming

Description:

Title: Advanced UNIX progamming Author: asriniva Last modified by: asriniva Created Date: 6/5/2002 8:34:37 PM Document presentation format: On-screen Show – PowerPoint PPT presentation

Number of Views:86
Avg rating:3.0/5.0
Slides: 14
Provided by: asri9
Learn more at: http://www.cs.fsu.edu
Category:

less

Transcript and Presenter's Notes

Title: Advanced UNIX programming


1
Advanced UNIX programming
  • Fall 2002
  • Instructor Ashok Srinivasan
  • Lecture 25

Acknowledgements The syllabus and power point
presentations are modified versions of those by
T. Baker and X. Yuan
2
Announcements
  • Reading assignment
  • Chapter 9
  • Sections 9.1 to 9.9
  • Midterm Monday
  • Clarifications on project and HW3
  • Midterm review

3
Week 9 Topics
  • Socket options
  • getsockopt, setsockopt
  • fcntl
  • ioctl
  • Introduction to UDP
  • TCP vs UDP
  • UDP interface

4
Week 9 Topics ... continued
  • Name and address conversions
  • Domain name system
  • gethostbyname
  • gethostbyaddr
  • uname
  • gethostname
  • getservbyname
  • getservbyport

5
Name and address conversions
  • Names are easier to use
  • Names add a layer of indirection
  • Numeric addresses can be changed without
    modifying the name
  • A program can be more portable by using a name
  • The mapping between hostnames and IP addresses is
    done by the domain name system (DNS)

6
Domain name system
  • Mapping between names and addresses
  • xi.cs.fsu.edu lt--gt 128.186.121.41
  • References
  • See http//www.internic.net/faqs/authoritative-dns
    .html for information on
  • DNS organization
  • Why they should be the sole authority!

7
Domain name system ... continued
  • Hierarchical naming scheme
  • Name space partitioned into subdomains
  • Top level of domains
  • .com, .edu, .gov, .org, .us, .ca, .in, etc
  • Each domain can have subdomains
  • Distributed delegation of naming authority
  • Each domain has the authority to allow names
    within that domain
  • Naming follows organization boundary not physical
    network boundary

8
Resource records
  • Each server keeps resource records (RRs)
  • Information
  • IP address, record type, name, etc
  • Some relevant RR types
  • A Maps a hostname to an IPv4 address
  • AAAA Maps a hostname to an IPv6 address
  • PTR Pointer records, map IP addresses to
    hostnames
  • MX Mail exchanger for a host
  • CNAME Canonical name
  • Used to assign CNAME records for common services

9
Name servers
  • Name server
  • When a name server receives a DNS request, if the
    server is the authority for the name, it finds
    the resource record and replies
  • Otherwise it recursively asks the next level
  • Example gethostbyname(www.cs.yale.edu)
  • xi.cs.fsu.edu ---gt cs.fsu.edu --gt
    edu --gt
  • yale.edu --gtcs.yale.edu
    --gtyale.edu--gtedu
  • --gtcs.fsu.edu--gtxi.cs.fsu.edu
  • Optimizations
  • Replication and caching

10
gethostbyname
  • include ltnetdb.hgt
  • struct hostent gethostbyname(const char
    hostname)
  • struct hostent
  • char h_name
  • char h_aliases
  • int h_addrtype
  • int h_length
  • char h_addr_list
  • This function queries A or AAAA records

11
gethostbyaddr
  • include ltnetdb.hgt
  • struct hostent gethostbyaddr(const char addr,
    size_t len, int family)
  • addr is a pointer to an in_addr structure
  • len 4 for IPv4 and 16 for IPv6
  • This function queries PTR records
  • See example1.c and example2.c
  • These two system calls incur significant
    communication overhead
  • You can observe this in example1a.c

12
uname and gethostbyname
  • Information on name, os, and hardware
  • include ltsys/utsname.hgt
  • int uname (struct utsname name)
  • struct utsname
  • char sysname_UTS_NAMESIZE
  • char nodename_UTS_NODESIZE
  • char release_UTS_NAMESIZE
  • char version_UTS_NAMESIZE
  • char machine_UTS_NAMESIZE
  • See example2.c
  • gethostbyname can be used to get host name

13
getservbyname and getservbyport
  • Get service information
  • Not querying the DNS, but a system specific file,
    for example /etc/services
  • include ltnetdb.hgt
  • struct servent getservbyname(const char
    servname, const char protoname)
  • struct servent getservbyport(int port, const
    charprotoname)
  • struct servent
  • char s_name
  • char s_aliases
  • int s_port
  • char s_proto
  • See example3.c and example4.c
Write a Comment
User Comments (0)
About PowerShow.com