1 / 9

Homework Assignment #2

Homework Assignment #2. ICMP Message Processing. Homework Assignment #2: ICMP Message Processing. In this work, you are asked to use timestamp request/reply message to simulate the ping function and calculate the RTT value

bliss
Download Presentation

Homework Assignment #2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Homework Assignment #2 ICMP Message Processing

  2. Homework Assignment #2: ICMP Message Processing • In this work, you are asked to use timestamp request/reply message to simulate the ping function and calculate the RTT value • Write a program that send a ICMP timestamp request packet to a host, and receive ICMP timestamp reply packet • Furthermore, also calculate the round-trip time (RTT)

  3. Flowchart Start Header: #include <sys/types.h> #include <sys/socket.h> Define: int socket(int domain,int type,int protocol) The third parameter, Protocol, is ICMP Establish socket Header: #include <netinet/ip_icmp.h> struct icmp *icmp_hdr=(struct icmp *)buffer; //#define ICMP_TIMESTAMP icmp_hdr->icmp_type=13; icmp_hdr->icmp_code=0; Establish ICMP packet

  4. Flowchart (cont.) Use sendto() function Ex. sendto(sockfd,buffer,packsize,0,(struct sockaddr*)&addr,addr_len) Send ICMP request Use recvfrom() function Ex. recvfrom(sockfd,rbuf,sizeof(rbuf),0,NULL,NULL) Receive ICMP reply struct icmp *icmp_hdr_R=(struct iphdr*)(rbuf+20); 28~31 byte : original time(T1) 32~35 byte : receive time(T2) 36~40 byte : transmit time(T3) You need calculating back time by yourself (use time.h)(T4) RTT= (T4-T3) + (T2-T1) Calculate RTT

  5. Executable Command • Format: myping [addr] • Ex. • #myping 140.120.15.125 icmp_type= 13,icmp_code=0 Original time=11096271 Receive time=875902519 Transmit time=943274555 Back time=60140638416 RTT=-67372035 ------------------------------------------------ icmp_type=14,icmp_code=0 Original time=11096271 Receive time=11096271 Transmit time=11096271 Back time=11096276 RTT=6

  6. Turn In • Source code • Executing result (snapshot)

  7. Turn In (cont.) • Deadline • 23:59, Dec 22, 2005 • Ftp • IP:140.120.15.123 2222 • Username/Password: comm94/comm94 • Filename • HW2_ID.doc eg.HW2_79356001.doc • If you want to update • HW2_ID_new1.doc, HW2_ID_new2.doc …etc

  8. Turn In (cont.) • No late work is acceptable • You get zero if you miss the due day • No cheat work is acceptable • You get zero if you copy other people’s version

  9. Reference • Linux C/C++ 網路程式設計,金禾 • Linux C 函式庫參考手冊,旗標 • Linux Socket Programming,碁峰

More Related