cs 145a implementation issues
DESCRIPTION
CS 145A Implementation Issues. Netlab.caltech.edu/course. Topics of this thread. How does the TCP/IP work? (roughly) (Very) Simple & basic tools on network engineering Design and implementation of protocols. Mail lists. CS145class.cs.caltech.edu CS145ta.cs.caltech.edu. Today. - PowerPoint PPT PresentationTRANSCRIPT
CS 145ACS 145AImplementation Implementation
IssuesIssuesNetlab.caltech.edu/courseNetlab.caltech.edu/course
Topics of this threadTopics of this thread
How does the TCP/IP work? How does the TCP/IP work? (roughly)(roughly)
(Very) Simple & basic tools on (Very) Simple & basic tools on network engineeringnetwork engineering
Design and implementation of Design and implementation of protocolsprotocols
Mail listsMail lists
CS145class.cs.caltech.eduCS145class.cs.caltech.edu CS145ta.cs.caltech.eduCS145ta.cs.caltech.edu
TodayToday
The topology of InternetThe topology of Internet NamingNaming Packet transmissionPacket transmission Stream ConnectionStream Connection
What does the Internet What does the Internet look like?look like?
Example: (/sbin/traceroute) Example: (/sbin/traceroute) C:\>tracert cwis.usc.eduC:\>tracert cwis.usc.eduTracing route to cwis.usc.edu [128.125.253.146]Tracing route to cwis.usc.edu [128.125.253.146]1 <1 ms Jorgensen-RSM-44.caltech.edu [131.215.44.253]1 <1 ms Jorgensen-RSM-44.caltech.edu [131.215.44.253]2 <1 ms Booth-border.ilan.caltech.edu [131.215.254.254]2 <1 ms Booth-border.ilan.caltech.edu [131.215.254.254]3 <1 ms CalREN-Caltech.caltech.edu [192.41.208.49]3 <1 ms CalREN-Caltech.caltech.edu [192.41.208.49]4 <1 ms JPL--CIT.POS.calren2.net [198.32.248.5]4 <1 ms JPL--CIT.POS.calren2.net [198.32.248.5]5 1 ms UCLA--JPL.POS.calren2.net [198.32.248.1]5 1 ms UCLA--JPL.POS.calren2.net [198.32.248.1]6 1 ms ISI--UCLA.POS.calren2.net [198.32.248.29]6 1 ms ISI--UCLA.POS.calren2.net [198.32.248.29]7 2 ms USC--ISI.POS.calren2.net [198.32.248.25]7 2 ms USC--ISI.POS.calren2.net [198.32.248.25]8 3 ms rtr43-c2-gw.usc.edu [128.125.251.66]8 3 ms rtr43-c2-gw.usc.edu [128.125.251.66]9 2 ms rtr-gw-1.usc.edu [128.125.254.1]9 2 ms rtr-gw-1.usc.edu [128.125.254.1]10 2 ms cwis.usc.edu [128.125.253.146]10 2 ms cwis.usc.edu [128.125.253.146]
Topology of the NetworkTopology of the Network
131.215.44.214
131.215.44.253
131.215.254.254
192.41.
208.49
198.32.
248.5198.32.
248.1198.32.
248.29
198.32.
248.25
128.125.251.66
128.125.253.146
128.125.254.1
Global Network (From Global Network (From Quest)Quest)
Get your “IDs” on-lineGet your “IDs” on-line
Example: (/sbin/ifconfig)Example: (/sbin/ifconfig)C:\>ipconfig –allC:\>ipconfig –allPhysical Address. . . . . . . . . : 00-10-A4-7Physical Address. . . . . . . . . : 00-10-A4-7
9-F0-329-F0-32IP Address. . . . . . . . . . . . : 131.215.44.214IP Address. . . . . . . . . . . . : 131.215.44.214Subnet Mask . . . . . . . . . . . : 255.255.255.Subnet Mask . . . . . . . . . . . : 255.255.255.
00
Use of the IDsUse of the IDs
ApplicationApplication
TCP/UDPTCP/UDP
IPIP
MACMAC
PhysicPhysic
Physical Address00-10-A4-79-F0-32
I P Address131.215.44.214
ARP
Port Number80 / 23 / ...
The Journey of a packet (1)The Journey of a packet (1)131.215.44.214131.215.44.214
ApplicatioApplicationn
131.215.44.214:131.215.44.214:
Send [MSG] to “128.125.253.146 Send [MSG] to “128.125.253.146 : 5001”: 5001”
UDPUDP
IPIP
MACMAC
PhysicPhysic
131.215.44.214
131.215.44.253
131.215.254.254
The Journey of a packet (1)The Journey of a packet (1)131.215.44.214131.215.44.214
ApplicatioApplicationn
131.215.44.214:131.215.44.214:
Send [MSG] to “128.125.253.146 Send [MSG] to “128.125.253.146 : 5001”: 5001”
UDPUDP UDP header + [MSG]UDP header + [MSG]
Send to 128.125.253.146Send to 128.125.253.146
IPIP
MACMAC
PhysicPhysic
131.215.44.214
131.215.44.253
131.215.254.254
The Journey of a packet (1)The Journey of a packet (1)131.215.44.214131.215.44.214
ApplicatioApplicationn
131.215.44.214:131.215.44.214:
Send [MSG] to “128.125.253.146 Send [MSG] to “128.125.253.146 : 5001”: 5001”
UDPUDP UDP header + [MSG]UDP header + [MSG]
Send to 128.125.253.146Send to 128.125.253.146
IPIP IP header + UDP header + IP header + UDP header + [MSG][MSG]
Send to 131.215.44.253 (from Send to 131.215.44.253 (from routing table)routing table)
Send to 00:90:6D:E7:D4:00 Send to 00:90:6D:E7:D4:00 (from ARP)(from ARP)
MACMAC
PhysicPhysic
131.215.44.214
131.215.44.253
131.215.254.254
The Journey of a packet (1)The Journey of a packet (1)131.215.44.214131.215.44.214
ApplicatioApplicationn
131.215.44.214:131.215.44.214:
Send [MSG] to “128.125.253.146 Send [MSG] to “128.125.253.146 : 5001”: 5001”
UDPUDP UDP header + [MSG]UDP header + [MSG]
Send to 128.125.253.146Send to 128.125.253.146
IPIP IP header + UDP header + IP header + UDP header + [MSG][MSG]
Send to 131.215.44.253 (from Send to 131.215.44.253 (from routing table)routing table)
Send to 00:90:6D:E7:D4:00 Send to 00:90:6D:E7:D4:00 (from ARP)(from ARP)
MACMAC MAC header + IP + UDP + MAC header + IP + UDP + [MSG][MSG]
PhysicPhysic
131.215.44.214
131.215.44.253
131.215.254.254
The Journey of a packet (1)The Journey of a packet (1)131.215.44.214131.215.44.214
ApplicatioApplicationn
131.215.44.214:131.215.44.214:
Send [MSG] to “128.125.253.146 Send [MSG] to “128.125.253.146 : 5001”: 5001”
UDPUDP UDP header + [MSG]UDP header + [MSG]
Send to 128.125.253.146Send to 128.125.253.146
IPIP IP header + UDP header + IP header + UDP header + [MSG][MSG]
Send to 131.215.44.253 (from Send to 131.215.44.253 (from routing table)routing table)
Send to 00:90:6D:E7:D4:00 Send to 00:90:6D:E7:D4:00 (from ARP)(from ARP)
MACMAC MAC header + IP + UDP + MAC header + IP + UDP + [MSG][MSG]
PhysicPhysic Send to the EthernetSend to the Ethernet
131.215.44.214
131.215.44.253
131.215.254.254
The Journey of a packet (1)The Journey of a packet (1)131.215.44.214-131.215.44.214->131.215.44.253>131.215.44.253
131.215.44.214
131.215.44.253
131.215.254.254
192.41.
208.49
198.32.
248.5198.32.
248.1198.32.
248.29
198.32.
248.25
128.125.251.66
128.125.253.146
128.125.254.1
The Journey of a packet (2)The Journey of a packet (2)131.215.44.253131.215.44.253
IPIP
MACMAC
PhysicPhysic Get a packet From EthernetGet a packet From Ethernet
It’s for 00:90:6D:E7:D4:00. It’s for 00:90:6D:E7:D4:00.
That’s me. I should accept it.That’s me. I should accept it.
131.215.44.214
131.215.44.253
131.215.254.254
The Journey of a packet (2)The Journey of a packet (2)131.215.44.253131.215.44.253
IPIP
MACMAC ““OK, I am 00:90:6D:E7:D4:00”OK, I am 00:90:6D:E7:D4:00”
Pass the packet to IPPass the packet to IP
PhysicPhysic Get a packet from ethernet for : 00:Get a packet from ethernet for : 00:90:6D:E7:D4:0090:6D:E7:D4:00
131.215.44.214
131.215.44.253
131.215.254.254
The Journey of a packet (2)The Journey of a packet (2)131.215.44.253131.215.44.253
IPIP [IP] Header: [IP] Header:
From 131.215.44.214 to From 131.215.44.214 to “128.125.253.146”“128.125.253.146”
““Should go to next router: Should go to next router: 131.215.254.254”131.215.254.254”
MACMAC ““OK, I am 00:90:6D:E7:D4:00”OK, I am 00:90:6D:E7:D4:00”
Pass the packet to IPPass the packet to IP
PhysicPhysic Get a packet from ethernet for: 00:Get a packet from ethernet for: 00:90:6D:E7:D4:0090:6D:E7:D4:00
131.215.44.214
131.215.44.253
131.215.254.254
The Journey of a packet (2)The Journey of a packet (2) 131.215.44.253 131.215.44.253
IPIP [IP] Header: [IP] Header: From 131.215.44.214 to “128.125.2From 131.215.44.214 to “128.125.2
53.146”53.146”““Should go to next router: 131.215.Should go to next router: 131.215.
254.254”254.254”Send to zz:zz:zz:zz:zz:zz (from ARSend to zz:zz:zz:zz:zz:zz (from AR
P)P)MACMAC
PhysicPhysic
131.215.44.214
131.215.44.253
131.215.254.254
The Journey of a packet (2)The Journey of a packet (2) 131.215.44.253 131.215.44.253
IPIP [IP] Header: [IP] Header: From 131.215.44.214 to “128.125.2From 131.215.44.214 to “128.125.2
53.146”53.146”““Should go to next router: 131.215.Should go to next router: 131.215.
254.254”254.254”Send to zz:zz:zz:zz:zz:zz (from ARSend to zz:zz:zz:zz:zz:zz (from AR
P)P)MACMAC MAC header + IP + UDP + MAC header + IP + UDP +
[MSG][MSG]
PhysicPhysic
131.215.44.214
131.215.44.253
131.215.254.254
The Journey of a packet (2)The Journey of a packet (2) 131.215.44.253 131.215.44.253
IPIP [IP] Header: [IP] Header: From 131.215.44.214 to “128.125.2From 131.215.44.214 to “128.125.2
53.146”53.146”““Should go to next router: 131.215.Should go to next router: 131.215.
254.254”254.254”Send to zz:zz:zz:zz:zz:zz (from ARSend to zz:zz:zz:zz:zz:zz (from AR
P)P)MACMAC MAC header + IP + UDP + MAC header + IP + UDP +
[MSG][MSG]
PhysicPhysic Send to zz:zz:zz:zz:zz:zzSend to zz:zz:zz:zz:zz:zz
131.215.44.214
131.215.44.253
131.215.254.254
The Journey of a packet (2)The Journey of a packet (2)131.215.44.253-131.215.44.253-
>131.215.254.254>131.215.254.254131.215.44.214
131.215.44.253
131.215.254.254
192.41.
208.49
198.32.
248.5198.32.
248.1198.32.
248.29
198.32.
248.25
128.125.251.66
128.125.253.146
128.125.254.1
The Journey of a packet (n) The Journey of a packet (n) 128.125.254.1-128.125.254.1-
>128.125.253.146>128.125.253.146131.215.44.214
131.215.44.253
131.215.254.254
192.41.
208.49
198.32.
248.5198.32.
248.1198.32.
248.29
198.32.
248.25
128.125.251.66
128.125.253.146
128.125.254.1
The Journey of a packet (n)The Journey of a packet (n) 128.125.253.146 128.125.253.146
ApplicatiApplicationon
““I want to receive something on port 5I want to receive something on port 5001”001”
UDPUDP Listening to the port 5001Listening to the port 5001
IPIP
MACMAC
PhysicPhysic
The Journey of a packet (n)The Journey of a packet (n) 128.125.253.146 128.125.253.146
ApplicatiApplicationon
UDPUDP Listening to the Port 5001Listening to the Port 5001
IPIP
MACMAC
PhysicPhysic Get a packet from ethernetGet a packet from ethernetfor yy:yy:yy:yy:yy:yyfor yy:yy:yy:yy:yy:yy
The Journey of a packet (n)The Journey of a packet (n) 128.125.253.146 128.125.253.146
ApplicatiApplicationon
UDPUDP Listening to the Port 5001Listening to the Port 5001
IPIP
MACMAC ““Yes, I am yy:yy:yy:yy:yy:yy”Yes, I am yy:yy:yy:yy:yy:yy”Pass the packet to IPPass the packet to IP
PhysicPhysic Get a packet From ethernet forGet a packet From ethernet foryy:yy:yy:yy:yy:yyyy:yy:yy:yy:yy:yy
The Journey of a packet (n)The Journey of a packet (n) 128.125.253.146 128.125.253.146
ApplicatiApplicationon
UDPUDP Listening to port 5001Listening to port 5001
IPIP From 131.215.44.214 to From 131.215.44.214 to 128.125.253.146:5001128.125.253.146:5001
““Yes, I am 128.125.253.146. ”Yes, I am 128.125.253.146. ”
““Is there any program listening to Is there any program listening to this port?”this port?”
““Yes. One UDP is waiting. Pass it to Yes. One UDP is waiting. Pass it to UDP”UDP”
MACMAC ““Yes, I am yy:yy:yy:yy:yy:yy”Yes, I am yy:yy:yy:yy:yy:yy”Pass the packet to IPPass the packet to IP
PhysicPhysic Get a packet From ethernet forGet a packet From ethernet foryy:yy:yy:yy:yy:yyyy:yy:yy:yy:yy:yy
The Journey of a packet (n)The Journey of a packet (n) 128.125.253.146 128.125.253.146
ApplicatiApplicationon
Receive message from Receive message from 131.215.44.214131.215.44.214
UDPUDP Pass to ApplicationPass to Application
IPIP From 131.215.44.214 to From 131.215.44.214 to 128.125.253.146128.125.253.146
““Yes, I am 128.125.253.146. ”Yes, I am 128.125.253.146. ”
““Is there any program waiting for it?”Is there any program waiting for it?”
““Yes. One application is waiting. Pass Yes. One application is waiting. Pass it to UDP”it to UDP”
MACMAC ““Yes, I am yy:yy:yy:yy:yy:yy”Yes, I am yy:yy:yy:yy:yy:yy”Pass the packet to IPPass the packet to IP
PhysicPhysic Get a packet From EthernetGet a packet From EthernetFor yy:yy:yy:yy:yy:yyFor yy:yy:yy:yy:yy:yy
OverviewOverview
DirectLink
NetCardDriver
TCP 1
I P
TCP 2 UDP 1 UDP 2
NetCardDriver
TCP 1
I P
UDP 1
Directlink
NetCardDriver
NetCardDriver
TCP 1
I P
TCP 2 UDP 1 UDP 2
Necessary Information Necessary Information (1)(1)
Where shall I pass the packet, for a given Where shall I pass the packet, for a given destination IP address? – Routing Tabledestination IP address? – Routing Table
Exmaple:Exmaple:[weixl@orchestra:~]> route[weixl@orchestra:~]> route
DestinatiDestinationon
GatewayGateway Gen-maskGen-mask FlaFlagsgs
InterfaInterfacece
131.215.131.215.44.044.0
** 255.255.2255.255.255.055.0
UU Eth0Eth0
127.0.0.0 127.0.0.0 ** 255.0.0.0255.0.0.0 UU lolo
default default 131.215.44131.215.44.254.254
0.0.0.00.0.0.0 UFUF Eth0Eth0
Necessary Information Necessary Information (2)(2)
Where shall I pass the packet, for a given Where shall I pass the packet, for a given destination IP address? -- Arpdestination IP address? -- Arp
Exmaple:Exmaple:[weixl@orchestra:~]> arp -a[weixl@orchestra:~]> arp -a131.215.44.227 at 00:06:5B:DE:C5:72 on eth0131.215.44.227 at 00:06:5B:DE:C5:72 on eth0131.215.44.142 at 00:60:B0:7C:E8:02 on eth0131.215.44.142 at 00:60:B0:7C:E8:02 on eth0131.215.44.113 at 00:A0:C9:5A:26:6D on eth0131.215.44.113 at 00:A0:C9:5A:26:6D on eth0131.215.44.80 at 00:E0:81:02:7F:7B on eth0131.215.44.80 at 00:E0:81:02:7F:7B on eth0131.215.44.254 at 00:00:0C:07:AC:01 on eth0131.215.44.254 at 00:00:0C:07:AC:01 on eth0131.215.44.253 at 00:90:6D:E7:D4:00 on eth0131.215.44.253 at 00:90:6D:E7:D4:00 on eth0131.215.44.12 at 00:20:78:1B:13:2C on eth0131.215.44.12 at 00:20:78:1B:13:2C on eth0131.215.44.14 at 00:A0:C9:06:2F:2A on eth0131.215.44.14 at 00:A0:C9:06:2F:2A on eth0
More Information More Information (Bonus)(Bonus)
Get your phone book (Domain Name ServicGet your phone book (Domain Name Service).e).
Example:Example:[weixl@orchestra:~]> ping login.cs.caltech.e[weixl@orchestra:~]> ping login.cs.caltech.e
duduPING orchestra.cs.caltech.edu (131.215.44.2PING orchestra.cs.caltech.edu (131.215.44.2
0) from 131.215.44.20 : 56(84) bytes of data.0) from 131.215.44.20 : 56(84) bytes of data.[weixl@orchestra:~]> freebsd-login.cs.caltec[weixl@orchestra:~]> freebsd-login.cs.caltec
h.edu (131.215.44.14)h.edu (131.215.44.14) API:API:gethostbyname()gethostbyname()
How does DNS work?How does DNS work?
www.mit.eduwww.mit.edu??
18.181.0.3118.181.0.31
131.215.44.214
www.mit.edu?
131.215.44.113
131.215.44.227
HigherDNS
Server
ConnectionConnection
Streamless ConnectionStreamless ConnectionApplicationApplication Socket_send/receiveSocket_send/receive
DNSDNSUDPUDP UDP send/receiveUDP send/receive
IPIP Routing (IP / ARP)Routing (IP / ARP)
MACMAC Ethernet or other Ethernet or other LANLAN
PhysicPhysic Electronic/Optical Electronic/Optical signalssignals
Stream ConnectionStream Connection
ApplicationApplication Socket_send/receiveSocket_send/receiveDNSDNS
TCPTCP How to How to establish/maintain a establish/maintain a
connection?connection?
IPIP Routing (IP / ARP)Routing (IP / ARP)
MACMAC Ethernet/Token RingEthernet/Token Ring or other direct linksor other direct links
PhysicPhysic Electronic/Optical Electronic/Optical signalssignals
Stream ConnectionStream Connection
An Example: At: 1-626-395-3555 An Example: At: 1-626-395-3555 Call: DMVCall: DMV
Prerequisite: Prerequisite: You know the number of DMV (1-You know the number of DMV (1-
800-777-0133)800-777-0133) The service is now open at DMV.The service is now open at DMV. There is a link between the two There is a link between the two
phones.phones.
Stream ConnectionStream Connection
Steps at your site:Steps at your site:• Establish the phoneEstablish the phone• Dial the numberDial the number• Select the serviceSelect the service• TalkTalk• Hang upHang up
Steps at DMV:Steps at DMV:• Establish the phone Establish the phone • Establish the service on Establish the service on
phonephone• Accept your requestAccept your request• TalkTalk• Hang UpHang Up
An Example: At: 1-626-395-3555 Call: DMVAn Example: At: 1-626-395-3555 Call: DMV
Stream ConnectionStream Connection
Steps at DMV:Steps at DMV:• Establish the phoneEstablish the phone• Establish the service on Establish the service on
phonephone• Accept your requestAccept your request• Talk to youTalk to you• Hang UpHang Up
Steps at your site:Steps at your site:• Establish the phoneEstablish the phone• Dial the numberDial the number• Select the serviceSelect the service• Talk to the Talk to the
representativerepresentative• Hang upHang up
Stream ConnectionStream ConnectionSteps at Steps at client’sclient’s site: site:• Establish the Establish the socketsocket• Dial the numberDial the number• Select the serviceSelect the service• Talk to the Talk to the
representativerepresentative• Hang upHang up
Steps at Steps at server’s server’s site:site:• Establish the Establish the socketsocket• Establish the serviceEstablish the service• Accept your requestAccept your request• Talk to youTalk to you• Hang UpHang Up
Steps at DMV:Steps at DMV:• Establish the phoneEstablish the phone• Establish the service on Establish the service on
phonephone• Accept your requestAccept your request• Talk to youTalk to you• Hang UpHang Up
Steps at your site:Steps at your site:• Establish the phoneEstablish the phone• Dial the numberDial the number• Select the serviceSelect the service• Talk to the Talk to the
representativerepresentative• Hang upHang up
Stream ConnectionStream ConnectionSteps at Steps at client’sclient’s site: site:• Establish the Establish the socketsocket• Dial the numberDial the number• Select the serviceSelect the service• Talk to the Talk to the
representativerepresentative• Hang upHang up
Steps at Steps at server’s server’s site:site:• Establish the Establish the socketsocket• BindBind socket to port socket to port & &
ListenListen• Accept your requestAccept your request• Talk to youTalk to you• Hang UpHang Up
Steps at Steps at client’sclient’s site: site:• Establish the Establish the socketsocket• Dial the numberDial the number• Select the serviceSelect the service• Talk to the Talk to the
representativerepresentative• Hang upHang up
Steps at Steps at server’s server’s site:site:• Establish the Establish the socketsocket• Establish the service on Establish the service on
phonephone• Accept your requestAccept your request• Talk to youTalk to you• Hang UpHang Up
Stream ConnectionStream ConnectionSteps at Steps at client’sclient’s site: site:• Establish the Establish the socketsocket• connectconnect the address ( the address ( IPIP
+ + port port ))• Talk to the Talk to the
representativerepresentative• Hang upHang up
Steps at Steps at server’s server’s site:site:• Establish the Establish the socketsocket• Bind socket to a Bind socket to a port & port &
ListenListen• Accept your requestAccept your request• Talk to youTalk to you• Hang UpHang Up
Steps at Steps at client’sclient’s site: site:• Establish the Establish the socketsocket• Dial the numberDial the number• Select the serviceSelect the service• Talk to the Talk to the
representativerepresentative• Hang upHang up
Steps at Steps at server’s server’s site:site:• Establish the Establish the socketsocket• Bind socket to a Bind socket to a port & port &
ListenListen• Accept your requestAccept your request• Talk to youTalk to you• Hang UpHang Up
Stream ConnectionStream ConnectionSteps at Steps at client’sclient’s site: site:• Establish the Establish the socketsocket• connectconnect the address ( the address ( IPIP
+ + port port ))• TalkTalk• Hang upHang up
Steps at Steps at server’s server’s site:site:• Establish the Establish the socketsocket• Bind socket to a Bind socket to a port & port &
ListenListen• AcceptAccept the request from the request from
clientclient• Talk to youTalk to you• Hang UpHang Up
Steps at Steps at client’sclient’s site: site:• Establish the Establish the socketsocket• connectconnect the address ( the address ( IPIP
+ + port port ))• Talk to the Talk to the
representativerepresentative• Hang upHang up
Steps at Steps at server’s server’s site:site:• Establish the Establish the socketsocket• Bind socket to a Bind socket to a port & port &
ListenListen• Accept your requestAccept your request• Talk to youTalk to you• Hang UpHang Up
Stream ConnectionStream ConnectionSteps at Steps at client’sclient’s site: site:• Establish the Establish the socketsocket• connectconnect the address ( the address ( IPIP
+ + port port ))• Send/Receive DataSend/Receive Data• Hang upHang up
Steps at Steps at server’s server’s site:site:• Establish the Establish the socketsocket• Bind socket to a Bind socket to a port & port &
ListenListen• AcceptAccept the request from the request from
clientclient• Send/Receive DataSend/Receive Data• Hang UpHang Up
Steps at Steps at client’sclient’s site: site:• Establish the Establish the socketsocket• connectconnect the address ( the address ( IPIP
+ + port port ))• TalkTalk• Hang upHang up
Steps at Steps at server’s server’s site:site:• Establish the Establish the socketsocket• Bind socket to a Bind socket to a port & port &
ListenListen• AcceptAccept the request from the request from
clientclient• Talk to youTalk to you• Hang UpHang Up
Stream ConnectionStream ConnectionSteps at Steps at client’sclient’s site: site:• Establish the Establish the socketsocket• connectconnect the address ( the address ( IPIP
+ + port port ))• Send/Receive DataSend/Receive Data• Hang upHang up
Steps at Steps at server’s server’s site:site:• Establish the Establish the socketsocket• Bind socket to a Bind socket to a port & port &
ListenListen• AcceptAccept the request from the request from
clientclient• Send/Receive DataSend/Receive Data• Hang UpHang Up
Steps at Steps at client’sclient’s site: site:• Establish the Establish the socketsocket• connectconnect the address ( the address ( IPIP
+ + port port ))• Send/Receive DataSend/Receive Data• Hang upHang up
Steps at Steps at server’s server’s site:site:• Establish the Establish the socketsocket• Bind socket to a Bind socket to a port & port &
ListenListen• AcceptAccept the request from the request from
clientclient• Send/Receive DataSend/Receive Data• Hang UpHang Up
InsightInsight (from
LinuxFo (from
LinuxForum
)rum
)
CS 145A Lab 1CS 145A Lab 1ConnectionConnection
Netlab.caltech.edu/courseNetlab.caltech.edu/course
How to establish a How to establish a connection?connection?
UDPUDPSteps at Steps at client’sclient’s site: site:• Establish the Establish the socketsocket• Send Data to Send Data to the the
address ( address ( IPIP
+ + port port ))• Close the socketClose the socket
Steps at Steps at server’s server’s site:site:• Establish the Establish the socketsocket• Bind socket to a Bind socket to a portport• Receive DataReceive Data• Close the socketClose the socket
How to establish a How to establish a connection?connection?
TCPTCPSteps at Steps at client’sclient’s site: site:• Establish the socketEstablish the socket• connect the address connect the address
( IP( IP
+ port )+ port )• Send/Receive DataSend/Receive Data• Close the socketClose the socket
Steps at Steps at server’s server’s site:site:• Establish the socketEstablish the socket• Bind socket to a port & Bind socket to a port &
ListenListen• Accept the request from Accept the request from
client and client and create a new create a new socket for socket for communicationcommunication
• Send/Receive Data Send/Receive Data on on the new socketthe new socket
• Close the socketClose the socket
Tasks for Lab 1Tasks for Lab 1
Be familiar with the basic commands tBe familiar with the basic commands that we talked about in class (see those hat we talked about in class (see those examples in the lecture).examples in the lecture).
Write a program (“server”) that can Write a program (“server”) that can act as a Serveract as a Server
Write a program (“udp client”) that cWrite a program (“udp client”) that can send UDP packetsan send UDP packets
Write a program (“tcp client”) that cWrite a program (“tcp client”) that can send TCP packetsan send TCP packets
ServerServer accept TCP connections in one portaccept TCP connections in one port The server should “talk” with the clients. The server should “talk” with the clients.
That is, the server return the same That is, the server return the same contents as the client sends to it. If the contents as the client sends to it. If the client does not send anything in 10 client does not send anything in 10 seconds, the server should actively seconds, the server should actively disconnect the connection. disconnect the connection.
The server is able to “talk” with 5 The server is able to “talk” with 5 different clients at the same time. The different clients at the same time. The server should not keep more than 5 server should not keep more than 5 clients at the same time.clients at the same time.
Server Server
accept UDP packets in one port (may accept UDP packets in one port (may be different from the TCP) be different from the TCP)
The server should talk to the clients.The server should talk to the clients.
The input format:The input format:Server <port 1> <port2>Server <port 1> <port2>(port 1 is for TCP, port2 is for UDP)(port 1 is for TCP, port2 is for UDP)
Tcp clientTcp client send a message to the server, wait for ssend a message to the server, wait for s
everal seconds, then disconnect.everal seconds, then disconnect.Input format:Input format:tcpclient <host> <port> <message> <timtcpclient <host> <port> <message> <tim
e>e><time> is a number indicating the <time> is a number indicating the
seconds the client should wait before dseconds the client should wait before disconnection.isconnection.
Udp clientUdp client send a message to the serversend a message to the server
Input format:Input format:udpclient <host> <port> <message>udpclient <host> <port> <message>
TipsTips For the unknown commands, use For the unknown commands, use
“man”/ “info”/Richard Stevens’ book“man”/ “info”/Richard Stevens’ book Testing: you can use “telnet” to test Testing: you can use “telnet” to test
the server, use the server to test the the server, use the server to test the clients. clients.
How to implement the “disconnection How to implement the “disconnection after 10-sec?”after 10-sec?”
1.1. Child-processChild-process2.2. ““select”select”3.3. ……
Submission (due Submission (due Oct Oct 1818thth))
Task 1: route.txt arp.txt ifconfig.txt traceroute.txtTask 1: route.txt arp.txt ifconfig.txt traceroute.txtTask 2: server.c; server.txtTask 2: server.c; server.txtTask 3: udpclient.c; udpclient.txtTask 3: udpclient.c; udpclient.txtTask 4: tcpclient.c; tcpclient.txtTask 4: tcpclient.c; tcpclient.txtMailto: Mailto: [email protected]@cs.caltech.edu (Do NOT send to (Do NOT send to [email protected]@cs.caltech.edu ) )Documents:Documents: How to use the program: compile, run… How to use the program: compile, run… Your design, your testing, the problems you mYour design, your testing, the problems you m
etet Any other commentsAny other comments
GradingGrading
Correctness (70%) Correctness (70%) Documentation and comments (20%)Documentation and comments (20%) Program style (10%)Program style (10%)
TA HoursTA Hours
Tue: 20:00 ~22:00 JRG 154 / 170Tue: 20:00 ~22:00 JRG 154 / 170 Thu: 20:00 ~22:00 JRG 154 / 170Thu: 20:00 ~22:00 JRG 154 / 170