LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-08-2004, 12:22 AM   #1
shinkm
LQ Newbie
 
Registered: Jan 2004
Posts: 6

Rep: Reputation: 0
packet reordering and delay using libipq


When using libipq, is it possible to delay/reorder individual packets? In particular, I am curious whether the following pseudo code can be implemented using libipq. Situation is like this: Assume that this imaginary software is running on a router which forwards packets to other hosts. Packet 1 arrives at the router first and packet 2 arrives one second after packet 1 does. The goal is to send out packet 2 one second before packet 1 is sent out. In other words, packet 1 should be delayed by two seconds while packet 2 is immediately forwarded.

Very approximate code without all the bells and whistles follows.

main(){
int status;
unsigned char buf1[BUFSIZE]; // buffer for packet1
unsigned char buf2[BUFSIZE]; // buffer for packet2
struct ipq_handle *h;

h = ipq_create_handle(0, PF_INET);
status = ipq_set_mode(h, IPQ_COPY_PACKET, BUFSIZE);
do{
// get packet1
status = ipq_read(h, buf1, BUFSIZE, 0);
ipq_packet_msg_t *m1 = ipq_get_packet(buf1);

// get packet2
status = ipq_read(h, buf2, BUFSIZE, 0);
ipq_packet_msg_t *m2 = ipq_get_packet(buf2);

// set verdict on packet2
status = ipq_set_verdict(h, m1->packet_id, NF_ACCEPT, 0, NULL);

// delay
delay(2000); // I am not exactly sure about how to implement delay, but for
// the sake of the argument, this line should be clear enough

// set verdict on packet1
status = ipq_set_verdict(h, m2->packet_id, NF_ACCEPT, 0, NULL);

} while (1);
}

What worries me the most about my pseudo code is that the underlying ip_queue might hang waiting for the return value (such as NF_ACCEPT), which will prevent packet 2 from being forwarded before packet 1. I haven't actually implemented the code yet because it is not very easy for me to test it with just one lousy computer...I would like to know whether somebody has successfully reordered/applied delays to individual packets using libipq. Also, it would be great if somebody could point out what I am doing wrong if that is the case. Thanx in advance.

Last edited by shinkm; 09-08-2004 at 12:26 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kernel AODV and libipq mahbub_bd Linux - Networking 1 05-19-2011 04:24 AM
How to retrieve an sk_buff from libipq netfunk Linux - Networking 2 03-20-2006 04:16 AM
how to delay and drop the packet sonika_singhi Linux - Networking 4 04-02-2005 04:55 PM
MYSQL-Reordering Problem in REDHAT9.0 JsSS Programming 8 09-08-2004 05:24 AM
problem with trying the libipq example code enjoyzj Programming 4 12-07-2003 07:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration