Who’s listening?‘nicecho.c’Memory-layoutSharing of packet-buffersInterrupt-processingPacket-processingIn-class experimentsWho’s listening?Some experiments with an ‘echo’ service on our anchor-cluster’s local network of 82573L nic’s‘nicecho.c’•Module uses a set of eight packet-buffers•Same buffer is used for both RX and TX•The NIC operates in “promiscuous” mode •Interrupt-hander ‘reflects’ each received packet back to the station it came from•Pseudo-file shows both descriptor-queuesMemory-layout#define KMEM_SIZE (4<<12) // 16KB kernel memory allocation kmem rxring txring12KB 4KB Each of the 8 packet-buffers has size 1536 bytes (=0x600) Each of descriptor-table occupies 8*(16 bytes) =128 bytesSharing of packet-buffersRx-descriptorsTx-descriptorsInterrupt-processing irqreturn_t my_isr(int irq, void *dev_id ) {int intr_cause = ioread32( io + E1000_ICR );if ( intr_cause == 0 ) return IRQ_NONE;if ( intr_cause & (1<<7) ) // receiver timeout: a new packet arrived{int index = ioread32( io + E1000_TDT );unsigned long where = txring[ index ].base_address;unsigned char *cp = phys_to_virt( where );memcpy( cp+0, cp+6, 6 ); // source becomes destinationmemcpy( cp+6, mac, 6 ); // our station becomes sourcetxring[ index ].desc_status = 0;txring[ index ].packet_length = rxring[ index ].packet_length;index = (1 + index) % 8;’ // ring-buffer index advancesiowrite32( io + E1000_TDT ); // start sending packet back}iowrite32( intr_cause, io + E1000_ICR ); // clear the interruptsreturn IRQ_HANDLED; }Packet-processingdestn-address source-addressTYPE/LENGTH-- data ---- data ---- data –-- data ---- data ---- data -- mac[6] source becomes destination… …then our station becomes sourceIn-class experiments•Let’s compile and install our ‘nicecho.c’ module on one (or more) anchor stations •Then let’s transmit a ‘broadcast’ packet from a different anchor station, while we simultaneously listen for any replies•Then let’s see what happens if we ‘omit’ our processing of the
View Full Document