Name and Address Conversions Part I

Slides:



Advertisements
Similar presentations
IPv4 and IPv6 Interoperability
Advertisements

Chapter 10 IPv4 and IPv6 Interoperability. contents Introduction IPv4 Client, IPv6 Server IPv6 Client, IPv4 Server IPv6 Address Testing Macros IPV6_ADDRFORM.
Topics: –DNS system –Gathering machine information How to find out the machines ip address, name, OS, version, etc.
CSE 333 – SECTION 8 Networking and sockets. Overview Network Sockets IP addresses and IP address structures in C/C++ DNS – Resolving DNS names Demos.
Programming with UDP – I Covered Subjects: IPv4 Socket Address Structure Byte Ordering Functions Address Access/Conversion Functions Functions: 1.socket()
Today’s topic: Basic TCP API –Socket –Bind –Listen –Connect –Accept –Read –Write –Close.
Name and Address Conversions© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid.
Networks: TCP/IP Socket Calls1 Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
TDC375 Autumn 03/04 John Kristoff - DePaul University 1 Network Protocols Domain Name System (DNS) largely based on slides from D. Comer.
1 Advanced Name and Address Conversions getaddrinfo, getnameinfo, gai_strerror, freeaddrinfo host_serv, tcp_connect, tcp_listen, udp_client, udp_connect,
UNIX Sockets COS 461 Precept 1. Clients and Servers Client program – Running on end host – Requests service – E.g., Web browser Server program – Running.
UNIX Sockets COS 461 Precept 1.
Client Software Design Objectives: Understand principles of C/S design, with focus on clients Review Windows implementations of Socket functions.
Internetworking Topics Client-server programming model Networks Internetworks Global IP Internet IP addresses Domain names Connections CS 105 “Tour of.
TCP/IP Protocol Stack IP Device Drivers TCPUDP Application Sockets (Gate to network) TCP: –Establish connection –Maintain connection during the communication.
Netprog: DNS and name lookups1 Address Conversion Functions and The Domain Name System Refs: Chapter 9 RFC 1034 RFC 1035.
Socket Programming. Introduction Sockets are a protocol independent method of creating a connection between processes. Sockets can be either – Connection.
Client-Side Network Programming
Class A Addresses The 1 st bit of a class A address is 0 The 1 st byte has a value from (128.x.x.x would not be a class A) 127.x.x.x is reserved.
Elementary Name and Address Conversions
Chapter 17 Domain Name System
Chapter 29 Domain Name System (DNS) Allows users to reference computer names via symbolic names translates symbolic host names into associated IP addresses.
Deploying a Web Application Presented By: Muhammad Naveed Date:
Netprog: DNS and name lookups1 Address Conversion Functions and The Domain Name System Refs: Chapter 9 RFC 1034 RFC 1035.
The Socket Interface Chapter 22. Introduction This chapter reviews one example of an Application Program Interface (API) which is the interface between.
1 Kyung Hee University Chapter 18 Domain Name System.
Domain Name System Refs: Chapter 9 RFC 1034 RFC 1035.
Elementary Name and Address Conversions
Name and Address Conversions Chap 11. Domain Name System  A lookup mechanism for translating objects into other objects  A globally distributed, loosely.
UNIX Sockets COS 461 Precept 1. Socket and Process Communication The interface that the OS provides to its networking subsystem application layer transport.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 19 Domain Name System (DNS)
TELE 402 Lecture 6: Name and address conversions 1 Overview Last Lecture –Socket Options and elementary UDP sockets This Lecture –Name and address conversions.
Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.
Internetworking Topics Client-server programming model Networks Internetworks Global IP Internet IP addresses Domain names Connections CS 105 “Tour of.
Advanced UNIX programming Fall 2002 Instructor: Ashok Srinivasan Lecture 25 Acknowledgements: The syllabus and power point presentations are modified versions.
Research and developments Introduction to IPv6 Lana Abadie, Februar 5 th 2008.
Chapter 11 Advanced Name and Address Conversion. Introduction gethostbyname, gethostbyaddr: protocol dependent getaddrinfo: –a function providing protocol.
Socket Programming(1/2). Outline  1. Introduction to Network Programming  2. Network Architecture – Client/Server Model  3. TCP Socket Programming.
CSE 333 – SECTION 8 Client-Side Network Programming.
Understand Names Resolution
Name and Address Conversions
Name/Address conversion:
Sockets and Beginning Network Programming
UNIX Sockets COS 461 Precept 1.
Domain Name System (DNS)
Implementing TCP/IP.
IMPLEMENTING NAME RESOLUTION USING DNS
Advanced Computer Networks
Chapter 10 IPv4 and IPv6 Interoperability
CS 105 “Tour of the Black Holes of Computing”
Class A Addresses The 1st bit of a class A address is 0
CpSc 360: Distributed and Network Programming
Chapter 19 Domain Name System (DNS)
Transport layer API: Socket Programming
תקשורת ומחשוב תרגול 3-5 סוקטים ב-C.
Advanced Sockets Programming
Chapter 11 Name and Address Conversions (Part II)
Lecture 6: TCP/IP Networking 1nd semester By: Adal ALashban.
DNS and DHCP Configuration
Domain Name System Refs: Chapter 9 RFC 1034 RFC 1035.
Server-side Programming CSE 333 Summer 2018
Client-side Networking CSE 333 Summer 2018
Network Programming: Part I CSCI 380: Operating Systems
Domain Name System: DNS
Socket Programming(1/2)
Today’s topic: Basic TCP API
IPv4 and IPv6 Interoperability
Exceptions and networking
Client-side Networking CSE 333 Spring 2019
Presentation transcript:

Name and Address Conversions Part I Chapter 11 Name and Address Conversions Part I Presented by Jessy Yau Chiew Lian

11.1 Introduction Conversion Protocol Information hostnames  IPv4 addresses gethostbyname gethostbyaddr Server names  post numbers getservbyname getservbyport Protocol Information getaddrinfo getnameinfo

11.2 Domain Name System(DNS) DNS maps between hostnames and IP addresses. Simple hostname : solaries, freebsd Fully qualified domain name (FQDN) :solaries.unpbook.com An absolute name Must end with a period but ignored by users often Entries in the DNS Resource Records(RRs) Trailing period tells the resolver that this name is fully qualified and it doesn’t need to search its list of possible domains.

Type of Resource Records A - maps a hostname into a 32-bit IPv4 address AAAA – maps a hostname into a 128-bit IPv6 addresses. PTR – maps IP address into hostname IPv4 address 4 bytes are reversed each byte converted to decimal ASCII value (0-255) in-addr.arpa is appended Ipv6 address 32 bytes are reversed each byte converted to hexadecimal ASCII value (0-9,a-f) ip6.arpa is appended

MX – mail exchanger CNAME – canonical name Multiple MX records exist Starting with the smallest value CNAME – canonical name ftp and www AAAA with host’s link-local address

Link-Local address vs Site-Local address Prefix of fe80::/64 Host bits are built from the interface’s EUI64 address Contacting host and router on the same network only. Addresses are not visible or reachable from different subnet. Site-local address Prefix of fec0::/10 Subnet and hosts can be addressed just as for provider-assigned network. The addresses will not be visible to outside machines, as these are on a different network, and their site-local addresses are in a different physical net Site-local addresses are rather uncommon today, and is no substitute for globally unique addresses if global connectivity is required. For IPv6, it's most common to have hosts assigned a local link and a global IP address.

Resolvers and Name Servers Applications such as the clients and servers that we are writing contact a DNS server by calling functions in a library known as Resolver It is contained in a system library and is link-edited into application. It reads its system-dependent configuration files to determine the location of the organization's name servers. /etc/resolv.conf Example functions: gethostbyname and gethostbyaddr There are a centralized resolver daemon that all applications share, and the system library code performs RPCs to this daemon.

The resolver sends the query to the local name server using UDP. If the local name server does not know the answer, it will query to other name servers If answer is too large to fit in UDP packet, it will automatically switch to TCP.

DNS Alternatives Get name and address information without using DNS Static host files - file /etc/hosts Network Information System(NIS) Lightweight Directory Access Protocol (LDAP) Implementation-dependent Solaries 2.x, HP-UX 10, FreeBSD 5.x - file /etc/nsswitch.conf AIX - file /etc/netsvc.conf BIND 9.2.2 - file /etc/irs.conf If a name server is used for hostname lookups Uses file /etc/resolv.conf to specify IP addresses of name servers. Calls resolver functions

11.3 gethostbyname Function Previous example using IP addresses instead of names connect, sendto, accept and recvfrom Most of applications should deal with names especially when move to IPv6 addresses (hex strings) gethostbyname returns a pointer to a hostent structure that contains all the IPv4 addresses for the host Not supports IPv6 addresses

11.4 gethostbyaddr Function Reverses of gethostbyname, takes a binary IPv4 address to look up hostname addr is a pointer to an in_addr structure len is 4 Family argument is AF_INET In term of DNS, gethostbyaddr queries a name server for a PTR record in the in-addr.arpa domain.

11.5 getservbyname and getservbyport Functions getservbyname gets port number associated with an Internet service and protocol. file /etc/services

getservbyport gets Internet service which corresponds to port and protocol file /etc/services

we try using the inet_aton function (Section 3 we try using the inet_aton function (Section 3.6) to see if the argument was an ASCII-format address. If it was, we construct a single-element list consisting of the corresponding address. Continues..

Resource Records Try each server address 29–35 We now code the calls to socket and connect in a loop that is executed for every server address until a connect succeeds or the list of IP addresses is exhausted

11.6 getaddrinfo Function gethostbyname and gethostbyaddr functions only support IPv4 getaddrinfo handles both name-to-address and service-to-port translation, and returns sockaddr structures instead of addresses. hostname - hostname or address string (dotted-decimal for IPv4 or hex string for IPv6) service - service name or a decimal port number string hints – null pointer or pointer to an addrinfo structure

There are two ways that multiple structures can be returned: If multiple addresses associated with the hostname, a structure is returned for each address – ai_family hint If service is provided for multiple socket types, a structure is returned for each socket type – ai_socktype hint

Port 53 is for the domain service Port 53 is for the domain service. This port number will be in network byte order in the socket address structures. We also show the returned ai_protocol values as IPPROTO_TCP or IPPROTO_UDP. It would also be acceptable for getaddrinfo to return an ai_protocol of 0 for the two SOCK_STREAM structures if that is sufficient to specify TCP (it is not sufficient if the system implements SCTP, for example), and an ai_protocol of 0 for the two SOCK_DGRAM structures if the system doesn't implement any other SOCK_DGRAM protocols for IP (as of this writing, none are yet standardized, but two are in development in the IETF). It is safest for getaddrinfo to always return the specific protocol.

11.7 gai_strerror Function Nonzero error returns values from getaddrinfo have the names and meanings gai_strerror takes one of these values as an argument and returns a pointer to the corresponding error string

11.8 freeaddrinfo Function All the storage returned by getaddrinfo, the addrinfo structures, the ai_addr structures, and the ai_canonname string are obtained dynamically. This storage is returned by calling freeaddrinfo.

11.9 getaddrinfo Function: IPv6 getaddrinfo is dealing with two different inputs: Type of socket address structure the caller wants back Type of records that should be searched for in the DNS or other database.

11.10 getaddrinfo Function: Examples Example of Figure 11.5: Example of a multihomed host with three IPv4 addresses:

Example: we specify our host aix, which has both a AAAA record and an A record. We do not specify the address family, but we provide a service name of ftp, which is provided by TCP only Example: we specify the AI_PASSIVE flag. We do not specify an address family or hostname. We also specify a port number of 8888 and a stream socket.