ex2 2 sol spr06

Upload: phuc-nguyen-thai-vinh

Post on 04-Jun-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Ex2 2 Sol Spr06

    1/10

    Comprehensive Final Exam for Computer Networks Spring 2006

    >>> SOLUTIONS

  • 8/13/2019 Ex2 2 Sol Spr06

    2/10

    Problem #2

    Describe how email works. Describe the key components and flows. Identify key standards that apply.

    Use figures as needed. About 150 words should be sufficient.

    Email is an asynchronous communications medium based on sent and received text

    messages (may include non-text attachments). The three major components of emailare user agents, mail servers, and the SMTP (Simple Mail Transfer Protocol). SMTP

    is used to transfer messages between mail servers using TCP/IP (client/server).

    SMTP uses ASCII commands and headers. Commands are not authenticated. Between a

    mail server and a user agent, POP (Post Office Protocol), IMAP (Internet Mail

    Access Protocol), or HTTP (HyperText Transfer Protocol) is used to access received

    mail stored in inboxes on the mail server. Mail servers have a fixed IP address

    and are always powered-on. The user agents need not always be powered-on and also

    need not be fixed in location or IP address. The figure shows a user agent

    accessing a mail server with POP, two mail servers exchanging messages using SMTP,

    and another user agent accessing its mail server using IMAP.

    user agent server server user agent

    +-----+ POP +-----+ SMTP +-----+ IMAP +-----+

    | |---------| |---------| |---------| || | | | | | | |

    +-----+ +-----+ +-----+ +-----+

    |-------------------------------|

    The Internet

    Problem #3

    Attached are server.cand client.cwith some bugs. Identify the bugs and explain how to fix

    them.

    Server program:

    Missing welcome_s = socket() after line 25

    Missing htons() in line 28

    Missing bind() after line 29

    Listen must have more than 0 connections in line 31

    Missing addr_len assignment after line 32

    Missing +1 for strlen for \0 in line 38

    Should recv() on connect_s in line 38

    Should send() on connect_s in line 38

    Missing closesocket() of welcome_s after line 42

    Client program:

    Type of server_addr should be struct sickaddr_in in line 18

    Size of out_buf and in_buf is too small in lines 19 and 20

    Should be SOCK_STREAM and not DATAGRAM in line 24

    Missing htons() in line 28

    Missing +1 for strlen for \0 in line 36

  • 8/13/2019 Ex2 2 Sol Spr06

    3/10

    Problem #4

    Derive the formula for link utilization (U) for the stop-and-wait protocol. You may assume that a sender

    always has packets to send and that packets are never lost or in error. If other assumptions are needed to

    complete a reasonable derivation, state them.

    Problem #5

    Answer the following questions about TCP:

    a) Describe how TCP sets its retransmission time-out (RTO) value.

    The ideal RTO value would be the exact RTT for the current packet sent. TCP uses

    an algorithm to estimate the RTT value. The algorithm uses exponential smoothing

    (alpha is the smoothing parameter) to generate an SRTT (smoothed RTT) as a

    function of the last measured RTT sample and past history as SRTT(k+1) =

    alpha*SRTT(k) + (1 alpha)*RTT_sample(k+1). RTO(k+1) is then beta*SRTT(k+1). A

    more recent algorithm also estimates the variability in RTT and uses this

    variability estimate to add a value to SRTT(k+1) instead of just multiplying it by

    a fixed beta.

    b) Show the packet flows for TCP connection establishment and termination.

    t_pr

    t_fr

    t_proc

    t_proc

    t_pr

    t_ack

    data

    ack

    t_pr

    t_fr

    t_proc

    t_proc

    t_pr

    t_ack

    data

    ack

    We know U = t_useful / (t_useful + t_overhead).

    For SAW protocol we have the following time

    components, t_fr for data frame transmission,

    t_pr for propagation, t_proc for processing,

    and t_ack for ack frame transmission. We have:

    t_useful = t_fr

    t_overhead = 2t_pr + 2t_proc + t_ack.

    Thus U = t_fr / (t_fr + 2t_pr +2t_proc + t_ack).

    SYN

    SYN-ACK

    ACK

    FIN

    ACK

    FIN

    ACK

    Establish Terminate

    SYN

    SYN-ACK

    ACK

    FIN

    ACK

    FIN

    ACK

    Establish Terminate

  • 8/13/2019 Ex2 2 Sol Spr06

    4/10

    Problem #6

    Below are the first 60 bytes of a TCP/IP packet captured using Ethereal on an Ethernet network. On the

    last pages of this exam are packet header templates. Decode the packet for the following fields:

    - Ethernet MAC source and destination addresses (hexadecimal)- IP source and destination addresses (in standard dotted-decimal format)

    - TCP source and destination port numbers (decimal)- Type of TCP segment (e.g., SYN, FIN, ACK, etc.)- Application layer protocol (and command, if applicable)

    08 00 20 f7 88 7d 00 11 43 b7 92 43 08 00 45 00 .. ..}..C..C..E.

    02 4b 1f f8 40 00 80 06 ca 9b 83 f7 03 2a 83 f7 .K..@........*..

    03 01 08 68 00 50 e0 5a 79 da 38 0b ef 53 50 18 ...h.P.Zy.8..SP.

    ff ff 80 d7 00 00 47 45 54 20 2f 7e 63 68 72 69 ......GET /~chri

    73 74 65 6e 2f 63 68 72 69 73 74 65 6e 2e 68 74 sten/christen.ht

    6d 6c 20 48 54 54 50 2f 31 2e 31 0d 0a 48 6f 73 ml HTTP/1.1..Hos

    MAC source = 080020f7887d hex

    MAC dest = 001143b79243 hexIP source = 131.247.3.42

    IP dest = 131.247.3.1

    TCP source port = 2152

    TCP dest port = 80

    TCP type = PUSH, ACK

    Application = HTTP (this is an HTTP 1.1 GET)

    Problem #7

    Answer the following questions about LANs (wired and wireless):

    a) What is a LAN? Define it precisely.

    A LAN is a data network optimized for a medium-sized area (10s to 100s of stations

    and 100s to 1000s of meters). A LAN is owned and operated by a single

    organization.

    b) Describe CSMA/CD and BEB as used in IEEE 802.3 Ethernet.

    CSMA/CD is Carrier Sense Multiple Access / Collision Detection and enables the

    sharing of a wired medium among multiple hosts. A 1-persistent CSMA algorithm is

    implemented as follows (for when a host has a frame to transmit):

    1) if medium is idle then transmit

    2) if medium is busy then wait for medium to go idle and then transmit3) if detect a collision then xmit a brief jam signal, stop transmitting,

    wait a random period of time, then (1)

    The "wait a random period of time" is implemented with Binary Exponential Backoff:

    while (attempts < 16)

    k = min(attempts, 10)

    r = rand(0, 2^k)

    delay = r * slot_time

  • 8/13/2019 Ex2 2 Sol Spr06

    5/10

    A slot_time is the time it takes to transmit 64 bytes. This time determines the

    maximum span of an Ethernet (i.e., tpr

  • 8/13/2019 Ex2 2 Sol Spr06

    6/10

    Problem #9

    IEEE 802.11 WiFi uses three address fields in its frame format to forward packets from a host in a hotspot

    to the Internet and from the Internet to a host in a hotspot. Assume that a WiFi access point (AP) isconnected to a router port via an Ethernet link. Describe the packet flow from WiFi host to Internet and

    from Internet to WiFi host. Carefully identify the contents of all WiFi and Ethernet addresses fields.

    From host to AP to router port:

    Host to AP: WiFi frame has addr1 = AP MAC, addr2 = host MAC, addr3 = router MAC

    AP to router: Ethernet frame has DA = router MAC and SA = host MAC

    From router port to AP to host:

    Router to AP: Ethernet frame has DA = host MAC, SA = router MAC

    AP to host: WiFi frame has addr1 = host MAC, addr2 =AP MAC, addr3 = router MAC

    Problem #10

    Answer the following questions about multimedia networking and security:

    a) What is a jitter buffer? How does it work? Why is it needed?

    A jitter buffer is a FIFO queue in a receiving host where prefetched video (or

    audio) data is played-out. The playout rate is the same as the sender rate. The

    amount of pre-fetched data is such that it can tolerate delay variability in the

    network without starving (running out of data). A jitter buffer is needed to

    guarantee a needed constant playout rate (i.e., the same constant rate as at the

    sender) to the decoder in the receiver.

    b) If we were to design a next generation network that would give QoS guarantees, what are the four basic

    principles (or pillars) needed for this network?

    The four pillars are packet classification, isolation, call admission, and high

    utilization.

    c) What are the three desirable properties of secure communications? Describe each property in one

    sentence.

    The three properties are confidentiality, authentication, and integrity.

    Confidentiality is that only sender and receiver should be able to understand the

    message transmitted. Authentication is to confirm or prove the identity of the

    sender or receiver in the communication. Integrity assures that the message

    transmitted is not altered maliciously or by accident to achieve non-repudiation.

    Extra Credit

    Give 40 networking-related acronyms (covered in this class, or in the textbook) and define them. Forexample, TCP = Transmission Control Protocol is good. MCSE = Microsoft Certified Systems

    Engineering is not good (we did not cover this topic or acronym in class).

    No specific solution. To be graded individually. Key is that the acronym is

    related to networking.

  • 8/13/2019 Ex2 2 Sol Spr06

    7/10

  • 8/13/2019 Ex2 2 Sol Spr06

    8/10

    1. //======================================================= file = client.c =====2. //= A message "client" program to demonstrate sockets programming =3. //= - TCP/IP client/server model is implemented =4. //=============================================================================

    5. //----- Include files ---------------------------------------------------------6. #include // Needed for printf()7. #include // Needed for memcpy() and strcpy()8. #include // Needed for all Winsock stuff

    9. //----- Defines ---------------------------------------------------------------10. #define PORT_NUM 1050 // Port number used at the server11. #define IP_ADDR "127.0.0.1" // IP address of server (*** HARDWIRED ***)

    12. //===== Main program ==========================================================13. void main(void)14. {15. WORD wVersionRequested = MAKEWORD(1,1); // Stuff for WSA functions16. WSADATA wsaData; // Stuff for WSA functions17. unsigned int client_s; // Client socket descriptor

    18. double server_addr; // Server Internet address19. char out_buf[10]; // Output buffer for data20. char in_buf[10]; // Input buffer for data

    21. // This stuff initializes winsock22. WSAStartup(wVersionRequested, &wsaData);

    23. // Create a client socket24. client_s = socket(AF_INET, DATAGRAM, 0);

    25. // Fill-in the server's address information and do a connect with the26. // listening server27. server_addr.sin_family = AF_INET;28. server_addr.sin_port = PORT_NUM;29. server_addr.sin_addr.s_addr = inet_addr(IP_ADDR);30. connect(client_s, (struct sockaddr *)&server_addr, sizeof(server_addr));

    31. // Receive from the server using the client socket32. recv(client_s, in_buf, sizeof(in_buf), 0);33. printf("Received from server... data = '%s' \n", in_buf);

    34. // Send to the server using the client socket35. strcpy(out_buf, "Test message from client to server");36. send(client_s, out_buf, strlen(out_buf), 0);

    37. // Close and clean-up38. closesocket(client_s);

    39. WSACleanup();40. }

  • 8/13/2019 Ex2 2 Sol Spr06

    9/10

  • 8/13/2019 Ex2 2 Sol Spr06

    10/10