Like Tree1Likes
  • 1 Post By ledow

Multiple NIC network programming

This is a discussion on Multiple NIC network programming within the C Programming forums, part of the General Programming Boards category; Hi all! I'm assigned to develop a network testbed. my situation is like this: * I am working with Linux ...

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    5

    Multiple NIC network programming

    Hi all!

    I'm assigned to develop a network testbed.

    my situation is like this:
    * I am working with Linux (Red Hat like)
    * My computer has multiple network interfaces (8 actually, but i'll start with 2) IN THE SAME NETWORK SUBNET.
    So: NIC 1: 10.240.10.1 /24 and NIC 3: 10.240.10.2 /24

    Now, i connect NIC 1 and NIC 2 with an UTP cable. I have a network !

    Now I want to send messages using C between these NIC's, over the cable of course.

    I already read C Programming/Networking in UNIX - Wikibooks, open books for an open world

    But that way, e.g. messages from NIC 1 -> NIC 2 get sent over the cable, but messages from NIC 2 -> NIC 1 not, because of the computer's routing table.

    How can i solve this?

    I'd rather not change the computers routing table...

    If things are not well explained yet, please ask...

    Thanks in advance,
    Krulle

  2. #2
    Registered User ledow's Avatar
    Join Date
    Dec 2011
    Posts
    435
    Your routing is incorrect if you can't send messages to the relevant IP. Both NIC's are in the same subnet but have different IP's, so the routing table should handle it properly for you. You need "host" routes for each IP on the correct interface and it might be helpful to remove any other routes you have for them (e.g. "net" routes for the entire subnet).

    You *can* do it manually, but do you REALLY want to get into hardware/OS-specific NIC-level programming just to send a message between two IP's? It's a lot more work than you think.
    rags_to_riches likes this.

    - Compiler warnings are like "Bridge Out Ahead" warnings. DON'T just ignore them.
    - A compiler error is something SO stupid that the compiler genuinely can't carry on with its job. A compiler warning is the compiler saying "Well, that's bloody stupid but if you WANT to ignore me..." and carrying on.
    - The best debugging tool in the world is a bunch of printf()'s for everything important around the bits you think might be wrong.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. c network programming
    By paoloC in forum C Programming
    Replies: 1
    Last Post: 01-23-2010, 12:01 PM
  2. Multiple servers on one network (winsock)
    By IsmAvatar2 in forum Networking/Device Communication
    Replies: 1
    Last Post: 01-25-2009, 01:55 AM
  3. network programming
    By surdy in forum Networking/Device Communication
    Replies: 9
    Last Post: 10-03-2004, 09:14 AM
  4. Want Some Help on Network Programming..
    By Ankit_mcg in forum C Programming
    Replies: 2
    Last Post: 04-17-2002, 12:40 PM
  5. how to listen to multiple Network cards in one go?
    By C beginner in forum C++ Programming
    Replies: 0
    Last Post: 08-16-2001, 01:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21