![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3
![]() |
promiscious sockets
hi all,
I am about to embark on a projectthat involves creating a program that accepts packets from an interface and outputs them after a certain amount of delay and jitter on another interface. Kind of like a simulation of the internet. Now so far, I know that when u want to recieve somehting u open a socket on a certain port. Now in my case how should the sockets be different? and how can i retain the destination IP so that i can forward the packet. This should be the same socket operation of a firewall i think. can anyone suggest any reading material or google keyword or similar project for me to look at. thanks |
|
|
|
|
|
#2 | |||
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 748
Rep Power: 3
![]() |
Re: promiscious sockets
Quote:
Quote:
For a firewall, though, you [can] read up a little further into the packet and decide whether to accept it based on other traits, such as port number, source IP address, etc... With NAT your router keeps a mapping of inner IP addresses to outside facing IP addresses (e.g. you have the 212.13.49.0/24 network, and you remap each one into 192.168.0.0/24). With PAT, your router keeps a mapping of inner IP addresses to outside facing ports (e.g. you have 212.13.49.0/24 and you remap it to 192.168.0.3:80, 192.168.0.3:115, 192.168.0.4:12345, etc...). NAT and PAT are not necessarily firewall functions. Quote:
![]()
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|||
|
|
|
|
|
#3 | ||
|
Hobbyist Programmer
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3
![]() |
Re: promiscious sockets
Quote:
Quote:
|
||
|
|
|
|
|
#4 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
Re: promiscious sockets
No, you definitely wouldn't do this by opening a bunch of sockets.
Promiscuous mode is commonly used for sniffing. Getting the packets is not the hard part in your case. Linking two interfaces together as you want brings in a lot of subtle, lower level stuff. Thankfully, you probably don't need to worry about it. Bridging interfaces is supported by most any OS you'd care to use. This is in the C# forum but if you intend to put something like this on an actual network - as in, two physical interface cards, one in, one out, handling what ever network traffic happens to pass through, Linux and iptables would be a good choice. It's amazing what you can do with iptables rules. A quick search revealed this solution. Packets incoming on a particular interface are, by an iptables rule, handed off to a usermode program which holds on to them for some defined period. You'd want to bridge two physical interfaces and apply a similar rule to your bridge device. Should work. If you want to test stuff just on the one machine without multiple interfaces, you could also apply the rule to the loopback device (think localhost). If you really need to do this on windows, things might be much uglier. Do you really need to delay *all* traffic going through this segment of the network? You say "simulation"...if you plan to use this to test your network applications, why not just implement it as a simple proxy? Your app connects to your delay tool, which then connects to the predefined "real" target and fondles the data as it wishes.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3
![]() |
Re: promiscious sockets
Its very impressive what you can do under linux. i will definitely keep that in mind for future work. Unfortunately, yes i have to do this under windows. what i want to do is basically simulate WAN delay jitter...etc. I guess doing it through a proxy on the sending PC is a neat idea. But in that case, what about the traffic comming back? how can i delay that too?
what about the ports issue? does this mean i have to specify a port for my proxy to listen on? what im trying to do should look like this: SENDER(e.d LIVE UDP VIDEO) ---->>> INTERMEDIATE PROgRAM -------->>>>> RECIEVER the scope of my work is this intermediate program, which simply captures the data and delays it before it sends it off to its specified location. you can think of the three systems above as 3 different PC's, perhaps on 2 subnets with the Intermediate have 2 ethernet interfaces. unless i go with the proxy idea? |
|
|
|
|
|
#6 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Re: promiscious sockets
Just route the entire damn program through Tor and watch the slowdown begin. No need for fancy programs.
![]() |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3
![]() |
Re: promiscious sockets
That would be cool... but this is just brainstorming for a project im supposed to propose and implement myself for a course in multimedia networking..
|
|
|
|
|
|
#8 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
Re: promiscious sockets
You mentioned UDP video
Start intermediate program Listen on port 123 Target host: my_remote_server Target port: 456 Start server Listen on port: 456 Start client: Connect to localhost:123 Anything sent to localhost:123 will get delayed by the intermediate program. When the server replies to sender address as is common in UDP, the intermediate program will get it, delay once again, and then send it to the client. This requires just a little bit of logic for the intermediate program. You have to know where the real server is (since there is no proxy protocol like SOCKS involved here, the client doesn't tell you), you have to track what client is sending you stuff (to send replies from the server) and need to make sure that check up on both sockets (can't just block on one of them - the other might get something). If you are comfortable with threading, this can be easy. Threads 1 and 2 each handle a socket. They loop until they are supposed to exit, receiving a datagram and adding it to a shared queue. Store with each datagram the time in which it should be sent (current time + latency). In threads 3 and 4, loop such that you check the first item in the queue, send it if at or past the send time, and sleep for 1-2ms. (Not terribly efficient, but much easier. You could improve this for fun). 1 and 3, 2 and 4 are effectively paired, with a queue for each pair. One pair handles the client, the other handles the server.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3
![]() |
Re: promiscious sockets
Thats a pretty cool formulation, thanks Dameon.
although, your suggestion implies listening/sending/recieving on specified port for which i have to open a socket. I s there anyway i can make this completely dynamic. i.e no specific ports, listen to any port, recieve any packet, delay it, look at the destination ip and port, then forward it to its destination. kind of like a gateway? |
|
|
|
|
|
#10 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
Re: promiscious sockets
If that's what you need to do, investigate what I said about Linux/iptables.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simple BSD Sockets Problem | Soulstorm | C | 16 | Mar 7th, 2008 5:02 PM |
| Sockets Lib | King | C++ | 7 | Apr 10th, 2007 7:17 AM |
| Hello Sockets | hbe02 | C++ | 7 | May 21st, 2006 6:34 AM |
| help with sockets, having a client recieve data as well as send. | cypherkronis | Python | 7 | Jul 1st, 2005 5:59 PM |
| Windows sockets programming | davidsiaw | C | 1 | Jun 15th, 2005 6:17 AM |