EmbeddedRelated.com
Forums

Using Static IP mode

Started by Steve January 31, 2005

Personally, I like to do a dhcp_release prior to switching over to static IP mode since it always tries to acquire a DHCP address once you’ve defined USE_DHCP. You can step through and see what dhcp_release and then ifconfig return and see if there are any errors when you are trying to configure things. If you had a packet sniffer setup, you would be able to see the Rabbit announce itself to the network and know what IP address it was using.

 

From: Steve Trigero [mailto:s...@yahoo.com]
Sent: Monday, January 31, 2005 3:52 PM
To: r...@yahoogroups.com
Subject: RE: [rabbit-semi] Using Static IP mode

 

Perhaps its the way I'm initializing the Rabbit for
Static IP mode.

This is my initialization code:

#define IFCONFIG_ETH0 \
        IFS_DOWN,     \
        IFS_DHCP, 0,  \
        IFS_IPADDR,   static_ip_adrs, \
        IFS_NETMASK,  net_mask init_enet()
{
   if( first_time )
      ifconfig(  IF_DEFAULT,
                 IFS_DHCP,    0,
                 IFS_IPADDR,  static_ip_adrs,
                 IFS_NETMASK, net_mask,
                 IFS_END );

      first_time = 0;
   else {  // Do this 5-seconds later..
     pd_havelink( 0 ){
       if ( use_dhcp ) {
         // do DHCP init
       }
       else {
          ifconfig(  IF_DEFAULT,
                     IFCONFIG_ETH0,
                     IFS_UP,
                     IFS_END );

       }
     }
   }
}

--- Steve Trigero <s...@yahoo.com> wrote:

>
> --- Dave Moore <d...@questcontrols.com> wrote:
>
> > When do you get the message?  When you try to
> telnet
> > into the Win98 box or
> > something?
>
> I'm using a Visual Basic application to connect to
> the
> Rabbit. When it issues the "Connect" command is when
> I
> get the error message.
>
> Steve
>
>




Are you missing "IFS_UP" in your first_time code ?
Looks like you have it in your other ifconfig code.

Regards,
Matt On Mon, 31 Jan 2005 12:51:52 -0800 (PST), Steve Trigero wrote:

>
>Perhaps its the way I'm initializing the Rabbit for
>Static IP mode.
>
>This is my initialization code:
>
>#define IFCONFIG_ETH0 \
> IFS_DOWN, \
> IFS_DHCP, 0, \
> IFS_IPADDR, static_ip_adrs, \
> IFS_NETMASK, net_mask >init_enet()
>{
> if( first_time )
> ifconfig( IF_DEFAULT,
> IFS_DHCP, 0,
> IFS_IPADDR, static_ip_adrs,
> IFS_NETMASK, net_mask,
> IFS_END );
>
> first_time = 0;
> else { // Do this 5-seconds later..
> pd_havelink( 0 ){
> if ( use_dhcp ) {
> // do DHCP init
> }
> else {
> ifconfig( IF_DEFAULT,
> IFCONFIG_ETH0,
> IFS_UP,
> IFS_END );
>
> }
> }
> }
>}




There is no IFS_UP is the "first_time" call to
ifconfig. That was intentional. After sock_init()
executes then the next ifconfig call sets IFS_UP.

I did find one problem with my code. It seems that
pd_havelink() does not return true when connected
peer-to-peer. So my intialization code for static IP
was not being executed. I rearrainged the code to only
call pd_havelink() when DHCP is the selected mode. Now
it calls the static IP mode ifconfig(), and it returns
zero, meaing success. But it still doesn't work. Even
a simple ping fails.

Steve --- mlinder <mlinder@mlin...> wrote:

> Are you missing "IFS_UP" in your first_time code ?
> Looks like you have it in your other ifconfig code.
>
> Regards,
> Matt > On Mon, 31 Jan 2005 12:51:52 -0800 (PST), Steve
> Trigero wrote:
>
> >
> >Perhaps its the way I'm initializing the Rabbit for
> >Static IP mode.
> >
> >This is my initialization code:
> >
> >#define IFCONFIG_ETH0 \
> > IFS_DOWN, \
> > IFS_DHCP, 0, \
> > IFS_IPADDR, static_ip_adrs, \
> > IFS_NETMASK, net_mask
> >
> >
> >init_enet()
> >{
> > if( first_time )
> > ifconfig( IF_DEFAULT,
> > IFS_DHCP, 0,
> > IFS_IPADDR, static_ip_adrs,
> > IFS_NETMASK, net_mask,
> > IFS_END );
> >
> > first_time = 0;
> > else { // Do this 5-seconds later..
> > pd_havelink( 0 ){
> > if ( use_dhcp ) {
> > // do DHCP init
> > }
> > else {
> > ifconfig( IF_DEFAULT,
> > IFCONFIG_ETH0,
> > IFS_UP,
> > IFS_END );
> >
> > }
> > }
> > }
> >} >
>




Ok, I've installed Ethereal and I managed to set a
filter to capture all traffic to port 2000, the TCP
port on the Rabbit that I'm trying to connect to.
I then ran my application and tried to connect. There
is one entry in the packet field, from my PC to the
Rabbit.

Now, what does it all mean?

Steve


It was probably an ARP request - right? The PC is saying "Who has address w.x.y.z?", and the RCM3000 should say "I DO! I DO!" and return it's MAC address to the PC - which will promptly put it in it's ARP cache for future reference.

Open a DOS window on the PC and enter 'arp -a' at the C:\> prompt. See if the address of the RCM3000 shows up in the list. My guess is it won't. So I think you still don't have the RCM3000 ready to talk - at least it probably isn't answering ARP's. You can make a manual entry in the ARP table in NT, 2000, and XP - not sure about Win98.

I think TCP/IP stack for the RCM3000 handles ARP requests natively - you shouldn't have to code anything up to make it respond to ARP's.

Arlen

----- Original Message -----
From: Steve Trigero <seecwriter@seec...>
Date: Monday, January 31, 2005 3:13 pm
Subject: RE: [rabbit-semi] Using Static IP mode

>
> Ok, I've installed Ethereal and I managed to set a
> filter to capture all traffic to port 2000, the TCP
> port on the Rabbit that I'm trying to connect to.
> I then ran my application and tried to connect. There
> is one entry in the packet field, from my PC to the
> Rabbit.
>
> Now, what does it all mean?
>
> Steve >
>
> Yahoo! Groups Links




On Jan 31, 2005, at 2:17 PM, Steve Trigero wrote:
> I did find one problem with my code. It seems that
> pd_havelink() does not return true when connected
> peer-to-peer.

It should.

Are you connecting the Rabbit and PC to a hub and getting link lights
for both?

If you're connecting them directly to each other, you need to use an
Ethernet crossover cable (pin 1 to 3 and 2 to 6)?

--
Tom Collins - tom@tom@...
Rabbit Software Developer/Consultant based in Napa, California
Info on the Sniffter hand-held Network Tester: http://sniffter.com/


> On Jan 31, 2005, at 2:17 PM, Steve Trigero wrote:
>> I did find one problem with my code. It seems that
>> pd_havelink() does not return true when connected peer-to-peer.

It may take a while to negotiate it...stick a delay in there.


The PC and the Rabbit are connected peer-to-peer,
there is no hub involved. And the cable I'm using is
supposed to be a cross-over coble. I asked our IT
department for a cross-cable and this is what they
gave me. Its a different color (orange) than all the
other ethernet cables if seem around.

And I verified with the debugger that pd_havelink()
never returned true when connected peer-to-peer. But
if the cable is wrong...well, that's something I'll
have to verify tomorrow morning when I get in to work.

As I mentioned before, if I change the Rabbit to
operate in DHCP mode, all is well. I can connect and
communicate with no problem. The only difference is
the initialization code, specifically, the call to
ifconfig(). Steve
--- Tom Collins <tom@tom@...> wrote:

> On Jan 31, 2005, at 2:17 PM, Steve Trigero wrote:
> > I did find one problem with my code. It seems
> that
> > pd_havelink() does not return true when connected
> > peer-to-peer.
>
> It should.
>
> Are you connecting the Rabbit and PC to a hub and
> getting link lights
> for both?
>
> If you're connecting them directly to each other,
> you need to use an
> Ethernet crossover cable (pin 1 to 3 and 2 to 6)?
>
> --
> Tom Collins - tom@tom@...
> Rabbit Software Developer/Consultant based in Napa,
> California
> Info on the Sniffter hand-held Network Tester:
> http://sniffter.com/





--- Dave Moore <dmoore@dmoo...> wrote:

> > On Jan 31, 2005, at 2:17 PM, Steve Trigero wrote:
> >> I did find one problem with my code. It seems
> that
> >> pd_havelink() does not return true when
> connected peer-to-peer.
>
> It may take a while to negotiate it...stick a delay
> in there.
>

Stick a delay where?

Steve


Steve Trigero wrote:
> --- Dave Moore <dmoore@dmoo...> wrote:
>
>>> On Jan 31, 2005, at 2:17 PM, Steve Trigero wrote:
>>>> I did find one problem with my code. It seems that
>>>> pd_havelink() does not return true when connected peer-to-peer.
>>
>> It may take a while to negotiate it...stick a delay in there.
>>
>
> Stick a delay where?
>

After the initial sock_init and ifconfig. After you start everything up,
the ethernet chip has to negotiate the physical link. The dhcp process may
be masking that time delay for you. The static ip call may be somewhat
instantaneous. Make your call to ifconfig, delay 3 secs or so, then check
pd_havelink. You should also be able to see the link light on the rcm3000.
pd_havelink should be reflecting that status.

If you want, connect both the PC and the rabbit using "normal" cables to a
hub. Then you don't have to worry about the cross-over cable maybe causing
you problems.