Download presentation
Presentation is loading. Please wait.
Published byKathlyn Doyle Modified over 9 years ago
1
CS 145A Implementation Issues Netlab.caltech.edu/course
2
Topics of this thread How does the TCP/IP work? (roughly) How does the TCP/IP work? (roughly) (Very) Simple & basic tools on network engineering (Very) Simple & basic tools on network engineering Design and implementation of protocols Design and implementation of protocols
3
Mail lists CS145class.cs.caltech.edu CS145class.cs.caltech.edu CS145ta.cs.caltech.edu CS145ta.cs.caltech.edu
4
Today The topology of Internet The topology of Internet Naming Naming Packet transmission Packet transmission Stream Connection Stream Connection
5
What does the Internet look like? Example: (/sbin/traceroute) Example: (/sbin/traceroute) C:\>tracert cwis.usc.edu Tracing route to cwis.usc.edu [128.125.253.146] 1 <1 ms Jorgensen-RSM-44.caltech.edu [131.215.44.253] 2 <1 ms Booth-border.ilan.caltech.edu [131.215.254.254] 3 <1 ms CalREN-Caltech.caltech.edu [192.41.208.49] 4 <1 ms JPL--CIT.POS.calren2.net [198.32.248.5] 5 1 ms UCLA--JPL.POS.calren2.net [198.32.248.1] 6 1 ms ISI--UCLA.POS.calren2.net [198.32.248.29] 7 2 ms USC--ISI.POS.calren2.net [198.32.248.25] 8 3 ms rtr43-c2-gw.usc.edu [128.125.251.66] 9 2 ms rtr-gw-1.usc.edu [128.125.254.1] 10 2 ms cwis.usc.edu [128.125.253.146]
6
Topology of the Network
7
Global Network (From Quest)
8
Get your “ IDs ” on-line Example: (/sbin/ifconfig) Example: (/sbin/ifconfig) C:\>ipconfig – all Physical Address......... : 00-10-A4-79-F0-32 IP Address............ : 131.215.44.214 Subnet Mask........... : 255.255.255.0
9
Use of the IDs Application TCP/UDP IP MAC Physic
10
The Journey of a packet (1) 131.215.44.214 Application131.215.44.214: Send [MSG] to “ 128.125.253.146 : 5001 ” UDP IP MAC Physic
11
The Journey of a packet (1) 131.215.44.214 Application131.215.44.214: Send [MSG] to “ 128.125.253.146 : 5001 ” UDP UDP header + [MSG] Send to 128.125.253.146 IP MAC Physic
12
The Journey of a packet (1) 131.215.44.214 Application131.215.44.214: Send [MSG] to “ 128.125.253.146 : 5001 ” UDP UDP header + [MSG] Send to 128.125.253.146 IP IP header + UDP header + [MSG] Send to 131.215.44.253 (from routing table) Send to 00:90:6D:E7:D4:00 (from ARP) MAC Physic
13
The Journey of a packet (1) 131.215.44.214 Application131.215.44.214: Send [MSG] to “ 128.125.253.146 : 5001 ” UDP UDP header + [MSG] Send to 128.125.253.146 IP IP header + UDP header + [MSG] Send to 131.215.44.253 (from routing table) Send to 00:90:6D:E7:D4:00 (from ARP) MAC MAC header + IP + UDP + [MSG] Physic
14
The Journey of a packet (1) 131.215.44.214 Application131.215.44.214: Send [MSG] to “ 128.125.253.146 : 5001 ” UDP UDP header + [MSG] Send to 128.125.253.146 IP IP header + UDP header + [MSG] Send to 131.215.44.253 (from routing table) Send to 00:90:6D:E7:D4:00 (from ARP) MAC MAC header + IP + UDP + [MSG] Physic Send to the Ethernet
15
The Journey of a packet (1) 131.215.44.214->131.215.44.253
16
The Journey of a packet (2) 131.215.44.253 IP MAC Physic Get a packet From Ethernet It ’ s for 00:90:6D:E7:D4:00. That ’ s me. I should accept it.
17
The Journey of a packet (2) 131.215.44.253 IP MAC “ OK, I am 00:90:6D:E7:D4:00 ” Pass the packet to IP Physic Get a packet from ethernet for : 00:90:6D:E7:D4:00
18
The Journey of a packet (2) 131.215.44.253 IP [IP] Header: From 131.215.44.214 to “ 128.125.253.146 ” “ Should go to next router: 131.215.254.254 ” MAC “ OK, I am 00:90:6D:E7:D4:00 ” Pass the packet to IP Physic Get a packet from ethernet for: 00:90:6D:E7:D4:00
19
The Journey of a packet (2) 131.215.44.253 IP [IP] Header: From 131.215.44.214 to “ 128.125.253.146 ” “ Should go to next router: 131.215.254.254 ” Send to zz:zz:zz:zz:zz:zz (from ARP) MAC Physic
20
The Journey of a packet (2) 131.215.44.253 IP [IP] Header: From 131.215.44.214 to “ 128.125.253.146 ” “ Should go to next router: 131.215.254.254 ” Send to zz:zz:zz:zz:zz:zz (from ARP) MAC MAC header + IP + UDP + [MSG] Physic
21
The Journey of a packet (2) 131.215.44.253 IP [IP] Header: From 131.215.44.214 to “ 128.125.253.146 ” “ Should go to next router: 131.215.254.254 ” Send to zz:zz:zz:zz:zz:zz (from ARP) MAC MAC header + IP + UDP + [MSG] Physic Send to zz:zz:zz:zz:zz:zz
22
The Journey of a packet (2) 131.215.44.253->131.215.254.254
23
The Journey of a packet (n) 128.125.254.1->128.125.253.146
24
The Journey of a packet (n) 128.125.253.146 Application “ I want to receive something on port 5001 ” UDP Listening to the port 5001 IP MAC Physic
25
The Journey of a packet (n) 128.125.253.146 Application UDP Listening to the Port 5001 IP MAC Physic Get a packet from ethernet for yy:yy:yy:yy:yy:yy
26
The Journey of a packet (n) 128.125.253.146 Application UDP Listening to the Port 5001 IP MAC “ Yes, I am yy:yy:yy:yy:yy:yy ” Pass the packet to IP Physic Get a packet From ethernet for yy:yy:yy:yy:yy:yy
27
The Journey of a packet (n) 128.125.253.146 Application UDP Listening to port 5001 IP From 131.215.44.214 to 128.125.253.146:5001 “ Yes, I am 128.125.253.146. ” “ Is there any program listening to this port? ” “ Yes. One UDP is waiting. Pass it to UDP ” MAC “ Yes, I am yy:yy:yy:yy:yy:yy ” Pass the packet to IP Physic Get a packet From ethernet for yy:yy:yy:yy:yy:yy
28
The Journey of a packet (n) 128.125.253.146 Application Receive message from 131.215.44.214 UDP Pass to Application IP From 131.215.44.214 to 128.125.253.146 “ Yes, I am 128.125.253.146. ” “ Is there any program waiting for it? ” “ Yes. One application is waiting. Pass it to UDP ” MAC “ Yes, I am yy:yy:yy:yy:yy:yy ” Pass the packet to IP Physic Get a packet From Ethernet For yy:yy:yy:yy:yy:yy
29
Overview
30
Necessary Information (1) Where shall I pass the packet, for a given destination IP address? – Routing Table Where shall I pass the packet, for a given destination IP address? – Routing Table Exmaple: Exmaple: [weixl@orchestra:~]> route DestinationGatewayGen-maskFlagsInterface 131.215.44.0*255.255.255.0UEth0 127.0.0.0*255.0.0.0Ulo default131.215.44.2540.0.0.0UFEth0
31
Necessary Information (2) Where shall I pass the packet, for a given destination IP address? -- Arp Where shall I pass the packet, for a given destination IP address? -- Arp Exmaple: Exmaple: [weixl@orchestra:~]> arp -a 131.215.44.227 at 00:06:5B:DE:C5:72 on eth0 131.215.44.142 at 00:60:B0:7C:E8:02 on eth0 131.215.44.113 at 00:A0:C9:5A:26:6D on eth0 131.215.44.80 at 00:E0:81:02:7F:7B on eth0 131.215.44.254 at 00:00:0C:07:AC:01 on eth0 131.215.44.253 at 00:90:6D:E7:D4:00 on eth0 131.215.44.12 at 00:20:78:1B:13:2C on eth0 131.215.44.14 at 00:A0:C9:06:2F:2A on eth0
32
More Information (Bonus) Get your phone book (Domain Name Service). Get your phone book (Domain Name Service). Example: Example: [weixl@orchestra:~]> ping login.cs.caltech.edu PING orchestra.cs.caltech.edu (131.215.44.20) from 131.215.44.20 : 56(84) bytes of data. [weixl@orchestra:~]> freebsd- login.cs.caltech.edu (131.215.44.14) API: API:gethostbyname()
33
How does DNS work? www.mit.eduwww.mit.edu? www.mit.edu18.181.0.31
34
Connection
35
Streamless Connection ApplicationSocket_send/receiveDNS UDP UDP send/receive IP Routing (IP / ARP) MAC Ethernet or other LAN Physic Electronic/Optical signals
36
Stream Connection ApplicationSocket_send/receiveDNS TCP How to establish/maintain a connection? IP Routing (IP / ARP) MAC Ethernet/Token Ring or other direct links Physic Electronic/Optical signals
37
Stream Connection An Example: At: 1-626-395-3555 Call: DMV An Example: At: 1-626-395-3555 Call: DMV Prerequisite: Prerequisite: You know the number of DMV (1-800-777- 0133) You know the number of DMV (1-800-777- 0133) The service is now open at DMV. The service is now open at DMV. There is a link between the two phones. There is a link between the two phones.
38
Stream Connection Steps at your site: Establish the phone Establish the phone Dial the number Dial the number Select the service Select the service Talk Talk Hang up Hang up Steps at DMV: Establish the phone Establish the service on phone Accept your request Talk Hang Up An Example: At: 1-626-395-3555 Call: DMV An Example: At: 1-626-395-3555 Call: DMV
39
Stream Connection Steps at DMV: Establish the phone Establish the phone Establish the service on phone Establish the service on phone Accept your request Accept your request Talk to you Talk to you Hang Up Hang Up Steps at your site: Establish the phone Establish the phone Dial the number Dial the number Select the service Select the service Talk to the representative Talk to the representative Hang up Hang up
40
Stream Connection Steps at client’s site: Establish the socket Establish the socket Dial the number Dial the number Select the service Select the service Talk to the representative Talk to the representative Hang up Hang up Steps at server’s site: Establish the socket Establish the service Accept your request Talk to you Hang Up Steps at DMV: Establish the phone Establish the phone Establish the service on phone Establish the service on phone Accept your request Accept your request Talk to you Talk to you Hang Up Hang Up Steps at your site: Establish the phone Establish the phone Dial the number Dial the number Select the service Select the service Talk to the representative Talk to the representative Hang up Hang up
41
Stream Connection Steps at client’s site: Establish the socket Establish the socket Dial the number Dial the number Select the service Select the service Talk to the representative Talk to the representative Hang up Hang up Steps at server’s site: Establish the socket Bind socket to port & Listen Accept your request Talk to you Hang Up Steps at client’s site: Establish the socket Establish the socket Dial the number Dial the number Select the service Select the service Talk to the representative Talk to the representative Hang up Hang up Steps at server’s site: Establish the socket Establish the socket Establish the service on phone Establish the service on phone Accept your request Accept your request Talk to you Talk to you Hang Up Hang Up
42
Stream Connection Steps at client’s site: Establish the socket Establish the socket connect the address ( IP connect the address ( IP + port ) + port ) Talk to the representative Talk to the representative Hang up Hang up Steps at server’s site: Establish the socket Bind socket to a port & Listen Accept your request Talk to you Hang Up Steps at client’s site: Establish the socket Establish the socket Dial the number Dial the number Select the service Select the service Talk to the representative Talk to the representative Hang up Hang up Steps at server’s site: Establish the socket Establish the socket Bind socket to a port & Listen Bind socket to a port & Listen Accept your request Accept your request Talk to you Talk to you Hang Up Hang Up
43
Stream Connection Steps at client’s site: Establish the socket Establish the socket connect the address ( IP connect the address ( IP + port ) + port ) Talk Talk Hang up Hang up Steps at server’s site: Establish the socket Bind socket to a port & Listen Accept the request from client Talk to you Hang Up Steps at client’s site: Establish the socket Establish the socket connect the address ( IP connect the address ( IP + port ) + port ) Talk to the representative Talk to the representative Hang up Hang up Steps at server’s site: Establish the socket Establish the socket Bind socket to a port & Listen Bind socket to a port & Listen Accept your request Accept your request Talk to you Talk to you Hang Up Hang Up
44
Stream Connection Steps at client’s site: Establish the socket Establish the socket connect the address ( IP connect the address ( IP + port ) + port ) Send/Receive Data Send/Receive Data Hang up Hang up Steps at server’s site: Establish the socket Bind socket to a port & Listen Accept the request from client Send/Receive Data Hang Up Steps at client’s site: Establish the socket Establish the socket connect the address ( IP connect the address ( IP + port ) + port ) Talk Talk Hang up Hang up Steps at server’s site: Establish the socket Establish the socket Bind socket to a port & Listen Bind socket to a port & Listen Accept the request from client Accept the request from client Talk to you Talk to you Hang Up Hang Up
45
Stream Connection Steps at client’s site: Establish the socket Establish the socket connect the address ( IP connect the address ( IP + port ) + port ) Send/Receive Data Send/Receive Data Hang up Hang up Steps at server’s site: Establish the socket Bind socket to a port & Listen Accept the request from client Send/Receive Data Hang Up Steps at client’s site: Establish the socket Establish the socket connect the address ( IP connect the address ( IP + port ) + port ) Send/Receive Data Send/Receive Data Hang up Hang up Steps at server’s site: Establish the socket Establish the socket Bind socket to a port & Listen Bind socket to a port & Listen Accept the request from client Accept the request from client Send/Receive Data Send/Receive Data Hang Up Hang Up
46
Insight (from LinuxForum)
47
CS 145A Lab 1 Connection Netlab.caltech.edu/course
48
How to establish a connection? UDP UDP Steps at client’s site: Establish the socket Establish the socket Send Data to the address ( IP Send Data to the address ( IP + port ) + port ) Close the socket Close the socket Steps at server’s site: Establish the socket Establish the socket Bind socket to a port Bind socket to a port Receive Data Receive Data Close the socket Close the socket
49
How to establish a connection? TCP TCP Steps at client’s site: Establish the socket Establish the socket connect the address ( IP connect the address ( IP + port ) + port ) Send/Receive Data Send/Receive Data Close the socket Close the socket Steps at server’s site: Establish the socket Establish the socket Bind socket to a port & Listen Bind socket to a port & Listen Accept the request from client and create a new socket for communication Accept the request from client and create a new socket for communication Send/Receive Data on the new socket Send/Receive Data on the new socket Close the socket Close the socket
50
Tasks for Lab 1 Be familiar with the basic commands that we talked about in class (see those examples in the lecture). Be familiar with the basic commands that we talked about in class (see those examples in the lecture). Write a program ( “ server ” ) that can act as a Server Write a program ( “ server ” ) that can act as a Server Write a program ( “ udp client ” ) that can send UDP packets Write a program ( “ udp client ” ) that can send UDP packets Write a program ( “ tcp client ” ) that can send TCP packets Write a program ( “ tcp client ” ) that can send TCP packets
51
Server accept TCP connections in one port accept TCP connections in one port The server should “ talk ” with the clients. That is, the server return the same contents as the client sends to it. If the client does not send anything in 10 seconds, the server should actively disconnect the connection. The server should “ talk ” with the clients. That is, the server return the same contents as the client sends to it. If the client does not send anything in 10 seconds, the server should actively disconnect the connection. The server is able to “ talk ” with 5 different clients at the same time. The server should not keep more than 5 clients at the same time. The server is able to “ talk ” with 5 different clients at the same time. The server should not keep more than 5 clients at the same time.
52
Server accept UDP packets in one port (may be different from the TCP) accept UDP packets in one port (may be different from the TCP) The server should talk to the clients. The server should talk to the clients. The input format: Server Server (port 1 is for TCP, port2 is for UDP)
53
Tcp client send a message to the server, wait for several seconds, then disconnect. send a message to the server, wait for several seconds, then disconnect. Input format: tcpclient tcpclient is a number indicating the seconds the client should wait before disconnection. is a number indicating the seconds the client should wait before disconnection.
54
Udp client send a message to the server send a message to the server Input format: udpclient udpclient
55
Tips For the unknown commands, use “ man ” / “ info ” /Richard Stevens ’ book For the unknown commands, use “ man ” / “ info ” /Richard Stevens ’ book Testing: you can use “ telnet ” to test the server, use the server to test the clients. Testing: you can use “ telnet ” to test the server, use the server to test the clients. How to implement the “ disconnection after 10-sec? ” How to implement the “ disconnection after 10-sec? ” 1. Child-process 2. “ select ” 3. …
56
Submission (due Oct 18 th ) Task 1: route.txt arp.txt ifconfig.txt traceroute.txt Task 2: server.c; server.txt Task 3: udpclient.c; udpclient.txt Task 4: tcpclient.c; tcpclient.txt Mailto: cs145ta@cs.caltech.edu cs145ta@cs.caltech.edu (Do NOT send to cs145class@cs.caltech.edu ) cs145class@cs.caltech.edu Documents: How to use the program: compile, run … Your design, your testing, the problems you met Any other comments
57
Grading Correctness (70%) Correctness (70%) Documentation and comments (20%) Documentation and comments (20%) Program style (10%) Program style (10%) TA Hours Tue: 20:00 ~22:00 JRG 154 / 170 Tue: 20:00 ~22:00 JRG 154 / 170 Thu: 20:00 ~22:00 JRG 154 / 170 Thu: 20:00 ~22:00 JRG 154 / 170
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.