Presentation is loading. Please wait.

Presentation is loading. Please wait.

IPv6 Intro & Demo Yuxin Ouyang Yuhui Feng. Why IPv6 Space allowed by IPv4 is saturating IPv4 is not secure by itself Data prioritization in IPv4 is not.

Similar presentations


Presentation on theme: "IPv6 Intro & Demo Yuxin Ouyang Yuhui Feng. Why IPv6 Space allowed by IPv4 is saturating IPv4 is not secure by itself Data prioritization in IPv4 is not."— Presentation transcript:

1 IPv6 Intro & Demo Yuxin Ouyang Yuhui Feng

2 Why IPv6 Space allowed by IPv4 is saturating IPv4 is not secure by itself Data prioritization in IPv4 is not up to date Does not provide a mechanism to have a globally unique IP address

3 Features Larger address space Simplified Header End-to-end Connectivity and more…

4 IPv6 - Addressing Modes Unicast Multicast And…Anycast

5 IPv6 - Anycast When a host wishes to communicate with a host equipped with an Anycast IP address, it sends a Unicast message. With the help of complex routing mechanism, that Unicast message is delivered to the host closest to the Sender in terms of Routing cost.

6 IPv6 - Anycast

7 IPv6 Subnetting The second half of the address (least significant 64 bits) is always used for hosts only. Therefore, there is no compromise if we subnet the network. /48 prefix can be allocated to an organization providing it the benefit of ha-v ing up to /64 subnet prefixes 16 bits of subnet is equivalent to IPv4’s Class B Network. Using these sub- net bits, an organization can have another 65 thousands of subnets which i s by far, more than enough.

8 IPv6 Subnetting

9 IPv6 - Header Version (4-bits) Traffic Class (8-bits) Flow Label (20-bits) Payload Length (16-bits) Next Header (8-bits) Hop Limit (8-bits) Source Address (128-bits) Destination Address (128-bits)

10

11 IPv6 – Mobility (connected to home link)

12 IPv6 – Mobility (connected to foreign link)

13 include struct sockaddr_in6 { u_int16_tsin6_family; // address family, AF_INET6 u_int16_tsin6_port; // port number, Network Byte Order u_int32_tsin6_flowinfo; // IPv6 flow information struct in6_addrsin6_addr; // IPv6 address u_int32_t sin6_scope_id; // Scope ID }; struct in6_addr { unsigned chars6_addr[16];// load with inet_pton() }; IPv6 socket programming

14 // General socket address holding structure, big enough to hold either // struct sockaddr_in or struct sockaddr_in6 data: struct sockaddr_storage { sa_family_t ss_family; // address family char __ss_pad1[_SS_PAD1SIZE]; int64_t __ss_align; char __ss_pad2[_SS_PAD2SIZE]; }; IPv6 socket programming

15 IPv4IPv6 FamilyAF_INETAF_INET6 IP address Structuresockaddr_insockaddr_in6 Wildcard addressINADDR_ANYin6addr_any string->IP addressinet_aton( )inet_pton( ) IP address-> stringinet_ntoa( )inet_ntop( ) Get IP address by host name gethostbyname( )getaddrinfo( ) Get host name by IP address gethostbyaddr( )getnameinfo( )

16 IPv6 socket programming AF_xxx Versus PF_xxx The “AF_” prefix stands for “address family” and the "PF_" prefix stands for "protocol family.” Historically, the intent was that a single protocol family might support multipl e address families and that the PF_ value was used to create the socket an d the AF_ value was used in socket address structures. But in actuality, a protocol family supporting multiple address families has n ever been supported and the header defines the PF_ value for a given protocol to be equal to the AF_ value for that protocol. While the re is no guarantee that this equality between the two will always be true, sh ould anyone change this for existing protocols, lots of existing code would b reak. The PF_ value is mainly used in calls to socket.

17 int main(int argc, const char * argv[]) { unsigned int client_s; //Connection socket descriptor struct sockaddr_in6 server_addr; //Server Internet address char out_buf[BUFSIZE]; //Output buffer char in_buf[BUFSIZE]; //Input buffer const char *ip_num="::1"; const char *port_num="10501"; const char *file_name="1.jpg"; int port=atoi(port_num); server_addr.sin6_family =AF_INET6; server_addr.sin6_port =htons(port); inet_pton(AF_INET6, ip_num, &server_addr.sin6_addr); //Socket client_s=socket(AF_INET6,SOCK_STREAM,0); //Connection connect(client_s,(struct sockaddr *)&server_addr,sizeof(server_addr)); //Start file and find the size of it FILE *fp=fopen(file_name,"r"); //Send the file name to server bzero(out_buf,BUFSIZE); strncpy(out_buf,file_name,strlen(file_name)); send(client_s,out_buf,(strlen(out_buf)+1),0); //Start to transfer the file data long int send_length=0; bzero(out_buf,BUFSIZE); while ((send_length=fread(out_buf,sizeof(char),BUFSIZE,fp))>0){ if (send(client_s,out_buf,send_length,0)<0){ perror("File send failed."); exit(1); } bzero(out_buf,BUFSIZE); } fclose(fp); close(client_s); return 0; } Client TCP

18 int main(int argc, const char * argv[]) { unsigned int server_s; //Server socket descriptor and bind indicator struct sockaddr_in6 server_addr, client_addr; //Server and Client internet address unsigned int connect_s; //Connection socket descriptor unsigned int addr_len; //Internet address length char out_buf[BUFSIZE]; //Output buffer for data char in_buf[BUFSIZE]; //Input buffer for data char file_name[FILENAME_SIZE+1]; //File name for transferred onst char *port_num="10501"; long int port=atoi(port_num); server_addr.sin6_family =AF_INET6; server_addr.sin6_port =htons(port); server_addr.sin6_addr =in6addr_any; //Socket server_s=socket(AF_INET6,SOCK_STREAM,0); //Bind bind(server_s,(struct sockaddr *)&server_addr,sizeof(server_addr)); //Listen listen(server_s,SERVER_QUEUE); //Accept conncection addr_len=sizeof(client_addr); connect_s=accept(server_s,(struct sockaddr *)&client_addr,&addr_len); //Receive the file name from client bzero(in_buf,BUFSIZE); bzero(file_name,FILENAME_SIZE+1); recv(connect_s,in_buf,sizeof(in_buf),0); strncpy(file_name,in_buf,FILENAME_SIZE); //Create a file to write the data; FILE *fp=fopen(file_name,"w"); Server TCP

19 //Receive data from client to buffer and write them into the file long int recv_length; bzero(in_buf,BUFSIZE); while ((recv_length=recv(connect_s,in_buf,sizeof(in_buf),0))>0){ if(fwrite(in_buf,sizeof(char),recv_length,fp)<recv_length){ perror("File write filed.\n"); exit(1); } bzero(in_buf,BUFSIZE); } char str[40]; //IPv6 address in string inet_ntop(AF_INET6, &(client_addr.sin6_addr), str, 40); printf("File '%s' recieved successful!(From IP= '%s' port ='%d')\n", file_name, str, ntohs(client_addr.sin6_port)); fclose(fp); close(connect_s); close(server_s); return 0; }

20 http://www.tutorialspoint.com/ipv6/index.htm http://www.tutorialspoint.com/ipv6/index.htm Tutorialspoint http://en.wikipedia.org/wiki/IPv6http://en.wikipedia.org/wiki/IPv6 Wikipedia IPv6 http://beej.us/guide/bgnet/output/html/multipage/soc kaddr_inman.htmlhttp://beej.us/guide/bgnet/output/html/multipage/soc kaddr_inman.html Beej's Guide to Network Programming Reference


Download ppt "IPv6 Intro & Demo Yuxin Ouyang Yuhui Feng. Why IPv6 Space allowed by IPv4 is saturating IPv4 is not secure by itself Data prioritization in IPv4 is not."

Similar presentations


Ads by Google