IPv6 Porting Applications

Similar documents
CSE 333 SECTION 7. Client-Side Network Programming

CSE 333 SECTION 7. Client-Side Network Programming

CSE 333 SECTION 6. Networking and sockets

CSE 333 SECTION 8. Sockets, Network Programming

CSE 333 SECTION 7. C++ Virtual Functions and Client-Side Network Programming

Programming guidelines on transition to IPv6

Category: Informational J. Bound J. McCann Hewlett-Packard W. Stevens February 2003

CSE 333 Section 3. Thursday 12 April Thursday, April 12, 12

The Berkeley Sockets API. Networked Systems Architecture 3 Lecture 4

IP Addresses, DNS. CSE 333 Spring Instructor: Justin Hsia

CSE 333 Lecture network programming intro

Socket Programming(2/2)

CSE 333 Lecture 16 - network programming intro

CS 43: Computer Networks. 05: Socket Programming September 12-14, 2018

IP Addresses, DNS. CSE 333 Summer Teaching Assistants: Renshu Gu William Kim Soumya Vasisht

Network Programming in C: The Berkeley Sockets API. Networked Systems 3 Laboratory Sessions

Network Programming in C. Networked Systems 3 Laboratory Sessions and Problem Sets

Network Programming Worksheet 2. Simple TCP Clients and Servers on *nix with C.

CLIENT-SIDE PROGRAMMING

CS321: Computer Networks Socket Programming

CS321: Computer Networks Introduction to Application Layer

ECE 435 Network Engineering Lecture 2

Network programming(i) Lenuta Alboaie

CSE 333 Lecture 8 - file and network I/O

Lecture 7 Overview. IPv6 Source: Chapter 12 of Stevens book Chapter 31 of Comer s book

System Programming. Sockets

sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements

CSE 124 Discussion Section Sockets Programming 10/10/17

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

UNIX System Programming Lecture 19: IP Sockets

Lecture 6 Overview. Last Lecture. This Lecture. Next Lecture. Name and address conversions

UNIX Network Programming. Overview of Socket API Network Programming Basics

Context. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement

Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C

A Client-Server Exchange

Network Socket Programming - 3 BUPT/QMUL

Introduction to Socket Programming

SOCKET PROGRAMMING. What is a socket? Using sockets Types (Protocols) Associated functions Styles

Network Socket Programming - 3 BUPT/QMUL

Ports under 1024 are often considered special, and usually require special OS privileges to use.

IBM i Version 7.3. Programming Socket programming IBM

Session NM056. Programming TCP/IP with Sockets. Geoff Bryant Process software

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CS 3516: Computer Networks

Socket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme

Outline. Distributed Computing Systems. Socket Basics (1 of 2) Socket Basics (2 of 2) 3/28/2014

C Structures in Practice

SOCKETS. COMP750 Distributed Systems

Unix Network Programming

ECE 435 Network Engineering Lecture 2

목포해양대해양컴퓨터공학과. IPv6 적용

IPv6 Network Programming

Socket Programming TCP UDP

CS118 Discussion 1B, Week 1. Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm

PA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~

Redesde Computadores(RCOMP)

Porting to Dual Stack -- Not that hard. Owen DeLong

Announcements. CS 5565 Network Architecture and Protocols. Queuing. Demultiplexing. Demultiplexing Issues (1) Demultiplexing Issues (2)

Lab 0. Yvan Petillot. Networks - Lab 0 1

Computer Network Programming

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.

Server-side Programming

last time redo logging copy-on-write filesystems / snapshots distributed systems motivation, etc.

Tutorial on Socket Programming

CS 640: Computer Networking

WinSock. What Is Sockets What Is Windows Sockets What Are Its Benefits Architecture of Windows Sockets Network Application Mechanics

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

Outline. Operating Systems. Socket Basics An end-point for a IP network connection. Ports. Network Communication. Sockets and the OS

CptS 360 (System Programming) Unit 17: Network IPC (Sockets)

Outline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer.

Topics for this Week

Outline. Option Types. Socket Options SWE 545. Socket Options. Out-of-Band Data. Advanced Socket. Many socket options are Boolean flags

Networks class. CS144 Introduction to Computer Networking. Administrivia. Administrivia 2. Grading. Labs. Goal: Teach the concepts underlying networks

Socket Programming for TCP and UDP

Introduction to Network Programming in C/C++

Introduction to Network Programming using C/C++

Programming with TCP/IP. Ram Dantu

Internet applications

Writing Network Applications using the TCP/IP Protocol Stack: Socket Programming

ICT 6544 Distributed Systems Lecture 5

What s an API? Do we need standardization?

Elementary TCP Sockets

Introduction to Computer Networks

Lecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005

UNIT IV- SOCKETS Part A

CSE 333 Section 8 - Client-Side Networking

Client Server Computing

Christian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel

use Socket qw(pf_inet SOCK_STREAM pack_sockaddr_in inet_aton);

Oral. Total. Dated Sign (2) (5) (3) (2)

UNIX Sockets. COS 461 Precept 1

Sockets 15H2. Inshik Song

Application Architecture

Network Programming November 3, 2008

Modern System Calls(IPv4/IPv6)

CSc 450/550 Computer Networks Network Architectures & Client-Server Model

Transcription:

IPv6 Porting Applications US IPv6 Summit Dec 8-11, 8 2003 Eva M. Castro eva@gsyc.escet.urjc.es Systems and Communications Group (GSyC( GSyC) Experimental Sciences and Technology Department (ESCET) Rey Juan Carlos University (URJC)

Agenda Transition Architecture Evolution of Applications Application Transition Scenarios Application Porting Considerations BSD Socket API IP Version Independent Applications Recommendations Page 2

Transition Architecture Network End-point nodes Applications Applications App App Applications End-point Node TCP/UDP IP Link layer Network Routing/Addressing TCP/UDP IP Link layer End-point Node Page 3

Network (routing/addressing) IPv6 -only Network /IPv6 Transition Mechanisms: Tunnels Protocol translation IPv6-only Network /IPv6 Dual Network IPv6 Heterogeneous Network Page 4

End-point Nodes (IP stack) -only node TCP/UDP Dual stack node TCP/UDP IPv6-only node TCP/UDP IPv6 IPv6 Link layer Link layer Link layer /IPv6 IPv6 Page 5

Applications (source code) -only Applications Appv4 IPv6-only Applications Appv6 Dual Applications Dual app Appv4 Appv4 Dual Dual app app Appv6 Appv6 Dual Dual app app Appv4 Appv4 Dual Dual app app Appv6 Appv6 TCP/UDP Link layer TCP/UDP IPv6 Link layer TCP/UDP IPv6 Link layer Page 6

Applications - Dual Nodes Appv4 Appv4 Appv6 Appv6 Appv6 Appv6 TCP/UDP addresses x.y.z.w IPv6 addresses x.y.z.w Data Link IPv6 addresses x:x:x:x:x:x:x:x IPv6 addresses x:x:x:x:x:x:x:x -mapped TCP/UDP IPv6 addresses ::FFFF:x.y.z.w IPv6 addresses x.y.z.w Data Link Data link header header data Data link header IPv6 header IPv6 data Data link header header data Page 7

Agenda Transition Architecture Evolution of Applications Application Transition Scenarios Application Porting Considerations BSD Socket API IP Version Independent Applications Recommendations Page 8

Evolution of Applications Substituting calls and structures by IPv6 ones Appv6 Appv4 Page 9

Evolution of Applications Substituting calls and structures by IPv6 ones Appv6 Appv4 ADVANTAGES: Easy task, short time Appv4 Appv4 Appv6 Appv6 PROBLEMS: Application selection Source code maintainability TCP/UDP IPv6 Link layer Page 10

Evolution of Applications Appv4 Adding IPv6 support Dual app Page 11

Evolution of Applications Appv4 ADVANTAGES: One application for all kind of nodes Source code maintainability DISADVANTAGES: More changes, long time Dual Dual app app TCP/UDP IPv6 Link layer Adding IPv6 support Dual app Page 12

Evolution of Applications Substituting calls and structures by IPv6 ones Appv6 Appv4 Adding support Adding IPv6 support Dual app Page 13

Evolution of Applications Substituting calls and structures by IPv6 ones Gradual transition Appv6 Appv4 Adding IPv6 support Adding support Dual app Page 14

Agenda Transition Architecture Evolution of Applications Application Transition Scenarios Application Porting Considerations BSD Socket API IP Version Independent Applications Recommendations Page 15

Application Transition Scenarios From existing applications in node: 1. applications in dual-stack nodes 2. IPv6 applications in dual-stack nodes 3. Dual applications in dual-stack nodes 4. Dual applications in nodes Page 16

1. applications in dual-stack nodes source code dependencies Use If IPv6 communication is required: port source code to IPv6, then applications use native IPv6, or use transition mechanisms. Applications use, but IPv6 packets are exchanged: BIA: applications + Dual stack nodes BIS: applications + nodes Dual stack nodes Page 17

Applications Application Level Appv4 libc BSD sockets interface Resolver O.S. Kernel TCP/UDP UNIX IPv6 Page 18

BIA Bump In the API Application Level Appv4 BIA Socket Library Address mapper libc BSD sockets interface Resolver O.S. Kernel TCP/UDP UNIX IPv6 Page 19

BIA resolver calls Application Level Appv4 Resolver calls BIA Socket Library Address mapper libc O.S. Kernel BSD sockets interface TCP/UDP UNIX Resolver IPv6 Page 20

BIA socket calls Application Level Appv4 BIA addr BIA Socket Library Socket calls Address mapper libc O.S. Kernel BSD sockets interface TCP/UDP UNIX Resolver IPv6 REAL addr Page 21

BIS Bump In the Stack Application Level libc Appv4 BSD sockets interface Resolver O.S. Kernel TCP/UDP UNIX BIS module IPv6 Address mapper Page 22

BIS Bump In the Stack Application Level libc Appv4 BIS addr BSD sockets interface Resolver O.S. Kernel TCP/UDP UNIX BIS module IPv6 Address mapper REAL addr Page 23

2. IPv6 applications in dual-stack nodes IPv6 source code dependencies Use IPv6 If communication is required: change source to dual application, or two different applications: appv4 & appv6, or use -mapped IPv6 addresses Built from addresses a.b.c.d ::FFFF:a.b.c.d addr -mapped IPv6 addr Page 24

IPv6 Apps -mapped IPv6 addr Client_v4 Client_v4 TCP / UDP Link layer packets Server_v6 Server_v6 TCP / UDP IPv6 Link layer -mapped IPv6 addr ::FFFF:a.b.c.d a.b.c.d -mapped IPv6 addr ::FFFF:a.b.c.d Client_v6 Client_v6 TCP / UDP IPv6 Server_v4 Server_v4 TCP / UDP a.b.c.d Link layer packets Link layer Page 25

Client/Server interoperability server IPv6 server node node Dual stack IPv6 node Dual stack client node node Dual stack IPv6 client IPv6 node Dual stack IPv6 IPv6 IPv6 IPv6 Page 26

Client/Server interoperability server IPv6 server node node Dual stack IPv6 node Dual stack client node node Dual stack Fail Fail IPv6 client IPv6 node Dual stack Fail Fail IPv6 IPv6 IPv6 IPv6 Page 27

3. Dual applications in dual-stack nodes Applications use both protocols. Ways of implementation: Applications request IPv6 addresses related to a host name if not valid, applications request addresses. IP VERSION DEPENDENT SOURCE CODE Applications request all addresses related to a host name, and try connection with the list of addresses until connection succeeds. IP VERSION INDEPENDENT SOURCE CODE Page 28

4. Dual applications in nodes Write dual applications which can also run in -only nodes: Try first AF_INET6 socket and the AF_INET. If kernel does not have IPv6 support, the socket call will return an error. Try AF_INET even socket call returned an error. Page 29

Agenda Transition Architecture Evolution of Applications Application Transition Scenarios Application Porting Considerations BSD Socket API IP Version Independent Applications Recommendations Page 30

Application Porting Considerations IP version dependencies in applications: Presentation format for an IP address Transport layer API Name and address resolution Specific IP dependencies Page 31

1. Presentation format for an IP addr IP addresses are usually provided in a presentation format, string: 10.0.0.1 PROBLEMS Allocated memory to store the string could be not enough. uses. as separator, IPv6 uses :. Parsers should be complaint with both formats. Ambiguity using : character in URLs: http://[ipv6address]:portnumber RECOMMENDATION Use FQDN Page 32

2. Transport layer API Network information storage. Address conversion functions. Communication API functions. Network configuration options. PROBLEMS Network API makes visible IP version dependencies, functions and structures must be changed RECOMMENDATION Develop IP version independent applications Page 33

3. Name and address resolution Two basic resolution functions DNS queries/responses are sent using /IPv6, regardless data records. PROBLEMS Existing name/address resolution calls are not valid for IPv6. RECOMMENDATION Use new IP version independent structures and functions Page 34

4. Specific IP dependencies IP address selection. Application framing. Storage of IP addresses. PROBLEMS There are more IP dependencies apart from network API calls and structures. RECOMMENDATION Review source code in detail Page 35

Agenda Transition Architecture Evolution of Applications Application Transition Scenarios Application Porting Considerations BSD Socket API IP Version Independent Applications Recommendations Page 36

BSD Socket API IPv6 addresses are 128 bit long. Changes in in the application networking part 1. Data structures: Socket address struct 2. Conversion functions between: String and binary representation Name and address 3. Socket calls Page 37

Generic Socket Address sockaddr Family AF_XXXX Data struct sockaddr { sa_family_t sa_family; char char sa_data[14]; }; }; 16 bits Page 38

socket address structure sockaddr_in Family Port Number Address (32 bits) Unused AF_INET struct sockaddr_in { sa_family_t sin_family; in_port_t sin_port; struct in_addr sin_addr; char char sin_zero[8]; }; }; struct in_addr { uint32_t s_addr; }; }; 16 bits Page 39

IPv6 socket address structure sockaddr_in6 Family Port Number Flow Info IPv6 Address (128 bits) Scope ID AF_INET6 struct sockaddr_in6 { sa_family_t sin6_family; in_port_t sin6_port; uint32_t sin6_flowinfo; struct in6_addr sin6_addr; uint32_t sin6_scope_id; }; }; struct in6_addr { uint8_t s6_addr[16]; }; }; 16 bits Page 40

Protocol independent structure sockaddr_storage Family Align (32, 64 bits) AF_XXXX struct sockaddr_storage { sa_family_t sin6_family; ss_aligntype ss_align; char char ss_padding[_ss_padsize]; }; }; Padding 16 bits Page 41

Structure Allocation -only struct sockaddr_in serveraddr; /* /* */ */ bind(serverfd, (struct sockaddr *)&serveraddr, &alen); IPv6-only struct sockaddr_in6 serveraddr; /* /* */ */ bind(serverfd, (struct sockaddr *)&serveraddr, &alen); Protocol independent struct sockaddr_storage serveraddr; /* /* */ */ bind(serverfd, (struct sockaddr *)&serveraddr, &alen); Page 42

BSD Socket API IPv6 addresses are 128 bit long. Changes in in the application networking part 1. Data structures: Socket address struct 2. Conversion functions between: String and binary representation Name and address 3. Socket calls Page 43

Conversion functions RESOLVER: returns IP address structure. Req Application code Resolver code Resp UDP Req UDP Resp Local Name Server Conf Files Page 44

Conversion: name & IP addr only (v4 addr) & IPv6 (v4, v6, v4-map v6 addr) gethostbyname() gethostbyaddr() getaddrinfo() getnameinfo() Protocol Independent Functions Page 45

Getaddrinfo struct addrinfo hints, *res; *res; memset(0, &hints, sizeof(hints); hints.ai_flags = AI_PASSIVE; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; /* /* SOCK_DGRAM */ */ getaddrinfo(null, DAYTIME_PORT, &hints, &res); /* /* */ */ freeaddrinfo(res); res: AF_INET6 AF_INET :: 0.0.0.0 Page 46

Getnameinfo struct sockaddr_storage clientaddr; char char clienthost[addrlen]; char char clientport[portlen]; /* /* */ */ connectedfd = accept(serverfd, (struct sockaddr *)&clientaddr, &alen); getnameinfo((struct sockaddr *)&clientaddr, addrlen, clienthost, sizeof(clienthost), clientport, sizeof(clientport), NI_NUMERICHOST); printf("request from from host=[%s] port=[%s]\n", clienthost, clientservice); } Page 47

Conversion: string & binary Conversions between the text representation and the binary value in network byte ordered (socket address structure). String -> Binary Binary -> String only inet_aton() inet_addr() inet_ntoa() & IPv6 inet_pton() inet_ntop() Page 48

inet_pton -only code struct struct in_addr addr4; char char *addrstr4= 127.0.0.1 ; /* */ /* */ inet_aton(addrstr4, &addr4); IPv6-only code struct struct sockaddr_in6 addr6; addr6; char char *addrstr6= ::1 ; /* */ /* */ inet_pton(af_inet6, addrstr6, &addr6); /IPv6 code struct sockaddr_storage addr; addr; int int family = AF_INET6; char char *addrstr= ::1 /* */ /* */ inet_pton(family, addrstr, &addr); Page 49

inet_ntop Old -only code struct struct in_addr addr4; char char *addrstr4; /* */ /* */ addrstr4 = inet_ntoa(addr4); /IPv6 code New IPv6-only code struct struct sockaddr_in6 addr6; addr6; char char addrstr6[inet6_addrstrlen]; /* */ /* */ inet_ntop(af_inet6, addr6, addrstr6, INET6_ADDRSTRLEN); struct sockaddr_storage addr; addr; char char addrstr[addrstrlen]; /* */ /* */ inet_ntop(addr.ss_family, addr, addr, addrstr, sizeof(addrstr)); Page 50

BSD Socket API IPv6 addresses are 128 bit long. Changes in in the application networking part 1. Data structures: Socket address struct 2. Conversion functions between: String and binary representation Name and address 3. Socket calls Page 51

Socket calls (TCP) Server socket bind listen accept read write close Client socket connect write read close Page 52

Socket calls (UDP) Server socket Client bind socket recvfrom sendto close sendto recvfrom close Page 53

Same socket calls & IPv6 Address family, socket type and protocol in the socket call: int int socket (int family, int int type, int int protocol); Casting to generic socket structure struct sockaddr *. : from (struct sockaddr_in *) IPv6: from (struct sockaddr_in6 *) Protocol independent: from (struct sockaddr_storage *) Size of socket address structure. Page 54

Socket Options (setsockopt( setsockopt) IPV6_UNICAST_HOPS Multicast: IPV6_MULTICAST_IF IPV6_MULTICAST_HOPS IPV6_MULTICAST_LOOP IPV6_JOIN_GROUP IPV6_LEAVE_GROUP IPV6_V6ONLY for AF_INET6 Page 55

Agenda Transition Architecture Evolution of Applications Application Transition Scenarios Application Porting Considerations BSD Socket API IP Version Independent Applications Recommendations Page 56

IP Version Independent Applications Use IP version independent structures: sockaddr_storage Use IP version independent functions: getaddrinfo()/getnameinfo() Not use inet_ntop()/inet_pton() Iterated jobs for finding the working address: Server: listening packets addressed to a specific port. Clients: connecting to one of the server addresses. Page 57

Server example get_list_of_ip_addresses list_of_ip_addresses == == null null create_socket (address_family) Protocol not support no error? error? no bind_socket yes error? error? no listen_socket yes NO NO SOCKET Page 58

Client example get_list_of_ip_addresses list_of_ip_addresses == == null null create_socket (address_family) Protocol not support no error? error? no connect_socket yes error? error? no SOCKET CONNECTED yes NO NO SOCKET Page 59

Server applications supporting & IPv6 IPv6 servers : clients connect using an -mapped IPv6 address IPv6 clients connect using an IPv6 address Dual servers: servers use different sockets for and IPv6 connections (IPV6_ONLY): clients connect using an address IPv6 clients connect using an IPv6 address Page 60

Dual servers: different & IPv6 sockets get_list_of_ip_addresses list_of_ip_addresses == == null null maxsock== 2 no create_socket (address_family) Protocol not support error? error? no no ipv6? ipv6? yes IPV6_ONLY yes yes bind_socket error? error? no listen_socket NO NO SOCKET Page 61

Agenda Transition Architecture Evolution of Applications Application Transition Scenarios Application Porting Considerations BSD Socket API IP Version Independent Applications Recommendations Page 62

Recommendations for applications Not use hard coded IP addresses IP version independent applications Structures & functions Iterated jobs to find a valid connection Develop dual applications: Valid for both protocols & IPv6 Page 63