Socket Programming(2/2)
|
|
- Kristian Atkins
- 6 years ago
- Views:
Transcription
1 Socket Programming(2/2) 1
2 Outline 1. Introduction to Network Programming 2. Network Architecture Client/Server Model 3. TCP Socket Programming 4. UDP Socket Programming 5. IPv4/IPv6 Programming Migration 2
3 UDP Socket Programming 3
4 Review of Transport Layer Services Connection-Oriented Transport Services Transmission Control Protocol (TCP) Stream Control Transmission Protocol (SCTP) Connectionless Transport Services User Datagram Protocol (UDP) 4
5 Connectionless Transport Services No (Logical) Connection Establishment Packet Switching Each Datagram is individually transmitted Out-of-order Unreliable Data Transfer Datagram Loss No Connection State No Flow control and Congestion Control 5
6 Comparisons of Transport Services 6
7 User Datagram Protocol (UDP) UDP provides an unreliable, connectionless service to the invoking application No handshaking between sending and receiving transport layer entities before sending data segments UDP is defined in RFC 768 ( UDP-based Internet Services/Applications: DNS, SNMP, RIP, Internet Telephony 7
8 Comparison of UDP and TCP Segments 8
9 Preview of UDP Sockets Functions UDP Sockets Interfaces between application layer and UDP transport layer Using socket() to a UDP socket without connection establishment Using sendto() and recvfrom() to send and/or receive user datagrams from peer hosts 9
10 Categories of UDP Sockets Functions 10
11 Operations of UDP Client/Server 11
12 Elementary UDP Socket Functions 12
13 Review of UDP Unreliable Data Transfer No (Logical) Connection Establishment Packet Switching Each Datagram is individually transmitted Out-of-order Sequence Unreliable Data Transfer Datagram Loss No Connection State No Flow control and Congestion Control 13
14 IP and Port Addressing for UDP UDP does not create a (virtual) logical channel before data transfer No peer service port binding information Each datagram should be explicitly specified its addressing information Source IP, Source Port Destination IP, Destination Port 14
15 UDP Socket Creation socket() socket -- create an endpoint for communication int socket(int domain, int type, int protocol) domain : Specify a communications domain - PF_INET type: Specify the semantics of communication - SOCK_DGRAM protocol: Specify a particular protocol to be used with the socket 0 15
16 sockfd = socket(pf_inet, SOCK_DGM, 0) ; 16
17 sockfd = socket(pf_inet, SOCK_DGM, 0) ; sockfd socket descriptor (handler) integer -1 means that socket is creating failure 17
18 sockfd = socket(pf_inet, SOCK_DGM, 0) ; Parameter : domain Domain value: PF_INET Internet Protocol version 4 PF_INET6 Internet Protocol version 6 PF_LINK - Link Layer Interface 18
19 sockfd = socket(pf_inet, SOCK_DGM, 0) ; Parameter : type type value : SOCK_STREAM - TCP SOCK_DGRAM - UDP SOCK_RAW - Raw Socket 19
20 UDP Socket Service Binding bind() Assign a local protocol address to a socket int bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen) sockfd : socket descriptor created by socket() my_addr: Local address information including IP address and port value addrlen: byte length of local address information my_addr On success, zero is returned. On error, -1 is returned It is usually used in server port binding 20
21 RetValue = bind(sockfd,(struct sockaddr *)&srvaddr,length); 21
22 If RetValue is equal to 0, RetValue = bind(sockfd,(struct binding local address, sockaddr local port *)&srvaddr,length); to the socket is Successfully If RetValue is less than 0, binding process is failed. 22
23 Application Process U Socket D P Transport RetValue = bind(sockfd,(struct sockaddr *)&srvaddr,length); 23
24 Service Addressing Information PF_INET Application Process U Socket D P Transport RetValue = bind(sockfd,(struct sockaddr *)&srvaddr,length); 24
25 Application Process U Socket D P Transport RetValue = bind(sockfd,(struct sockaddr *)&srvaddr,length);
26 sockfd = socket(pf_inet, SOCK_DRGM, 0) RetValue = bind(sockfd,(struct sockaddr *)&srvaddr,length); 26
27 srvaddr.sin_family Protocol Family (PF_INET) srvaddr.sin_addr.s_addr Local IP (0,0.0.0) srvaddr.sin_port Local Port (1260) RetValue = bind(sockfd,(struct sockaddr *)&srvaddr,length); 27
28 Length of srvaddr structure RetValue = bind(sockfd,(struct sockaddr *)&srvaddr,length); 28
29 Comparison of TCP and UDP Socket s IP and Port Binding TCP and UDP sockets use same function to create socket interface and IP and port information binding at server side TCP uses connect() to create a communication channel Communication channel is identified by the binding of local IP, local Port, remote IP, and remote Port UDP has no connection process to bind their IP and Port between local and remote hosts 29
30 UDP Socket Data Sending sendto() Send a message on a socket ssize_t sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); s: File descriptor of the sending socket buf: Content of sending message len: Byte length of sending message flags: Control information of flags to: Addressing information of destination host tolen: Byte length of to structure 30
31 RetValue = sendto(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &server,length); 31
32 RetValue = sendto(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &server,length); 32
33 RetValue = sendto(sockfd,buffer, On success, these calls strlen(buffer),0, return the number (struct of characters sockaddr*) sent. &server,length); On error, -1 is returned 33
34 o l l e H Application Process U Socket D 1340 P Transport Destination Addressing Information. PF_INET RetValue = sendto(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &server,length); 34
35 o l l e H Application Process Socket Transport U D P RetValue = sendto(sockfd,buffer, 1340 strlen(buffer),0, (struct sockaddr*) &server,length); 35
36 Application Process U Socket D P RetValue = sendto(sockfd,buffer, 1340 strlen(buffer),0, Transport (struct sockaddr*) &server,length); o l l e H 36
37 Application Process U Socket D P RetValue = sendto(sockfd,buffer, 1340 strlen(buffer),0, Transport (struct sockaddr*) &server,length); o l 37
38 Application Process U Socket D P RetValue = sendto(sockfd,buffer, 1340 strlen(buffer),0, Transport (struct sockaddr*) &server,length); 38
39 sockfd : created by socket(pf_inet, SOCK_DGM, 0) ; RetValue = sendto(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &server,length); 39
40 buffer : block data Example: strcpy(buffer, Hello ) ; RetValue = sendto(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &server,length); 40
41 buffer length Example: strlen(buffer) RetValue = sendto(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &server,length); 41
42 control information of sento() function Flag value normally is 0 RetValue = sendto(sockfd,buffer, strlen(buffer), 0, (struct sockaddr*) &server,length); 42
43 server.sin_family Protocol Family (PF_INET) server.sin_addr.s_addr Destination IP ( ) sserver.sin_port Destination Port (1690) RetValue = sendto(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &server,length); 43
44 Size (length) of server structure RetValue = sendto(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &server,length); 44
45 UDP Socket Data Receiving recvfrom() Receive a message from a socket ssize_t recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen); s: File descriptor of the sending socket buf: Content of receiving message len: length of allocated buffer to receive message flags: Control information of flags from: Addressing information of sending host fromlen: Byte length of from structure 45
46 RetValue = recvfrom(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &peer,length); 46
47 RetValue = recvfrom(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &peer,length); 47
48 RetValue = On recvfrom(sockfd,buffer, success, these calls strlen(buffer),0, return the number (struct of characters sockaddr*) received. &peer,length); On error, -1 is returned 48
49 Application Process U Socket D 1340 P Transport RetValue = recvfrom(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &peer,length); H e l l o 49
50 Application Process U Socket D 1340 P Transport H e l l o RetValue = recvfrom(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &peer,length); 50
51 Addressing Information.of Sending Host PF_INET Application Process U Socket H D 1340 P e Transport l RetValue = recvfrom(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &peer,length); l o 51
52 H e l l o U Application Process Socket D 1340 P Transport Addressing Information.of Sending Host PF_INET RetValue = recvfrom(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &peer,length); 52
53 H e l l o Application Process U Socket D 1340 P Transport Addressing Information of Source Host PF_INET RetValue = recvfrom(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &peer,length); 53
54 sockfd : created by socket(pf_inet, SOCK_DGM, 0) ; RetValue = recvfrom(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &peer,length); 54
55 buffer: allocated space to receive incoming message RetValue = recvfrom(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &peer,length); 55
56 strlen(buffer) : size of allocated space RetValue = recvfrom(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &peer,length); 56
57 control information of recvfrom() function Flag value normally is 0 RetValue = recvfrom(sockfd,buffer, strlen(buffer), 0, (struct sockaddr*) &peer,length); 57
58 peer.sin_family Protocol Family (PF_INET) peer.sin_addr.s_addr Source IP ( ) peer.sin_port Source Port (1340) RetValue = recvfrom(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &peer,length); 58
59 length = size of peer structure RetValue = recvfrom(sockfd,buffer, strlen(buffer),0, (struct sockaddr*) &peer,length); 59
60 Comparison of TCP and UDP Socket Data Sending and Receiving 60
61 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() Receiving Message recv() recvfrom() 61
62 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Receiving Message recv() recvfrom() send(int s, const void *buf, size_t len, int flags) sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) UDP 62
63 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Receiving Message recv() recvfrom() send(int s, const void *buf, size_t len, int flags) int s, const void *buf, size_t len, int flags sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) UDP Same socket and sending buffer parameters 63
64 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Receiving Message recv() recvfrom() send(int s, const void *buf, size_t len, int flags) sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) UDP 64
65 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Receiving Message recv() recvfrom() send(int s, const void *buf, size_t len, int flags) const struct sockaddr *to, socklen_t tolen sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) UDP UDP should specify addressing information to identify the destination at every sendto() process 65
66 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Receiving Message recv() recvfrom() send(int s, const void *buf, size_t len, int flags) sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) UDP 66
67 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() Receiving Message recv() recvfrom() TCP recv(int s, void *buf, size_t len, int flags) recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen); UDP 67
68 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Receiving Message recv() recvfrom() recv(int s, void *buf, size_t len, int flags) int s, void *buf, size_t len, int flags recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen); UDP Same socket and receiving buffer parameters 68
69 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() Receiving Message recv() recvfrom() TCP recv(int s, void *buf, size_t len, int flags) recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen); UDP 69
70 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() Receiving Message recv() recvfrom() TCP recv(int s, void *buf, size_t len, int flags) struct sockaddr *from, socklen_t *fromlen recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen); UDP UDP can get specific source information of receiving message at every recvfrom() process 70
71 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() Receiving Message recv() recvfrom() TCP recv(int s, void *buf, size_t len, int flags) recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen); UDP 71
72 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), connect(), and accept(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client server UDP 72
73 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), connect(), and accept(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client server UDP 73
74 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept() and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application Transport server Application Transport UDP 74
75 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport server Application socket Transport UDP 75
76 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport Local IP : Local Port: 1460 server Application socket Transport UDP 76
77 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport Local IP : Local Port: 1460 server Application socket Transport UDP 77
78 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport Local IP : Local Port: 1460 server Application socket Transport UDP 78
79 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport Local IP : Local Port: 3865 (assigned by system) Local IP : Local Port: 1460 server Application socket Transport UDP 79
80 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport Local IP : Local Port: 3865 Local IP : Local Port: 1460 server Application socket Transport UDP 80
81 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport Local IP : Local Port: 3865 Local IP : Local Port: 1460 server Application socket Transport UDP 81
82 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport Local IP : Local Port: 3865 Local IP : Local Port: 3865 Local IP : Local Port: 1460 Local IP : Local Port: 1460 server Application socket Transport UDP 82
83 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport Local IP : Local Port: 3865 Client IP : Client Port: 3865 Server IP : Server Port: 1460 Channel Addressing Information Local IP : Local Port: 1460 server Application socket Transport UDP 83
84 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport Local IP : Local Port: 3865 Client IP : Client Port: 3865 Server IP : Server Port: 1460 Channel Addressing Information Local IP : Local Port: 1460 server Application socket Transport UDP 84
85 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport Local IP : Local Port: 3865 Client IP : Client Port: 3865 Server IP : Server Port: 1460 Channel Addressing Information Local IP : Local Port: 1460 server Application socket Transport Only use bind() to address service port, no other procedures to establish a logical transport channel with specific addressing information. The destination addressing information must be injected into the sendto() function UDP 85
86 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport Local IP : Local Port: 3865 Client IP : Client Port: 3865 Server IP : Server Port: 1460 Channel Addressing Information Local IP : Local Port: 1460 server Application socket Transport client server Only use bind() to address service port, no other procedures to establish a logical transport channel with specific addressing information. The destination addressing information must be injected into the sendto() function UDP 86
87 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport Local IP : Local Port: 3865 Client IP : Client Port: 3865 Server IP : Server Port: 1460 Channel Addressing Information Local IP : Local Port: 1460 server Application socket Transport client server Application Application Transport Transport Only use bind() to address service port, no other procedures to establish a logical transport channel with specific addressing information. The destination addressing information must be injected into the sendto() function UDP 87
88 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport Local IP : Local Port: 3865 Client IP : Client Port: 3865 Server IP : Server Port: 1460 Channel Addressing Information Local IP : Local Port: 1460 server Application socket Transport client Application socket Transport Local IP : Local Port: 1460 server Application socket Transport Only use bind() to address service port, no other procedures to establish a logical transport channel with specific addressing information. The destination addressing information must be injected into the sendto() function UDP 88
89 Protocol TCP UDP Service Connection- Oriented Connectionless Sending Message send() sendto() TCP Using the following operations, bind(), listen(), accept(), and connect(), to create a logical transport channel with specific addressing information between two hosts. Receiving Message recv() recvfrom() client Application socket Transport client Application socket Transport Local IP : Local Port: 3865 Client IP : Client Port: 3865 Server IP : Server Port: 1460 Channel Addressing Information No Specific Channel Addressing Information UDP Local IP : Local Port: 1460 Local IP : Local Port: 1460 Only use bind() to address service port, no other procedures to establish a logical transport channel with specific addressing information. The destination addressing information must be injected into the sendto() function server Application socket Transport server Application socket Transport 89
90 UDP Socket Release close() close - Close a file descriptor int close(int fd); fd: socket descriptor 90
91 RetValue = close(sockfd) ; 91
92 RetValue = close(sockfd) ; 92
93 returns zero on success. On error, -1 is returned RetValue = close(sockfd) ; 93
94 Application Process U Socket D P Transport 1340 RetValue = close(sockfd) ; 94
95 Application Process Socket Transport RetValue = close(sockfd) ; 95
96 Application Process Transport RetValue = close(sockfd) ; 96
97 sockfd : created by socket(pf_inet, SOCK_DGM, 0) ; RetValue = close(sockfd) ; 97
98 Review of UDP Client/Server Operation 98
99 UDP Client UDP Server 99
100 UDP Client UDP Server Running Time 100
101 UDP Client UDP Server Running Time 101
102 UDP Client UDP Server socket() socket() 102
103 UDP Client UDP Server socket() socket() bind() 103
104 UDP Client UDP Server socket() socket() bind() recvfrom() 104
105 UDP Client UDP Server socket() socket() bind() recvfrom() Blocking!! wait incomming userdatagram 105
106 UDP Client UDP Server socket() sendto() socket() bind() recvfrom() Blocking!! wait incomming userdatagram 106
107 UDP Client UDP Server socket() sendto() recvfrom() socket() bind() recvfrom() Blocking!! wait incomming userdatagram 107
108 UDP Client UDP Server socket() socket() bind() recvfrom() sendto() recvfrom() 108
109 UDP Client UDP Server socket() socket() bind() recvfrom() sendto() recvfrom() 109
110 UDP Client UDP Server socket() socket() bind() recvfrom() sendto() recvfrom() 110
111 UDP Client UDP Server socket() socket() bind() recvfrom() sendto() recvfrom() sendto() 111
112 UDP Client UDP Server socket() socket() bind() recvfrom() sendto() recvfrom() sendto() 112
113 UDP Client UDP Server socket() socket() bind() recvfrom() sendto() recvfrom() sendto() close() Wait another UDP Client 113
114 UDP Client UDP Server socket() bind() socket() recvfrom() 114
115 IPv6 Socket Programming 115
116 IPv6 Socket Programming 116
117 117
118 118
119 IPv4 Addressing Problems Does IPv4 Addressing Space be exhausted? Every Equipment(Host Needs) a Unique IPv4 Address Network Usage is an Exponential Growth 119
120 IPv4 Addressing - Temporary Solution Sub-Netting Classless Inter Domain Routing CIDR Dynamic Address Allocation Dynamic Host Configuration Protocol (DHCP) Network Address Translation (NAT) Private Networks 120
121 IPv4 Addressing Permanent Solution Extend IPv4 Addressing Space New Addressing Model Revise IPv4 Originating Design Defects Compromise the Developing Trend of Network Technology 121
122 IPv4 Originating Defects Variable Header Length Option Fields Cyclic Redundancy Check (CRC) Overloading Maximum Transmission Unit (MTU) IP Packet Fragmentation/Resassembly 122
123 Next Generation Internet Protocol IPv6 Internet Protocol Version 6 RFC 2460 Expanded Addressing Capability 128 bits Autoconfiguration Mechanisms Simplification of Header Format Fixed 40 bytes Improved Support for Extensions and Options Extension for Authentication and Privacy Flow Label Capability 123
124 IPv4 and IPv6 Headers 124
125 ver Header Length Type of Service Datagram Length 16-bit Identifier Flags 13-bit Fragmentation Offset Time-to-Live Upper-Layer Protocol Header Checksum 32-bit Source IP Address 32-bit Destination IP Address Options (if any) + Padding 125
126 version Traffic Class Flow Label Payload Length Next Header Hop Limit 128-bit Source IP Address 128-bit Destination IP Address 126
127 ver Header Length TOS Datagram Length ver Traffic Class Flow Label 16-bit Identifier F L A G s 13-bit Fragmentation Offset Payload Length Next Header Hop Limit Time-to-Live Upper-Layer Protocol Header Checksum 32-bit Source IP Address 128-bit Source IP Address 32-bit Destination IP Address Options (if any) + Padding 128-bit Destination IP Address 127
128 Protocol Version ver Header Length TOS Datagram Length ver Traffic Class Flow Label 16-bit Identifier F L A G s 13-bit Fragmentation Offset Payload Length Next Header Hop Limit Time-to-Live Upper-Layer Protocol Header Checksum 32-bit Source IP Address 128-bit Source IP Address 32-bit Destination IP Address Options (if any) + Padding 128-bit Destination IP Address 128
129 Quality of Service ver Header Length TOS Datagram Length ver Traffic Class Flow Label 16-bit Identifier F L A G s 13-bit Fragmentation Offset Payload Length Next Header Hop Limit Time-to-Live Upper-Layer Protocol Header Checksum 32-bit Source IP Address 128-bit Source IP Address 32-bit Destination IP Address Options (if any) + Padding 128-bit Destination IP Address 129
130 Payload Length ver Header Length TOS Datagram Length ver Traffic Class Flow Label 16-bit Identifier F L A G s 13-bit Fragmentation Offset Payload Length Next Header Hop Limit Time-to-Live Upper-Layer Protocol Header Checksum 32-bit Source IP Address 128-bit Source IP Address 32-bit Destination IP Address Options (if any) + Padding 128-bit Destination IP Address 130
131 Lifetime of Packet ver Header Length TOS Datagram Length ver Traffic Class Flow Label 16-bit Identifier F L A G s 13-bit Fragmentation Offset Payload Length Next Header Hop Limit Time-to-Live Upper-Layer Protocol Header Checksum 32-bit Source IP Address 128-bit Source IP Address 32-bit Destination IP Address Options (if any) + Padding 128-bit Destination IP Address 131
132 Protocol Indicator ver Header Length TOS Datagram Length ver Traffic Class Flow Label 16-bit Identifier F L A G s 13-bit Fragmentation Offset Payload Length Next Header Hop Limit Time-to-Live Upper-Layer Protocol Header Checksum 32-bit Source IP Address 128-bit Source IP Address 32-bit Destination IP Address Options (if any) + Padding 128-bit Destination IP Address 132
133 Source Address ver Header Length TOS Datagram Length ver Traffic Class Flow Label 16-bit Identifier F L A G s 13-bit Fragmentation Offset Payload Length Next Header Hop Limit Time-to-Live Upper-Layer Protocol Header Checksum 32-bit Source IP Address 128-bit Source IP Address 32-bit Destination IP Address Options (if any) + Padding 128-bit Destination IP Address 133
134 Destination Address ver Header Length TOS Datagram Length ver Traffic Class Flow Label 16-bit Identifier F L A G s 13-bit Fragmentation Offset Payload Length Next Header Hop Limit Time-to-Live Upper-Layer Protocol Header Checksum 32-bit Source IP Address 128-bit Source IP Address 32-bit Destination IP Address Options (if any) + Padding 128-bit Destination IP Address 134
135 Header Checksum ver Header Length TOS Datagram Length ver Traffic Class Flow Label 16-bit Identifier F L A G s 13-bit Fragmentation Offset Payload Length Next Header Hop Limit Time-to-Live Upper-Layer Protocol Header Checksum 32-bit Source IP Address 128-bit Source IP Address 32-bit Destination IP Address Options (if any) + Padding 128-bit Destination IP Address 135
136 Datagram Fragmentation/Reassembly ver Header Length TOS Datagram Length ver Traffic Class Flow Label 16-bit Identifier F L A G s 13-bit Fragmentation Offset Payload Length Next Header Hop Limit Time-to-Live Upper-Layer Protocol Header Checksum 32-bit Source IP Address 128-bit Source IP Address 32-bit Destination IP Address Options (if any) + Padding 128-bit Destination IP Address 136
137 Variable Header Length with Option Fields ver Header Length TOS Datagram Length ver Traffic Class Flow Label 16-bit Identifier F L A G s 13-bit Fragmentation Offset Payload Length Next Header Hop Limit Time-to-Live Upper-Layer Protocol Header Checksum 32-bit Source IP Address 128-bit Source IP Address 32-bit Destination IP Address Options (if any) + Padding 128-bit Destination IP Address 137
138 IPv4 and IPv6 Socket Functions IPv4 and IPv6 use the same socket functions With Different Protocol Family and Socket Address Structure 138
139 IPv4 and IPv6 Socket Address Structures Different Protocol Family Different Addressing Length 139
140 socket() 140
141 socket() connect() bind() 141
142 socket() connect() bind() setsockopt() listen() 142
143 socket() connect() bind() setsockopt() listen() close() accept() 143
144 socket() connect() bind() setsockopt() listen() close() accept() send() recv() 144
145 socket() connect() bind() setsockopt() listen() close() accept() send() recv() sendto() recvfrom() 145
146 socket() connect() bind() setsockopt() listen() close() accept() send() recv() sendto() recvfrom() 146
147 socket() connect() bind() setsockopt() listen() close() accept() send() recv() sendto() recvfrom() 147
148 socket() connect() bind() setsockopt() listen() close() accept() send() recv() sendto() recvfrom() 148
149 socket() IPv4 Address : IPv6 Address : fe80::20c:f1ff:fe28:2f15 sockaddr_in sockaddr_in6 connect() bind() setsockopt() listen() close() accept() send() recv() sendto() recvfrom() 149
150 socket() IPv4 Address : IPv6 Address : fe80::20c:f1ff:fe28:2f15 sockaddr_in sockaddr_in6 connect() bind() setsockopt() struct sockaddr_in { u_int8_t sin_len ; u_int8_t sin_family close() ; u_int16_t sin_port ; struct in_addr sin_addr ; int8_t size_zero[8] send() ; } ; sendto() listen() struct sockaddr_in6 { u_int8_t sin6_len ; u_int8_t accept() sin6_family ; u_int16_t sin6_port ; u_int32_t sin6_flowinfo ; struct recv() in6_addr sin6_addr ; u_int32_t sin6_scope_id ; } ; recvfrom() 150
151 socket() IPv4 Address : IPv6 Address : fe80::20c:f1ff:fe28:2f15 sockaddr_in sockaddr_in6 length connect() AF_INET 16 bit Port # 32-bit setsockopt() struct IPv4 sockaddr_in Address { u_int8_t sin_len ; u_int8_t sin_family close() ; u_int16_t (unused) sin_port ; struct in_addr sin_addr ; int8_t fixed-length size_zero[8] (16 send() bytes) ; } ; sendto() bind() length AF_INET6 16 bit port # listen() 32-bit struct sockaddr_in6 Flow Label { u_int8_t sin6_len ; u_int8_t accept() sin6_family ; u_int16_t 128-bit sin6_port ; u_int32_t IPv6 sin6_flowinfo Address ; struct recv() in6_addr sin6_addr ; u_int32_t sin6_scope_id ; } ; 32-bit recvfrom() Scope ID fixed-length (28 bytes) 151
152 socket() IPv4 Address : IPv6 Address : fe80::20c:f1ff:fe28:2f15 sockaddr_in sockaddr_in6 length connect() AF_INET 16 bit Port # 32-bit setsockopt() struct IPv4 sockaddr_in Address { u_int8_t sin_len ; u_int8_t sin_family close() ; u_int16_t (unused) sin_port ; struct in_addr sin_addr ; int8_t fixed-length size_zero[8] (16 send() bytes) ; } ; sendto() bind() length AF_INET6 16 bit port # listen() 32-bit struct sockaddr_in6 Flow Label { u_int8_t sin6_len ; u_int8_t accept() sin6_family ; u_int16_t 128-bit sin6_port ; u_int32_t IPv6 sin6_flowinfo Address ; struct recv() in6_addr sin6_addr ; u_int32_t sin6_scope_id ; } ; 32-bit recvfrom() Scope ID fixed-length (28 bytes) 152
153 IPv4 and IPv6 Coexisting 153
154 Only IPv4 Protocol Stack IPv4 Client IPv4 Server TCP TCP IPv4 IPv4 Datalink Datalink 154
155 IPv4 Client IPv4 Server TCP TCP IPv4 IPv4 Datalink Datalink 155
156 Only IPv6 Protocol Stack IPv6 Client IPv6 Server TCP TCP IPv6 IPv6 Datalink Datalink 156
157 IPv6 Client IPv6 Server TCP TCP IPv6 IPv6 Datalink Datalink 157
158 IPv4/IPv6 Client IPv4/IPv6 Server TCP TCP IPv4 mapped IPv6 Address IPv4 IPv6 IPv4 IPv6 Datalink Datalink 158
159 IPv4/IPv6 Client IPv4/IPv6 Server TCP TCP IPv4 mapped IPv6 Address IPv4 IPv6 IPv4 IPv6 Datalink Datalink 159
160 Comparison of IPv4 and IPv6 Socket Functions 160
161 IPv4 Address Format IPv4 Address Length : 32 bits (4 bytes) Dotted-Decimal String Network Byte Ordered IPv4 Internet Address Structure struct in_addr { in_addr_t s_addr ; } in_addr_t : uint32_t (Unsigned 32-bit integer) Conversion of Network Byte Address and Address String Byte Manipulation Functions int inet_aton() in_addr_t inet_addr() char *inet_ntoa() 161
162 int inet_aton() int inet_aton(const char *cp, struct in_addr *inp); Converts the Internet host address cp from the standard numbers-and-dots notation into binary data and stores it in the structure that inp points to inet_aton() returns non-zero if the address is valid, zero if not. struct in_addr dest ; inet_aton(" ", &dest.sin_addr); 162
163 in_addr_t inet_addr() in_addr_t inet_addr(const char *cp); Convert the Internet host address cp from numbers-and-dots notation into binary data in network byte order. If the input is invalid, INADDR_NONE (usually -1) is returned. struct in_addr dest ; dest.sin_addr = inet_addr( ); 163
164 char *inet_ntoa() char *inet_ntoa(struct in_addr in); Convert the Internet host address in given in network byte order to a string in standard numbers-and-dots notation. The string is returned in a statically allocated buffer, which subsequent calls will overwrite. struct in_addr in ; char ipstr[17] ; memset(ipst, 17,0) ; in.s_addr = inet_addr(" "); strcpy(ipstr, inet_ntoa(in)) ; 164
165 IPv6 Address Format IPv6 Address Length : 128 bits (16 bytes) fe80:0000:0000:0000:0202:b3ff:fe1e:8329 Colon-Hexadecimal String fe80:0:0:0:202:b3ff:fe1e:8329 fe80::202:b3ff:fele:8239 Abbreviation Network Byte Ordered IPv6 Internet Address Structure struct in6_addr { uint8_t s6_addr[16] ; } uint8_t (Unsigned 8-bit integer) 165
166 IPv6 Address Format Conversion of Network Byte Address and Address String Byte Manipulation Functions int inet_pton() const char *inet_ntop() 166
167 int inet_pton() int inet_pton(int af, const char *src, void *dst); Convert the character string src into a network address structure in the af address family, then copies the network address structure to dst parameters af src dst IPv4 AF_INET char struct in_addr{} ; IPv6 AF_INET6 char struct in6_addr{} ; struct in_addr in4 ; struct in6_addr in6 ; inet_pton(af_inet, " ", &in4); inet_pton(af_inet6, fe80:0000:0000:0000:0202:b3ff:fe1e:8329, &in6) 167
168 const char *inet_ntop() const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt); Convert the network address structure src in the af address family into a character string, which is copied to a character buffer dst, which is cnt bytes long. parameters af src dst cnt IPv4 AF_INET struct in_addr{} ; char INET_ADDRSTRLEN(14) IPv6 AF_INET6 struct in6_addr{} ; char INET6_ADDRSTRLEN(48) struct in_addr in4 ; struct in6_addr in6 ; char ipstr[256] ; inet_ntop(af_inet, in4, &ipstr, INET_ADDRSTRLEN); inet_pton(af_inet6, in6, &ipstr, INET6_ADDRSTRLEN) 168
169 Comparison of Socket Address Structures 169
170 IPv4/IPv6 Socket Functions Same Socket Functions Socket Creation Socket Connection Message Sending/Receiving Different Protocol Domains and Socket Address Structure IPv4 Protocol Domain - AF_INET IPv4 Socket Address Structure - sockaddr_in{} IPv6 Protocol Domain - AF_INET6 IPv6 Socket Address Structure - sockaddr_in6{} 170
171 IPv4/IPv6 Program Migration Direct change Domain Protocol AF_INET (IPv4) AF_INET6 (IPv6) IP_PROTO_IP (IPv4) IP_PROTO_IP6 (IPv6) Direct change Socket Address Structure and Internet Address Structure sockaddr_in{} (IPv4) sockaddr_in6{}/sockaddr_storage (IPv6) Conversion of Network Byte Ordered Address and IP String inet_aton(), inet_addr(), inet_ntoa() IPv4 inet_pton(), inet_ntop() IPv6 Host Name and IP Address Translations Function gethostbyname(), gethostbyaddr () IPv4 getaddrinfo(), getnameinfo() IPv6 Conversion of data message containing IP address information FTP, SIP, H323, 171
172 IPv4/IPv6 Program Migration Utility Tool Microsoft s checkv4.exe Included in Microsoft Platform SDK List the suggestion of code modification Protocol Domain / Protocol Type Socket Address Structures Network Byte Ordered Functions Host Name and IP Address Translation Functions 172
173 IPv4/IPv6 TCP Operations 173
174 TCP Client TCP Server socket connect send recv IPv4 AF_INET in_addr{} sockaddr_in{} IPv6 AF_INET6 in6_addr{} sockaddr_in6{} socket bind listen accept recv send 174
175 IPv4/IPv6 UDP Operations 175
176 UDP Client UDP Server socket IPv4 AF_INET in_addr{} sockaddr_in{} socket bind recvfrom sendto recvfrom IPv6 AF_INET6 in6_addr{} sockaddr_in6{} sendto 176
177 Question 在 IPv4/IPv6 的程式設計, 最主要的差異在於 (A). Socket Address Structure 與 Internet Address Format() (B). Socket 建立階段 :socket(), bind(), listen(), accept() (C). Socket 資料送收階段 :send()/recv(), sendto()/recvfrom() (D). 以上皆是 177
Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements
Announcements CS 5565 Network Architecture and Protocols Lecture 5 Godmar Back Problem Set 1 due Feb 17 Project 1 handed out shortly 2 Layer The Layer Let s look at some s (in keeping with top-down) architectures:
More informationsottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani
Titolo presentazione Piattaforme Software per la Rete sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Outline 1) Introduction to Sockets 2) UDP communication 3) TCP communication 4) RAW
More informationOral. Total. Dated Sign (2) (5) (3) (2)
R N Oral Total Dated Sign (2) (5) (3) (2) Assignment Group- A_07 Problem Definition Write a program using TCP socket for wired network for following Say Hello to Each other ( For all students) File transfer
More informationSocket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C
1 CSIS0234A Computer and Communication Networks Socket Programming in C References Beej's Guide to Network Programming Official homepage: http://beej.us/guide/bgnet/ Local mirror http://www.cs.hku.hk/~c0234a/bgnet/
More informationCLIENT-SIDE PROGRAMMING
CLIENT-SIDE PROGRAMMING George Porter Apr 11, 2018 ATTRIBUTION These slides are released under an Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) Creative Commons license These slides
More informationProcesses communicating. Network Communication. Sockets. Addressing processes 4/15/2013
Processes communicating Network Communication Process: program running within a host. within same host, two processes communicate using inter-process communication (defined by OS). processes in different
More informationNetwork Communication
Network Communication Processes communicating Process: program running within a host. q within same host, two processes communicate using inter- process communica6on (defined by OS). q processes in different
More informationUnix Network Programming
Introduction to Computer Networks Polly Huang EE NTU Unix Network Programming The socket struct and data handling System calls Based on Beej's Guide to Network Programming 1 The Unix Socket A file descriptor
More informationSocket Programming for TCP and UDP
CSCI4430 Data Communication and Computer Networks Socket Programming for TCP and UDP ZHANG, Mi Jan. 19, 2017 Outline Socket Programming for TCP Introduction What is TCP What is socket TCP socket programming
More informationCSE 124 Discussion Section Sockets Programming 10/10/17
CSE 124 Discussion Section Sockets Programming 10/10/17 Topics What s a socket? Creating a socket Connecting a socket Sending data Receiving data Resolving URLs to IPs Advanced socket options Live code
More informationCS 43: Computer Networks. 05: Socket Programming September 12-14, 2018
CS 43: Computer Networks 05: Socket Programming September 12-14, 2018 Reading Quiz Lecture 5/6 - Slide 2 Socket Programming Adapted from: Donahoo, Michael J., and Kenneth L. Calvert. TCP/IP sockets in
More informationOutline. Distributed Computing Systems. Socket Basics (1 of 2) Socket Basics (2 of 2) 3/28/2014
Outline Distributed Computing Systems Sockets Socket basics Socket details (TCP and UDP) Socket options Final notes Socket Basics (1 of 2) An end-point for an Internet network connection what application
More informationPorts under 1024 are often considered special, and usually require special OS privileges to use.
1 2 Turns out that besides an IP address (used by the IP layer), there is another address that is used by TCP (stream sockets) and, coincidentally, by UDP (datagram sockets). It is the port number. It's
More informationTCP: Three-way handshake
Sockets in C 1 Sockets in C The slides by themselves will not be sufficient to learn how to write socket code. If you did not attend class, then you will want to review the relevant chapters in Kerrisk
More informationHyo-bong Son Computer Systems Laboratory Sungkyunkwan University
Sockets Hyo-bong Son (proshb@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Client-Server Model Most network application is based on the client-server model: A server
More informationCSE 333 SECTION 8. Sockets, Network Programming
CSE 333 SECTION 8 Sockets, Network Programming Overview Domain Name Service (DNS) Client side network programming steps and calls Server side network programming steps and calls dig and ncat tools Network
More informationOutline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer.
Outline Distributed Computer Systems Socket basics Socket details (TCP and UDP) Socket options Final notes Sockets Socket Basics An end-point for a IP network connection what the application layer plugs
More informationCSE 333 SECTION 6. Networking and sockets
CSE 333 SECTION 6 Networking and sockets Overview Network Sockets IP addresses and IP address structures in C/C++ DNS Resolving DNS names Demos Section exercise Sockets Network sockets are network interfaces
More informationCSE 333 SECTION 7. Client-Side Network Programming
CSE 333 SECTION 7 Client-Side Network Programming Overview Domain Name Service (DNS) Client side network programming steps and calls dig and ncat tools Network programming for the client side Recall the
More informationCSE 333 SECTION 7. C++ Virtual Functions and Client-Side Network Programming
CSE 333 SECTION 7 C++ Virtual Functions and Client-Side Network Programming Overview Virtual functions summary and worksheet Domain Name Service (DNS) Client side network programming steps and calls dig
More informationChapter 6. The Transport Layer. Transport Layer 3-1
Chapter 6 The Transport Layer Transport Layer 3-1 Transport services and protocols provide logical communication between app processes running on different hosts transport protocols run in end systems
More informationProgramming Internet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806
Programming Internet with Socket API Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806 10/19/2015 CSCI 445 - Fall 2015 1 Acknowledgements Some pictures
More informationUNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.
UNIX Sockets Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E. Socket and Process Communication application layer User Process Socket transport layer (TCP/UDP) network layer (IP)
More informationEEC-484/584 Computer Networks
EEC-484/584 Computer Networks Lecture 15 wenbing@ieee.org (Lecture nodes are based on materials supplied by Dr. Louise Moser at UCSB and Prentice-Hall) Outline 2 Review of last lecture The network layer
More informationGroup-A Assignment No. 6
Group-A Assignment No. 6 R N Oral Total Dated Sign (2) (5) (3) (10) Title : File Transfer using TCP Socket Problem Definition: Use Python for Socket Programming to connect two or more PCs to share a text
More informationAnnouncements. CS 5565 Network Architecture and Protocols. Queuing. Demultiplexing. Demultiplexing Issues (1) Demultiplexing Issues (2)
Announcements CS 5565 Network Architecture and Protocols Problem Set 1 due Feb 18 Project 1A due Feb 19 Lecture 5 Godmar Back 2 Queuing Demultiplexing send queues Layer k+1 Layer k recv queues End systems
More informationSocket Programming TCP UDP
Socket Programming TCP UDP Introduction Computer Network hosts, routers, communication channels Hosts run applications Routers forward information Packets: sequence of bytes contain control information
More informationTutorial on Socket Programming
Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Hao Wang (Slides are mainly from Seyed Hossein Mortazavi, Monia Ghobadi, and Amin Tootoonchian, ) 1 Outline Client-server
More informationCS321: Computer Networks Introduction to Application Layer
CS321: Computer Networks Introduction to Application Layer Dr. Manas Khatua Assistant Professor Dept. of CSE IIT Jodhpur E-mail: manaskhatua@iitj.ac.in Basic Application layer provides services to the
More informationCSE 333 SECTION 7. Client-Side Network Programming
CSE 333 SECTION 7 Client-Side Network Programming Overview Homework 3 due tonight Questions? Domain Name Service (DNS) Review Client side network programming steps and calls intro dig tool Network programming
More informationSTUDY OF SOCKET PROGRAMMING
STUDY OF SOCKET PROGRAMMING Sockets : An application programming interface(api) used for inter process communication. Sockets allow communication between two different processes on the same or different
More informationNetwork Socket Programming - 3 BUPT/QMUL
Network Socket Programming - 3 BUPT/QMUL 2018-04-02 Agenda Basic concepts in NP Introduction to IP & TCP/UDP Introduction to Sockets 2 Introduction to Sockets Reviews of some helpful points Sockets interface
More informationNetwork Socket Programming - 3 BUPT/QMUL
Network Socket Programming - 3 BUPT/QMUL 2017-3-27 Agenda Basic concepts in NP Introduction to IP & TCP/UDP Introduction to Sockets 2 Introduction to Sockets Reviews of some helpful points Sockets interface
More informationOutline. Operating Systems. Socket Basics An end-point for a IP network connection. Ports. Network Communication. Sockets and the OS
Outline Operating Systems Socket basics Socket details Socket options Final notes Project 3 Sockets Socket Basics An end-point for a IP network connection what the application layer plugs into programmer
More informationNetwork programming(i) Lenuta Alboaie
Network programming(i) Lenuta Alboaie adria@info.uaic.ro 2017 2018 Computer Network http://www.info.uaic.ro/~computernetworks 1 Content Client/server paradigm API for network programming BSD Socket Characteristics
More informationCS321: Computer Networks Socket Programming
CS321: Computer Networks Socket Programming Dr. Manas Khatua Assistant Professor Dept. of CSE IIT Jodhpur E-mail: manaskhatua@iitj.ac.in Socket Programming It shows how the network application programs
More informationIPv6 Porting Applications
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
More informationCSC209H Lecture 9. Dan Zingaro. March 11, 2015
CSC209H Lecture 9 Dan Zingaro March 11, 2015 Socket Programming (Kerrisk Ch 56, 57, 59) Pipes and signals are only useful for processes communicating on the same machine Sockets are a general interprocess
More informationCS 3516: Computer Networks
Welcome to CS 3516: Prof. Yanhua Li Time: 9:00am 9:50am M, T, R, and F Location: AK219 Fall 2018 A-term 1 Some slides are originally from the course materials of the textbook Computer Networking: A Top
More informationProgramming guidelines on transition to IPv6
Programming guidelines on transition to IPv6 Tomás P. de Miguel and Eva M. Castro tmiguel@dit.upm.es eva@gsyc.escet.urjc.es Department of Telematic Systems Engineering (DIT) Technical University of Madrid
More informationElementary TCP Sockets
Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens Distributed Computer Systems 1 socket interface Application 1 Application 2 socket interface user kernel user kernel
More informationSockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Sockets Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Internet Connections (1) Connection Clients and servers communicate by sending streams of
More informationA Socket Example. Haris Andrianakis & Angelos Stavrou George Mason University
A Socket Example & George Mason University Everything is a file descriptor Most socket system calls operate on file descriptors Server - Quick view socket() bind() listen() accept() send(), recv() close()
More informationLecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005
Followup symbolic link (soft link): pathname, can be across file systems, replacement of file will be active on all symbolic links, consumes at least an inode. hard link: pointers to an inode, only in
More informationIntroduction to Socket Programming
UNIT II - ELEMENTARY TCP SOCKETS Introduction to Socket Programming Introduction to Sockets Socket address Structures Byte ordering functions address conversion functions Elementary TCP Sockets socket,
More informationTypes (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar
Socket Programming What is a socket? Using sockets Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar - Advanced Data Communications:
More informationCSc 450/550 Computer Networks Network Architectures & Client-Server Model
CSc 450/550 Computer Networks Network Architectures & Client-Server Model Jianping Pan Summer 2007 5/17/07 CSc 450/550 1 Last lectures So far, nuts and bolts views of the Internet Internet evolution and
More informationContext. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement
Distributed Systems: Sockets Programming Alberto Bosio, Associate Professor UM Microelectronic Departement bosio@lirmm.fr Context Computer Network hosts, routers, communication channels Hosts run applications
More informationInternet applications
CSc 450/550 Computer Networks Worldwide Web Jianping Pan Summer 2006 5/18/06 CSc 450/550 1 Traditionally Internet applications remote login: e.g., telnet file transfer: e.g., FTP electronic mail: e.g.,
More informationProgramming with TCP/IP. Ram Dantu
1 Programming with TCP/IP Ram Dantu 2 Client Server Computing Although the Internet provides a basic communication service, the protocol software cannot initiate contact with, or accept contact from, a
More informationCS 640: Computer Networking
CS 640: Computer Networking Yu-Chi Lai Lecture 3 Network Programming Topics Client-server model Sockets interface Socket primitives Example code for echoclient and echoserver Debugging With GDB Programming
More informationSocket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme
Socket Programming Dr. -Ing. Abdalkarim Awad Informatik 7 Rechnernetze und Kommunikationssysteme Before we start Can you find the ip address of an interface? Can you find the mac address of an interface?
More informationSockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.
1 Sockets Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University http://nyx.skku.ac.kr Internet Connections (1) 2 Connection Clients and servers communicate by sending streams of bytes over
More informationCommunication. Sockets (Haviland Ch. 10)
Communication Sockets (Haviland Ch. 10) 1 Simple Web Request 5LFKDUG V+RPH3DJH &RXUVHV 5HVHDUFK 2 How do we find the server? Every computer on the Internet has an Internet address. Called an IP address
More informationSOCKET PROGRAMMING. What is a socket? Using sockets Types (Protocols) Associated functions Styles
LABORATORY SOCKET PROGRAMMING What is a socket? Using sockets Types (Protocols) Associated functions Styles 2 WHAT IS A SOCKET? An interface between application and network The application creates a socket
More informationIP Addresses, DNS. CSE 333 Summer Teaching Assistants: Renshu Gu William Kim Soumya Vasisht
IP Addresses, DNS CSE 333 Summer 2018 Instructor: Hal Perkins Teaching Assistants: Renshu Gu William Kim Soumya Vasisht Lecture Outline Network Programming Sockets API Network Addresses DNS Lookup 2 Files
More informationIP Addresses, DNS. CSE 333 Spring Instructor: Justin Hsia
IP Addresses, DNS CSE 333 Spring 2018 Instructor: Justin Hsia Teaching Assistants: Danny Allen Dennis Shao Eddie Huang Kevin Bi Jack Xu Matthew Neldam Michael Poulain Renshu Gu Robby Marver Waylon Huang
More informationNETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science
NETWORK PROGRAMMING CSC- 341 25 Instructor: Junaid Tariq, Lecturer, Department of Computer Science 26 9 Lecture Sockets as means for inter-process communication (IPC) application layer Client Process Socket
More informationPA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~
Sockets Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Dong-Yun Lee(dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu PA #2 Reviews set_name, get_name, del_name Will
More informationThe User Datagram Protocol
The User Datagram Protocol Stefan D. Bruda Winter 2018 UDP Very similar to the TCP in terms of API Dissimilar with TCP in terms of innards (and hence programming techniques) Many-to-many communication.
More informationSystems software design NETWORK COMMUNICATIONS & RPC SYSTEMS
Systems software design NETWORK COMMUNICATIONS & RPC SYSTEMS outline network programming BSD/POSIX Socket API RPC systems object-oriented bridges CORBA DCOM RMI WebServices WSDL/SOAP XML-RPC REST network
More informationCSE 333 Section 3. Thursday 12 April Thursday, April 12, 12
CSE 333 Section 3 Thursday 12 April 2012 Goals for Today 1. Overview IP addresses 2. Look at the IP address structures in C/C++ 3. Overview DNS 4. Talk about how to use DNS to translate IP addresses 5.
More informationSession NM056. Programming TCP/IP with Sockets. Geoff Bryant Process software
Session NM056 Programming TCP/IP with Sockets Geoff Bryant Process software Course Roadmap Slide 57 NM055 (11:00-12:00) Important Terms and Concepts TCP/IP and Client/Server Model Sockets and TLI Client/Server
More informationCSE 333 Lecture 16 - network programming intro
CSE 333 Lecture 16 - network programming intro Hal Perkins Department of Computer Science & Engineering University of Washington Today Network programming - dive into the Berkeley / POSIX sockets API -
More informationUDP CONNECT TO A SERVER
UDP The User Datagram Protocol Stefan D. Bruda Winter 2018 Very similar to the TCP in terms of API Dissimilar with TCP in terms of innards (and hence programming techniques) Many-to-many communication.
More informationCSE/EE 461 Lecture 14. Connections. Last Time. This Time. We began on the Transport layer. Focus How do we send information reliably?
CSE/EE 461 Lecture 14 Connections Last Time We began on the Transport layer Focus How do we send information reliably? Topics ARQ and sliding windows Application Presentation Session Transport Network
More informationReview. Preview. Closing a TCP Connection. Closing a TCP Connection. Port Numbers 11/27/2017. Packet Exchange for TCP Connection
Review Preview Algorithms and Issues in Client Software Design Client Architecture Identifying the Location of a Parsing an Address Argument Looking Up a Domain Name Looking Up a Well-Known Port by Name
More informationChristian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel
Internettechnologien (CS262) Socket Programming in C 4. März 2015 Christian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel
More informationSystem Programming. Sockets
Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Introducing 2 3 Internet
More informationCSE 333 Lecture network programming intro
CSE 333 Lecture 17 -- network programming intro Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington Administrivia HW3 due Thursday night HW4 out Friday morning -
More informationUNIX Network Programming. Overview of Socket API Network Programming Basics
UNIX Network Programming Overview of Socket API Network Programming Basics 1 Client-Server Model Client Machine A Network Server Machine B Web browser and server FTP client and server Telnet client and
More informationA Client-Server Exchange
Socket programming A Client-Server Exchange A server process and one or more client processes Server manages some resource. Server provides service by manipulating resource for clients. 1. Client sends
More informationProgramming Ethernet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806
Programming Ethernet with Socket API Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806 9/14/2015 CSCI 445 Fall 2015 1 Acknowledgements Some pictures
More informationDepartment of Computer Science
Department of Computer Science Notes on Interprocess Communication in Unix Jean Dollimore,Oct.1990, last revised Feb. 1996 These notes explain how you can write "distributed programs" in C or C++ running
More informationIntroduction to Network Programming in C/C++
Introduction to Network Programming in C/C++ 10.09.2009 Varun SINGH, Based on the slides by Joerg Ott and Carsten Bormann 1 Starting Point IDE Unix/Linux available in the department
More informationCS118 Discussion 1B, Week 1. Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm
CS118 Discussion 1B, Week 1 Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm 1 TA Taqi, PhD student in Computer Networking Discussion (1B): Bunche 1209, Fri 12:00 1:50 p.m. Office hours: Boelter Hall
More informationIntroduction to Network Programming using C/C++
Introduction to Network Programming using C/C++ Slides mostly prepared by Joerg Ott (TKK) and Olaf Bergmann (Uni Bremen TZI) 1 Would be giving brief introduction on... Parsing Command line Socket Related
More informationCS4700/CS5700 Fundamentals of Computer Networking
CS4700/CS5700 Fundamentals of Computer Networking Prof. Alan Mislove Lecture 3: Crash course in socket programming September 10th, 2009 Project 0 Goal: Familiarize you with socket programming in C Implement
More informationThe Berkeley Sockets API. Networked Systems Architecture 3 Lecture 4
The Berkeley Sockets API Networked Systems Architecture 3 Lecture 4 The Berkeley Sockets API Widely used low-level C networking API First introduced in 4.3BSD Unix Now available on most platforms: Linux,
More informationNetworked Applications: Sockets. Goals of Todayʼs Lecture. End System: Computer on the ʻNet. Client-server paradigm End systems Clients and servers
Networked Applications: Sockets CS 375: Computer Networks Spring 2009 Thomas Bressoud 1 Goals of Todayʼs Lecture Client-server paradigm End systems Clients and servers Sockets and Network Programming Socket
More informationNetworked Applications: Sockets. End System: Computer on the Net
Networked Applications: Sockets Topics Programmer s view of the Internet Sockets interface End System: Computer on the Net Internet Also known as a host 2 Page 1 Clients and Servers Client program Running
More informationUNIT IV- SOCKETS Part A
1. Define sockets - SOCKETS Part A A socket is a construct to provide a communication between computers. It hides the underlying networking concepts and provides us with an interface to communicate between
More informationProject 3. Reliable Data Transfer over UDP. NTU CSIE Computer Networks 2011 Spring
Project 3 Reliable Data Transfer over UDP NTU CSIE Computer Networks 2011 Spring Project Goal In Project 3, students are asked to understand and implement reliable data transfer mechanism over UDP. UDP
More informationAgenda. Before we start: Assignment #1. Routing in a wide area network. Protocols more concepts. Internetworking. Congestion control
Agenda Last time (Tues) No class Tuesday Jan 30 (Marty at conference) Will be made up Thurs Feb 8 / Fri Feb 9 This time Continue with Networks (chpt 3) Interprocess Communication (chpt 4) 1 st HW/PA out
More informationSocket Programming. What is a socket? Using sockets. Types (Protocols) Associated functions Styles
Socket Programming What is a socket? Using sockets Types (Protocols) Associated functions Styles We will look at using sockets in C Note: Java and C# sockets are conceptually quite similar 1 What is a
More informationSocket Programming. #In the name of Allah. Computer Engineering Department Sharif University of Technology CE443- Computer Networks
#In the name of Allah Computer Engineering Department Sharif University of Technology CE443- Computer Networks Socket Programming Acknowledgments: Lecture slides are from Computer networks course thought
More informationSOCKETS. COMP750 Distributed Systems
SOCKETS COMP750 Distributed Systems Sockets The Socket library is a traditional Application Program Interface (API) to the transport layer. Sockets were originally implemented in Unix systems and have
More informationProgramming Ethernet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806
Programming Ethernet with Socket API Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806 9/14/2016 CSCI 445 Fall 2016 1 Acknowledgements Some pictures
More informationCSMC 412. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala Set 2. September 15 CMSC417 Set 2 1
CSMC 412 Computer Networks Prof. Ashok K Agrawala 2015 Ashok Agrawala Set 2 September 15 CMSC417 Set 2 1 Contents Client-server paradigm End systems Clients and servers Sockets Socket abstraction Socket
More informationSockets 15H2. Inshik Song
Sockets 15H2 Inshik Song Internet CAU www server (www.cau.ac.kr) Your web browser (Internet Explorer/Safari) Sockets 2 How do we find the server? Every computer on the Internet has an Internet address.
More informationThe TCP Protocol Stack
The TCP Protocol Stack Michael Brockway February 16, 2018 Introduction - Layered archtecture Networking software is desgined in a layered fashion The bottom layer is the services offered by the underlying
More informationOutline. Option Types. Socket Options SWE 545. Socket Options. Out-of-Band Data. Advanced Socket. Many socket options are Boolean flags
Outline SWE 545 Socket Options POSIX name/address conversion Out-of-Band Data Advanced Socket Programming 2 Socket Options Various attributes that are used to determine the behavior of sockets Setting
More informationCS UDP: User Datagram Protocol, Other Transports, Sockets. congestion worse);
CS314-26 UDP: User Datagram Protocol, Other Transports, Sockets! IP is an unreliable datagram protocol " congestion or transmission errors cause lost packets " multiple routes may lead to out-of-order
More informationLecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation
Lecture 2 Outline Wireshark Project 1 posted, due in a week Lab from a different textbook Work through the lab and answer questions at the end Chapter 1 - Foundation 1.1 Applications 1.2 Requirements 1.3
More informationLecture 7 Overview. IPv6 Source: Chapter 12 of Stevens book Chapter 31 of Comer s book
Last Lecture Lecture 7 Overview Name and address conversions This Lecture IPv6 Source: Chapter 12 of Stevens book Chapter 31 of Comer s book Next Lecture Broadcast and multicast sockets Source: Chapters
More informationComputer Networks Prof. Ashok K. Agrawala
CMSC417 Computer Networks Prof. Ashok K. Agrawala 2018Ashok Agrawala September 6, 2018 Fall 2018 Sept 6, 2018 1 Overview Client-server paradigm End systems Clients and servers Sockets Socket abstraction
More informationThe BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1. Interprocess Communication (IPC) Work Individually (no groups)
The BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1 Work Individually (no groups) Due Date: in class, Monday, September 19 Robert T Olsen olsen@cswiscedu 7390CS Office Hours: 3-5T, 11-12F - exception
More informationSocket Programming 2007/03/28
Socket Programming 2007/03/28 Reference W. Richard Stevens, Unix Network Programming 2/e Volume 1,1998 James F. Kurose and Keith W. Ross, "Computer Networks: A Top-Down Approach Featuring the Internet
More informationNetwork Programming in C: The Berkeley Sockets API. Networked Systems 3 Laboratory Sessions
Network Programming in C: The Berkeley Sockets API Networked Systems 3 Laboratory Sessions The Berkeley Sockets API Widely used low-level C networking API First introduced in 4.3BSD Unix Now available
More informationUNIX Sockets. COS 461 Precept 1
UNIX Sockets COS 461 Precept 1 Socket and Process Communica;on application layer User Process Socket transport layer (TCP/UDP) OS network stack network layer (IP) link layer (e.g. ethernet) Internet Internet
More information