5 #include "diag/diag_types.h"
13 using namespace boost::posix_time;
19 DiagEntry(ping_req->get_source_ip(), ping_req->get_dest_ip(),
20 ping_req->get_protocol(), ping_req->get_source_port(),
21 ping_req->get_dest_port(),
Agent::GetInstance()->fabric_vrf_name(),
22 ping_req->get_interval() * 100, ping_req->get_count(), diag_table),
24 remote_vm_mac_(ping_req->get_vm_remote_mac()),
25 data_len_(ping_req->get_packet_size()),
26 context_(ping_req->context()),
57 void OverlayPingReq::HandleRequest()
const {
59 boost::system::error_code ec;
64 IpAddress sip(IpAddress::from_string(get_source_ip(), ec));
66 err_str =
"Invalid source IP";
71 err_str =
"V6 is not supported";
75 IpAddress dip(IpAddress::from_string(get_dest_ip(), ec));
77 err_str =
"Invalid destination IP";
82 err_str =
"V6 is not supported";
86 uint8_t proto = get_protocol();
87 if (proto != IPPROTO_TCP && proto != IPPROTO_UDP) {
88 err_str =
"Invalid protocol. Valid Protocols are TCP & UDP";
94 err_str =
"Invalid VN segment";
102 err_str =
"Invalid vxlan segment";
109 err_str =
"Invalid remote mac";
117 PingErrResp *resp =
new PingErrResp;
118 resp->set_error_response(err_str);
119 resp->set_context(context());
139 boost::system::error_code ec;
152 tunneldst = *nh->
GetDip();
153 tunnelsrc = *nh->
GetSip();
155 boost::shared_ptr<PktInfo> pkt_info(
new PktInfo(agent,
len_,
157 uint8_t *buf = pkt_info->packet_buffer()->data();
158 memset(buf, 0,
len_);
163 senttime_ = microsec_clock::universal_time();
168 pkt_info->eth = (
struct ether_header *)(buf);
171 pkt_info->ip = (
struct ip *)(pkt_info->eth +1);
172 pkt_info->transp.udp = (
struct udphdr *)(pkt_info->ip + 1);
174 len = data_len_+2 *
sizeof(udphdr)+
sizeof(
VxlanHdr)+
175 sizeof(
struct ip) + sizeof(struct ether_header);
179 pkt_handler->
IpHdr(len +
sizeof(
struct ip), ntohl(tunnelsrc.to_ulong()),
180 ntohl(tunneldst.to_ulong()), IPPROTO_UDP,
184 + sizeof(struct ether_header));
185 vxlanhdr->
vxlan_id = ntohl(vxlan_id << 8);
189 pkt_info->eth = (
struct ether_header *)(vxlanhdr + 1);
194 pkt_info->ip = (
struct ip *)(pkt_info->eth +1);
195 Ip4Address dip = Ip4Address::from_string(
"127.0.0.1", ec);
196 pkt_info->transp.udp = (
struct udphdr *)(pkt_info->ip + 1);
197 len = data_len_+
sizeof(
struct udphdr);
200 pkt_handler->
IpHdr(len +
sizeof(
struct ip), ntohl(
sip_.to_v4().to_ulong()),
201 ntohl(dip.to_ulong()),
proto_,
217 PingResp *resp =
new PingResp();
219 resp->set_seq_no(ntohl(pktdata->
seq_no_));
220 boost::posix_time::ptime time = microsec_clock::universal_time();
221 boost::posix_time::time_duration rtt = time -
senttime_;
225 resp->set_rtt(rtt_str);
226 resp->set_resp(
"Success");
228 resp->set_more(
true);
233 PingResp *resp =
new PingResp();
235 resp->set_resp(
"Timed Out");
238 resp->set_more(
true);
243 PingSummaryResp *resp =
new PingSummaryResp();
249 std::string avg_rtt_string;
251 resp->set_average_rtt(avg_rtt_string);
253 resp->set_request_sent(
seq_no_);
256 resp->set_pkt_loss(pkt_loss_percent);
uint32_t GetMaxAttempts()
virtual void RequestTimedOut(uint32_t seq_no)
static Agent * GetInstance()
static boost::uuids::uuid StringToUuid(const std::string &str)
VrfEntry * fabric_vrf() const
OverlayPing(const OverlayPingReq *req, DiagTable *diag_table)
static const uint32_t kVxlanRABit
const VrfEntry * GetVrf() const
boost::uuids::uuid vn_uuid_
const Interface * vhost_interface() const
boost::asio::ip::address IpAddress
void set_len(uint32_t len)
boost::posix_time::time_duration avg_rtt_
InterfaceTable * interface_table() const
const Ip4Address * GetDip() const
MacAddress remote_vm_mac_
VnTable * vn_table() const
const string & GetName() const
const MacAddress & mac() const
std::string ToString() const
void FillOamPktHeader(OverlayOamPktData *pktdata, uint32_t vxlan_id, const boost::posix_time::ptime &time)
virtual void SendSummary()
const AgentPath * GetActivePath() const
NextHop * nexthop() const
int EthHdr(const MacAddress &src, const MacAddress &dest, const uint16_t proto)
#define VXLAN_UDP_DEST_PORT
const std::string & fabric_interface_name() const
EventManager * event_manager() const
void Send(uint32_t itf, uint32_t vrf, uint16_t, PktHandler::PktModuleName)
AgentRouteTable * GetBridgeRouteTable() const
static const MacAddress in_dst_mac_
const Ip4Address * GetSip() const
AgentDBEntry * Find(const DBEntry *key, bool ret_del)
PktInfo * pkt_info() const
const uint32_t vrf_id() const
VnEntry * Find(const boost::uuids::uuid &vn_uuid)
boost::asio::ip::address_v4 Ip4Address
const NextHop * nexthop() const
uint32_t HashValUdpSourcePort()
static const uint32_t kVxlanIBit
void time_duration_to_string(time_duration &td, std::string &str)
VxLanId * Find(uint32_t vxlan_id)
boost::posix_time::ptime senttime_
VxLanTable * vxlan_table() const
void UdpHdr(uint16_t len, in_addr_t src, uint16_t src_port, in_addr_t dest, uint16_t dest_port)
const Peer * local_vm_peer() const
const MacAddress * GetDmac() const
virtual void SendRequest()
static MacAddress FromString(const std::string &str, boost::system::error_code *error=NULL)
static const uint32_t kOverlayUdpHdrLength
virtual void HandleReply(DiagPktHandler *handler)
static BridgeRouteEntry * L2RouteGet(VxLanId *vxlan, string remotemac, Agent *agent)
static const MacAddress in_source_mac_
void IpHdr(uint16_t len, in_addr_t src, in_addr_t dest, uint8_t protocol, uint16_t id, uint8_t ttl)