Presentation is loading. Please wait.

Presentation is loading. Please wait.

ICMP Message Processing

Similar presentations


Presentation on theme: "ICMP Message Processing"— Presentation transcript:

1 ICMP Message Processing
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 Establish socket Establish ICMP packet 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.) Receive ICMP reply Calculate RTT
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= Receive time= Transmit time= Back time= RTT= icmp_type=14,icmp_code=0 Receive time= Transmit time= Back time= RTT=6

6 Turn In Source code Executing result (snapshot)

7 Turn In (cont.) Deadline Ftp Filename If you want to update
23:59, May 16, 2005 Ftp IP: Username/Password: comm93/comm93 Filename HW2_ID.doc eg.HW2_ doc If you want to update HW2_ID_new1.doc, HW2_ID_new2.doc …etc

8 Turn In (cont.) No late work is acceptable No cheat 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,碁峰


Download ppt "ICMP Message Processing"

Similar presentations


Ads by Google