View previous topic :: View next topic |
Author |
Message |
TimC
Joined: 12 Nov 2005 Posts: 7
|
How do I send an ICMP packet? |
Posted: Mon Sep 25, 2006 10:51 am |
|
|
Hi all,
I am using the CCS Embedded Ethernet Dev kit and there are 2 examples in chapter 10 on receiving a response from a ICMP ping packet but I have no idea on how to send a ping request.
My project is to increment the TTL value for several Ping requests going to the same destination. I should be able to trace my Ping route as the number of hops exceeds the TTL value.
Thank You
Tim C |
|
|
erhan
Joined: 17 Aug 2005 Posts: 7
|
|
Posted: Fri Dec 15, 2006 2:29 am |
|
|
How can we send ping?My ip address=10.0.0.10
Code: | NODE_INFO PingDest;
int PingData[]={'e','r','h','a','n',0};
int16 SeqNo=0;
PingDest.MACAddr.v[0]= MY_MAC_BYTE1;
PingDest.MACAddr.v[1]= MY_MAC_BYTE2;
PingDest.MACAddr.v[2]= MY_MAC_BYTE3;
PingDest.MACAddr.v[3]= MY_MAC_BYTE4;
PingDest.MACAddr.v[4]= MY_MAC_BYTE5;
PingDest.MACAddr.v[5]= MY_MAC_BYTE6;
PingDest.IPAddr.v[0]=10;
PingDest.IPAddr.v[1]=0;
PingDest.IPAddr.v[2]=0;
PingDest.IPAddr.v[3]=25;
//ping
ICMPPut(&PingDest,ICMP_ECHO_REQUEST,&PingData[0],5,12,++SeqNo); |
This code did'nt work.I am watching bus with ethereal.it says 10.0.0.10 ping request but it doesn't say 10.0.0.25 echo reply. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Fri Dec 15, 2006 2:56 am |
|
|
There are a number of possible problems.
Ensure that the source MAC address of the outbound packet is a unicast MAC address
If the source MAC address unique?
Have you set the sunbet mask correctly?
Does the target have a personal firewall - if so is ICMP enabled (not blocked)?
Do you see an ARP request from the Target looking for the PIC? If so does the PIC respond? _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Last edited by asmallri on Fri Dec 15, 2006 5:15 am; edited 1 time in total |
|
|
erhan
Joined: 17 Aug 2005 Posts: 7
|
|
Posted: Fri Dec 15, 2006 3:18 am |
|
|
I know destination mac address so I don't have to do arp request.
I corrected my code like this
Code: | NODE_INFO PingDest;
int PingData[]={'e','r','h','a','n',0};
int16 SeqNo=0;
PingDest.MACAddr.v[0]= 0;
PingDest.MACAddr.v[1]= 0x17;
PingDest.MACAddr.v[2]= 0x31;
PingDest.MACAddr.v[3]= 0x2E;
PingDest.MACAddr.v[4]= 0x26;
PingDest.MACAddr.v[5]= 0xD5;
PingDest.IPAddr.v[0]=10;
PingDest.IPAddr.v[1]=0;
PingDest.IPAddr.v[2]=0;
PingDest.IPAddr.v[3]=25;
ICMPPut(&PingDest,ICMP_ECHO_REQUEST,&PingData[0],5,0,++SeqNo); |
Anyway now I can send ping.But I want to do arp request to learn destination mac address automatically.How can I do this |
|
|
erhan
Joined: 17 Aug 2005 Posts: 7
|
|
Posted: Fri Dec 15, 2006 7:10 am |
|
|
this is the working ping code with arp request
Code: |
void ping(IP_ADDR *IPAddr)
{
NODE_INFO remoteNode;
int PingData[]="abcdefghijklmnnopqrstuwxvyz12345";
int i;
static int SeqNo=0;
remoteNode.IPAddr = *IPAddr;
ArpResolve(&remoteNode.IPAddr.v[0]);
for(i=0;i<6;i++)
remoteNode.MACAddr.v[i]=Cache.MACAddr.v[i];
ICMPPut(&remoteNode,ICMP_ECHO_REQUEST,&PingData[0],32,0,SeqNo);
} |
in main
Code: | NODE_INFO PingDest;
PingDest.IPAddr.v[0]=10;
PingDest.IPAddr.v[1]=0;
PingDest.IPAddr.v[2]=0;
PingDest.IPAddr.v[3]=25;
ping(&PingDest.IPAddr.v[0]); |
|
|
|
dpechman
Joined: 04 Dec 2007 Posts: 43
|
|
Posted: Thu Mar 22, 2012 7:24 pm |
|
|
My ping stop working after I change another parts of the code and I cannot find the bug.
In icmp.c the MyTxBuffer is equal to INVALID_BUFFER.
If I bypass the avoid check the ping is sent and looks ok to the address that I have pointed to.
How is the right way to set the MyTxBuffer?
Code: |
void ICMPPut(NODE_INFO *remote,
ICMP_CODE code,
BYTE *data,
BYTE len,
WORD id,
WORD seq)
{
ICMP_PACKET packet;
WORD ICMPLen;
BUFFER MyTxBuffer;
MyTxBuffer = MACGetTxBuffer(TRUE);
// Abort if there is no where in the Ethernet controller to
// store this packet.
//if(MyTxBuffer == INVALID_BUFFER) <<==here is true
// return;
|
|
|
|
|