Shop OBEX P1 Docs P2 Docs Learn Events
ENC28J60 and router ? — Parallax Forums

ENC28J60 and router ?

catostaycatostay Posts: 8
edited 2009-05-24 23:45 in Propeller 1
I am trying to build an application to switch relays on and off trough TCP/IP using the ENC28J60 chip and the PropTCP drivers. I need to run my application with a static IP address. At this point I am able to switch LED's on and off trough telnet on my local network but I am unable to control the LED's trough WIFI or even the internet. I think the reason is that my router only acts as a hub on the local network and if the request comes from the internet the router doesn't know where to send the request to.
I also don't see the IP address of the my "PropTCP" board in the list of the connected devices list of my router. I tried to forward port 23 to the ip address of the "PropTCP" board but it didn't work because the router doesn't now that the "probtcp" board is on the local network.

My questions:

1) How can I tell my router that my board is connect on the local network and that all request are getting forwarded?
2) Can I send a command from the "ProbTCP" board to the router and register as a local network address?

Well TCP/IP seems to be more complicated that I thought. Any help would be appreciated

Thanks,

Wolfgang

Comments

  • Harrison.Harrison. Posts: 484
    edited 2009-05-23 19:11
    1) A simple port forward should be all that you need. The router obtains its list of 'connected devices' by keeping track of DHCP leases. The current PropTCP drivers do not support DHCP, so your router doesn't show the device as 'connected'.
    2) Again, you don't need to send a command to the router for address registration. Just set a static IP on the Propeller that is in your local network's subnet (and outside the DHCP range).

    Also: PropTCP is fully aware of subnets and routing, so it should work through routers and the internet (both in client and server modes).

    Please post your source code. It's hard to tell what's wrong without looking at what you are doing.

    Harrison
  • catostaycatostay Posts: 8
    edited 2009-05-23 19:24
    Thank for your quick response.

    I tried for hours to get the signals trough my router without any success so far. I attached the code to this post.

    This works fine on the local network but not outside.

    Thanks,

    Wolfgang
  • jazzedjazzed Posts: 11,803
    edited 2009-05-23 20:39
    I could be totaly wrong, but shouldn't you be using DHCP to get your IP address rather than assigning one on 192.168.1.x ?· Maybe it doesn't matter.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • catostaycatostay Posts: 8
    edited 2009-05-23 20:53
    PropTCP doesn't support DHCP and I need a static IP since I would like to run several of my boards on the same network. I think the best way to identify the boards is by knowing the IP rather than scan trough the whole network to find one of the boards.

    Well so far I was not able to control my board other than trough the local network. I am playing all afternoon with my router configuration but no success yet.
  • jazzedjazzed Posts: 11,803
    edited 2009-05-23 22:24
    But the YBOX2 code supports DHCP ... should be little difference between that and PropTCP. The problem is 192.168.1.x is designed to be used with DHCP and your router might be ignoring anything it did not assign. Static IPs are useful ... I really do miss the one's I had at home until last year.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • catostaycatostay Posts: 8
    edited 2009-05-23 23:36
    Well I downloaded "Microsoft Network Monitor" and I try to read all the packets in my network. I wanted to make sure the the router forwards the packets.

    What I am seeing is an ARP request from 192.168.1.250 (PC on WIFI) to 192.168.1.4 (PropTCP) and shortly after that an ARP request from 192.168.1.1 (router) to 192.168.1.4 (PropTCP) but in both cases no ARP response from 192.168.1.4 (PropTCP)

    If try to connect from a local network PC (192.168.1.243). I will get an ARP request (192.168.1.243 > 192.168.1.4) and shortly after that a response from 192.168.1.4. Shortly after that 192.168.1.243 and 192.168.1.4 communicate trough port 23 in TCP.

    So my router forwards the request from the WIFI PC but the PropTCP doesn't respond.

    Any ideas anybody ?


    Thanks

    Wolfgang
  • Ron SutcliffeRon Sutcliffe Posts: 420
    edited 2009-05-24 00:29
    Normally a network computer makes requests from a LAN port via the router WAN port.
    To access a computer on a LAN or WLAN from a WAN port you may have to set up DMZ and change your firewall settings.
    I presume your ISP had provided you with a static address. Note Harrisons comments on Port forwarding too.

    BTW I use the same set up to monitor my bilge pump and battery voltages on my boat whilst it is in the marina and remotely control some
    other functions)

    regards
    Ron

    Post Edited (Ron Sutcliffe) : 5/24/2009 12:45:42 AM GMT
  • catostaycatostay Posts: 8
    edited 2009-05-24 00:47
    Hi Ron:

    Well I have 2 setups here:

    Setup 1: PropTCP > ROUTER > PC (all wired) With this setup my PC talks to the PropTCP

    Setup 2: PropTCP > ROUTER > WIFI-PC (wired from PropTCP to Router and wireless from Router to Wifi-PC) With this setup the wifi PC doesn't talk to the PropTCP

    I forwarded port 23 to my PropTCP and additional I setup DMZ to the PropTCP. With Microsoft Network Monitor I can see ARP requests from both setups but only an ARP response in setup 2

    As you can see I am not even going trough the internet yet.

    In option one the router acts as a hub only but in the second option it acts as a gateway.

    So far I can't figure out the problem. I am trying to understand the ARP functions in the file "driver_socket" but this will take me a couple more our and lots of coffee..

    Sorry if I explain everything so complicated but English is only my second language.

    Wolfgang
  • Harrison.Harrison. Posts: 484
    edited 2009-05-24 01:02
    You likely won't see all packets on the network unless you are using a hub or are packet monitoring from the same computer the requests are originating from. Switched and routed networks won't let you see all network traffic, and hence why you likely don't see the ARP replies. ARP requests are broadcasted, and are visible to all devices on the network.

    Also, you'll want to prepend all socket accesses with a \ to catch aborts. Most of the socket operations can abort on socket failures (read or write to a closed socket, etc). It's very likely that the stack is aborting due to socket errors, which causes your application to stop.

    Change your code to:
    PUB start | in, gotstart, port , delaytime ,a
      tv.start(12)
      dira[noparse][[/noparse] 16..23]~~
      tel.start(1,2,3,4,5,6,@local_macaddr,@ip_addr)
      tv.dec(in)
      \tel.listen(23)
      repeat
        a:=\tel.rxcheck
        if not (a==-1)
        case a
          49:
            !outa[noparse][[/noparse] 16]
            \tel.str(string("LED1"))                                                                
          50: !outa[noparse][[/noparse] 17]
          51: !outa[noparse][[/noparse] 18]
          52: !outa[noparse][[/noparse] 19]
          53: !outa[noparse][[/noparse] 20]
          54: !outa[noparse][[/noparse] 21]
          55: !outa[noparse][[/noparse] 22]
    
    



    Also try changing the MAC address to:
    local_macaddr   byte    $02, $00, $00, $00, $00, $03
    
  • catostaycatostay Posts: 8
    edited 2009-05-24 01:13
    Thank you very much Harrison. Everything works fine now trough my Wifi computer. I will test it trough the internet later today.

    Thanks again.

    Wolfgang
  • mikedivmikediv Posts: 825
    edited 2009-05-24 23:45
    catostay I might not be understanding your question fully but if you are trying to route a 192.168 address it will not work, the 192.168 address is considered a private network address it will function fine for your inside the firewall or router LAN but it can not be routed Wan
    Try doing a tracert command go to the dos prompt in windows or console if unix/linux and type tracert the address 192.168.?.? and you can watch it over its hops it will stop at your router gateway address ??192.168.1.1
    if you are trying to see from the Wan side you can go into your router I am guessing something like 128.34.56.? and do the same thing but it will stop at the private address 192.168.?.?
    if you are trying to watch the packets with Netmon or something similar the same thing will happen you will see packets stop at the private address space.
Sign In or Register to comment.