TCP/IP Programming Basics Recall the Basics of TCP/IP
Total Page:16
File Type:pdf, Size:1020Kb
TCP/IP Programming Basics recall the basics of TCP/IP IP uses datagrams TCP uses segments TCP is stream-oriented (programs read and write byte streams to communicate) “client” initiates connection with “server” multiplexing (demultiplexing) uses ports programs use sockets what is the difference between socket and port? 1 the socket approach client and server (these are just names for the two applications at the endpoints of a connection) read from sockets, write to sockets, in the same way programs read from files and write to ¡ ¢¥¤ £ ¥¢ files using file descriptors like ¡£¢¥¤§¦©¨ , , etc client server sockets ports connection Host A Host B 2 useful programming background network programming is complicated because two programs are running at the same time (client and server) useful to have two windows, one for client, one for server can debug on one host, using loopback address name — ¥ ¥¡£¢ address — port — any number greater than 1024; usually choose some number greater than 5000 system call to get time of day system call to “timeout” if server unavailable networking calls to convert name into address, etc (see Pocket Socket Guide) know how to cast byte string in various ways be aware of different binary representations on different hard- ware multi-tasking basics needed if multiple concurrent clients per server 3 Linux and non-LAN Links modems, ISDN lines, etc — point to point links not covered here, but textbook covers some of these SLIP (Serial Line IP) PPP (Point-to-Point Protocol) SLiRP (TCP/IP emulator turning an ordinary shell into (C)SLIP/PPP) problem suppose host B is on the Internet, and we wish to have host A dial up (using SLIP/PPP) host B and then use Internet applications (www, etc) host A does not have an IP address (and even if DHCP used, host B may not have an extra IP address to give to host A) — what can be done? 4 A B C SLIP Internet host A unknown in global Internet (only dialed in to B) — how can C and A communicate? primitive solution: user on A uses ¢ ¨!"¢ to B (user must have account on host B), then all subsequent com- mands appear to originate at B note: even X-windows is possible ¤§¦&¡('§") *,+- (use command such as ¡#"¢$¨ % ) A B C packets for X-windows ftp, www, etc drawback: can’t copy file from C to A easily 5 proxy ARP idea: change ARP so that more than one IP address can be associated with an interface motivation: to “extend” LAN to hosts that aren’t really on the LAN x y dialup LAN host x has two IP addresses I1 and I2, one for itself (I1) and I2 for y, so that the any datagram with destination I2 will arrive on x’s interface if y isn’t dialed in when datagram with destination I2 arrives at x, then datagram will be discarded / note: for any host t in LAN, t . x, the ARP table for t can have two IP addresses (I1 and I2) for x’s hardware Ethernet address host x is similar to a gateway — but no need for a new subnet 6 more complicated use of proxy ARP x LAN not on Internet y1 y3 LAN on Internet y2 y4 proxy ARP associates all IP addresses of y1–y4 with x’s interface on primary (Internet) LAN — so other hosts send anything for y1–y4 to x’s interface host x can use netmask in routing table to route y1, y2, etc via secondary interface with one row in x’s routing table not a true subnet for more details, see Linux HOWTO for Proxy ARP 7 HTTP proxy www server http proxy web users (yahoo) using HTTP proxy server, many web users all appear (to yahoo) to have the same IP address — namely the proxy’s IP address acts as “concentrator” of web requests can be a shared cache of web pages security possibilities (hide real IP address of user) control possibilities (block some kinds of web pages) transparent to users (proxy is almost invisible) what are shared themes of Proxy ARP and HTTP Proxy? 1. one host acts on behalf of others ( / proxy) 2. to outside hosts, proxy is not visible implies no need to change Internet protocols and servers! this is important design principle! 8.