Author Topic: two IPs  (Read 11992 times)

Offline cs

  • Newbie
  • *
  • Posts: 4
    • View Profile
two IPs
« on: May 01, 2008, 01:33:20 AM »
I am building a device based on a 52233 to encapsulate ip traffic between  two networks. i need the device to have two IPs (one the ip on the local network and the other on the remote). Is this possible?

Thanks
Carlos

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: two IPs
« Reply #1 on: May 01, 2008, 12:58:52 PM »
Hi

Generally each Ethernet interface has its own MAC/IP and I haven't heard of this requirement before.

To do this with one Ethernet interface will require it to have 2 MAC addresses and an IP for each one.
This is certainly possible but will need some work since the TCP/IP stack works with a single network parameter block and will need to be able to work with two - and known which one to use for each frame. (Note: The ATMEL SAM7X is interesting since it allows the Ethernet interface to be programmed with up to 4 MAC addresses - most devices suppport just one MAC and so these will need to work in promiscuous mode to be able to handle more that one - with resulting CPU overhead to check every received frame, even when not relevant).

If the two networks are physically separated two Ethernet interfaces would be required.

Also take a look at VLAN - this is a technique for realising a virtual local network within a physical network. Possibly it could be used for such a requirement (?).

Regards

Mark


Offline cs

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: two IPs
« Reply #2 on: May 05, 2008, 01:00:34 PM »
Hi Mark,

Thanks for your answer. I do not need two MACs, I can do with one MAC and two IPs the same way as a PC can have two IPs with only one network interface. The idea is that the network will have two IP ranges, the 52233 will act as the default gateway for certain devices encapsulating the traffic and resending it through the other IP.

Thanks

Carlos

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: two IPs
« Reply #3 on: May 05, 2008, 01:26:43 PM »
Hi Carlos

I checked my XP PC and it is possible to set a second (alternative) IP address and the instructions say that it is used when the PC is to be used in multiple networks - it can also take its settings from a DHCP server. However I am not familiar with its actual use.

Does this mean that the 2 IP addresses will be in different sub-nets?

I can imagine that it will be necessary to add a second block of network settings - if rx frames are not in the first sub-net they will normally be silently discarded but then the second network setting could be checked. If this matches it can be handled and passed on.

At which protocol level will the gateway function be realised? I assume IP.

Regards

Mark

Offline cs

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: two IPs
« Reply #4 on: May 05, 2008, 05:01:28 PM »
Hi Mark,

Once again thank you. On a PC, normally you can setup your server to listen to one or to all IPs on an interface. That way you could have two HTTP server running on the same PC but will respond differently depending on the IP address used.

Normally the IPs are in different subnets but the default gateway of a PC is unique to both. In my case, I want to encapsulate IP traffic. In my setup:

Internet Router: IP = 192.168.1.1/24
52233 Device :   IP 1 = 192.168.1.10/24
                       IP 2 = 10.1.240.1/24
                       Gateway = 192.168.1.1
VoIP Device:      IP = 10.1.240.2
                       Gateway = 10.1.240.1

On the second IP all I need to support is ARP and raw IP. The device just looks at Ethernet packets to the device MAC and an IP outside the subnet (MAC and IP broadcasts are discarded) encapsulates it in UDP and sends it to another device that does the opposite. The packets it will receive do not even have the 10.1.240.1 IP as the VoIP device thinks it is a gateway that will know how to forward a packet outside its subnet.

The main reason for the device is that my brother´s ISP restricts all kind of VoIP and VPN traffic. This device is a simple way to tunnel part of his traffic trough my ADSL connection though a UDP port. I have a working version with a ATMega128 and a RTL8109 and wrote most of the UDP/IP/ARP code from scratch but throughput is not that good. I though it was a nice project to jump to 32 bits and get to know the Coldfire processor. I also want to do some dynamic DNS update and add some more features so a stable TCP stack will be a great aid.

Thanks for your work and support
Carlos

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: two IPs
« Reply #5 on: May 05, 2008, 09:37:24 PM »
Carlos

Thanks for the explanation, which is making the task clearer.

As you already realise it is not possible to configure the present project to do this since it only supports the standard single IP case. To do what you aim to do requires some modification of the TCP/IP stack.

However I see no big difficulty in doing this and I think that you will find it rather easier than your original project due to the fact that all development is possible in the uTasker simulator. If you haven't already done it, try working though the tutorial and then there is nothing stopping you digging in and changing a few lines in the source.

Eg. Step though the code when an ARP frame is sent to the second IP address (although not yet supported) [this will always arrive in int fnProcessARP(ETHERNET_FRAME *frame)]. You will see that it will be ignored due to the fact that its address doesn't match. In this case add code to check whether it maybe corresponds to the IP of the second configuration (add the second configuration alongside network_default[] in application.c). If it matches, use the equivalent ARP sub-routines to send a response and add details to a second ARP table (alongside tARP in arp.c). Then move on to IP and anything else which you need in a similar fashion.

The simulator will allow fast experimentation, testing and debugging until things are doing what you require. Then compile for the target and load to the board. Such coding will generally work 100% first time on the HW so you can then immediately do performance measurements, knowing that there there will be usually no need for extra target level debugging.

If you have any difficulties just post them here. Maybe some other users will be interested in a similar project so you are welcome to share your results here.

Good luck

Regards

Mark

Offline cs

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: two IPs
« Reply #6 on: May 06, 2008, 01:32:31 AM »
Thanks. i will keep you posted on progress.
Carlos

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: two IPs
« Reply #7 on: October 12, 2010, 10:35:47 AM »
Hi Carlos,

Did you every get anywhere with this?

Regards

Martin