[Click] how to create a new packet , and set header fields

Hamid Farhadi qq119512 at iii.u-tokyo.ac.jp
Thu Nov 28 01:13:30 EST 2013


Hi

you may find some hints here. I recieve 2Packet *p" as the input and 
assign fileds to my own variable. you want the viseversa. make a new 
packet using 
WritablePacket:http://read.cs.ucla.edu/click/doxygen/class_writable_packet.html

Then do similar thing to assign values

check these classes and routines in the Doxygen. Search similar code on 
the github to find samples: https://github.com/kohler/click

	EtherAddress _smac;
	EtherAddress _smac2;
	EtherAddress _dmac;
	IPAddress _saddr;
	IPAddress _daddr;
	uint16_t _sport;
	uint16_t _dport;



		const click_ether *eth = p->ether_header();
		const click_ip *iph = p->ip_header();
		const click_udp *udph = p->udp_header();		
		
		 _smac = EtherAddress(eth->ether_shost);
		 _dmac = EtherAddress(eth->ether_dhost);
		
  	          //sa << IPAddress(pick());
         	  //sa << " > " << IPAddress(iph->ip_dst);
           	  //click_chatter("src: %s",sa.c_str());
		
		 _saddr = iph->ip_src.s_addr;		
		 _daddr = iph->ip_dst.s_addr;
		 _sport = udph->uh_sport;
		 _dport = udph->uh_dport;


--Hamid

On 11/27/13 5:30 PM, sophia wright wrote:
> Hello,
>
> i have created my own element on click .
> at this moment i want to create  numbers of TCP-reset packets.
> I have Dest IP, dest Port, Source IP, source Port , Seq Number and Ack
> number .
> Based on the above info , i want to create some numbers of reset packets,
> Any idea,or some hints , how i could create those with click modular router?
>
> General how to create a new packet ,and how i can set its header field?
>
>
> thank you in advance
> sophia
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>


More information about the click mailing list