Title: CS 145A Implementation Issues
1CS 145AImplementation Issues
- Netlab.caltech.edu/course
2Topics of this thread
- How does the TCP/IP work? (roughly)
- (Very) Simple basic tools on network
engineering - Design and implementation of protocols
3Mail lists
- CS145class.cs.caltech.edu
- CS145ta.cs.caltech.edu
4Today
- The topology of Internet
- Naming
- Packet transmission
- Stream Connection
5What does the Internet look like?
- Example (/sbin/traceroute)
- C\gttracert cwis.usc.edu
- Tracing route to cwis.usc.edu 128.125.253.146
- 1 lt1 ms Jorgensen-RSM-44.caltech.edu
131.215.44.253 - 2 lt1 ms Booth-border.ilan.caltech.edu
131.215.254.254 - 3 lt1 ms CalREN-Caltech.caltech.edu
192.41.208.49 - 4 lt1 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
6Topology of the Network
7Global Network (From Quest)
8Get your IDs on-line
- Example (/sbin/ifconfig)
- C\gtipconfig all
- Physical Address. . . . . . . . .
00-10-A4-79-F0-32 - IP Address. . . . . . . . . . . .
131.215.44.214 - Subnet Mask . . . . . . . . . . . 255.255.255.0
-
9Use of the IDs
Application
TCP/UDP
IP
MAC
Physic
10The Journey of a packet (1)131.215.44.214
Application 131.215.44.214 Send MSG to 128.125.253.146 5001
UDP
IP
MAC
Physic
11The Journey of a packet (1)131.215.44.214
Application 131.215.44.214 Send MSG to 128.125.253.146 5001
UDP UDP header MSG Send to 128.125.253.146
IP
MAC
Physic
12The Journey of a packet (1)131.215.44.214
Application 131.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 00906DE7D400 (from ARP)
MAC
Physic
13The Journey of a packet (1)131.215.44.214
Application 131.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 00906DE7D400 (from ARP)
MAC MAC header IP UDP MSG
Physic
14The Journey of a packet (1)131.215.44.214
Application 131.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 00906DE7D400 (from ARP)
MAC MAC header IP UDP MSG
Physic Send to the Ethernet
15The Journey of a packet (1)131.215.44.214-gt131.21
5.44.253
16The Journey of a packet (2)131.215.44.253
IP
MAC
Physic Get a packet From Ethernet Its for 00906DE7D400. Thats me. I should accept it.
17The Journey of a packet (2)131.215.44.253
IP
MAC OK, I am 00906DE7D400 Pass the packet to IP
Physic Get a packet from ethernet for 00906DE7D400
18The 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 00906DE7D400 Pass the packet to IP
Physic Get a packet from ethernet for 00906DE7D400
19The 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 zzzzzzzzzzzz (from ARP)
MAC
Physic
20The 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 zzzzzzzzzzzz (from ARP)
MAC MAC header IP UDP MSG
Physic
21The 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 zzzzzzzzzzzz (from ARP)
MAC MAC header IP UDP MSG
Physic Send to zzzzzzzzzzzz
22The Journey of a packet (2)131.215.44.253-gt131.21
5.254.254
23The Journey of a packet (n) 128.125.254.1-gt128.12
5.253.146
24The 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
25The 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 yyyyyyyyyyyy
26The Journey of a packet (n) 128.125.253.146
Application
UDP Listening to the Port 5001
IP
MAC Yes, I am yyyyyyyyyyyy Pass the packet to IP
Physic Get a packet From ethernet for yyyyyyyyyyyy
27The 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.1465001 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 yyyyyyyyyyyy Pass the packet to IP
Physic Get a packet From ethernet for yyyyyyyyyyyy
28The 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 yyyyyyyyyyyy Pass the packet to IP
Physic Get a packet From Ethernet For yyyyyyyyyyyy
29Overview
30Necessary Information (1)
- Where shall I pass the packet, for a given
destination IP address? Routing Table - Exmaple
- weixl_at_orchestragt route
Destination Gateway Gen-mask Flags Interface
131.215.44.0 255.255.255.0 U Eth0
127.0.0.0 255.0.0.0 U lo
default 131.215.44.254 0.0.0.0 UF Eth0
31Necessary Information (2)
- Where shall I pass the packet, for a given
destination IP address? -- Arp - Exmaple
- weixl_at_orchestragt arp -a
- 131.215.44.227 at 00065BDEC572 on eth0
- 131.215.44.142 at 0060B07CE802 on eth0
- 131.215.44.113 at 00A0C95A266D on eth0
- 131.215.44.80 at 00E081027F7B on eth0
- 131.215.44.254 at 00000C07AC01 on eth0
- 131.215.44.253 at 00906DE7D400 on eth0
- 131.215.44.12 at 0020781B132C on eth0
- 131.215.44.14 at 00A0C9062F2A on eth0
32More Information (Bonus)
- Get your phone book (Domain Name Service).
- Example
- weixl_at_orchestragt 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_at_orchestragt freebsd-login.cs.caltech.edu
(131.215.44.14) - API
- gethostbyname()
33How does DNS work?
34Connection
35Streamless Connection
Application Socket_send/receive DNS
UDP UDP send/receive
IP Routing (IP / ARP)
MAC Ethernet or other LAN
Physic Electronic/Optical signals
36Stream Connection
Application Socket_send/receive DNS
TCP How to establish/maintain a connection?
IP Routing (IP / ARP)
MAC Ethernet/Token Ring or other direct links
Physic Electronic/Optical signals
37Stream Connection
- An Example At 1-626-395-3555 Call DMV
- Prerequisite
- You know the number of DMV (1-800-777-0133)
- The service is now open at DMV.
- There is a link between the two phones.
38Stream Connection
- An Example At 1-626-395-3555 Call DMV
- Steps at your site
- Establish the phone
- Dial the number
- Select the service
- Talk
- Hang up
- Steps at DMV
- Establish the phone
- Establish the service on phone
- Accept your request
- Talk
- Hang Up
39Stream Connection
- Steps at your site
- Establish the phone
- Dial the number
- Select the service
- Talk to the representative
- Hang up
- Steps at DMV
- Establish the phone
- Establish the service on phone
- Accept your request
- Talk to you
- Hang Up
40Stream Connection
- Steps at clients site
- Establish the socket
- Dial the number
- Select the service
- Talk to the representative
- Hang up
- Steps at your site
- Establish the phone
- Dial the number
- Select the service
- Talk to the representative
- Hang up
- Steps at servers site
- Establish the socket
- Establish the service
- Accept your request
- Talk to you
- Hang Up
- Steps at DMV
- Establish the phone
- Establish the service on phone
- Accept your request
- Talk to you
- Hang Up
41Stream Connection
- Steps at clients site
- Establish the socket
- Dial the number
- Select the service
- Talk to the representative
- Hang up
- Steps at clients site
- Establish the socket
- Dial the number
- Select the service
- Talk to the representative
- Hang up
- Steps at servers site
- Establish the socket
- Bind socket to port Listen
- Accept your request
- Talk to you
- Hang Up
- Steps at servers site
- Establish the socket
- Establish the service on phone
- Accept your request
- Talk to you
- Hang Up
42Stream Connection
- Steps at clients site
- Establish the socket
- Dial the number
- Select the service
- Talk to the representative
- Hang up
- Steps at clients site
- Establish the socket
- connect the address ( IP
- port )
- Talk to the representative
- Hang up
- Steps at servers site
- Establish the socket
- Bind socket to a port Listen
- Accept your request
- Talk to you
- Hang Up
- Steps at servers site
- Establish the socket
- Bind socket to a port Listen
- Accept your request
- Talk to you
- Hang Up
43Stream Connection
- Steps at clients site
- Establish the socket
- connect the address ( IP
- port )
- Talk
- Hang up
- Steps at clients site
- Establish the socket
- connect the address ( IP
- port )
- Talk to the representative
- Hang up
- Steps at servers site
- Establish the socket
- Bind socket to a port Listen
- Accept the request from client
- Talk to you
- Hang Up
- Steps at servers site
- Establish the socket
- Bind socket to a port Listen
- Accept your request
- Talk to you
- Hang Up
44Stream Connection
- Steps at clients site
- Establish the socket
- connect the address ( IP
- port )
- Send/Receive Data
- Hang up
- Steps at clients site
- Establish the socket
- connect the address ( IP
- port )
- Talk
- Hang up
- Steps at servers site
- Establish the socket
- Bind socket to a port Listen
- Accept the request from client
- Send/Receive Data
- Hang Up
- Steps at servers site
- Establish the socket
- Bind socket to a port Listen
- Accept the request from client
- Talk to you
- Hang Up
45Stream Connection
- Steps at clients site
- Establish the socket
- connect the address ( IP
- port )
- Send/Receive Data
- Hang up
- Steps at clients site
- Establish the socket
- connect the address ( IP
- port )
- Send/Receive Data
- Hang up
- Steps at servers site
- Establish the socket
- Bind socket to a port Listen
- Accept the request from client
- Send/Receive Data
- Hang Up
- Steps at servers site
- Establish the socket
- Bind socket to a port Listen
- Accept the request from client
- Send/Receive Data
- Hang Up
46- Insight (from LinuxForum)
47CS 145A Lab 1Connection
- Netlab.caltech.edu/course
48How to establish a connection?
- Steps at clients site
- Establish the socket
- Send Data to the address ( IP
- port )
- Close the socket
- Steps at servers site
- Establish the socket
- Bind socket to a port
- Receive Data
- Close the socket
49How to establish a connection?
- Steps at clients site
- Establish the socket
- connect the address ( IP
- port )
- Send/Receive Data
- Close the socket
- Steps at servers site
- Establish the socket
- Bind socket to a port Listen
- Accept the request from client and create a new
socket for communication - Send/Receive Data on the new socket
- Close the socket
50Tasks for Lab 1
- 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 (udp client) that can send UDP
packets - Write a program (tcp client) that can send TCP
packets
51Server
- 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 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.
52Server
- accept UDP packets in one port (may be different
from the TCP) - The server should talk to the clients.
- The input format
- Server ltport 1gt ltport2gt
- (port 1 is for TCP, port2 is for UDP)
53Tcp client
- send a message to the server, wait for several
seconds, then disconnect. - Input format
- tcpclient lthostgt ltportgt ltmessagegt lttimegt
- lttimegt is a number indicating the seconds the
client should wait before disconnection.
54Udp client
- send a message to the server
- Input format
- udpclient lthostgt ltportgt ltmessagegt
55Tips
- 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. - How to implement the disconnection after
10-sec? - Child-process
- select
56Submission (due Oct 18th)
- 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_at_cs.caltech.edu
- (Do NOT send to cs145class_at_cs.caltech.edu )
- Documents
- How to use the program compile, run
- Your design, your testing, the problems you met
- Any other comments
57Grading
- Correctness (70)
- Documentation and comments (20)
- Program style (10)
TA Hours
- Tue 2000 2200 JRG 154 / 170
- Thu 2000 2200 JRG 154 / 170