I have a Single Board Computer running Vxworks 5.5.1 which has two
ethernet controllers (gteth) type. One device gets initialized at the
boot stage. Once VxWorks is running, am trying to add the second
device using the functions ipAttach, ifMaskSet, ifAddrSet. I am able
to add the second device into a different subnet mask but not the same
one as the first ethernet device.
My requirement is to set one ethernet controller to IP address
192.168.50.1 and the other to 192.168.50.2.
Have anybody come across this type of issue. If else request you to
provide some pointers to fulfill the requirement.
Thanks in advance,
Kiran
Assigning 2 IP addresses within one subnet to 2 interfaces does not
have any influence: all data will go through the same interface.
VxWorks determines the outgoing interface based on the subnet. So all
outgoing traffic will go through the first port.
Incoming traffic will probbaly also use this port. This is based on
the following assumprion.
As external devices will use ARP to find out the MAC address, the
broadcast for port 2 will be received on port 2, but the reply will go
out on port 1, attaching the MAC address of port 1 to the ARP reply.
If you want to have 2 ports and divide traffic between these you have
to come up with a different scheme, for example 2 subnets, each half
the size of the original subnet.
Kind regards,
Johan Borkhuis
The BSD networking stack (upon which the VxWorks 5.5.1 network stack
is based) normally doesn't want you to assign two interfaces to the
same subnet. However, it's been my experience that people frequently
want to configure things like this, mainly when designing cable
modems. Apparently part of the DOCSIS spec requires this. (Note: if
you're not actually doing this because of a requirement such as this,
I recommend rethinking your reasons for wanting to do things this way.
It may not actually be the right solution for your problem.)
The one way I can think of to make it work is to use a netmask of
255.255.255.255 for at least one of the interfaces. The netmask
basically tells the stack: "this interface can handle traffic for this
block of addresses." If you use 255.255.255.0, then the stack will
know that to reach any address from 192.168.50.0 to 192.168.50.255, it
has to go through that one particular interface. If you try to assign
a second interface to the same network with the same netmask, the
stack thinks "wait a minute, I already have an interface to use as a
destination for that network; I don't want another one!" so you get an
error when trying to set up the second interface.
Using a netmask of 255.255.255.255 gets around this issue by telling
the stack that only one IP address is reachable through that interface
rather than a group of addresses. This removes the conflict since now
it appears there is no overlap between interfaces.
So basically, I would do:
-> usrNetIfConfig("gteth", 0, "192.168.50.1", "port1",
255.255.255.255")
-> usrNetIfConfig("gteth", 1, "192.168.50.2", "port2",
255.255.255.255")
You may then need to carefully add routes to make sure that traffic
goes where you want it.
-Bill
Hi Bill, Johan,
Thanks for your response.
I tried what Bill suggested i.e. ipAttach the second ethernet
controller & configured using the API usrNetIfConfig.
However, As Johan described: The broadcast is always to the first
port. If i remove the ethernet cable from the first port, both the
links are down.
Bill,
you were mentioning about carefully adding routes to make sure the
traffic routing. Can you please explain what needs to be done?
I shall give you brief of my requirement:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Two PCs each having an ethernet card assigned with IP address as
"192.168.50.3" & '192.168.50.4" respectively
As SBC having two ethernet ports one assigned as "192.168.50.1" and
the other as "192.168.50.2"
All the 4 ethernet ports are on the same network.
Now, PC 1 pings Port 1 (IP Address: 192.168.50.1) and PC2 pings Port2
(IP Address: 192.168.50.2).
If Port1 cable is disconnected, PC1 should stop pinging whereas PC2
should continue to ping Port2. and vice versa.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks in Advance,
Cheers,
Kiran
---------------------------------------------------------------------------------
Hi,
i have faced a similar kind of problem, when using 2 END devs.
and find out a way to up more than one device at a time.
to do this follow below steps,
1. initially END1 device will be attached, configured and up (while
booting).
2. attach and configure END2
3. down END1
4. up END2
5. up END1.
note: you can use same class id for both END devs.
now both of your END devs will be ready and you can test them by
pinging parallely from two host PCs.
- Giri.