Docsity

Notes on Programming, Others, TCP, UD - Network Programming | CS 228, Study notes of Computer Science

Toggle sidebar
bg1
HTTP
1) Firefox has a setting browser. cache. check_doc_frequency entitled "Document is cache is
compared to document on network". The choices are "Every time", "Once per session", and "Never".
For instance, if "every time" is set then the cached document is compared to the servers version every
time the document is displayed to the user. If the documents differ, the new document is loaded. What
would be the most efficient way to implement this feature?
Use a 'Head' command where possible
Use a "Head" command with a 'Send-if-modified' if possible
Use a "Get" command with a "If-Modified-Since" if possible
Use a "Get" command with a "Send-date" or "Send-Etag" modifier if possible
None of these. It's actually ________________________________
2) You want everything to go right. What return code do you hope for from the server?
1. Something in the 100's
2. Something in the 200's
3. Something in the 300's
4. Something in the 400's
5. Something in the 500's
3) Using HTTP/1.1, how can you tell what type the incoming file is?
______________________________________________________________________________
4) Suppose you make an HTTP/1.0 request. You receive data in reply. How can you tell where the
metadata stops and the file contents begin?
Programming
1) As a receiver I execute the code ret = read(sock, buf, 1000); However, the sender
only sends 28 bytes and then closes the socket and then exist. What value will I get for 'ret'?
2) Spock has 3 piles of Mars sand. Kirk has 4 piles of Mars sand. If they put them together, how many
piles do they have? ______________
3) Consider the two programs below. What happens if I launch ONE server and the try and start TWO
clients at nearly the same time?
main() {
struct sockaddr_in sa;
int sa_len;
char hostname[1024];
sa.sin_port = htons(7777);
gethostname(hostname, 1024);
struct hostent *hp =
gethostbyname(localhostname);
bcopy((char *)hp->haddr, (char
*)&sa.sin_addr, hp->h_length);
int sock = socket(hp->h_addrtype,
SOCK_STREAM, 0);
main() {
struct sockaddr_in sa;
int sa_len;
sa.sin_port = htons(7777);
struct hostent *hp =
gethostbyname("euclid.nmu.edu");
bcopy((char *)hp->haddr, (char
*)&sa.sin_addr, hp->h_length);
int sock = socket(hp->h_addrtype,
SOCK_STREAM, 0);
pf3
pf4

Partial preview of the text

Download Notes on Programming, Others, TCP, UD - Network Programming | CS 228 and more Study notes Computer Science in PDF only on Docsity!

HTTP

  1. Firefox has a setting browser. cache. check_doc_frequency entitled "Document is cache is compared to document on network". The choices are "Every time", "Once per session", and "Never". For instance, if "every time" is set then the cached document is compared to the servers version every time the document is displayed to the user. If the documents differ, the new document is loaded. What would be the most efficient way to implement this feature? Use a 'Head' command where possible Use a "Head" command with a 'Send-if-modified' if possible Use a "Get" command with a "If-Modified-Since" if possible Use a "Get" command with a "Send-date" or "Send-Etag" modifier if possible None of these. It's actually ________________________________
  2. You want everything to go right. What return code do you hope for from the server?
  1. Something in the 100's
  2. Something in the 200's
  3. Something in the 300's
  4. Something in the 400's
  5. Something in the 500's
  1. Using HTTP/1.1, how can you tell what type the incoming file is?

  1. Suppose you make an HTTP/1.0 request. You receive data in reply. How can you tell where the metadata stops and the file contents begin? Programming
  2. As a receiver I execute the code ret = read(sock, buf, 1000); However, the sender only sends 28 bytes and then closes the socket and then exist. What value will I get for 'ret'?
  3. Spock has 3 piles of Mars sand. Kirk has 4 piles of Mars sand. If they put them together, how many piles do they have? ______________
  4. Consider the two programs below. What happens if I launch ONE server and the try and start TWO clients at nearly the same time? main() { struct sockaddr_in sa; int sa_len; char hostname[1024]; sa.sin_port = htons(7777); gethostname(hostname, 1024); struct hostent *hp = gethostbyname(localhostname); bcopy((char *)hp->haddr, (char *)&sa.sin_addr, hp->h_length); int sock = socket(hp->h_addrtype, SOCK_STREAM, 0); main() { struct sockaddr_in sa; int sa_len; sa.sin_port = htons(7777); struct hostent *hp = gethostbyname("euclid.nmu.edu"); bcopy((char *)hp->haddr, (char *)&sa.sin_addr, hp->h_length); int sock = socket(hp->h_addrtype, SOCK_STREAM, 0);

bind(s, (struct sockaddr *)&sa, sizeof(sa)); listen(s, 99); int fd = accept(s, (struct sockaddr *)&sa, (unsigned int *)sa_len); sleep(3600); // wait for one hour write(fd, "Hi\0", 3); } int fd = connect(sock, (struct sockaddr *)sa, sizeof(sa)); read(fd, buf, 1024); cout << buf << endl; } 4)What type of protocol does this program use? (Pick ALL that apply) TCP UDP IP Aloha

  1. Assume I run one client and one server from above, and no errors occur. Which of the following is true? (Pick exactly ONE) a) When the client finishes the connect call, the server has finished accept. b) When the server finishes the socket() call, the client must have finished it's socket() call. c) When the client is at connect(), the server is at bind(). d) Both the server and client will run gethostbyname at the same time.
  2. With what type of problems does one use fork() to handle multiple clients? What is a good indication that the fork() technique will work well? TCP/UDP/IP
  3. Suppose I start a TCP connection. I receive bytes 0 .... 1000, then 1001 ... 2000, then 5000 .. 6000. What byte number should my last ack contain?
  4. Suppose I am a TCP sender and a timeout occurs without receiving an ack. What should do? List two things?


  1. Suppose I am a TCP receiver and I receive a packet containing repeat data. What should I do?
  2. How many packets does it take to send a small HTTP request and get a small reply. Count all packets.
  3. (Source/Not Source) General Hospital is going to be attached to the Internet. Do computers attached to the internet generally choose the whole route when the packet is sent (source routing) or just choose the link to send the packet out on, trusting that the next computer in line can send it closer still to the destination
  4. Lost TCP ack's do not necessarily force a retransmission. Explain how this can happen?

5) Calculus !! What does this expression evaluate to? ___________ lim (^) x-->2 17

  1. Using DHCP, what must a client do if the server refuses to renew a lease and the lease period runs out?
  2. My IP number is 192.168.1.103. What is the host portion of my IP number? The host portion is the part that says 'which computer within the given network'. NETWORK ADDRESS TRANSLATION
  3. At my house we are using Network Address Translation to access the internet via our cable modem. When my computer goes to access www.ebay.com, what IP number does it use for the destination on the outgoing packets? The cable modem www.ebay.com something else my computer
  4. At my house we are using Network Address Translation to access the internet via our cable modem. When my computer goes to access www.ebay.com, what Ethernet MAC address does it use for the destination on the outgoing packets? The cable modem www.ebay.com something else my computer
  5. When www.ebay.com replies, what IP address does it use on the reply? The cable modem www.ebay.com something else my computer