Name and Address Conversions - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Name and Address Conversions

Description:

Name and Address Conversions Chap 11 – PowerPoint PPT presentation

Number of Views:124
Avg rating:3.0/5.0
Slides: 23
Provided by: JinP165
Category:

less

Transcript and Presenter's Notes

Title: Name and Address Conversions


1
Name and Address Conversions
  • Chap 11

2
Domain Name System
  • A lookup mechanism for translating objects into
    other objects
  • A globally distributed, loosely coherent,
    scalable, reliable, dynamic database
  • Comprised of three components
  • Name space
  • Servers making that name space available
  • Resolvers (clients) which query the servers about
    the name space

3
Domain Name Space
  • DNS's distributed database is indexed by domain
    names.
  • Each domain name is essentially just a path in a
    large inverted tree, called the domain name
    space.

4
Domain, Delegation, Zone
5
Name Server Architecture
From disk
Zone transfer
6
Authoritative Data
Response
Query
7
Using Other Name Servers
Response
Response
Query
Query
8
Cached Data
Response
Query
9
Name Resolution
  • A DNS query has three parameters
  • A domain name (e.g., ice.hufs.ac.kr),
  • Remember, every node has a domain name!
  • A class (e.g., IN), and
  • A type (e.g., A)
  • DNS message format

10
Mapping Addresses to Names
11
Resource Records
  • ?? RRs
  • SOA Record (Start Of Authority) ?? ???? ?? ?????
    ??(authoritative)? ??? ?? ??? ??
  • NS(Name Server) Record ?? ???? ?? delegation??
    ????? ??
  • A Record ???? IPv4 ??? mapping
  • AAAA Record ???? IPv6 ??? mapping
  • CNAME Record ???? ?? ? ?? ?? ??
  • MX(Mail eXchanger) Record ?? ???? ?? ??? ??? ??
  • PTR(Pointer) Record IP ??? domain name?? reverse
    mapping? ??, Reverse Zone ???? ??

NAME (Dynamic)
TYPE(2 Byte)
CLASS(2 Byte)
TTL(4 Byte)
RDLENGTH(2 Byte)
RDATA(Dynamic)
12
Name and Address Conversion Functions
  • Domain name ? IPv4 address
  • IPv4 address ? domain name
  • gethostbyname/gethostbyaddr are not reentrant !!

static struct hostent host / result stored here
/ struct hostent gethostbyname(const char
hostname) / call DNS functions for A or
AAAA query / / fill in host structure /
return(host)
13
Service Name Conversion Functions
  • Service name ? port ( See /etc/services )
  • Port ? service name

14
Example name/daytimetcpcli1.c
Network-related information
15
New Name/Address Conversion Function (1)
  • hostname hostname or address string
  • service service name or decimal port number
    string
  • result addrinfo data structure is dynamically
    allocated
  • Re-entrant, thread-safe, and protocol independent
    functions (support IPv4, IPv6)

16
New Name/Address Conversion Function (2)
  • hints NULL or pointer to addrinfo data structure
  • The following member can be set by caller
  • ai_flag / AI_PASSIVE for server, AI_CANNONNAME
    /
  • ai_family / AF_xxx /
  • ai_socktype / SOCK_xxx /
  • ai_protocol / 0 or IPPROTO_xxx for IPv4 and IPv6
    /
  • Example

17
getaddrinfo Actions and Results
18
UNP Library Functions
  • include unp.h
  • struct addrinfo host_serv(const char hostname,
    const char service, int family, int socktype)
  • Returns pointer to addrinfo structure if OK,
    NULL on error
  • int tcp_connect(const char hostname, const char
    service)
  • int tcp_listen(const char hostname, const char
    service, socklen_t lenptr)
  • Both returns connected socket descriptor if OK,
    no return on error
  • int udp_client(const char hostname, const char
    service, void saptr, socklen_t lenp)
  • Returns unconnected socket descriptor if OK, no
    return on error
  • saptr address of a pointer to a socket address
    structure that stores destination IP addr/port
    for future calls to sendto
  • int udp_connect(const char hostname, const char
    service)
  • Returns connected socket descriptor if OK, no
    return on error
  • int udp_server(const char hostname, const char
    service, socklen_t lenptr)
  • Rerurns unconnected socket descriptor if OK, no
    return on error

19
tcp_connect and tcp_listen Functions
20
Protocol-indep Daytime TCP Client/Server
names/daytimetcpsrv1.c
names/daytimetcpcli.c
21
Protocol-indep Daytime UDP Client/Server
names/daytimeudpcli1.c
names/daytimeudpsrv2.c
22
getnameinfo Function
  • If the caller does not want to return host(serv)
    string, specify hostlen(servlen) of 0
  • flags
Write a Comment
User Comments (0)
About PowerShow.com