Hi Haopeng,
You can create bridges in the local host first. Then in VM you can create interfaces and connect to those bridges, and in ns-3 you can use the
tap bridge model to connect an ns-3 virtual node to a real tap which is attached to those bridges. Basically it's something like:
TapBridgeHelper tbh;
tbh.SetAttribute ("Mode", StringValue ("UseBridge"));
tbh.SetAttribute ("DeviceName", StringValue (tap_left));
tbh.Install (endNode.Get (0), device.Get (0));
tbh.SetAttribute ("DeviceName", StringValue (tap_right));
tbh.Install (endNode.Get (1), device.Get (3));
I think all you need to know is in that link, and make sure you use the correct device name and the right mode in ns-3. Besides, you may need to configure the routes in the VM using route or ip route.
Hope it helps.
Best,
Jason